aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-06-20 08:59:45 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-06-20 08:59:45 -0400
commitd59bf96cdde5b874a57bfd1425faa45da915d0b7 (patch)
tree351a40b72514d620e5bebea2de38c26f23277ffc
parent28df955a2ad484d602314b30183ea8496a9aa34a (diff)
parent25f42b6af09e34c3f92107b36b5aa6edc2fdba2f (diff)
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
-rw-r--r--Documentation/feature-removal-schedule.txt9
-rw-r--r--Documentation/infiniband/ipoib.txt12
-rw-r--r--Documentation/kernel-parameters.txt9
-rw-r--r--Documentation/memory-barriers.txt348
-rw-r--r--Documentation/networking/README.ipw220010
-rw-r--r--Documentation/networking/bonding.txt323
-rw-r--r--Documentation/networking/ip-sysctl.txt7
-rw-r--r--Documentation/networking/netdevices.txt8
-rw-r--r--MAINTAINERS6
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/Kconfig2
-rw-r--r--arch/arm/mach-imx/irq.c2
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c5
-rw-r--r--arch/arm/mach-pxa/spitz.c1
-rw-r--r--arch/arm/mach-sa1100/neponset.c8
-rw-r--r--arch/arm/mach-versatile/core.c5
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c20
-rw-r--r--arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c11
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longhaul.c20
-rw-r--r--arch/i386/kernel/cpu/cpufreq/longrun.c1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k7.c13
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c344
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.h40
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c12
-rw-r--r--arch/mips/Kconfig244
-rw-r--r--arch/mips/Makefile37
-rw-r--r--arch/mips/au1000/common/au1xxx_irqmap.c4
-rw-r--r--arch/mips/au1000/common/pci.c16
-rw-r--r--arch/mips/au1000/common/setup.c6
-rw-r--r--arch/mips/au1000/common/time.c9
-rw-r--r--arch/mips/au1000/csb250/irqmap.c4
-rw-r--r--arch/mips/au1000/db1x00/irqmap.c4
-rw-r--r--arch/mips/au1000/hydrogen3/irqmap.c4
-rw-r--r--arch/mips/au1000/mtx-1/irqmap.c4
-rw-r--r--arch/mips/au1000/pb1000/irqmap.c4
-rw-r--r--arch/mips/au1000/pb1100/irqmap.c4
-rw-r--r--arch/mips/au1000/pb1200/irqmap.c4
-rw-r--r--arch/mips/au1000/pb1500/irqmap.c4
-rw-r--r--arch/mips/au1000/pb1550/irqmap.c4
-rw-r--r--arch/mips/au1000/xxs1500/irqmap.c4
-rw-r--r--arch/mips/basler/excite/Makefile9
-rw-r--r--arch/mips/basler/excite/excite_dbg_io.c122
-rw-r--r--arch/mips/basler/excite/excite_device.c404
-rw-r--r--arch/mips/basler/excite/excite_flashtest.c294
-rw-r--r--arch/mips/basler/excite/excite_fpga.h80
-rw-r--r--arch/mips/basler/excite/excite_iodev.c183
-rw-r--r--arch/mips/basler/excite/excite_iodev.h10
-rw-r--r--arch/mips/basler/excite/excite_irq.c129
-rw-r--r--arch/mips/basler/excite/excite_procfs.c81
-rw-r--r--arch/mips/basler/excite/excite_prom.c148
-rw-r--r--arch/mips/basler/excite/excite_setup.c307
-rw-r--r--arch/mips/cobalt/console.c5
-rw-r--r--arch/mips/cobalt/setup.c43
-rw-r--r--arch/mips/configs/atlas_defconfig11
-rw-r--r--arch/mips/configs/bigsur_defconfig11
-rw-r--r--arch/mips/configs/capcella_defconfig11
-rw-r--r--arch/mips/configs/cobalt_defconfig11
-rw-r--r--arch/mips/configs/db1000_defconfig11
-rw-r--r--arch/mips/configs/db1100_defconfig11
-rw-r--r--arch/mips/configs/db1200_defconfig11
-rw-r--r--arch/mips/configs/db1500_defconfig11
-rw-r--r--arch/mips/configs/db1550_defconfig11
-rw-r--r--arch/mips/configs/ddb5477_defconfig11
-rw-r--r--arch/mips/configs/decstation_defconfig13
-rw-r--r--arch/mips/configs/e55_defconfig11
-rw-r--r--arch/mips/configs/emma2rh_defconfig1207
-rw-r--r--arch/mips/configs/ev64120_defconfig11
-rw-r--r--arch/mips/configs/ev96100_defconfig11
-rw-r--r--arch/mips/configs/excite_defconfig1220
-rw-r--r--arch/mips/configs/ip22_defconfig11
-rw-r--r--arch/mips/configs/ip27_defconfig13
-rw-r--r--arch/mips/configs/ip32_defconfig11
-rw-r--r--arch/mips/configs/it8172_defconfig11
-rw-r--r--arch/mips/configs/ivr_defconfig11
-rw-r--r--arch/mips/configs/jaguar-atx_defconfig11
-rw-r--r--arch/mips/configs/jmr3927_defconfig11
-rw-r--r--arch/mips/configs/lasat200_defconfig11
-rw-r--r--arch/mips/configs/malta_defconfig11
-rw-r--r--arch/mips/configs/mipssim_defconfig11
-rw-r--r--arch/mips/configs/mpc30x_defconfig11
-rw-r--r--arch/mips/configs/ocelot_3_defconfig11
-rw-r--r--arch/mips/configs/ocelot_c_defconfig11
-rw-r--r--arch/mips/configs/ocelot_defconfig11
-rw-r--r--arch/mips/configs/ocelot_g_defconfig11
-rw-r--r--arch/mips/configs/pb1100_defconfig11
-rw-r--r--arch/mips/configs/pb1500_defconfig11
-rw-r--r--arch/mips/configs/pb1550_defconfig11
-rw-r--r--arch/mips/configs/pnx8550-jbs_defconfig11
-rw-r--r--arch/mips/configs/pnx8550-v2pci_defconfig11
-rw-r--r--arch/mips/configs/qemu_defconfig11
-rw-r--r--arch/mips/configs/rbhma4500_defconfig11
-rw-r--r--arch/mips/configs/rm200_defconfig11
-rw-r--r--arch/mips/configs/sb1250-swarm_defconfig11
-rw-r--r--arch/mips/configs/sead_defconfig11
-rw-r--r--arch/mips/configs/tb0226_defconfig11
-rw-r--r--arch/mips/configs/tb0229_defconfig11
-rw-r--r--arch/mips/configs/tb0287_defconfig11
-rw-r--r--arch/mips/configs/workpad_defconfig11
-rw-r--r--arch/mips/configs/wrppmc_defconfig (renamed from arch/mips/configs/ddb5476_defconfig)359
-rw-r--r--arch/mips/configs/yosemite_defconfig11
-rw-r--r--arch/mips/ddb5xxx/common/prom.c8
-rw-r--r--arch/mips/ddb5xxx/ddb5074/Makefile8
-rw-r--r--arch/mips/ddb5xxx/ddb5074/irq.c169
-rw-r--r--arch/mips/ddb5xxx/ddb5074/nile4_pic.c286
-rw-r--r--arch/mips/ddb5xxx/ddb5074/setup.c234
-rw-r--r--arch/mips/ddb5xxx/ddb5476/Makefile9
-rw-r--r--arch/mips/ddb5xxx/ddb5476/dbg_io.c136
-rw-r--r--arch/mips/ddb5xxx/ddb5476/irq.c165
-rw-r--r--arch/mips/ddb5xxx/ddb5476/nile4_pic.c190
-rw-r--r--arch/mips/ddb5xxx/ddb5476/setup.c296
-rw-r--r--arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c109
-rw-r--r--arch/mips/ddb5xxx/ddb5477/setup.c2
-rw-r--r--arch/mips/dec/setup.c2
-rw-r--r--arch/mips/dec/time.c2
-rw-r--r--arch/mips/defconfig11
-rw-r--r--arch/mips/emma2rh/common/Makefile13
-rw-r--r--arch/mips/emma2rh/common/irq.c108
-rw-r--r--arch/mips/emma2rh/common/irq_emma2rh.c134
-rw-r--r--arch/mips/emma2rh/common/prom.c77
-rw-r--r--arch/mips/emma2rh/markeins/Makefile13
-rw-r--r--arch/mips/emma2rh/markeins/irq.c134
-rw-r--r--arch/mips/emma2rh/markeins/irq_markeins.c197
-rw-r--r--arch/mips/emma2rh/markeins/led.c60
-rw-r--r--arch/mips/emma2rh/markeins/platform.c170
-rw-r--r--arch/mips/emma2rh/markeins/setup.c182
-rw-r--r--arch/mips/galileo-boards/ev96100/setup.c2
-rw-r--r--arch/mips/gt64120/ev64120/setup.c2
-rw-r--r--arch/mips/gt64120/momenco_ocelot/setup.c2
-rw-r--r--arch/mips/gt64120/wrppmc/Makefile14
-rw-r--r--arch/mips/gt64120/wrppmc/int-handler.S59
-rw-r--r--arch/mips/gt64120/wrppmc/irq.c63
-rw-r--r--arch/mips/gt64120/wrppmc/pci.c53
-rw-r--r--arch/mips/gt64120/wrppmc/reset.c50
-rw-r--r--arch/mips/gt64120/wrppmc/setup.c173
-rw-r--r--arch/mips/gt64120/wrppmc/time.c57
-rw-r--r--arch/mips/ite-boards/generic/it8172_setup.c76
-rw-r--r--arch/mips/jazz/setup.c2
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c61
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/apm.c605
-rw-r--r--arch/mips/kernel/asm-offsets.c66
-rw-r--r--arch/mips/kernel/branch.c2
-rw-r--r--arch/mips/kernel/i8259.c4
-rw-r--r--arch/mips/kernel/irixsig.c2
-rw-r--r--arch/mips/kernel/ptrace.c26
-rw-r--r--arch/mips/kernel/ptrace32.c16
-rw-r--r--arch/mips/kernel/r4k_switch.S13
-rw-r--r--arch/mips/kernel/setup.c56
-rw-r--r--arch/mips/kernel/traps.c9
-rw-r--r--arch/mips/lasat/setup.c2
-rw-r--r--arch/mips/lib/Makefile3
-rw-r--r--arch/mips/lib/ashldi3.c29
-rw-r--r--arch/mips/lib/ashrdi3.c31
-rw-r--r--arch/mips/lib/libgcc.h26
-rw-r--r--arch/mips/lib/lshrdi3.c29
-rw-r--r--arch/mips/math-emu/cp1emu.c15
-rw-r--r--arch/mips/math-emu/ieee754.h2
-rw-r--r--arch/mips/math-emu/kernel_linkage.c24
-rw-r--r--arch/mips/mips-boards/atlas/atlas_setup.c2
-rw-r--r--arch/mips/mips-boards/generic/memory.c9
-rw-r--r--arch/mips/mips-boards/malta/malta_setup.c12
-rw-r--r--arch/mips/mips-boards/malta/malta_smp.c19
-rw-r--r--arch/mips/mips-boards/sead/sead_setup.c2
-rw-r--r--arch/mips/mips-boards/sim/sim_setup.c2
-rw-r--r--arch/mips/mips-boards/sim/sim_smp.c21
-rw-r--r--arch/mips/mm/tlb-r4k.c1
-rw-r--r--arch/mips/momentum/jaguar_atx/setup.c2
-rw-r--r--arch/mips/momentum/ocelot_3/setup.c2
-rw-r--r--arch/mips/momentum/ocelot_c/setup.c2
-rw-r--r--arch/mips/momentum/ocelot_g/setup.c2
-rw-r--r--arch/mips/pci/Makefile7
-rw-r--r--arch/mips/pci/fixup-ddb5074.c21
-rw-r--r--arch/mips/pci/fixup-emma2rh.c102
-rw-r--r--arch/mips/pci/fixup-excite.c36
-rw-r--r--arch/mips/pci/fixup-wrppmc.c37
-rw-r--r--arch/mips/pci/ops-bridge.c306
-rw-r--r--arch/mips/pci/ops-ddb5074.c271
-rw-r--r--arch/mips/pci/ops-ddb5476.c286
-rw-r--r--arch/mips/pci/ops-emma2rh.c186
-rw-r--r--arch/mips/pci/ops-it8172.c34
-rw-r--r--arch/mips/pci/ops-sni.c12
-rw-r--r--arch/mips/pci/ops-titan.c25
-rw-r--r--arch/mips/pci/pci-ddb5074.c79
-rw-r--r--arch/mips/pci/pci-ddb5476.c93
-rw-r--r--arch/mips/pci/pci-ddb5477.c32
-rw-r--r--arch/mips/pci/pci-emma2rh.c90
-rw-r--r--arch/mips/pci/pci-excite.c149
-rw-r--r--arch/mips/pci/pci-ip27.c295
-rw-r--r--arch/mips/pci/pci-jmr3927.c16
-rw-r--r--arch/mips/pci/pci-ocelot.c8
-rw-r--r--arch/mips/pci/pci-yosemite.c10
-rw-r--r--arch/mips/pci/pci.c5
-rw-r--r--arch/mips/philips/pnx8550/common/pci.c16
-rw-r--r--arch/mips/philips/pnx8550/common/setup.c27
-rw-r--r--arch/mips/pmc-sierra/yosemite/setup.c2
-rw-r--r--arch/mips/qemu/Makefile2
-rw-r--r--arch/mips/qemu/q-reset.c34
-rw-r--r--arch/mips/qemu/q-setup.c6
-rw-r--r--arch/mips/sgi-ip22/ip22-setup.c2
-rw-r--r--arch/mips/sgi-ip27/Kconfig38
-rw-r--r--arch/mips/sgi-ip27/ip27-init.c4
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c2
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c61
-rw-r--r--arch/mips/sgi-ip32/ip32-setup.c2
-rw-r--r--arch/mips/sibyte/bcm1480/time.c17
-rw-r--r--arch/mips/sibyte/sb1250/irq.c8
-rw-r--r--arch/mips/sibyte/swarm/setup.c4
-rw-r--r--arch/mips/sni/Makefile1
-rw-r--r--arch/mips/sni/setup.c135
-rw-r--r--arch/mips/sni/sniprom.c158
-rw-r--r--arch/mips/tx4927/common/tx4927_setup.c2
-rw-r--r--arch/mips/tx4938/common/setup.c2
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/setup.c5
-rw-r--r--arch/mips/vr41xx/Kconfig7
-rw-r--r--arch/mips/vr41xx/common/init.c2
-rw-r--r--arch/powerpc/kernel/prom_init.c10
-rw-r--r--arch/powerpc/kernel/signal_32.c11
-rw-r--r--arch/powerpc/kernel/signal_64.c2
-rw-r--r--arch/powerpc/mm/hash_native_64.c4
-rw-r--r--arch/powerpc/platforms/cell/setup.c11
-rw-r--r--arch/powerpc/platforms/pseries/setup.c8
-rw-r--r--arch/sparc/kernel/smp.c11
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c124
-rw-r--r--arch/sparc64/kernel/smp.c35
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c1
-rw-r--r--arch/sparc64/kernel/traps.c11
-rw-r--r--block/cfq-iosched.c11
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/pci_link.c3
-rw-r--r--drivers/acpi/processor_perflib.c5
-rw-r--r--drivers/block/aoe/aoenet.c3
-rw-r--r--drivers/cdrom/cdrom.c6
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/agp/alpha-agp.c15
-rw-r--r--drivers/char/agp/generic.c4
-rw-r--r--drivers/char/agp/intel-agp.c2
-rw-r--r--drivers/char/agp/uninorth-agp.c4
-rw-r--r--drivers/char/n_tty.c4
-rw-r--r--drivers/connector/cn_queue.c2
-rw-r--r--drivers/cpufreq/cpufreq.c8
-rw-r--r--drivers/cpufreq/cpufreq_stats.c6
-rw-r--r--drivers/cpufreq/freq_table.c16
-rw-r--r--drivers/dma/Kconfig34
-rw-r--r--drivers/dma/Makefile3
-rw-r--r--drivers/dma/dmaengine.c408
-rw-r--r--drivers/dma/ioatdma.c840
-rw-r--r--drivers/dma/ioatdma.h125
-rw-r--r--drivers/dma/ioatdma_hw.h52
-rw-r--r--drivers/dma/ioatdma_io.h118
-rw-r--r--drivers/dma/ioatdma_registers.h126
-rw-r--r--drivers/dma/iovlock.c301
-rw-r--r--drivers/infiniband/Kconfig5
-rw-r--r--drivers/infiniband/core/Makefile11
-rw-r--r--drivers/infiniband/core/addr.c367
-rw-r--r--drivers/infiniband/core/cache.c30
-rw-r--r--drivers/infiniband/core/cm.c119
-rw-r--r--drivers/infiniband/core/cma.c1927
-rw-r--r--drivers/infiniband/core/fmr_pool.c30
-rw-r--r--drivers/infiniband/core/mad.c97
-rw-r--r--drivers/infiniband/core/mad_priv.h2
-rw-r--r--drivers/infiniband/core/sa_query.c31
-rw-r--r--drivers/infiniband/core/ucm.c183
-rw-r--r--drivers/infiniband/core/uverbs.h4
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c971
-rw-r--r--drivers/infiniband/core/uverbs_main.c35
-rw-r--r--drivers/infiniband/core/uverbs_marshall.c138
-rw-r--r--drivers/infiniband/core/verbs.c44
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mad.c42
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c23
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c12
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mad.c14
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c33
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.h3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c40
-rw-r--r--drivers/infiniband/hw/mthca/mthca_reset.c59
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h34
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c27
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c28
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c17
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c3
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c482
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h33
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c4
-rw-r--r--drivers/message/fusion/mptspi.c2
-rw-r--r--drivers/message/i2o/exec-osm.c72
-rw-r--r--drivers/message/i2o/iop.c4
-rw-r--r--drivers/net/3c501.c2
-rw-r--r--drivers/net/3c503.c2
-rw-r--r--drivers/net/3c505.c2
-rw-r--r--drivers/net/3c507.c2
-rw-r--r--drivers/net/3c523.c2
-rw-r--r--drivers/net/3c527.c2
-rw-r--r--drivers/net/8139cp.c14
-rw-r--r--drivers/net/8139too.c14
-rw-r--r--drivers/net/Kconfig36
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/au1000_eth.c1802
-rw-r--r--drivers/net/au1000_eth.h134
-rw-r--r--drivers/net/bnx2.c190
-rw-r--r--drivers/net/bnx2.h15
-rw-r--r--drivers/net/bnx2_fw.h5256
-rw-r--r--drivers/net/bonding/bond_main.c9
-rw-r--r--drivers/net/cassini.c9
-rw-r--r--drivers/net/e100.c75
-rw-r--r--drivers/net/e1000/Makefile3
-rw-r--r--drivers/net/e1000/e1000.h6
-rw-r--r--drivers/net/e1000/e1000_ethtool.c41
-rw-r--r--drivers/net/e1000/e1000_hw.c115
-rw-r--r--drivers/net/e1000/e1000_hw.h7
-rw-r--r--drivers/net/e1000/e1000_main.c385
-rw-r--r--drivers/net/e1000/e1000_osdep.h3
-rw-r--r--drivers/net/e1000/e1000_param.c3
-rw-r--r--drivers/net/epic100.c56
-rw-r--r--drivers/net/forcedeth.c1779
-rw-r--r--drivers/net/hamradio/6pack.c8
-rw-r--r--drivers/net/hamradio/mkiss.c8
-rw-r--r--drivers/net/hp-plus.c2
-rw-r--r--drivers/net/hp.c4
-rw-r--r--drivers/net/ibmlana.c20
-rw-r--r--drivers/net/ibmlana.h6
-rw-r--r--drivers/net/ibmveth.c291
-rw-r--r--drivers/net/ibmveth.h11
-rw-r--r--drivers/net/ifb.c10
-rw-r--r--drivers/net/irda/Kconfig15
-rw-r--r--drivers/net/irda/Makefile1
-rw-r--r--drivers/net/irda/ali-ircc.c106
-rw-r--r--drivers/net/irda/irda-usb.c327
-rw-r--r--drivers/net/irda/irda-usb.h10
-rw-r--r--drivers/net/irda/mcs7780.c1009
-rw-r--r--drivers/net/irda/mcs7780.h167
-rw-r--r--drivers/net/irda/stir4200.c38
-rw-r--r--drivers/net/irda/vlsi_ir.c2
-rw-r--r--drivers/net/ixgb/Makefile2
-rw-r--r--drivers/net/ixgb/ixgb.h12
-rw-r--r--drivers/net/ixgb/ixgb_ee.c2
-rw-r--r--drivers/net/ixgb/ixgb_ee.h2
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c57
-rw-r--r--drivers/net/ixgb/ixgb_hw.c2
-rw-r--r--drivers/net/ixgb/ixgb_hw.h3
-rw-r--r--drivers/net/ixgb/ixgb_ids.h6
-rw-r--r--drivers/net/ixgb/ixgb_main.c304
-rw-r--r--drivers/net/ixgb/ixgb_osdep.h2
-rw-r--r--drivers/net/ixgb/ixgb_param.c26
-rw-r--r--drivers/net/mv643xx_eth.c2
-rw-r--r--drivers/net/myri10ge/Makefile5
-rw-r--r--drivers/net/myri10ge/myri10ge.c2869
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp.h205
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp_gen_header.h58
-rw-r--r--drivers/net/natsemi.c4
-rw-r--r--drivers/net/ne.c2
-rw-r--r--drivers/net/ne2.c2
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c42
-rw-r--r--drivers/net/phy/Kconfig6
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/smsc.c101
-rw-r--r--drivers/net/ppp_generic.c2
-rw-r--r--drivers/net/r8169.c1
-rw-r--r--drivers/net/s2io-regs.h32
-rw-r--r--drivers/net/s2io.c1476
-rw-r--r--drivers/net/s2io.h59
-rw-r--r--drivers/net/sis900.c26
-rw-r--r--drivers/net/sis900.h10
-rw-r--r--drivers/net/skge.c232
-rw-r--r--drivers/net/skge.h6
-rw-r--r--drivers/net/sky2.c53
-rw-r--r--drivers/net/smc-ultra.c2
-rw-r--r--drivers/net/smc-ultra32.c2
-rw-r--r--drivers/net/smc911x.c2307
-rw-r--r--drivers/net/smc911x.h835
-rw-r--r--drivers/net/smc9194.c7
-rw-r--r--drivers/net/smc91x.h18
-rw-r--r--drivers/net/sungem_phy.c6
-rw-r--r--drivers/net/tg3.c226
-rw-r--r--drivers/net/tg3.h24
-rw-r--r--drivers/net/tulip/de2104x.c58
-rw-r--r--drivers/net/tulip/de4x5.c716
-rw-r--r--drivers/net/tulip/de4x5.h14
-rw-r--r--drivers/net/tulip/dmfe.c2
-rw-r--r--drivers/net/tulip/eeprom.c8
-rw-r--r--drivers/net/tulip/interrupt.c126
-rw-r--r--drivers/net/tulip/media.c2
-rw-r--r--drivers/net/tulip/tulip.h2
-rw-r--r--drivers/net/tulip/tulip_core.c14
-rw-r--r--drivers/net/tulip/uli526x.c80
-rw-r--r--drivers/net/tulip/winbond-840.c33
-rw-r--r--drivers/net/tulip/xircom_cb.c208
-rw-r--r--drivers/net/via-velocity.c10
-rw-r--r--drivers/net/via-velocity.h2
-rw-r--r--drivers/net/wan/pci200syn.c27
-rw-r--r--drivers/net/wireless/Kconfig47
-rw-r--r--drivers/net/wireless/Makefile2
-rw-r--r--drivers/net/wireless/airo.c271
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c48
-rw-r--r--drivers/net/wireless/hermes.c66
-rw-r--r--drivers/net/wireless/hermes.h43
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c11
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c6
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c2
-rw-r--r--drivers/net/wireless/ipw2200.c849
-rw-r--r--drivers/net/wireless/ipw2200.h83
-rw-r--r--drivers/net/wireless/orinoco.c255
-rw-r--r--drivers/net/wireless/orinoco.h19
-rw-r--r--drivers/net/wireless/orinoco_cs.c42
-rw-r--r--drivers/net/wireless/orinoco_nortel.c171
-rw-r--r--drivers/net/wireless/orinoco_pci.c210
-rw-r--r--drivers/net/wireless/orinoco_pci.h104
-rw-r--r--drivers/net/wireless/orinoco_plx.c223
-rw-r--r--drivers/net/wireless/orinoco_tmd.c99
-rw-r--r--drivers/net/wireless/spectrum_cs.c81
-rw-r--r--drivers/net/wireless/zd1201.c (renamed from drivers/usb/net/zd1201.c)67
-rw-r--r--drivers/net/wireless/zd1201.h (renamed from drivers/usb/net/zd1201.h)0
-rw-r--r--drivers/pci/pci-driver.c13
-rw-r--r--drivers/pci/pci.c21
-rw-r--r--drivers/s390/net/Makefile3
-rw-r--r--drivers/s390/net/ctcmain.c45
-rw-r--r--drivers/s390/net/ctcmain.h12
-rw-r--r--drivers/s390/net/ctctty.c1259
-rw-r--r--drivers/s390/net/ctctty.h35
-rw-r--r--drivers/scsi/libata-core.c1
-rw-r--r--drivers/scsi/sata_mv.c3
-rw-r--r--drivers/usb/host/ohci-pxa27x.c3
-rw-r--r--drivers/usb/net/Kconfig17
-rw-r--r--drivers/usb/net/Makefile1
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/intelfb/intelfb.h16
-rw-r--r--drivers/video/intelfb/intelfbdrv.c85
-rw-r--r--drivers/video/intelfb/intelfbhw.c494
-rw-r--r--drivers/video/intelfb/intelfbhw.h25
-rw-r--r--fs/bio.c5
-rw-r--r--fs/locks.c2
-rw-r--r--include/asm-arm/arch-pxa/ohci.h2
-rw-r--r--include/asm-mips/addrspace.h35
-rw-r--r--include/asm-mips/apm.h65
-rw-r--r--include/asm-mips/asmmacro-32.h4
-rw-r--r--include/asm-mips/asmmacro-64.h19
-rw-r--r--include/asm-mips/bootinfo.h13
-rw-r--r--include/asm-mips/ddb5074.h11
-rw-r--r--include/asm-mips/ddb5xxx/ddb5074.h38
-rw-r--r--include/asm-mips/ddb5xxx/ddb5476.h157
-rw-r--r--include/asm-mips/ddb5xxx/ddb5xxx.h11
-rw-r--r--include/asm-mips/emma2rh/emma2rh.h330
-rw-r--r--include/asm-mips/emma2rh/markeins.h76
-rw-r--r--include/asm-mips/fpu.h3
-rw-r--r--include/asm-mips/fpu_emulator.h4
-rw-r--r--include/asm-mips/futex.h32
-rw-r--r--include/asm-mips/mach-ddb5074/mc146818rtc.h31
-rw-r--r--include/asm-mips/mach-dec/param.h18
-rw-r--r--include/asm-mips/mach-emma2rh/irq.h (renamed from include/asm-mips/mach-mips/param.h)8
-rw-r--r--include/asm-mips/mach-excite/cpu-feature-overrides.h40
-rw-r--r--include/asm-mips/mach-excite/excite.h155
-rw-r--r--include/asm-mips/mach-excite/excite_nandflash.h7
-rw-r--r--include/asm-mips/mach-excite/rm9k_eth.h23
-rw-r--r--include/asm-mips/mach-excite/rm9k_wdt.h12
-rw-r--r--include/asm-mips/mach-excite/rm9k_xicap.h16
-rw-r--r--include/asm-mips/mach-generic/param.h13
-rw-r--r--include/asm-mips/mach-ip22/cpu-feature-overrides.h2
-rw-r--r--include/asm-mips/mach-ip27/cpu-feature-overrides.h3
-rw-r--r--include/asm-mips/mach-ip32/cpu-feature-overrides.h2
-rw-r--r--include/asm-mips/mach-jazz/param.h16
-rw-r--r--include/asm-mips/mach-mips/cpu-feature-overrides.h4
-rw-r--r--include/asm-mips/mach-qemu/param.h13
-rw-r--r--include/asm-mips/mach-rm200/cpu-feature-overrides.h4
-rw-r--r--include/asm-mips/mach-sim/cpu-feature-overrides.h4
-rw-r--r--include/asm-mips/mach-wrppmc/mach-gt64120.h84
-rw-r--r--include/asm-mips/mipsregs.h4
-rw-r--r--include/asm-mips/mmzone.h11
-rw-r--r--include/asm-mips/page.h19
-rw-r--r--include/asm-mips/param.h2
-rw-r--r--include/asm-mips/pci/bridge.h3
-rw-r--r--include/asm-mips/pgtable.h2
-rw-r--r--include/asm-mips/processor.h16
-rw-r--r--include/asm-mips/qemu.h6
-rw-r--r--include/asm-mips/rm9k-ocd.h56
-rw-r--r--include/asm-mips/sn/addrs.h27
-rw-r--r--include/asm-mips/sn/fru.h (renamed from include/asm-mips/sn/sn0/sn0_fru.h)8
-rw-r--r--include/asm-mips/sn/klconfig.h89
-rw-r--r--include/asm-mips/sn/kldir.h34
-rw-r--r--include/asm-mips/sn/sn0/addrs.h87
-rw-r--r--include/asm-mips/sn/sn0/arch.h17
-rw-r--r--include/asm-mips/sn/sn0/hub.h4
-rw-r--r--include/asm-mips/sn/sn0/hubio.h16
-rw-r--r--include/asm-mips/sn/sn0/hubmd.h2
-rw-r--r--include/asm-mips/sn/sn0/hubpi.h18
-rw-r--r--include/asm-mips/sn/sn0/ip27.h9
-rw-r--r--include/asm-mips/sni.h7
-rw-r--r--include/asm-mips/war.h5
-rw-r--r--include/asm-powerpc/cputable.h2
-rw-r--r--include/linux/console.h4
-rw-r--r--include/linux/dmaengine.h359
-rw-r--r--include/linux/i2o.h5
-rw-r--r--include/linux/igmp.h2
-rw-r--r--include/linux/netdevice.h45
-rw-r--r--include/linux/netfilter/nf_conntrack_common.h4
-rw-r--r--include/linux/netfilter/nfnetlink_conntrack.h4
-rw-r--r--include/linux/netfilter/xt_CONNSECMARK.h13
-rw-r--r--include/linux/netfilter/xt_SECMARK.h26
-rw-r--r--include/linux/netfilter/xt_quota.h16
-rw-r--r--include/linux/netfilter/xt_statistic.h32
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack.h6
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_h323.h7
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h3
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_sip.h44
-rw-r--r--include/linux/pci-acpi.h2
-rw-r--r--include/linux/pci.h2
-rw-r--r--include/linux/pci_ids.h12
-rw-r--r--include/linux/pfkeyv2.h2
-rw-r--r--include/linux/security.h40
-rw-r--r--include/linux/selinux.h32
-rw-r--r--include/linux/skbuff.h74
-rw-r--r--include/linux/sysctl.h4
-rw-r--r--include/linux/tcp.h8
-rw-r--r--include/linux/xfrm.h4
-rw-r--r--include/net/ieee80211.h9
-rw-r--r--include/net/ieee80211softmac.h40
-rw-r--r--include/net/ieee80211softmac_wx.h5
-rw-r--r--include/net/ip.h1
-rw-r--r--include/net/llc_if.h17
-rw-r--r--include/net/netdma.h44
-rw-r--r--include/net/netfilter/nf_conntrack.h5
-rw-r--r--include/net/netfilter/nf_conntrack_compat.h26
-rw-r--r--include/net/raw.h2
-rw-r--r--include/net/sctp/sctp.h2
-rw-r--r--include/net/sctp/structs.h3
-rw-r--r--include/net/sock.h20
-rw-r--r--include/net/tcp.h15
-rw-r--r--include/net/xfrm.h26
-rw-r--r--include/rdma/ib_addr.h114
-rw-r--r--include/rdma/ib_cache.h13
-rw-r--r--include/rdma/ib_cm.h26
-rw-r--r--include/rdma/ib_marshall.h50
-rw-r--r--include/rdma/ib_sa.h7
-rw-r--r--include/rdma/ib_smi.h36
-rw-r--r--include/rdma/ib_user_cm.h86
-rw-r--r--include/rdma/ib_user_sa.h60
-rw-r--r--include/rdma/ib_user_verbs.h80
-rw-r--r--include/rdma/ib_verbs.h22
-rw-r--r--include/rdma/rdma_cm.h256
-rw-r--r--include/rdma/rdma_cm_ib.h47
-rw-r--r--include/scsi/srp.h5
-rw-r--r--kernel/exit.c8
-rw-r--r--kernel/posix-cpu-timers.c48
-rw-r--r--kernel/power/main.c2
-rw-r--r--kernel/printk.c28
-rw-r--r--mm/shmem.c2
-rw-r--r--mm/vmscan.c2
-rw-r--r--net/Kconfig22
-rw-r--r--net/atm/clip.c4
-rw-r--r--net/bridge/Makefile2
-rw-r--r--net/bridge/br.c28
-rw-r--r--net/bridge/br_device.c6
-rw-r--r--net/bridge/br_forward.c12
-rw-r--r--net/bridge/br_if.c13
-rw-r--r--net/bridge/br_netfilter.c14
-rw-r--r--net/bridge/br_netlink.c199
-rw-r--r--net/bridge/br_notify.c2
-rw-r--r--net/bridge/br_private.h12
-rw-r--r--net/bridge/br_stp_if.c4
-rw-r--r--net/core/Makefile1
-rw-r--r--net/core/dev.c185
-rw-r--r--net/core/dev_mcast.c28
-rw-r--r--net/core/ethtool.c9
-rw-r--r--net/core/netpoll.c9
-rw-r--r--net/core/pktgen.c4
-rw-r--r--net/core/skbuff.c10
-rw-r--r--net/core/sock.c6
-rw-r--r--net/core/user_dma.c131
-rw-r--r--net/dccp/ackvec.c1
-rw-r--r--net/dccp/proto.c4
-rw-r--r--net/decnet/dn_nsp_in.c3
-rw-r--r--net/decnet/dn_route.c3
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c11
-rw-r--r--net/ieee80211/ieee80211_rx.c18
-rw-r--r--net/ieee80211/ieee80211_tx.c88
-rw-r--r--net/ieee80211/ieee80211_wx.c44
-rw-r--r--net/ieee80211/softmac/Kconfig1
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c96
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c15
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_event.c30
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_io.c169
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c117
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_priv.h5
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c36
-rw-r--r--net/ipv4/Kconfig50
-rw-r--r--net/ipv4/Makefile6
-rw-r--r--net/ipv4/ah4.c15
-rw-r--r--net/ipv4/esp4.c18
-rw-r--r--net/ipv4/fib_frontend.c1
-rw-r--r--net/ipv4/icmp.c5
-rw-r--r--net/ipv4/igmp.c2
-rw-r--r--net/ipv4/ip_forward.c1
-rw-r--r--net/ipv4/ip_output.c3
-rw-r--r--net/ipv4/ipcomp.c34
-rw-r--r--net/ipv4/netfilter/Kconfig40
-rw-r--r--net/ipv4/netfilter/Makefile2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_amanda.c143
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c9
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c77
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c111
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323_types.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c85
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_gre.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_icmp.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_udp.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_sip.c471
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c18
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_h323.c77
-rw-r--r--net/ipv4/netfilter/ip_nat_sip.c249
-rw-r--r--net/ipv4/netfilter/ip_nat_snmp_basic.c2
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c20
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c1
-rw-r--r--net/ipv4/netfilter/ipt_hashlimit.c73
-rw-r--r--net/ipv4/netfilter/ipt_recent.c1276
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c2
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/sysctl_net_ipv4.c26
-rw-r--r--net/ipv4/tcp.c127
-rw-r--r--net/ipv4/tcp_bic.c7
-rw-r--r--net/ipv4/tcp_compound.c448
-rw-r--r--net/ipv4/tcp_cong.c6
-rw-r--r--net/ipv4/tcp_cubic.c6
-rw-r--r--net/ipv4/tcp_highspeed.c24
-rw-r--r--net/ipv4/tcp_htcp.c9
-rw-r--r--net/ipv4/tcp_input.c93
-rw-r--r--net/ipv4/tcp_ipv4.c18
-rw-r--r--net/ipv4/tcp_lp.c338
-rw-r--r--net/ipv4/tcp_output.c6
-rw-r--r--net/ipv4/tcp_probe.c181
-rw-r--r--net/ipv4/tcp_veno.c231
-rw-r--r--net/ipv4/tcp_westwood.c80
-rw-r--r--net/ipv4/xfrm4_input.c28
-rw-r--r--net/ipv4/xfrm4_mode_transport.c83
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c125
-rw-r--r--net/ipv4/xfrm4_output.c61
-rw-r--r--net/ipv4/xfrm4_policy.c6
-rw-r--r--net/ipv4/xfrm4_state.c1
-rw-r--r--net/ipv6/Kconfig20
-rw-r--r--net/ipv6/Makefile2
-rw-r--r--net/ipv6/addrconf.c28
-rw-r--r--net/ipv6/ah6.c10
-rw-r--r--net/ipv6/esp6.c20
-rw-r--r--net/ipv6/ip6_output.c3
-rw-r--r--net/ipv6/ipcomp6.c38
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c10
-rw-r--r--net/ipv6/tcp_ipv6.c12
-rw-r--r--net/ipv6/xfrm6_input.c29
-rw-r--r--net/ipv6/xfrm6_mode_transport.c88
-rw-r--r--net/ipv6/xfrm6_mode_tunnel.c121
-rw-r--r--net/ipv6/xfrm6_output.c63
-rw-r--r--net/ipv6/xfrm6_policy.c6
-rw-r--r--net/ipv6/xfrm6_state.c1
-rw-r--r--net/ipx/ipx_route.c2
-rw-r--r--net/irda/irlmp.c6
-rw-r--r--net/key/af_key.c17
-rw-r--r--net/llc/af_llc.c6
-rw-r--r--net/llc/llc_if.c2
-rw-r--r--net/llc/llc_input.c10
-rw-r--r--net/llc/llc_sap.c59
-rw-r--r--net/netfilter/Kconfig48
-rw-r--r--net/netfilter/Makefile4
-rw-r--r--net/netfilter/nf_conntrack_core.c9
-rw-r--r--net/netfilter/nf_conntrack_ftp.c77
-rw-r--r--net/netfilter/nf_conntrack_netlink.c85
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c5
-rw-r--r--net/netfilter/nf_conntrack_proto_udp.c3
-rw-r--r--net/netfilter/nf_conntrack_standalone.c16
-rw-r--r--net/netfilter/xt_CONNSECMARK.c155
-rw-r--r--net/netfilter/xt_SECMARK.c156
-rw-r--r--net/netfilter/xt_connmark.c2
-rw-r--r--net/netfilter/xt_dccp.c3
-rw-r--r--net/netfilter/xt_mark.c2
-rw-r--r--net/netfilter/xt_multiport.c7
-rw-r--r--net/netfilter/xt_quota.c96
-rw-r--r--net/netfilter/xt_sctp.c4
-rw-r--r--net/netfilter/xt_statistic.c112
-rw-r--r--net/netfilter/xt_string.c2
-rw-r--r--net/sched/sch_generic.c28
-rw-r--r--net/sched/sch_teql.c9
-rw-r--r--net/sctp/input.c6
-rw-r--r--net/sctp/ipv6.c6
-rw-r--r--net/sctp/output.c48
-rw-r--r--net/sctp/outqueue.c1
-rw-r--r--net/sctp/protocol.c8
-rw-r--r--net/sctp/sm_statefuns.c10
-rw-r--r--net/sctp/socket.c28
-rw-r--r--net/sctp/ulpevent.c30
-rw-r--r--net/xfrm/xfrm_policy.c141
-rw-r--r--net/xfrm/xfrm_state.c15
-rw-r--r--net/xfrm/xfrm_user.c19
-rw-r--r--security/dummy.c12
-rw-r--r--security/selinux/Kconfig29
-rw-r--r--security/selinux/exports.c22
-rw-r--r--security/selinux/hooks.c246
-rw-r--r--security/selinux/include/av_inherit.h1
-rw-r--r--security/selinux/include/av_perm_to_string.h3
-rw-r--r--security/selinux/include/av_permissions.h26
-rw-r--r--security/selinux/include/class_to_string.h2
-rw-r--r--security/selinux/include/flask.h2
-rw-r--r--security/selinux/include/xfrm.h4
-rw-r--r--security/selinux/selinuxfs.c66
-rw-r--r--security/selinux/xfrm.c51
-rw-r--r--sound/oss/Kconfig4
711 files changed, 41752 insertions, 18041 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 43ab119963d5..f50cf8fac3f0 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -212,15 +212,6 @@ Who: Greg Kroah-Hartman <gregkh@suse.de>
212 212
213--------------------------- 213---------------------------
214 214
215What: Support for NEC DDB5074 and DDB5476 evaluation boards.
216When: June 2006
217Why: Board specific code doesn't build anymore since ~2.6.0 and no
218 users have complained indicating there is no more need for these
219 boards. This should really be considered a last call.
220Who: Ralf Baechle <ralf@linux-mips.org>
221
222---------------------------
223
224What: USB driver API moves to EXPORT_SYMBOL_GPL 215What: USB driver API moves to EXPORT_SYMBOL_GPL
225When: Febuary 2008 216When: Febuary 2008
226Files: include/linux/usb.h, drivers/usb/core/driver.c 217Files: include/linux/usb.h, drivers/usb/core/driver.c
diff --git a/Documentation/infiniband/ipoib.txt b/Documentation/infiniband/ipoib.txt
index 5c5a4ccce76a..187035560d7f 100644
--- a/Documentation/infiniband/ipoib.txt
+++ b/Documentation/infiniband/ipoib.txt
@@ -1,10 +1,10 @@
1IP OVER INFINIBAND 1IP OVER INFINIBAND
2 2
3 The ib_ipoib driver is an implementation of the IP over InfiniBand 3 The ib_ipoib driver is an implementation of the IP over InfiniBand
4 protocol as specified by the latest Internet-Drafts issued by the 4 protocol as specified by RFC 4391 and 4392, issued by the IETF ipoib
5 IETF ipoib working group. It is a "native" implementation in the 5 working group. It is a "native" implementation in the sense of
6 sense of setting the interface type to ARPHRD_INFINIBAND and the 6 setting the interface type to ARPHRD_INFINIBAND and the hardware
7 hardware address length to 20 (earlier proprietary implementations 7 address length to 20 (earlier proprietary implementations
8 masqueraded to the kernel as ethernet interfaces). 8 masqueraded to the kernel as ethernet interfaces).
9 9
10Partitions and P_Keys 10Partitions and P_Keys
@@ -53,3 +53,7 @@ References
53 53
54 IETF IP over InfiniBand (ipoib) Working Group 54 IETF IP over InfiniBand (ipoib) Working Group
55 http://ietf.org/html.charters/ipoib-charter.html 55 http://ietf.org/html.charters/ipoib-charter.html
56 Transmission of IP over InfiniBand (IPoIB) (RFC 4391)
57 http://ietf.org/rfc/rfc4391.txt
58 IP over InfiniBand (IPoIB) Architecture (RFC 4392)
59 http://ietf.org/rfc/rfc4392.txt
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index b3a6187e5305..a9d3a1794b23 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1402,6 +1402,15 @@ running once the system is up.
1402 If enabled at boot time, /selinux/disable can be used 1402 If enabled at boot time, /selinux/disable can be used
1403 later to disable prior to initial policy load. 1403 later to disable prior to initial policy load.
1404 1404
1405 selinux_compat_net =
1406 [SELINUX] Set initial selinux_compat_net flag value.
1407 Format: { "0" | "1" }
1408 0 -- use new secmark-based packet controls
1409 1 -- use legacy packet controls
1410 Default value is 0 (preferred).
1411 Value can be changed at runtime via
1412 /selinux/compat_net.
1413
1405 serialnumber [BUGS=IA-32] 1414 serialnumber [BUGS=IA-32]
1406 1415
1407 sg_def_reserved_size= [SCSI] 1416 sg_def_reserved_size= [SCSI]
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index c61d8b876fdb..4710845dbac4 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -19,6 +19,7 @@ Contents:
19 - Control dependencies. 19 - Control dependencies.
20 - SMP barrier pairing. 20 - SMP barrier pairing.
21 - Examples of memory barrier sequences. 21 - Examples of memory barrier sequences.
22 - Read memory barriers vs load speculation.
22 23
23 (*) Explicit kernel barriers. 24 (*) Explicit kernel barriers.
24 25
@@ -248,7 +249,7 @@ And there are a number of things that _must_ or _must_not_ be assumed:
248 we may get either of: 249 we may get either of:
249 250
250 STORE *A = X; Y = LOAD *A; 251 STORE *A = X; Y = LOAD *A;
251 STORE *A = Y; 252 STORE *A = Y = X;
252 253
253 254
254========================= 255=========================
@@ -344,9 +345,12 @@ Memory barriers come in four basic varieties:
344 345
345 (4) General memory barriers. 346 (4) General memory barriers.
346 347
347 A general memory barrier is a combination of both a read memory barrier 348 A general memory barrier gives a guarantee that all the LOAD and STORE
348 and a write memory barrier. It is a partial ordering over both loads and 349 operations specified before the barrier will appear to happen before all
349 stores. 350 the LOAD and STORE operations specified after the barrier with respect to
351 the other components of the system.
352
353 A general memory barrier is a partial ordering over both loads and stores.
350 354
351 General memory barriers imply both read and write memory barriers, and so 355 General memory barriers imply both read and write memory barriers, and so
352 can substitute for either. 356 can substitute for either.
@@ -546,9 +550,9 @@ write barrier, though, again, a general barrier is viable:
546 =============== =============== 550 =============== ===============
547 a = 1; 551 a = 1;
548 <write barrier> 552 <write barrier>
549 b = 2; x = a; 553 b = 2; x = b;
550 <read barrier> 554 <read barrier>
551 y = b; 555 y = a;
552 556
553Or: 557Or:
554 558
@@ -563,6 +567,18 @@ Or:
563Basically, the read barrier always has to be there, even though it can be of 567Basically, the read barrier always has to be there, even though it can be of
564the "weaker" type. 568the "weaker" type.
565 569
570[!] Note that the stores before the write barrier would normally be expected to
571match the loads after the read barrier or data dependency barrier, and vice
572versa:
573
574 CPU 1 CPU 2
575 =============== ===============
576 a = 1; }---- --->{ v = c
577 b = 2; } \ / { w = d
578 <write barrier> \ <read barrier>
579 c = 3; } / \ { x = a;
580 d = 4; }---- --->{ y = b;
581
566 582
567EXAMPLES OF MEMORY BARRIER SEQUENCES 583EXAMPLES OF MEMORY BARRIER SEQUENCES
568------------------------------------ 584------------------------------------
@@ -600,8 +616,8 @@ STORE B, STORE C } all occuring before the unordered set of { STORE D, STORE E
600 | | +------+ 616 | | +------+
601 +-------+ : : 617 +-------+ : :
602 | 618 |
603 | Sequence in which stores committed to memory system 619 | Sequence in which stores are committed to the
604 | by CPU 1 620 | memory system by CPU 1
605 V 621 V
606 622
607 623
@@ -683,14 +699,12 @@ then the following will occur:
683 | : : | | 699 | : : | |
684 | : : | CPU 2 | 700 | : : | CPU 2 |
685 | +-------+ | | 701 | +-------+ | |
686 \ | X->9 |------>| | 702 | | X->9 |------>| |
687 \ +-------+ | | 703 | +-------+ | |
688 ----->| B->2 | | | 704 Makes sure all effects ---> \ ddddddddddddddddd | |
689 +-------+ | | 705 prior to the store of C \ +-------+ | |
690 Makes sure all effects ---> ddddddddddddddddd | | 706 are perceptible to ----->| B->2 |------>| |
691 prior to the store of C +-------+ | | 707 subsequent loads +-------+ | |
692 are perceptible to | B->2 |------>| |
693 successive loads +-------+ | |
694 : : +-------+ 708 : : +-------+
695 709
696 710
@@ -699,73 +713,239 @@ following sequence of events:
699 713
700 CPU 1 CPU 2 714 CPU 1 CPU 2
701 ======================= ======================= 715 ======================= =======================
716 { A = 0, B = 9 }
702 STORE A=1 717 STORE A=1
703 STORE B=2
704 STORE C=3
705 <write barrier> 718 <write barrier>
706 STORE D=4 719 STORE B=2
707 STORE E=5
708 LOAD A
709 LOAD B 720 LOAD B
710 LOAD C 721 LOAD A
711 LOAD D
712 LOAD E
713 722
714Without intervention, CPU 2 may then choose to perceive the events on CPU 1 in 723Without intervention, CPU 2 may then choose to perceive the events on CPU 1 in
715some effectively random order, despite the write barrier issued by CPU 1: 724some effectively random order, despite the write barrier issued by CPU 1:
716 725
717 +-------+ : : 726 +-------+ : : : :
718 | | +------+ 727 | | +------+ +-------+
719 | |------>| C=3 | } 728 | |------>| A=1 |------ --->| A->0 |
720 | | : +------+ } 729 | | +------+ \ +-------+
721 | | : | A=1 | } 730 | CPU 1 | wwwwwwwwwwwwwwww \ --->| B->9 |
722 | | : +------+ } 731 | | +------+ | +-------+
723 | CPU 1 | : | B=2 | }--- 732 | |------>| B=2 |--- | : :
724 | | +------+ } \ 733 | | +------+ \ | : : +-------+
725 | | wwwwwwwwwwwww} \ 734 +-------+ : : \ | +-------+ | |
726 | | +------+ } \ : : +-------+ 735 ---------->| B->2 |------>| |
727 | | : | E=5 | } \ +-------+ | | 736 | +-------+ | CPU 2 |
728 | | : +------+ } \ { | C->3 |------>| | 737 | | A->0 |------>| |
729 | |------>| D=4 | } \ { +-------+ : | | 738 | +-------+ | |
730 | | +------+ \ { | E->5 | : | | 739 | : : +-------+
731 +-------+ : : \ { +-------+ : | | 740 \ : :
732 Transfer -->{ | A->1 | : | CPU 2 | 741 \ +-------+
733 from CPU 1 { +-------+ : | | 742 ---->| A->1 |
734 to CPU 2 { | D->4 | : | | 743 +-------+
735 { +-------+ : | | 744 : :
736 { | B->2 |------>| |
737 +-------+ | |
738 : : +-------+
739
740
741If, however, a read barrier were to be placed between the load of C and the
742load of D on CPU 2, then the partial ordering imposed by CPU 1 will be
743perceived correctly by CPU 2.
744 745
745 +-------+ : : 746
746 | | +------+ 747If, however, a read barrier were to be placed between the load of E and the
747 | |------>| C=3 | } 748load of A on CPU 2:
748 | | : +------+ } 749
749 | | : | A=1 | }--- 750 CPU 1 CPU 2
750 | | : +------+ } \ 751 ======================= =======================
751 | CPU 1 | : | B=2 | } \ 752 { A = 0, B = 9 }
752 | | +------+ \ 753 STORE A=1
753 | | wwwwwwwwwwwwwwww \ 754 <write barrier>
754 | | +------+ \ : : +-------+ 755 STORE B=2
755 | | : | E=5 | } \ +-------+ | | 756 LOAD B
756 | | : +------+ }--- \ { | C->3 |------>| | 757 <read barrier>
757 | |------>| D=4 | } \ \ { +-------+ : | | 758 LOAD A
758 | | +------+ \ -->{ | B->2 | : | | 759
759 +-------+ : : \ { +-------+ : | | 760then the partial ordering imposed by CPU 1 will be perceived correctly by CPU
760 \ { | A->1 | : | CPU 2 | 7612:
761 \ +-------+ | | 762
762 At this point the read ----> \ rrrrrrrrrrrrrrrrr | | 763 +-------+ : : : :
763 barrier causes all effects \ +-------+ | | 764 | | +------+ +-------+
764 prior to the storage of C \ { | E->5 | : | | 765 | |------>| A=1 |------ --->| A->0 |
765 to be perceptible to CPU 2 -->{ +-------+ : | | 766 | | +------+ \ +-------+
766 { | D->4 |------>| | 767 | CPU 1 | wwwwwwwwwwwwwwww \ --->| B->9 |
767 +-------+ | | 768 | | +------+ | +-------+
768 : : +-------+ 769 | |------>| B=2 |--- | : :
770 | | +------+ \ | : : +-------+
771 +-------+ : : \ | +-------+ | |
772 ---------->| B->2 |------>| |
773 | +-------+ | CPU 2 |
774 | : : | |
775 | : : | |
776 At this point the read ----> \ rrrrrrrrrrrrrrrrr | |
777 barrier causes all effects \ +-------+ | |
778 prior to the storage of B ---->| A->1 |------>| |
779 to be perceptible to CPU 2 +-------+ | |
780 : : +-------+
781
782
783To illustrate this more completely, consider what could happen if the code
784contained a load of A either side of the read barrier:
785
786 CPU 1 CPU 2
787 ======================= =======================
788 { A = 0, B = 9 }
789 STORE A=1
790 <write barrier>
791 STORE B=2
792 LOAD B
793 LOAD A [first load of A]
794 <read barrier>
795 LOAD A [second load of A]
796
797Even though the two loads of A both occur after the load of B, they may both
798come up with different values:
799
800 +-------+ : : : :
801 | | +------+ +-------+
802 | |------>| A=1 |------ --->| A->0 |
803 | | +------+ \ +-------+
804 | CPU 1 | wwwwwwwwwwwwwwww \ --->| B->9 |
805 | | +------+ | +-------+
806 | |------>| B=2 |--- | : :
807 | | +------+ \ | : : +-------+
808 +-------+ : : \ | +-------+ | |
809 ---------->| B->2 |------>| |
810 | +-------+ | CPU 2 |
811 | : : | |
812 | : : | |
813 | +-------+ | |
814 | | A->0 |------>| 1st |
815 | +-------+ | |
816 At this point the read ----> \ rrrrrrrrrrrrrrrrr | |
817 barrier causes all effects \ +-------+ | |
818 prior to the storage of B ---->| A->1 |------>| 2nd |
819 to be perceptible to CPU 2 +-------+ | |
820 : : +-------+
821
822
823But it may be that the update to A from CPU 1 becomes perceptible to CPU 2
824before the read barrier completes anyway:
825
826 +-------+ : : : :
827 | | +------+ +-------+
828 | |------>| A=1 |------ --->| A->0 |
829 | | +------+ \ +-------+
830 | CPU 1 | wwwwwwwwwwwwwwww \ --->| B->9 |
831 | | +------+ | +-------+
832 | |------>| B=2 |--- | : :
833 | | +------+ \ | : : +-------+
834 +-------+ : : \ | +-------+ | |
835 ---------->| B->2 |------>| |
836 | +-------+ | CPU 2 |
837 | : : | |
838 \ : : | |
839 \ +-------+ | |
840 ---->| A->1 |------>| 1st |
841 +-------+ | |
842 rrrrrrrrrrrrrrrrr | |
843 +-------+ | |
844 | A->1 |------>| 2nd |
845 +-------+ | |
846 : : +-------+
847
848
849The guarantee is that the second load will always come up with A == 1 if the
850load of B came up with B == 2. No such guarantee exists for the first load of
851A; that may come up with either A == 0 or A == 1.
852
853
854READ MEMORY BARRIERS VS LOAD SPECULATION
855----------------------------------------
856
857Many CPUs speculate with loads: that is they see that they will need to load an
858item from memory, and they find a time where they're not using the bus for any
859other loads, and so do the load in advance - even though they haven't actually
860got to that point in the instruction execution flow yet. This permits the
861actual load instruction to potentially complete immediately because the CPU
862already has the value to hand.
863
864It may turn out that the CPU didn't actually need the value - perhaps because a
865branch circumvented the load - in which case it can discard the value or just
866cache it for later use.
867
868Consider:
869
870 CPU 1 CPU 2
871 ======================= =======================
872 LOAD B
873 DIVIDE } Divide instructions generally
874 DIVIDE } take a long time to perform
875 LOAD A
876
877Which might appear as this:
878
879 : : +-------+
880 +-------+ | |
881 --->| B->2 |------>| |
882 +-------+ | CPU 2 |
883 : :DIVIDE | |
884 +-------+ | |
885 The CPU being busy doing a ---> --->| A->0 |~~~~ | |
886 division speculates on the +-------+ ~ | |
887 LOAD of A : : ~ | |
888 : :DIVIDE | |
889 : : ~ | |
890 Once the divisions are complete --> : : ~-->| |
891 the CPU can then perform the : : | |
892 LOAD with immediate effect : : +-------+
893
894
895Placing a read barrier or a data dependency barrier just before the second
896load:
897
898 CPU 1 CPU 2
899 ======================= =======================
900 LOAD B
901 DIVIDE
902 DIVIDE
903 <read barrier>
904 LOAD A
905
906will force any value speculatively obtained to be reconsidered to an extent
907dependent on the type of barrier used. If there was no change made to the
908speculated memory location, then the speculated value will just be used:
909
910 : : +-------+
911 +-------+ | |
912 --->| B->2 |------>| |
913 +-------+ | CPU 2 |
914 : :DIVIDE | |
915 +-------+ | |
916 The CPU being busy doing a ---> --->| A->0 |~~~~ | |
917 division speculates on the +-------+ ~ | |
918 LOAD of A : : ~ | |
919 : :DIVIDE | |
920 : : ~ | |
921 : : ~ | |
922 rrrrrrrrrrrrrrrr~ | |
923 : : ~ | |
924 : : ~-->| |
925 : : | |
926 : : +-------+
927
928
929but if there was an update or an invalidation from another CPU pending, then
930the speculation will be cancelled and the value reloaded:
931
932 : : +-------+
933 +-------+ | |
934 --->| B->2 |------>| |
935 +-------+ | CPU 2 |
936 : :DIVIDE | |
937 +-------+ | |
938 The CPU being busy doing a ---> --->| A->0 |~~~~ | |
939 division speculates on the +-------+ ~ | |
940 LOAD of A : : ~ | |
941 : :DIVIDE | |
942 : : ~ | |
943 : : ~ | |
944 rrrrrrrrrrrrrrrrr | |
945 +-------+ | |
946 The speculation is discarded ---> --->| A->1 |------>| |
947 and an updated value is +-------+ | |
948 retrieved : : +-------+
769 949
770 950
771======================== 951========================
@@ -901,7 +1081,7 @@ IMPLICIT KERNEL MEMORY BARRIERS
901=============================== 1081===============================
902 1082
903Some of the other functions in the linux kernel imply memory barriers, amongst 1083Some of the other functions in the linux kernel imply memory barriers, amongst
904which are locking, scheduling and memory allocation functions. 1084which are locking and scheduling functions.
905 1085
906This specification is a _minimum_ guarantee; any particular architecture may 1086This specification is a _minimum_ guarantee; any particular architecture may
907provide more substantial guarantees, but these may not be relied upon outside 1087provide more substantial guarantees, but these may not be relied upon outside
@@ -966,6 +1146,20 @@ equivalent to a full barrier, but a LOCK followed by an UNLOCK is not.
966 barriers is that the effects instructions outside of a critical section may 1146 barriers is that the effects instructions outside of a critical section may
967 seep into the inside of the critical section. 1147 seep into the inside of the critical section.
968 1148
1149A LOCK followed by an UNLOCK may not be assumed to be full memory barrier
1150because it is possible for an access preceding the LOCK to happen after the
1151LOCK, and an access following the UNLOCK to happen before the UNLOCK, and the
1152two accesses can themselves then cross:
1153
1154 *A = a;
1155 LOCK
1156 UNLOCK
1157 *B = b;
1158
1159may occur as:
1160
1161 LOCK, STORE *B, STORE *A, UNLOCK
1162
969Locks and semaphores may not provide any guarantee of ordering on UP compiled 1163Locks and semaphores may not provide any guarantee of ordering on UP compiled
970systems, and so cannot be counted on in such a situation to actually achieve 1164systems, and so cannot be counted on in such a situation to actually achieve
971anything at all - especially with respect to I/O accesses - unless combined 1165anything at all - especially with respect to I/O accesses - unless combined
@@ -1016,8 +1210,6 @@ Other functions that imply barriers:
1016 1210
1017 (*) schedule() and similar imply full memory barriers. 1211 (*) schedule() and similar imply full memory barriers.
1018 1212
1019 (*) Memory allocation and release functions imply full memory barriers.
1020
1021 1213
1022================================= 1214=================================
1023INTER-CPU LOCKING BARRIER EFFECTS 1215INTER-CPU LOCKING BARRIER EFFECTS
diff --git a/Documentation/networking/README.ipw2200 b/Documentation/networking/README.ipw2200
index acb30c5dcff3..4f2a40f1dbc6 100644
--- a/Documentation/networking/README.ipw2200
+++ b/Documentation/networking/README.ipw2200
@@ -14,8 +14,8 @@ Copyright (C) 2004-2006, Intel Corporation
14 14
15README.ipw2200 15README.ipw2200
16 16
17Version: 1.0.8 17Version: 1.1.2
18Date : October 20, 2005 18Date : March 30, 2006
19 19
20 20
21Index 21Index
@@ -103,7 +103,7 @@ file.
103 103
1041.1. Overview of Features 1041.1. Overview of Features
105----------------------------------------------- 105-----------------------------------------------
106The current release (1.0.8) supports the following features: 106The current release (1.1.2) supports the following features:
107 107
108+ BSS mode (Infrastructure, Managed) 108+ BSS mode (Infrastructure, Managed)
109+ IBSS mode (Ad-Hoc) 109+ IBSS mode (Ad-Hoc)
@@ -247,8 +247,8 @@ and can set the contents via echo. For example:
247% cat /sys/bus/pci/drivers/ipw2200/debug_level 247% cat /sys/bus/pci/drivers/ipw2200/debug_level
248 248
249Will report the current debug level of the driver's logging subsystem 249Will report the current debug level of the driver's logging subsystem
250(only available if CONFIG_IPW_DEBUG was configured when the driver was 250(only available if CONFIG_IPW2200_DEBUG was configured when the driver
251built). 251was built).
252 252
253You can set the debug level via: 253You can set the debug level via:
254 254
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index 8d8b4e5ea184..afac780445cd 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -1,7 +1,7 @@
1 1
2 Linux Ethernet Bonding Driver HOWTO 2 Linux Ethernet Bonding Driver HOWTO
3 3
4 Latest update: 21 June 2005 4 Latest update: 24 April 2006
5 5
6Initial release : Thomas Davis <tadavis at lbl.gov> 6Initial release : Thomas Davis <tadavis at lbl.gov>
7Corrections, HA extensions : 2000/10/03-15 : 7Corrections, HA extensions : 2000/10/03-15 :
@@ -12,6 +12,8 @@ Corrections, HA extensions : 2000/10/03-15 :
12 - Jay Vosburgh <fubar at us dot ibm dot com> 12 - Jay Vosburgh <fubar at us dot ibm dot com>
13 13
14Reorganized and updated Feb 2005 by Jay Vosburgh 14Reorganized and updated Feb 2005 by Jay Vosburgh
15Added Sysfs information: 2006/04/24
16 - Mitch Williams <mitch.a.williams at intel.com>
15 17
16Introduction 18Introduction
17============ 19============
@@ -38,61 +40,62 @@ Table of Contents
382. Bonding Driver Options 402. Bonding Driver Options
39 41
403. Configuring Bonding Devices 423. Configuring Bonding Devices
413.1 Configuration with sysconfig support 433.1 Configuration with Sysconfig Support
423.1.1 Using DHCP with sysconfig 443.1.1 Using DHCP with Sysconfig
433.1.2 Configuring Multiple Bonds with sysconfig 453.1.2 Configuring Multiple Bonds with Sysconfig
443.2 Configuration with initscripts support 463.2 Configuration with Initscripts Support
453.2.1 Using DHCP with initscripts 473.2.1 Using DHCP with Initscripts
463.2.2 Configuring Multiple Bonds with initscripts 483.2.2 Configuring Multiple Bonds with Initscripts
473.3 Configuring Bonding Manually 493.3 Configuring Bonding Manually with Ifenslave
483.3.1 Configuring Multiple Bonds Manually 503.3.1 Configuring Multiple Bonds Manually
513.4 Configuring Bonding Manually via Sysfs
49 52
505. Querying Bonding Configuration 534. Querying Bonding Configuration
515.1 Bonding Configuration 544.1 Bonding Configuration
525.2 Network Configuration 554.2 Network Configuration
53 56
546. Switch Configuration 575. Switch Configuration
55 58
567. 802.1q VLAN Support 596. 802.1q VLAN Support
57 60
588. Link Monitoring 617. Link Monitoring
598.1 ARP Monitor Operation 627.1 ARP Monitor Operation
608.2 Configuring Multiple ARP Targets 637.2 Configuring Multiple ARP Targets
618.3 MII Monitor Operation 647.3 MII Monitor Operation
62 65
639. Potential Trouble Sources 668. Potential Trouble Sources
649.1 Adventures in Routing 678.1 Adventures in Routing
659.2 Ethernet Device Renaming 688.2 Ethernet Device Renaming
669.3 Painfully Slow Or No Failed Link Detection By Miimon 698.3 Painfully Slow Or No Failed Link Detection By Miimon
67 70
6810. SNMP agents 719. SNMP agents
69 72
7011. Promiscuous mode 7310. Promiscuous mode
71 74
7212. Configuring Bonding for High Availability 7511. Configuring Bonding for High Availability
7312.1 High Availability in a Single Switch Topology 7611.1 High Availability in a Single Switch Topology
7412.2 High Availability in a Multiple Switch Topology 7711.2 High Availability in a Multiple Switch Topology
7512.2.1 HA Bonding Mode Selection for Multiple Switch Topology 7811.2.1 HA Bonding Mode Selection for Multiple Switch Topology
7612.2.2 HA Link Monitoring for Multiple Switch Topology 7911.2.2 HA Link Monitoring for Multiple Switch Topology
77 80
7813. Configuring Bonding for Maximum Throughput 8112. Configuring Bonding for Maximum Throughput
7913.1 Maximum Throughput in a Single Switch Topology 8212.1 Maximum Throughput in a Single Switch Topology
8013.1.1 MT Bonding Mode Selection for Single Switch Topology 8312.1.1 MT Bonding Mode Selection for Single Switch Topology
8113.1.2 MT Link Monitoring for Single Switch Topology 8412.1.2 MT Link Monitoring for Single Switch Topology
8213.2 Maximum Throughput in a Multiple Switch Topology 8512.2 Maximum Throughput in a Multiple Switch Topology
8313.2.1 MT Bonding Mode Selection for Multiple Switch Topology 8612.2.1 MT Bonding Mode Selection for Multiple Switch Topology
8413.2.2 MT Link Monitoring for Multiple Switch Topology 8712.2.2 MT Link Monitoring for Multiple Switch Topology
85 88
8614. Switch Behavior Issues 8913. Switch Behavior Issues
8714.1 Link Establishment and Failover Delays 9013.1 Link Establishment and Failover Delays
8814.2 Duplicated Incoming Packets 9113.2 Duplicated Incoming Packets
89 92
9015. Hardware Specific Considerations 9314. Hardware Specific Considerations
9115.1 IBM BladeCenter 9414.1 IBM BladeCenter
92 95
9316. Frequently Asked Questions 9615. Frequently Asked Questions
94 97
9517. Resources and Links 9816. Resources and Links
96 99
97 100
981. Bonding Driver Installation 1011. Bonding Driver Installation
@@ -156,6 +159,9 @@ you're trying to build it for. Some distros (e.g., Red Hat from 7.1
156onwards) do not have /usr/include/linux symbolically linked to the 159onwards) do not have /usr/include/linux symbolically linked to the
157default kernel source include directory. 160default kernel source include directory.
158 161
162SECOND IMPORTANT NOTE:
163 If you plan to configure bonding using sysfs, you do not need
164to use ifenslave.
159 165
1602. Bonding Driver Options 1662. Bonding Driver Options
161========================= 167=========================
@@ -270,7 +276,7 @@ mode
270 In bonding version 2.6.2 or later, when a failover 276 In bonding version 2.6.2 or later, when a failover
271 occurs in active-backup mode, bonding will issue one 277 occurs in active-backup mode, bonding will issue one
272 or more gratuitous ARPs on the newly active slave. 278 or more gratuitous ARPs on the newly active slave.
273 One gratutious ARP is issued for the bonding master 279 One gratuitous ARP is issued for the bonding master
274 interface and each VLAN interfaces configured above 280 interface and each VLAN interfaces configured above
275 it, provided that the interface has at least one IP 281 it, provided that the interface has at least one IP
276 address configured. Gratuitous ARPs issued for VLAN 282 address configured. Gratuitous ARPs issued for VLAN
@@ -377,7 +383,7 @@ mode
377 When a link is reconnected or a new slave joins the 383 When a link is reconnected or a new slave joins the
378 bond the receive traffic is redistributed among all 384 bond the receive traffic is redistributed among all
379 active slaves in the bond by initiating ARP Replies 385 active slaves in the bond by initiating ARP Replies
380 with the selected mac address to each of the 386 with the selected MAC address to each of the
381 clients. The updelay parameter (detailed below) must 387 clients. The updelay parameter (detailed below) must
382 be set to a value equal or greater than the switch's 388 be set to a value equal or greater than the switch's
383 forwarding delay so that the ARP Replies sent to the 389 forwarding delay so that the ARP Replies sent to the
@@ -498,11 +504,12 @@ not exist, and the layer2 policy is the only policy.
4983. Configuring Bonding Devices 5043. Configuring Bonding Devices
499============================== 505==============================
500 506
501 There are, essentially, two methods for configuring bonding: 507 You can configure bonding using either your distro's network
502with support from the distro's network initialization scripts, and 508initialization scripts, or manually using either ifenslave or the
503without. Distros generally use one of two packages for the network 509sysfs interface. Distros generally use one of two packages for the
504initialization scripts: initscripts or sysconfig. Recent versions of 510network initialization scripts: initscripts or sysconfig. Recent
505these packages have support for bonding, while older versions do not. 511versions of these packages have support for bonding, while older
512versions do not.
506 513
507 We will first describe the options for configuring bonding for 514 We will first describe the options for configuring bonding for
508distros using versions of initscripts and sysconfig with full or 515distros using versions of initscripts and sysconfig with full or
@@ -530,7 +537,7 @@ $ grep ifenslave /sbin/ifup
530 If this returns any matches, then your initscripts or 537 If this returns any matches, then your initscripts or
531sysconfig has support for bonding. 538sysconfig has support for bonding.
532 539
5333.1 Configuration with sysconfig support 5403.1 Configuration with Sysconfig Support
534---------------------------------------- 541----------------------------------------
535 542
536 This section applies to distros using a version of sysconfig 543 This section applies to distros using a version of sysconfig
@@ -538,7 +545,7 @@ with bonding support, for example, SuSE Linux Enterprise Server 9.
538 545
539 SuSE SLES 9's networking configuration system does support 546 SuSE SLES 9's networking configuration system does support
540bonding, however, at this writing, the YaST system configuration 547bonding, however, at this writing, the YaST system configuration
541frontend does not provide any means to work with bonding devices. 548front end does not provide any means to work with bonding devices.
542Bonding devices can be managed by hand, however, as follows. 549Bonding devices can be managed by hand, however, as follows.
543 550
544 First, if they have not already been configured, configure the 551 First, if they have not already been configured, configure the
@@ -660,7 +667,7 @@ format can be found in an example ifcfg template file:
660 Note that the template does not document the various BONDING_ 667 Note that the template does not document the various BONDING_
661settings described above, but does describe many of the other options. 668settings described above, but does describe many of the other options.
662 669
6633.1.1 Using DHCP with sysconfig 6703.1.1 Using DHCP with Sysconfig
664------------------------------- 671-------------------------------
665 672
666 Under sysconfig, configuring a device with BOOTPROTO='dhcp' 673 Under sysconfig, configuring a device with BOOTPROTO='dhcp'
@@ -670,7 +677,7 @@ attempt to obtain the device address from DHCP prior to adding any of
670the slave devices. Without active slaves, the DHCP requests are not 677the slave devices. Without active slaves, the DHCP requests are not
671sent to the network. 678sent to the network.
672 679
6733.1.2 Configuring Multiple Bonds with sysconfig 6803.1.2 Configuring Multiple Bonds with Sysconfig
674----------------------------------------------- 681-----------------------------------------------
675 682
676 The sysconfig network initialization system is capable of 683 The sysconfig network initialization system is capable of
@@ -685,7 +692,7 @@ ifcfg-bondX files.
685options in the ifcfg-bondX file, it is not necessary to add them to 692options in the ifcfg-bondX file, it is not necessary to add them to
686the system /etc/modules.conf or /etc/modprobe.conf configuration file. 693the system /etc/modules.conf or /etc/modprobe.conf configuration file.
687 694
6883.2 Configuration with initscripts support 6953.2 Configuration with Initscripts Support
689------------------------------------------ 696------------------------------------------
690 697
691 This section applies to distros using a version of initscripts 698 This section applies to distros using a version of initscripts
@@ -756,7 +763,7 @@ options for your configuration.
756will restart the networking subsystem and your bond link should be now 763will restart the networking subsystem and your bond link should be now
757up and running. 764up and running.
758 765
7593.2.1 Using DHCP with initscripts 7663.2.1 Using DHCP with Initscripts
760--------------------------------- 767---------------------------------
761 768
762 Recent versions of initscripts (the version supplied with 769 Recent versions of initscripts (the version supplied with
@@ -768,7 +775,7 @@ above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp"
768and add a line consisting of "TYPE=Bonding". Note that the TYPE value 775and add a line consisting of "TYPE=Bonding". Note that the TYPE value
769is case sensitive. 776is case sensitive.
770 777
7713.2.2 Configuring Multiple Bonds with initscripts 7783.2.2 Configuring Multiple Bonds with Initscripts
772------------------------------------------------- 779-------------------------------------------------
773 780
774 At this writing, the initscripts package does not directly 781 At this writing, the initscripts package does not directly
@@ -784,8 +791,8 @@ Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels
784exhibiting this problem, it will be impossible to configure multiple 791exhibiting this problem, it will be impossible to configure multiple
785bonds with differing parameters. 792bonds with differing parameters.
786 793
7873.3 Configuring Bonding Manually 7943.3 Configuring Bonding Manually with Ifenslave
788-------------------------------- 795-----------------------------------------------
789 796
790 This section applies to distros whose network initialization 797 This section applies to distros whose network initialization
791scripts (the sysconfig or initscripts package) do not have specific 798scripts (the sysconfig or initscripts package) do not have specific
@@ -889,11 +896,139 @@ install bond1 /sbin/modprobe --ignore-install bonding -o bond1 \
889 This may be repeated any number of times, specifying a new and 896 This may be repeated any number of times, specifying a new and
890unique name in place of bond1 for each subsequent instance. 897unique name in place of bond1 for each subsequent instance.
891 898
8993.4 Configuring Bonding Manually via Sysfs
900------------------------------------------
901
902 Starting with version 3.0, Channel Bonding may be configured
903via the sysfs interface. This interface allows dynamic configuration
904of all bonds in the system without unloading the module. It also
905allows for adding and removing bonds at runtime. Ifenslave is no
906longer required, though it is still supported.
907
908 Use of the sysfs interface allows you to use multiple bonds
909with different configurations without having to reload the module.
910It also allows you to use multiple, differently configured bonds when
911bonding is compiled into the kernel.
912
913 You must have the sysfs filesystem mounted to configure
914bonding this way. The examples in this document assume that you
915are using the standard mount point for sysfs, e.g. /sys. If your
916sysfs filesystem is mounted elsewhere, you will need to adjust the
917example paths accordingly.
918
919Creating and Destroying Bonds
920-----------------------------
921To add a new bond foo:
922# echo +foo > /sys/class/net/bonding_masters
923
924To remove an existing bond bar:
925# echo -bar > /sys/class/net/bonding_masters
926
927To show all existing bonds:
928# cat /sys/class/net/bonding_masters
929
930NOTE: due to 4K size limitation of sysfs files, this list may be
931truncated if you have more than a few hundred bonds. This is unlikely
932to occur under normal operating conditions.
933
934Adding and Removing Slaves
935--------------------------
936 Interfaces may be enslaved to a bond using the file
937/sys/class/net/<bond>/bonding/slaves. The semantics for this file
938are the same as for the bonding_masters file.
939
940To enslave interface eth0 to bond bond0:
941# ifconfig bond0 up
942# echo +eth0 > /sys/class/net/bond0/bonding/slaves
943
944To free slave eth0 from bond bond0:
945# echo -eth0 > /sys/class/net/bond0/bonding/slaves
946
947 NOTE: The bond must be up before slaves can be added. All
948slaves are freed when the interface is brought down.
949
950 When an interface is enslaved to a bond, symlinks between the
951two are created in the sysfs filesystem. In this case, you would get
952/sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and
953/sys/class/net/eth0/master pointing to /sys/class/net/bond0.
954
955 This means that you can tell quickly whether or not an
956interface is enslaved by looking for the master symlink. Thus:
957# echo -eth0 > /sys/class/net/eth0/master/bonding/slaves
958will free eth0 from whatever bond it is enslaved to, regardless of
959the name of the bond interface.
960
961Changing a Bond's Configuration
962-------------------------------
963 Each bond may be configured individually by manipulating the
964files located in /sys/class/net/<bond name>/bonding
965
966 The names of these files correspond directly with the command-
967line parameters described elsewhere in in this file, and, with the
968exception of arp_ip_target, they accept the same values. To see the
969current setting, simply cat the appropriate file.
970
971 A few examples will be given here; for specific usage
972guidelines for each parameter, see the appropriate section in this
973document.
974
975To configure bond0 for balance-alb mode:
976# ifconfig bond0 down
977# echo 6 > /sys/class/net/bond0/bonding/mode
978 - or -
979# echo balance-alb > /sys/class/net/bond0/bonding/mode
980 NOTE: The bond interface must be down before the mode can be
981changed.
982
983To enable MII monitoring on bond0 with a 1 second interval:
984# echo 1000 > /sys/class/net/bond0/bonding/miimon
985 NOTE: If ARP monitoring is enabled, it will disabled when MII
986monitoring is enabled, and vice-versa.
987
988To add ARP targets:
989# echo +192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
990# echo +192.168.0.101 > /sys/class/net/bond0/bonding/arp_ip_target
991 NOTE: up to 10 target addresses may be specified.
992
993To remove an ARP target:
994# echo -192.168.0.100 > /sys/class/net/bond0/bonding/arp_ip_target
995
996Example Configuration
997---------------------
998 We begin with the same example that is shown in section 3.3,
999executed with sysfs, and without using ifenslave.
1000
1001 To make a simple bond of two e100 devices (presumed to be eth0
1002and eth1), and have it persist across reboots, edit the appropriate
1003file (/etc/init.d/boot.local or /etc/rc.d/rc.local), and add the
1004following:
1005
1006modprobe bonding
1007modprobe e100
1008echo balance-alb > /sys/class/net/bond0/bonding/mode
1009ifconfig bond0 192.168.1.1 netmask 255.255.255.0 up
1010echo 100 > /sys/class/net/bond0/bonding/miimon
1011echo +eth0 > /sys/class/net/bond0/bonding/slaves
1012echo +eth1 > /sys/class/net/bond0/bonding/slaves
1013
1014 To add a second bond, with two e1000 interfaces in
1015active-backup mode, using ARP monitoring, add the following lines to
1016your init script:
1017
1018modprobe e1000
1019echo +bond1 > /sys/class/net/bonding_masters
1020echo active-backup > /sys/class/net/bond1/bonding/mode
1021ifconfig bond1 192.168.2.1 netmask 255.255.255.0 up
1022echo +192.168.2.100 /sys/class/net/bond1/bonding/arp_ip_target
1023echo 2000 > /sys/class/net/bond1/bonding/arp_interval
1024echo +eth2 > /sys/class/net/bond1/bonding/slaves
1025echo +eth3 > /sys/class/net/bond1/bonding/slaves
1026
892 1027
8935. Querying Bonding Configuration 10284. Querying Bonding Configuration
894================================= 1029=================================
895 1030
8965.1 Bonding Configuration 10314.1 Bonding Configuration
897------------------------- 1032-------------------------
898 1033
899 Each bonding device has a read-only file residing in the 1034 Each bonding device has a read-only file residing in the
@@ -923,7 +1058,7 @@ generally as follows:
923 The precise format and contents will change depending upon the 1058 The precise format and contents will change depending upon the
924bonding configuration, state, and version of the bonding driver. 1059bonding configuration, state, and version of the bonding driver.
925 1060
9265.2 Network configuration 10614.2 Network configuration
927------------------------- 1062-------------------------
928 1063
929 The network configuration can be inspected using the ifconfig 1064 The network configuration can be inspected using the ifconfig
@@ -958,7 +1093,7 @@ eth1 Link encap:Ethernet HWaddr 00:C0:F0:1F:37:B4
958 collisions:0 txqueuelen:100 1093 collisions:0 txqueuelen:100
959 Interrupt:9 Base address:0x1400 1094 Interrupt:9 Base address:0x1400
960 1095
9616. Switch Configuration 10965. Switch Configuration
962======================= 1097=======================
963 1098
964 For this section, "switch" refers to whatever system the 1099 For this section, "switch" refers to whatever system the
@@ -991,7 +1126,7 @@ transmit policy for an EtherChannel group; all three will interoperate
991with another EtherChannel group. 1126with another EtherChannel group.
992 1127
993 1128
9947. 802.1q VLAN Support 11296. 802.1q VLAN Support
995====================== 1130======================
996 1131
997 It is possible to configure VLAN devices over a bond interface 1132 It is possible to configure VLAN devices over a bond interface
@@ -1042,7 +1177,7 @@ underlying device -- i.e. the bonding interface -- to promiscuous
1042mode, which might not be what you want. 1177mode, which might not be what you want.
1043 1178
1044 1179
10458. Link Monitoring 11807. Link Monitoring
1046================== 1181==================
1047 1182
1048 The bonding driver at present supports two schemes for 1183 The bonding driver at present supports two schemes for
@@ -1053,7 +1188,7 @@ monitor.
1053bonding driver itself, it is not possible to enable both ARP and MII 1188bonding driver itself, it is not possible to enable both ARP and MII
1054monitoring simultaneously. 1189monitoring simultaneously.
1055 1190
10568.1 ARP Monitor Operation 11917.1 ARP Monitor Operation
1057------------------------- 1192-------------------------
1058 1193
1059 The ARP monitor operates as its name suggests: it sends ARP 1194 The ARP monitor operates as its name suggests: it sends ARP
@@ -1071,7 +1206,7 @@ those slaves will stay down. If networking monitoring (tcpdump, etc)
1071shows the ARP requests and replies on the network, then it may be that 1206shows the ARP requests and replies on the network, then it may be that
1072your device driver is not updating last_rx and trans_start. 1207your device driver is not updating last_rx and trans_start.
1073 1208
10748.2 Configuring Multiple ARP Targets 12097.2 Configuring Multiple ARP Targets
1075------------------------------------ 1210------------------------------------
1076 1211
1077 While ARP monitoring can be done with just one target, it can 1212 While ARP monitoring can be done with just one target, it can
@@ -1094,7 +1229,7 @@ alias bond0 bonding
1094options bond0 arp_interval=60 arp_ip_target=192.168.0.100 1229options bond0 arp_interval=60 arp_ip_target=192.168.0.100
1095 1230
1096 1231
10978.3 MII Monitor Operation 12327.3 MII Monitor Operation
1098------------------------- 1233-------------------------
1099 1234
1100 The MII monitor monitors only the carrier state of the local 1235 The MII monitor monitors only the carrier state of the local
@@ -1120,14 +1255,14 @@ does not support or had some error in processing both the MII register
1120and ethtool requests), then the MII monitor will assume the link is 1255and ethtool requests), then the MII monitor will assume the link is
1121up. 1256up.
1122 1257
11239. Potential Sources of Trouble 12588. Potential Sources of Trouble
1124=============================== 1259===============================
1125 1260
11269.1 Adventures in Routing 12618.1 Adventures in Routing
1127------------------------- 1262-------------------------
1128 1263
1129 When bonding is configured, it is important that the slave 1264 When bonding is configured, it is important that the slave
1130devices not have routes that supercede routes of the master (or, 1265devices not have routes that supersede routes of the master (or,
1131generally, not have routes at all). For example, suppose the bonding 1266generally, not have routes at all). For example, suppose the bonding
1132device bond0 has two slaves, eth0 and eth1, and the routing table is 1267device bond0 has two slaves, eth0 and eth1, and the routing table is
1133as follows: 1268as follows:
@@ -1154,11 +1289,11 @@ by the state of the routing table.
1154 1289
1155 The solution here is simply to insure that slaves do not have 1290 The solution here is simply to insure that slaves do not have
1156routes of their own, and if for some reason they must, those routes do 1291routes of their own, and if for some reason they must, those routes do
1157not supercede routes of their master. This should generally be the 1292not supersede routes of their master. This should generally be the
1158case, but unusual configurations or errant manual or automatic static 1293case, but unusual configurations or errant manual or automatic static
1159route additions may cause trouble. 1294route additions may cause trouble.
1160 1295
11619.2 Ethernet Device Renaming 12968.2 Ethernet Device Renaming
1162---------------------------- 1297----------------------------
1163 1298
1164 On systems with network configuration scripts that do not 1299 On systems with network configuration scripts that do not
@@ -1207,7 +1342,7 @@ modprobe with --ignore-install to cause the normal action to then take
1207place. Full documentation on this can be found in the modprobe.conf 1342place. Full documentation on this can be found in the modprobe.conf
1208and modprobe manual pages. 1343and modprobe manual pages.
1209 1344
12109.3. Painfully Slow Or No Failed Link Detection By Miimon 13458.3. Painfully Slow Or No Failed Link Detection By Miimon
1211--------------------------------------------------------- 1346---------------------------------------------------------
1212 1347
1213 By default, bonding enables the use_carrier option, which 1348 By default, bonding enables the use_carrier option, which
@@ -1235,7 +1370,7 @@ carrier state. It has no way to determine the state of devices on or
1235beyond other ports of a switch, or if a switch is refusing to pass 1370beyond other ports of a switch, or if a switch is refusing to pass
1236traffic while still maintaining carrier on. 1371traffic while still maintaining carrier on.
1237 1372
123810. SNMP agents 13739. SNMP agents
1239=============== 1374===============
1240 1375
1241 If running SNMP agents, the bonding driver should be loaded 1376 If running SNMP agents, the bonding driver should be loaded
@@ -1281,7 +1416,7 @@ ifDescr, the association between the IP address and IfIndex remains
1281and SNMP functions such as Interface_Scan_Next will report that 1416and SNMP functions such as Interface_Scan_Next will report that
1282association. 1417association.
1283 1418
128411. Promiscuous mode 141910. Promiscuous mode
1285==================== 1420====================
1286 1421
1287 When running network monitoring tools, e.g., tcpdump, it is 1422 When running network monitoring tools, e.g., tcpdump, it is
@@ -1308,7 +1443,7 @@ sending to peers that are unassigned or if the load is unbalanced.
1308the active slave changes (e.g., due to a link failure), the 1443the active slave changes (e.g., due to a link failure), the
1309promiscuous setting will be propagated to the new active slave. 1444promiscuous setting will be propagated to the new active slave.
1310 1445
131112. Configuring Bonding for High Availability 144611. Configuring Bonding for High Availability
1312============================================= 1447=============================================
1313 1448
1314 High Availability refers to configurations that provide 1449 High Availability refers to configurations that provide
@@ -1318,7 +1453,7 @@ goal is to provide the maximum availability of network connectivity
1318(i.e., the network always works), even though other configurations 1453(i.e., the network always works), even though other configurations
1319could provide higher throughput. 1454could provide higher throughput.
1320 1455
132112.1 High Availability in a Single Switch Topology 145611.1 High Availability in a Single Switch Topology
1322-------------------------------------------------- 1457--------------------------------------------------
1323 1458
1324 If two hosts (or a host and a single switch) are directly 1459 If two hosts (or a host and a single switch) are directly
@@ -1332,7 +1467,7 @@ the load will be rebalanced across the remaining devices.
1332 See Section 13, "Configuring Bonding for Maximum Throughput" 1467 See Section 13, "Configuring Bonding for Maximum Throughput"
1333for information on configuring bonding with one peer device. 1468for information on configuring bonding with one peer device.
1334 1469
133512.2 High Availability in a Multiple Switch Topology 147011.2 High Availability in a Multiple Switch Topology
1336---------------------------------------------------- 1471----------------------------------------------------
1337 1472
1338 With multiple switches, the configuration of bonding and the 1473 With multiple switches, the configuration of bonding and the
@@ -1359,7 +1494,7 @@ switches (ISL, or inter switch link), and multiple ports connecting to
1359the outside world ("port3" on each switch). There is no technical 1494the outside world ("port3" on each switch). There is no technical
1360reason that this could not be extended to a third switch. 1495reason that this could not be extended to a third switch.
1361 1496
136212.2.1 HA Bonding Mode Selection for Multiple Switch Topology 149711.2.1 HA Bonding Mode Selection for Multiple Switch Topology
1363------------------------------------------------------------- 1498-------------------------------------------------------------
1364 1499
1365 In a topology such as the example above, the active-backup and 1500 In a topology such as the example above, the active-backup and
@@ -1381,7 +1516,7 @@ broadcast: This mode is really a special purpose mode, and is suitable
1381 necessary for some specific one-way traffic to reach both 1516 necessary for some specific one-way traffic to reach both
1382 independent networks, then the broadcast mode may be suitable. 1517 independent networks, then the broadcast mode may be suitable.
1383 1518
138412.2.2 HA Link Monitoring Selection for Multiple Switch Topology 151911.2.2 HA Link Monitoring Selection for Multiple Switch Topology
1385---------------------------------------------------------------- 1520----------------------------------------------------------------
1386 1521
1387 The choice of link monitoring ultimately depends upon your 1522 The choice of link monitoring ultimately depends upon your
@@ -1402,10 +1537,10 @@ regardless of which switch is active, the ARP monitor has a suitable
1402target to query. 1537target to query.
1403 1538
1404 1539
140513. Configuring Bonding for Maximum Throughput 154012. Configuring Bonding for Maximum Throughput
1406============================================== 1541==============================================
1407 1542
140813.1 Maximizing Throughput in a Single Switch Topology 154312.1 Maximizing Throughput in a Single Switch Topology
1409------------------------------------------------------ 1544------------------------------------------------------
1410 1545
1411 In a single switch configuration, the best method to maximize 1546 In a single switch configuration, the best method to maximize
@@ -1476,7 +1611,7 @@ destination to make load balancing decisions. The behavior of each
1476mode is described below. 1611mode is described below.
1477 1612
1478 1613
147913.1.1 MT Bonding Mode Selection for Single Switch Topology 161412.1.1 MT Bonding Mode Selection for Single Switch Topology
1480----------------------------------------------------------- 1615-----------------------------------------------------------
1481 1616
1482 This configuration is the easiest to set up and to understand, 1617 This configuration is the easiest to set up and to understand,
@@ -1607,7 +1742,7 @@ balance-alb: This mode is everything that balance-tlb is, and more.
1607 device driver must support changing the hardware address while 1742 device driver must support changing the hardware address while
1608 the device is open. 1743 the device is open.
1609 1744
161013.1.2 MT Link Monitoring for Single Switch Topology 174512.1.2 MT Link Monitoring for Single Switch Topology
1611---------------------------------------------------- 1746----------------------------------------------------
1612 1747
1613 The choice of link monitoring may largely depend upon which 1748 The choice of link monitoring may largely depend upon which
@@ -1616,7 +1751,7 @@ support the use of the ARP monitor, and are thus restricted to using
1616the MII monitor (which does not provide as high a level of end to end 1751the MII monitor (which does not provide as high a level of end to end
1617assurance as the ARP monitor). 1752assurance as the ARP monitor).
1618 1753
161913.2 Maximum Throughput in a Multiple Switch Topology 175412.2 Maximum Throughput in a Multiple Switch Topology
1620----------------------------------------------------- 1755-----------------------------------------------------
1621 1756
1622 Multiple switches may be utilized to optimize for throughput 1757 Multiple switches may be utilized to optimize for throughput
@@ -1651,7 +1786,7 @@ a single 72 port switch.
1651can be equipped with an additional network device connected to an 1786can be equipped with an additional network device connected to an
1652external network; this host then additionally acts as a gateway. 1787external network; this host then additionally acts as a gateway.
1653 1788
165413.2.1 MT Bonding Mode Selection for Multiple Switch Topology 178912.2.1 MT Bonding Mode Selection for Multiple Switch Topology
1655------------------------------------------------------------- 1790-------------------------------------------------------------
1656 1791
1657 In actual practice, the bonding mode typically employed in 1792 In actual practice, the bonding mode typically employed in
@@ -1664,7 +1799,7 @@ packets has arrived). When employed in this fashion, the balance-rr
1664mode allows individual connections between two hosts to effectively 1799mode allows individual connections between two hosts to effectively
1665utilize greater than one interface's bandwidth. 1800utilize greater than one interface's bandwidth.
1666 1801
166713.2.2 MT Link Monitoring for Multiple Switch Topology 180212.2.2 MT Link Monitoring for Multiple Switch Topology
1668------------------------------------------------------ 1803------------------------------------------------------
1669 1804
1670 Again, in actual practice, the MII monitor is most often used 1805 Again, in actual practice, the MII monitor is most often used
@@ -1674,10 +1809,10 @@ advantages over the MII monitor are mitigated by the volume of probes
1674needed as the number of systems involved grows (remember that each 1809needed as the number of systems involved grows (remember that each
1675host in the network is configured with bonding). 1810host in the network is configured with bonding).
1676 1811
167714. Switch Behavior Issues 181213. Switch Behavior Issues
1678========================== 1813==========================
1679 1814
168014.1 Link Establishment and Failover Delays 181513.1 Link Establishment and Failover Delays
1681------------------------------------------- 1816-------------------------------------------
1682 1817
1683 Some switches exhibit undesirable behavior with regard to the 1818 Some switches exhibit undesirable behavior with regard to the
@@ -1712,7 +1847,7 @@ switches take a long time to go into backup mode, it may be desirable
1712to not activate a backup interface immediately after a link goes down. 1847to not activate a backup interface immediately after a link goes down.
1713Failover may be delayed via the downdelay bonding module option. 1848Failover may be delayed via the downdelay bonding module option.
1714 1849
171514.2 Duplicated Incoming Packets 185013.2 Duplicated Incoming Packets
1716-------------------------------- 1851--------------------------------
1717 1852
1718 It is not uncommon to observe a short burst of duplicated 1853 It is not uncommon to observe a short burst of duplicated
@@ -1751,14 +1886,14 @@ behavior, it can be induced by clearing the MAC forwarding table (on
1751most Cisco switches, the privileged command "clear mac address-table 1886most Cisco switches, the privileged command "clear mac address-table
1752dynamic" will accomplish this). 1887dynamic" will accomplish this).
1753 1888
175415. Hardware Specific Considerations 188914. Hardware Specific Considerations
1755==================================== 1890====================================
1756 1891
1757 This section contains additional information for configuring 1892 This section contains additional information for configuring
1758bonding on specific hardware platforms, or for interfacing bonding 1893bonding on specific hardware platforms, or for interfacing bonding
1759with particular switches or other devices. 1894with particular switches or other devices.
1760 1895
176115.1 IBM BladeCenter 189614.1 IBM BladeCenter
1762-------------------- 1897--------------------
1763 1898
1764 This applies to the JS20 and similar systems. 1899 This applies to the JS20 and similar systems.
@@ -1861,7 +1996,7 @@ bonding driver.
1861avoid fail-over delay issues when using bonding. 1996avoid fail-over delay issues when using bonding.
1862 1997
1863 1998
186416. Frequently Asked Questions 199915. Frequently Asked Questions
1865============================== 2000==============================
1866 2001
18671. Is it SMP safe? 20021. Is it SMP safe?
@@ -1925,7 +2060,7 @@ not have special switch requirements, but do need device drivers that
1925support specific features (described in the appropriate section under 2060support specific features (described in the appropriate section under
1926module parameters, above). 2061module parameters, above).
1927 2062
1928 In 802.3ad mode, it works with with systems that support IEEE 2063 In 802.3ad mode, it works with systems that support IEEE
1929802.3ad Dynamic Link Aggregation. Most managed and many unmanaged 2064802.3ad Dynamic Link Aggregation. Most managed and many unmanaged
1930switches currently available support 802.3ad. 2065switches currently available support 802.3ad.
1931 2066
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index f12007b80a46..d46338af6002 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -362,6 +362,13 @@ tcp_workaround_signed_windows - BOOLEAN
362 not receive a window scaling option from them. 362 not receive a window scaling option from them.
363 Default: 0 363 Default: 0
364 364
365tcp_slow_start_after_idle - BOOLEAN
366 If set, provide RFC2861 behavior and time out the congestion
367 window after an idle period. An idle period is defined at
368 the current RTO. If unset, the congestion window will not
369 be timed out after an idle period.
370 Default: 1
371
365IP Variables: 372IP Variables:
366 373
367ip_local_port_range - 2 INTEGERS 374ip_local_port_range - 2 INTEGERS
diff --git a/Documentation/networking/netdevices.txt b/Documentation/networking/netdevices.txt
index 3c0a5ba614d7..847cedb238f6 100644
--- a/Documentation/networking/netdevices.txt
+++ b/Documentation/networking/netdevices.txt
@@ -42,9 +42,9 @@ dev->get_stats:
42 Context: nominally process, but don't sleep inside an rwlock 42 Context: nominally process, but don't sleep inside an rwlock
43 43
44dev->hard_start_xmit: 44dev->hard_start_xmit:
45 Synchronization: dev->xmit_lock spinlock. 45 Synchronization: netif_tx_lock spinlock.
46 When the driver sets NETIF_F_LLTX in dev->features this will be 46 When the driver sets NETIF_F_LLTX in dev->features this will be
47 called without holding xmit_lock. In this case the driver 47 called without holding netif_tx_lock. In this case the driver
48 has to lock by itself when needed. It is recommended to use a try lock 48 has to lock by itself when needed. It is recommended to use a try lock
49 for this and return -1 when the spin lock fails. 49 for this and return -1 when the spin lock fails.
50 The locking there should also properly protect against 50 The locking there should also properly protect against
@@ -62,12 +62,12 @@ dev->hard_start_xmit:
62 Only valid when NETIF_F_LLTX is set. 62 Only valid when NETIF_F_LLTX is set.
63 63
64dev->tx_timeout: 64dev->tx_timeout:
65 Synchronization: dev->xmit_lock spinlock. 65 Synchronization: netif_tx_lock spinlock.
66 Context: BHs disabled 66 Context: BHs disabled
67 Notes: netif_queue_stopped() is guaranteed true 67 Notes: netif_queue_stopped() is guaranteed true
68 68
69dev->set_multicast_list: 69dev->set_multicast_list:
70 Synchronization: dev->xmit_lock spinlock. 70 Synchronization: netif_tx_lock spinlock.
71 Context: BHs disabled 71 Context: BHs disabled
72 72
73dev->poll: 73dev->poll:
diff --git a/MAINTAINERS b/MAINTAINERS
index c3c5842402df..1421f74b6009 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1425,6 +1425,8 @@ P: Jesse Brandeburg
1425M: jesse.brandeburg@intel.com 1425M: jesse.brandeburg@intel.com
1426P: Jeff Kirsher 1426P: Jeff Kirsher
1427M: jeffrey.t.kirsher@intel.com 1427M: jeffrey.t.kirsher@intel.com
1428P: Auke Kok
1429M: auke-jan.h.kok@intel.com
1428W: http://sourceforge.net/projects/e1000/ 1430W: http://sourceforge.net/projects/e1000/
1429S: Supported 1431S: Supported
1430 1432
@@ -1437,6 +1439,8 @@ P: Jesse Brandeburg
1437M: jesse.brandeburg@intel.com 1439M: jesse.brandeburg@intel.com
1438P: Jeff Kirsher 1440P: Jeff Kirsher
1439M: jeffrey.t.kirsher@intel.com 1441M: jeffrey.t.kirsher@intel.com
1442P: Auke Kok
1443M: auke-jan.h.kok@intel.com
1440W: http://sourceforge.net/projects/e1000/ 1444W: http://sourceforge.net/projects/e1000/
1441S: Supported 1445S: Supported
1442 1446
@@ -1449,6 +1453,8 @@ P: John Ronciak
1449M: john.ronciak@intel.com 1453M: john.ronciak@intel.com
1450P: Jesse Brandeburg 1454P: Jesse Brandeburg
1451M: jesse.brandeburg@intel.com 1455M: jesse.brandeburg@intel.com
1456P: Auke Kok
1457M: auke-jan.h.kok@intel.com
1452W: http://sourceforge.net/projects/e1000/ 1458W: http://sourceforge.net/projects/e1000/
1453S: Supported 1459S: Supported
1454 1460
diff --git a/Makefile b/Makefile
index a3a7baad8555..1700d3f6ea22 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 17 3SUBLEVEL = 17
4EXTRAVERSION =-rc6 4EXTRAVERSION =
5NAME=Crazed Snow-Weasel 5NAME=Crazed Snow-Weasel
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 8290b69da202..213c7850d5fb 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -453,7 +453,7 @@ config ALPHA_IRONGATE
453 453
454config GENERIC_HWEIGHT 454config GENERIC_HWEIGHT
455 bool 455 bool
456 default y if !ALPHA_EV6 && !ALPHA_EV67 456 default y if !ALPHA_EV67
457 457
458config ALPHA_AVANTI 458config ALPHA_AVANTI
459 bool 459 bool
diff --git a/arch/arm/mach-imx/irq.c b/arch/arm/mach-imx/irq.c
index eeb8a6d4a399..a5de5f1da9f2 100644
--- a/arch/arm/mach-imx/irq.c
+++ b/arch/arm/mach-imx/irq.c
@@ -127,7 +127,7 @@ static void
127imx_gpio_ack_irq(unsigned int irq) 127imx_gpio_ack_irq(unsigned int irq)
128{ 128{
129 DEBUG_IRQ("%s: irq %d\n", __FUNCTION__, irq); 129 DEBUG_IRQ("%s: irq %d\n", __FUNCTION__, irq);
130 ISR(IRQ_TO_REG(irq)) |= 1 << ((irq - IRQ_GPIOA(0)) % 32); 130 ISR(IRQ_TO_REG(irq)) = 1 << ((irq - IRQ_GPIOA(0)) % 32);
131} 131}
132 132
133static void 133static void
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index a0724f2b24ce..9f55f5ae1044 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -232,8 +232,6 @@ static void __init intcp_init_irq(void)
232 for (i = IRQ_PIC_START; i <= IRQ_PIC_END; i++) { 232 for (i = IRQ_PIC_START; i <= IRQ_PIC_END; i++) {
233 if (i == 11) 233 if (i == 11)
234 i = 22; 234 i = 22;
235 if (i == IRQ_CP_CPPLDINT)
236 i++;
237 if (i == 29) 235 if (i == 29)
238 break; 236 break;
239 set_irq_chip(i, &pic_chip); 237 set_irq_chip(i, &pic_chip);
@@ -259,8 +257,7 @@ static void __init intcp_init_irq(void)
259 set_irq_flags(i, IRQF_VALID | IRQF_PROBE); 257 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
260 } 258 }
261 259
262 set_irq_handler(IRQ_CP_CPPLDINT, sic_handle_irq); 260 set_irq_chained_handler(IRQ_CP_CPPLDINT, sic_handle_irq);
263 pic_unmask_irq(IRQ_CP_CPPLDINT);
264} 261}
265 262
266/* 263/*
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 19b372df544a..44bcb8097c7a 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -371,6 +371,7 @@ static int spitz_ohci_init(struct device *dev)
371static struct pxaohci_platform_data spitz_ohci_platform_data = { 371static struct pxaohci_platform_data spitz_ohci_platform_data = {
372 .port_mode = PMM_NPS_MODE, 372 .port_mode = PMM_NPS_MODE,
373 .init = spitz_ohci_init, 373 .init = spitz_ohci_init,
374 .power_budget = 150,
374}; 375};
375 376
376 377
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index 9e02bc3712a0..af6d2775cf82 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -59,6 +59,14 @@ neponset_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *reg
59 if (irr & (IRR_ETHERNET | IRR_USAR)) { 59 if (irr & (IRR_ETHERNET | IRR_USAR)) {
60 desc->chip->mask(irq); 60 desc->chip->mask(irq);
61 61
62 /*
63 * Ack the interrupt now to prevent re-entering
64 * this neponset handler. Again, this is safe
65 * since we'll check the IRR register prior to
66 * leaving.
67 */
68 desc->chip->ack(irq);
69
62 if (irr & IRR_ETHERNET) { 70 if (irr & IRR_ETHERNET) {
63 d = irq_desc + IRQ_NEPONSET_SMC9196; 71 d = irq_desc + IRQ_NEPONSET_SMC9196;
64 desc_handle_irq(IRQ_NEPONSET_SMC9196, d, regs); 72 desc_handle_irq(IRQ_NEPONSET_SMC9196, d, regs);
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 799697d32dec..cebd48a3dae4 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -112,10 +112,9 @@ void __init versatile_init_irq(void)
112{ 112{
113 unsigned int i; 113 unsigned int i;
114 114
115 vic_init(VA_VIC_BASE, IRQ_VIC_START, ~(1 << 31)); 115 vic_init(VA_VIC_BASE, IRQ_VIC_START, ~0);
116 116
117 set_irq_handler(IRQ_VICSOURCE31, sic_handle_irq); 117 set_irq_chained_handler(IRQ_VICSOURCE31, sic_handle_irq);
118 enable_irq(IRQ_VICSOURCE31);
119 118
120 /* Do second interrupt controller */ 119 /* Do second interrupt controller */
121 writel(~0, VA_SIC_BASE + SIC_IRQ_ENABLE_CLEAR); 120 writel(~0, VA_SIC_BASE + SIC_IRQ_ENABLE_CLEAR);
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 3852d0a4c1b5..1a7bdcef1926 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -104,7 +104,7 @@ acpi_processor_set_performance (
104{ 104{
105 u16 port = 0; 105 u16 port = 0;
106 u8 bit_width = 0; 106 u8 bit_width = 0;
107 int ret = 0; 107 int ret;
108 u32 value = 0; 108 u32 value = 0;
109 int i = 0; 109 int i = 0;
110 struct cpufreq_freqs cpufreq_freqs; 110 struct cpufreq_freqs cpufreq_freqs;
@@ -195,7 +195,6 @@ acpi_processor_set_performance (
195 udelay(10); 195 udelay(10);
196 } 196 }
197 } else { 197 } else {
198 i = 0;
199 value = (u32) data->acpi_data.states[state].status; 198 value = (u32) data->acpi_data.states[state].status;
200 } 199 }
201 200
@@ -444,14 +443,15 @@ static struct freq_attr* acpi_cpufreq_attr[] = {
444}; 443};
445 444
446static struct cpufreq_driver acpi_cpufreq_driver = { 445static struct cpufreq_driver acpi_cpufreq_driver = {
447 .verify = acpi_cpufreq_verify, 446 .verify = acpi_cpufreq_verify,
448 .target = acpi_cpufreq_target, 447 .target = acpi_cpufreq_target,
449 .init = acpi_cpufreq_cpu_init, 448 .init = acpi_cpufreq_cpu_init,
450 .exit = acpi_cpufreq_cpu_exit, 449 .exit = acpi_cpufreq_cpu_exit,
451 .resume = acpi_cpufreq_resume, 450 .resume = acpi_cpufreq_resume,
452 .name = "acpi-cpufreq", 451 .name = "acpi-cpufreq",
453 .owner = THIS_MODULE, 452 .owner = THIS_MODULE,
454 .attr = acpi_cpufreq_attr, 453 .attr = acpi_cpufreq_attr,
454 .flags = CPUFREQ_STICKY,
455}; 455};
456 456
457 457
diff --git a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
index f275e0d4aee5..0d49d73d1b71 100644
--- a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
+++ b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * (C) 2004 Sebastian Witt <se.witt@gmx.net> 2 * (C) 2004-2006 Sebastian Witt <se.witt@gmx.net>
3 * 3 *
4 * Licensed under the terms of the GNU GPL License version 2. 4 * Licensed under the terms of the GNU GPL License version 2.
5 * Based upon reverse engineered information 5 * Based upon reverse engineered information
@@ -90,7 +90,7 @@ static int nforce2_calc_pll(unsigned int fsb)
90 90
91 /* Try to calculate multiplier and divider up to 4 times */ 91 /* Try to calculate multiplier and divider up to 4 times */
92 while (((mul == 0) || (div == 0)) && (tried <= 3)) { 92 while (((mul == 0) || (div == 0)) && (tried <= 3)) {
93 for (xdiv = 1; xdiv <= 0x80; xdiv++) 93 for (xdiv = 2; xdiv <= 0x80; xdiv++)
94 for (xmul = 1; xmul <= 0xfe; xmul++) 94 for (xmul = 1; xmul <= 0xfe; xmul++)
95 if (nforce2_calc_fsb(NFORCE2_PLL(xmul, xdiv)) == 95 if (nforce2_calc_fsb(NFORCE2_PLL(xmul, xdiv)) ==
96 fsb + tried) { 96 fsb + tried) {
@@ -117,8 +117,7 @@ static void nforce2_write_pll(int pll)
117 int temp; 117 int temp;
118 118
119 /* Set the pll addr. to 0x00 */ 119 /* Set the pll addr. to 0x00 */
120 temp = 0x00; 120 pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLADR, 0);
121 pci_write_config_dword(nforce2_chipset_dev, NFORCE2_PLLADR, temp);
122 121
123 /* Now write the value in all 64 registers */ 122 /* Now write the value in all 64 registers */
124 for (temp = 0; temp <= 0x3f; temp++) 123 for (temp = 0; temp <= 0x3f; temp++)
@@ -266,7 +265,7 @@ static int nforce2_target(struct cpufreq_policy *policy,
266 if (freqs.old == freqs.new) 265 if (freqs.old == freqs.new)
267 return 0; 266 return 0;
268 267
269 dprintk(KERN_INFO "cpufreq: Old CPU frequency %d kHz, new %d kHz\n", 268 dprintk("Old CPU frequency %d kHz, new %d kHz\n",
270 freqs.old, freqs.new); 269 freqs.old, freqs.new);
271 270
272 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 271 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
@@ -278,7 +277,7 @@ static int nforce2_target(struct cpufreq_policy *policy,
278 printk(KERN_ERR "cpufreq: Changing FSB to %d failed\n", 277 printk(KERN_ERR "cpufreq: Changing FSB to %d failed\n",
279 target_fsb); 278 target_fsb);
280 else 279 else
281 dprintk(KERN_INFO "cpufreq: Changed FSB successfully to %d\n", 280 dprintk("Changed FSB successfully to %d\n",
282 target_fsb); 281 target_fsb);
283 282
284 /* Enable IRQs */ 283 /* Enable IRQs */
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c
index 8ef38544453c..146f607e9c44 100644
--- a/arch/i386/kernel/cpu/cpufreq/longhaul.c
+++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c
@@ -77,13 +77,17 @@ static char speedbuffer[8];
77 77
78static char *print_speed(int speed) 78static char *print_speed(int speed)
79{ 79{
80 if (speed > 1000) { 80 if (speed < 1000) {
81 if (speed%1000 == 0) 81 snprintf(speedbuffer, sizeof(speedbuffer),"%dMHz", speed);
82 sprintf (speedbuffer, "%dGHz", speed/1000); 82 return speedbuffer;
83 else 83 }
84 sprintf (speedbuffer, "%d.%dGHz", speed/1000, (speed%1000)/100); 84
85 } else 85 if (speed%1000 == 0)
86 sprintf (speedbuffer, "%dMHz", speed); 86 snprintf(speedbuffer, sizeof(speedbuffer),
87 "%dGHz", speed/1000);
88 else
89 snprintf(speedbuffer, sizeof(speedbuffer),
90 "%d.%dGHz", speed/1000, (speed%1000)/100);
87 91
88 return speedbuffer; 92 return speedbuffer;
89} 93}
@@ -675,7 +679,7 @@ static int __init longhaul_init(void)
675 679
676static void __exit longhaul_exit(void) 680static void __exit longhaul_exit(void)
677{ 681{
678 int i=0; 682 int i;
679 683
680 for (i=0; i < numscales; i++) { 684 for (i=0; i < numscales; i++) {
681 if (clock_ratio[i] == maxmult) { 685 if (clock_ratio[i] == maxmult) {
diff --git a/arch/i386/kernel/cpu/cpufreq/longrun.c b/arch/i386/kernel/cpu/cpufreq/longrun.c
index e3868de4dc2e..b2689514295a 100644
--- a/arch/i386/kernel/cpu/cpufreq/longrun.c
+++ b/arch/i386/kernel/cpu/cpufreq/longrun.c
@@ -223,7 +223,6 @@ static unsigned int __init longrun_determine_freqs(unsigned int *low_freq,
223 /* set to 0 to try_hi perf_pctg */ 223 /* set to 0 to try_hi perf_pctg */
224 msr_lo &= 0xFFFFFF80; 224 msr_lo &= 0xFFFFFF80;
225 msr_hi &= 0xFFFFFF80; 225 msr_hi &= 0xFFFFFF80;
226 msr_lo |= 0;
227 msr_hi |= try_hi; 226 msr_hi |= try_hi;
228 wrmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi); 227 wrmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi);
229 228
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
index 2bf4237cb94e..694d4793bf6a 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
@@ -452,23 +452,23 @@ static int powernow_decode_bios (int maxfid, int startvid)
452 452
453 pst = (struct pst_s *) p; 453 pst = (struct pst_s *) p;
454 454
455 for (i = 0 ; i <psb->numpst; i++) { 455 for (j=0; j<psb->numpst; j++) {
456 pst = (struct pst_s *) p; 456 pst = (struct pst_s *) p;
457 number_scales = pst->numpstates; 457 number_scales = pst->numpstates;
458 458
459 if ((etuple == pst->cpuid) && check_fsb(pst->fsbspeed) && 459 if ((etuple == pst->cpuid) && check_fsb(pst->fsbspeed) &&
460 (maxfid==pst->maxfid) && (startvid==pst->startvid)) 460 (maxfid==pst->maxfid) && (startvid==pst->startvid))
461 { 461 {
462 dprintk ("PST:%d (@%p)\n", i, pst); 462 dprintk ("PST:%d (@%p)\n", j, pst);
463 dprintk (" cpuid: 0x%x fsb: %d maxFID: 0x%x startvid: 0x%x\n", 463 dprintk (" cpuid: 0x%x fsb: %d maxFID: 0x%x startvid: 0x%x\n",
464 pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid); 464 pst->cpuid, pst->fsbspeed, pst->maxfid, pst->startvid);
465 465
466 ret = get_ranges ((char *) pst + sizeof (struct pst_s)); 466 ret = get_ranges ((char *) pst + sizeof (struct pst_s));
467 return ret; 467 return ret;
468
469 } else { 468 } else {
469 unsigned int k;
470 p = (char *) pst + sizeof (struct pst_s); 470 p = (char *) pst + sizeof (struct pst_s);
471 for (j=0 ; j < number_scales; j++) 471 for (k=0; k<number_scales; k++)
472 p+=2; 472 p+=2;
473 } 473 }
474 } 474 }
@@ -581,10 +581,7 @@ static int __init powernow_cpu_init (struct cpufreq_policy *policy)
581 581
582 rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val); 582 rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val);
583 583
584 /* recalibrate cpu_khz */ 584 recalibrate_cpu_khz();
585 result = recalibrate_cpu_khz();
586 if (result)
587 return result;
588 585
589 fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID]; 586 fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID];
590 if (!fsb) { 587 if (!fsb) {
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index 71fffa174425..b4277f58f40c 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * (c) 2003, 2004, 2005 Advanced Micro Devices, Inc. 2 * (c) 2003-2006 Advanced Micro Devices, Inc.
3 * Your use of this code is subject to the terms and conditions of the 3 * Your use of this code is subject to the terms and conditions of the
4 * GNU general public license version 2. See "COPYING" or 4 * GNU general public license version 2. See "COPYING" or
5 * http://www.gnu.org/licenses/gpl.html 5 * http://www.gnu.org/licenses/gpl.html
@@ -14,13 +14,13 @@
14 * Based upon datasheets & sample CPUs kindly provided by AMD. 14 * Based upon datasheets & sample CPUs kindly provided by AMD.
15 * 15 *
16 * Valuable input gratefully received from Dave Jones, Pavel Machek, 16 * Valuable input gratefully received from Dave Jones, Pavel Machek,
17 * Dominik Brodowski, and others. 17 * Dominik Brodowski, Jacob Shin, and others.
18 * Originally developed by Paul Devriendt. 18 * Originally developed by Paul Devriendt.
19 * Processor information obtained from Chapter 9 (Power and Thermal Management) 19 * Processor information obtained from Chapter 9 (Power and Thermal Management)
20 * of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD 20 * of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD
21 * Opteron Processors" available for download from www.amd.com 21 * Opteron Processors" available for download from www.amd.com
22 * 22 *
23 * Tables for specific CPUs can be infrerred from 23 * Tables for specific CPUs can be inferred from
24 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf 24 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf
25 */ 25 */
26 26
@@ -46,7 +46,7 @@
46 46
47#define PFX "powernow-k8: " 47#define PFX "powernow-k8: "
48#define BFX PFX "BIOS error: " 48#define BFX PFX "BIOS error: "
49#define VERSION "version 1.60.2" 49#define VERSION "version 2.00.00"
50#include "powernow-k8.h" 50#include "powernow-k8.h"
51 51
52/* serialize freq changes */ 52/* serialize freq changes */
@@ -54,6 +54,8 @@ static DEFINE_MUTEX(fidvid_mutex);
54 54
55static struct powernow_k8_data *powernow_data[NR_CPUS]; 55static struct powernow_k8_data *powernow_data[NR_CPUS];
56 56
57static int cpu_family = CPU_OPTERON;
58
57#ifndef CONFIG_SMP 59#ifndef CONFIG_SMP
58static cpumask_t cpu_core_map[1]; 60static cpumask_t cpu_core_map[1];
59#endif 61#endif
@@ -64,16 +66,36 @@ static u32 find_freq_from_fid(u32 fid)
64 return 800 + (fid * 100); 66 return 800 + (fid * 100);
65} 67}
66 68
69
67/* Return a frequency in KHz, given an input fid */ 70/* Return a frequency in KHz, given an input fid */
68static u32 find_khz_freq_from_fid(u32 fid) 71static u32 find_khz_freq_from_fid(u32 fid)
69{ 72{
70 return 1000 * find_freq_from_fid(fid); 73 return 1000 * find_freq_from_fid(fid);
71} 74}
72 75
73/* Return a voltage in miliVolts, given an input vid */ 76/* Return a frequency in MHz, given an input fid and did */
74static u32 find_millivolts_from_vid(struct powernow_k8_data *data, u32 vid) 77static u32 find_freq_from_fiddid(u32 fid, u32 did)
78{
79 return 100 * (fid + 0x10) >> did;
80}
81
82static u32 find_khz_freq_from_fiddid(u32 fid, u32 did)
75{ 83{
76 return 1550-vid*25; 84 return 1000 * find_freq_from_fiddid(fid, did);
85}
86
87static u32 find_fid_from_pstate(u32 pstate)
88{
89 u32 hi, lo;
90 rdmsr(MSR_PSTATE_DEF_BASE + pstate, lo, hi);
91 return lo & HW_PSTATE_FID_MASK;
92}
93
94static u32 find_did_from_pstate(u32 pstate)
95{
96 u32 hi, lo;
97 rdmsr(MSR_PSTATE_DEF_BASE + pstate, lo, hi);
98 return (lo & HW_PSTATE_DID_MASK) >> HW_PSTATE_DID_SHIFT;
77} 99}
78 100
79/* Return the vco fid for an input fid 101/* Return the vco fid for an input fid
@@ -98,6 +120,9 @@ static int pending_bit_stuck(void)
98{ 120{
99 u32 lo, hi; 121 u32 lo, hi;
100 122
123 if (cpu_family)
124 return 0;
125
101 rdmsr(MSR_FIDVID_STATUS, lo, hi); 126 rdmsr(MSR_FIDVID_STATUS, lo, hi);
102 return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0; 127 return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;
103} 128}
@@ -111,6 +136,14 @@ static int query_current_values_with_pending_wait(struct powernow_k8_data *data)
111 u32 lo, hi; 136 u32 lo, hi;
112 u32 i = 0; 137 u32 i = 0;
113 138
139 if (cpu_family) {
140 rdmsr(MSR_PSTATE_STATUS, lo, hi);
141 i = lo & HW_PSTATE_MASK;
142 rdmsr(MSR_PSTATE_DEF_BASE + i, lo, hi);
143 data->currfid = lo & HW_PSTATE_FID_MASK;
144 data->currdid = (lo & HW_PSTATE_DID_MASK) >> HW_PSTATE_DID_SHIFT;
145 return 0;
146 }
114 do { 147 do {
115 if (i++ > 10000) { 148 if (i++ > 10000) {
116 dprintk("detected change pending stuck\n"); 149 dprintk("detected change pending stuck\n");
@@ -175,7 +208,7 @@ static int write_new_fid(struct powernow_k8_data *data, u32 fid)
175 do { 208 do {
176 wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION); 209 wrmsr(MSR_FIDVID_CTL, lo, data->plllock * PLL_LOCK_CONVERSION);
177 if (i++ > 100) { 210 if (i++ > 100) {
178 printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n"); 211 printk(KERN_ERR PFX "Hardware error - pending bit very stuck - no further pstate changes possible\n");
179 return 1; 212 return 1;
180 } 213 }
181 } while (query_current_values_with_pending_wait(data)); 214 } while (query_current_values_with_pending_wait(data));
@@ -255,7 +288,15 @@ static int decrease_vid_code_by_step(struct powernow_k8_data *data, u32 reqvid,
255 return 0; 288 return 0;
256} 289}
257 290
258/* Change the fid and vid, by the 3 phases. */ 291/* Change hardware pstate by single MSR write */
292static int transition_pstate(struct powernow_k8_data *data, u32 pstate)
293{
294 wrmsr(MSR_PSTATE_CTRL, pstate, 0);
295 data->currfid = find_fid_from_pstate(pstate);
296 return 0;
297}
298
299/* Change Opteron/Athlon64 fid and vid, by the 3 phases. */
259static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 reqvid) 300static int transition_fid_vid(struct powernow_k8_data *data, u32 reqfid, u32 reqvid)
260{ 301{
261 if (core_voltage_pre_transition(data, reqvid)) 302 if (core_voltage_pre_transition(data, reqvid))
@@ -474,26 +515,35 @@ static int check_supported_cpu(unsigned int cpu)
474 goto out; 515 goto out;
475 516
476 eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); 517 eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE);
477 if ((eax & CPUID_XFAM) != CPUID_XFAM_K8) 518 if (((eax & CPUID_XFAM) != CPUID_XFAM_K8) &&
519 ((eax & CPUID_XFAM) < CPUID_XFAM_10H))
478 goto out; 520 goto out;
479 521
480 if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || 522 if ((eax & CPUID_XFAM) == CPUID_XFAM_K8) {
481 ((eax & CPUID_XMOD) > CPUID_XMOD_REV_G)) { 523 if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) ||
482 printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax); 524 ((eax & CPUID_XMOD) > CPUID_XMOD_REV_G)) {
483 goto out; 525 printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax);
484 } 526 goto out;
527 }
485 528
486 eax = cpuid_eax(CPUID_GET_MAX_CAPABILITIES); 529 eax = cpuid_eax(CPUID_GET_MAX_CAPABILITIES);
487 if (eax < CPUID_FREQ_VOLT_CAPABILITIES) { 530 if (eax < CPUID_FREQ_VOLT_CAPABILITIES) {
488 printk(KERN_INFO PFX 531 printk(KERN_INFO PFX
489 "No frequency change capabilities detected\n"); 532 "No frequency change capabilities detected\n");
490 goto out; 533 goto out;
491 } 534 }
492 535
493 cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx); 536 cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);
494 if ((edx & P_STATE_TRANSITION_CAPABLE) != P_STATE_TRANSITION_CAPABLE) { 537 if ((edx & P_STATE_TRANSITION_CAPABLE) != P_STATE_TRANSITION_CAPABLE) {
495 printk(KERN_INFO PFX "Power state transitions not supported\n"); 538 printk(KERN_INFO PFX "Power state transitions not supported\n");
496 goto out; 539 goto out;
540 }
541 } else { /* must be a HW Pstate capable processor */
542 cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);
543 if ((edx & USE_HW_PSTATE) == USE_HW_PSTATE)
544 cpu_family = CPU_HW_PSTATE;
545 else
546 goto out;
497 } 547 }
498 548
499 rc = 1; 549 rc = 1;
@@ -547,12 +597,18 @@ static void print_basics(struct powernow_k8_data *data)
547{ 597{
548 int j; 598 int j;
549 for (j = 0; j < data->numps; j++) { 599 for (j = 0; j < data->numps; j++) {
550 if (data->powernow_table[j].frequency != CPUFREQ_ENTRY_INVALID) 600 if (data->powernow_table[j].frequency != CPUFREQ_ENTRY_INVALID) {
551 printk(KERN_INFO PFX " %d : fid 0x%x (%d MHz), vid 0x%x (%d mV)\n", j, 601 if (cpu_family) {
602 printk(KERN_INFO PFX " %d : fid 0x%x gid 0x%x (%d MHz)\n", j, (data->powernow_table[j].index & 0xff00) >> 8,
603 (data->powernow_table[j].index & 0xff0000) >> 16,
604 data->powernow_table[j].frequency/1000);
605 } else {
606 printk(KERN_INFO PFX " %d : fid 0x%x (%d MHz), vid 0x%x\n", j,
552 data->powernow_table[j].index & 0xff, 607 data->powernow_table[j].index & 0xff,
553 data->powernow_table[j].frequency/1000, 608 data->powernow_table[j].frequency/1000,
554 data->powernow_table[j].index >> 8, 609 data->powernow_table[j].index >> 8);
555 find_millivolts_from_vid(data, data->powernow_table[j].index >> 8)); 610 }
611 }
556 } 612 }
557 if (data->batps) 613 if (data->batps)
558 printk(KERN_INFO PFX "Only %d pstates on battery\n", data->batps); 614 printk(KERN_INFO PFX "Only %d pstates on battery\n", data->batps);
@@ -702,7 +758,7 @@ static int find_psb_table(struct powernow_k8_data *data)
702#ifdef CONFIG_X86_POWERNOW_K8_ACPI 758#ifdef CONFIG_X86_POWERNOW_K8_ACPI
703static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) 759static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index)
704{ 760{
705 if (!data->acpi_data.state_count) 761 if (!data->acpi_data.state_count || cpu_family)
706 return; 762 return;
707 763
708 data->irt = (data->acpi_data.states[index].control >> IRT_SHIFT) & IRT_MASK; 764 data->irt = (data->acpi_data.states[index].control >> IRT_SHIFT) & IRT_MASK;
@@ -715,9 +771,8 @@ static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned
715 771
716static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) 772static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
717{ 773{
718 int i;
719 int cntlofreq = 0;
720 struct cpufreq_frequency_table *powernow_table; 774 struct cpufreq_frequency_table *powernow_table;
775 int ret_val;
721 776
722 if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { 777 if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) {
723 dprintk("register performance failed: bad ACPI data\n"); 778 dprintk("register performance failed: bad ACPI data\n");
@@ -746,6 +801,85 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
746 goto err_out; 801 goto err_out;
747 } 802 }
748 803
804 if (cpu_family)
805 ret_val = fill_powernow_table_pstate(data, powernow_table);
806 else
807 ret_val = fill_powernow_table_fidvid(data, powernow_table);
808 if (ret_val)
809 goto err_out_mem;
810
811 powernow_table[data->acpi_data.state_count].frequency = CPUFREQ_TABLE_END;
812 powernow_table[data->acpi_data.state_count].index = 0;
813 data->powernow_table = powernow_table;
814
815 /* fill in data */
816 data->numps = data->acpi_data.state_count;
817 print_basics(data);
818 powernow_k8_acpi_pst_values(data, 0);
819
820 /* notify BIOS that we exist */
821 acpi_processor_notify_smm(THIS_MODULE);
822
823 return 0;
824
825err_out_mem:
826 kfree(powernow_table);
827
828err_out:
829 acpi_processor_unregister_performance(&data->acpi_data, data->cpu);
830
831 /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */
832 data->acpi_data.state_count = 0;
833
834 return -ENODEV;
835}
836
837static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table)
838{
839 int i;
840
841 for (i = 0; i < data->acpi_data.state_count; i++) {
842 u32 index;
843 u32 hi = 0, lo = 0;
844 u32 fid;
845 u32 did;
846
847 index = data->acpi_data.states[i].control & HW_PSTATE_MASK;
848 if (index > MAX_HW_PSTATE) {
849 printk(KERN_ERR PFX "invalid pstate %d - bad value %d.\n", i, index);
850 printk(KERN_ERR PFX "Please report to BIOS manufacturer\n");
851 }
852 rdmsr(MSR_PSTATE_DEF_BASE + index, lo, hi);
853 if (!(hi & HW_PSTATE_VALID_MASK)) {
854 dprintk("invalid pstate %d, ignoring\n", index);
855 powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
856 continue;
857 }
858
859 fid = lo & HW_PSTATE_FID_MASK;
860 did = (lo & HW_PSTATE_DID_MASK) >> HW_PSTATE_DID_SHIFT;
861
862 dprintk(" %d : fid 0x%x, did 0x%x\n", index, fid, did);
863
864 powernow_table[i].index = index | (fid << HW_FID_INDEX_SHIFT) | (did << HW_DID_INDEX_SHIFT);
865
866 powernow_table[i].frequency = find_khz_freq_from_fiddid(fid, did);
867
868 if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) {
869 printk(KERN_INFO PFX "invalid freq entries %u kHz vs. %u kHz\n",
870 powernow_table[i].frequency,
871 (unsigned int) (data->acpi_data.states[i].core_frequency * 1000));
872 powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID;
873 continue;
874 }
875 }
876 return 0;
877}
878
879static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table)
880{
881 int i;
882 int cntlofreq = 0;
749 for (i = 0; i < data->acpi_data.state_count; i++) { 883 for (i = 0; i < data->acpi_data.state_count; i++) {
750 u32 fid; 884 u32 fid;
751 u32 vid; 885 u32 vid;
@@ -786,7 +920,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
786 if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) || 920 if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) ||
787 (powernow_table[i].index != powernow_table[cntlofreq].index)) { 921 (powernow_table[i].index != powernow_table[cntlofreq].index)) {
788 printk(KERN_ERR PFX "Too many lo freq table entries\n"); 922 printk(KERN_ERR PFX "Too many lo freq table entries\n");
789 goto err_out_mem; 923 return 1;
790 } 924 }
791 925
792 dprintk("double low frequency table entry, ignoring it.\n"); 926 dprintk("double low frequency table entry, ignoring it.\n");
@@ -804,31 +938,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
804 continue; 938 continue;
805 } 939 }
806 } 940 }
807
808 powernow_table[data->acpi_data.state_count].frequency = CPUFREQ_TABLE_END;
809 powernow_table[data->acpi_data.state_count].index = 0;
810 data->powernow_table = powernow_table;
811
812 /* fill in data */
813 data->numps = data->acpi_data.state_count;
814 print_basics(data);
815 powernow_k8_acpi_pst_values(data, 0);
816
817 /* notify BIOS that we exist */
818 acpi_processor_notify_smm(THIS_MODULE);
819
820 return 0; 941 return 0;
821
822err_out_mem:
823 kfree(powernow_table);
824
825err_out:
826 acpi_processor_unregister_performance(&data->acpi_data, data->cpu);
827
828 /* data->acpi_data.state_count informs us at ->exit() whether ACPI was used */
829 data->acpi_data.state_count = 0;
830
831 return -ENODEV;
832} 942}
833 943
834static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) 944static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data)
@@ -844,20 +954,20 @@ static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned
844#endif /* CONFIG_X86_POWERNOW_K8_ACPI */ 954#endif /* CONFIG_X86_POWERNOW_K8_ACPI */
845 955
846/* Take a frequency, and issue the fid/vid transition command */ 956/* Take a frequency, and issue the fid/vid transition command */
847static int transition_frequency(struct powernow_k8_data *data, unsigned int index) 957static int transition_frequency_fidvid(struct powernow_k8_data *data, unsigned int index)
848{ 958{
849 u32 fid; 959 u32 fid = 0;
850 u32 vid; 960 u32 vid = 0;
851 int res, i; 961 int res, i;
852 struct cpufreq_freqs freqs; 962 struct cpufreq_freqs freqs;
853 963
854 dprintk("cpu %d transition to index %u\n", smp_processor_id(), index); 964 dprintk("cpu %d transition to index %u\n", smp_processor_id(), index);
855 965
966 /* fid/vid correctness check for k8 */
856 /* fid are the lower 8 bits of the index we stored into 967 /* fid are the lower 8 bits of the index we stored into
857 * the cpufreq frequency table in find_psb_table, vid are 968 * the cpufreq frequency table in find_psb_table, vid
858 * the upper 8 bits. 969 * are the upper 8 bits.
859 */ 970 */
860
861 fid = data->powernow_table[index].index & 0xFF; 971 fid = data->powernow_table[index].index & 0xFF;
862 vid = (data->powernow_table[index].index & 0xFF00) >> 8; 972 vid = (data->powernow_table[index].index & 0xFF00) >> 8;
863 973
@@ -881,22 +991,58 @@ static int transition_frequency(struct powernow_k8_data *data, unsigned int inde
881 991
882 dprintk("cpu %d, changing to fid 0x%x, vid 0x%x\n", 992 dprintk("cpu %d, changing to fid 0x%x, vid 0x%x\n",
883 smp_processor_id(), fid, vid); 993 smp_processor_id(), fid, vid);
884
885 freqs.cpu = data->cpu;
886 freqs.old = find_khz_freq_from_fid(data->currfid); 994 freqs.old = find_khz_freq_from_fid(data->currfid);
887 freqs.new = find_khz_freq_from_fid(fid); 995 freqs.new = find_khz_freq_from_fid(fid);
888 for_each_cpu_mask(i, cpu_core_map[data->cpu]) { 996
997 for_each_cpu_mask(i, *(data->available_cores)) {
889 freqs.cpu = i; 998 freqs.cpu = i;
890 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 999 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
891 } 1000 }
892 1001
893 res = transition_fid_vid(data, fid, vid); 1002 res = transition_fid_vid(data, fid, vid);
894
895 freqs.new = find_khz_freq_from_fid(data->currfid); 1003 freqs.new = find_khz_freq_from_fid(data->currfid);
896 for_each_cpu_mask(i, cpu_core_map[data->cpu]) { 1004
1005 for_each_cpu_mask(i, *(data->available_cores)) {
897 freqs.cpu = i; 1006 freqs.cpu = i;
898 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 1007 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
899 } 1008 }
1009 return res;
1010}
1011
1012/* Take a frequency, and issue the hardware pstate transition command */
1013static int transition_frequency_pstate(struct powernow_k8_data *data, unsigned int index)
1014{
1015 u32 fid = 0;
1016 u32 did = 0;
1017 u32 pstate = 0;
1018 int res, i;
1019 struct cpufreq_freqs freqs;
1020
1021 dprintk("cpu %d transition to index %u\n", smp_processor_id(), index);
1022
1023 /* get fid did for hardware pstate transition */
1024 pstate = index & HW_PSTATE_MASK;
1025 if (pstate > MAX_HW_PSTATE)
1026 return 0;
1027 fid = (index & HW_FID_INDEX_MASK) >> HW_FID_INDEX_SHIFT;
1028 did = (index & HW_DID_INDEX_MASK) >> HW_DID_INDEX_SHIFT;
1029 freqs.old = find_khz_freq_from_fiddid(data->currfid, data->currdid);
1030 freqs.new = find_khz_freq_from_fiddid(fid, did);
1031
1032 for_each_cpu_mask(i, *(data->available_cores)) {
1033 freqs.cpu = i;
1034 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
1035 }
1036
1037 res = transition_pstate(data, pstate);
1038 data->currfid = find_fid_from_pstate(pstate);
1039 data->currdid = find_did_from_pstate(pstate);
1040 freqs.new = find_khz_freq_from_fiddid(data->currfid, data->currdid);
1041
1042 for_each_cpu_mask(i, *(data->available_cores)) {
1043 freqs.cpu = i;
1044 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
1045 }
900 return res; 1046 return res;
901} 1047}
902 1048
@@ -933,18 +1079,21 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
933 dprintk("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n", 1079 dprintk("targ: cpu %d, %d kHz, min %d, max %d, relation %d\n",
934 pol->cpu, targfreq, pol->min, pol->max, relation); 1080 pol->cpu, targfreq, pol->min, pol->max, relation);
935 1081
936 if (query_current_values_with_pending_wait(data)) { 1082 if (query_current_values_with_pending_wait(data))
937 ret = -EIO;
938 goto err_out; 1083 goto err_out;
939 }
940 1084
941 dprintk("targ: curr fid 0x%x, vid 0x%x\n", 1085 if (cpu_family)
1086 dprintk("targ: curr fid 0x%x, did 0x%x\n",
1087 data->currfid, data->currvid);
1088 else {
1089 dprintk("targ: curr fid 0x%x, vid 0x%x\n",
942 data->currfid, data->currvid); 1090 data->currfid, data->currvid);
943 1091
944 if ((checkvid != data->currvid) || (checkfid != data->currfid)) { 1092 if ((checkvid != data->currvid) || (checkfid != data->currfid)) {
945 printk(KERN_INFO PFX 1093 printk(KERN_INFO PFX
946 "error - out of sync, fix 0x%x 0x%x, vid 0x%x 0x%x\n", 1094 "error - out of sync, fix 0x%x 0x%x, vid 0x%x 0x%x\n",
947 checkfid, data->currfid, checkvid, data->currvid); 1095 checkfid, data->currfid, checkvid, data->currvid);
1096 }
948 } 1097 }
949 1098
950 if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) 1099 if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate))
@@ -954,7 +1103,11 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
954 1103
955 powernow_k8_acpi_pst_values(data, newstate); 1104 powernow_k8_acpi_pst_values(data, newstate);
956 1105
957 if (transition_frequency(data, newstate)) { 1106 if (cpu_family)
1107 ret = transition_frequency_pstate(data, newstate);
1108 else
1109 ret = transition_frequency_fidvid(data, newstate);
1110 if (ret) {
958 printk(KERN_ERR PFX "transition frequency failed\n"); 1111 printk(KERN_ERR PFX "transition frequency failed\n");
959 ret = 1; 1112 ret = 1;
960 mutex_unlock(&fidvid_mutex); 1113 mutex_unlock(&fidvid_mutex);
@@ -962,7 +1115,10 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi
962 } 1115 }
963 mutex_unlock(&fidvid_mutex); 1116 mutex_unlock(&fidvid_mutex);
964 1117
965 pol->cur = find_khz_freq_from_fid(data->currfid); 1118 if (cpu_family)
1119 pol->cur = find_khz_freq_from_fiddid(data->currfid, data->currdid);
1120 else
1121 pol->cur = find_khz_freq_from_fid(data->currfid);
966 ret = 0; 1122 ret = 0;
967 1123
968err_out: 1124err_out:
@@ -1007,14 +1163,13 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1007 * Use the PSB BIOS structure. This is only availabe on 1163 * Use the PSB BIOS structure. This is only availabe on
1008 * an UP version, and is deprecated by AMD. 1164 * an UP version, and is deprecated by AMD.
1009 */ 1165 */
1010
1011 if ((num_online_cpus() != 1) || (num_possible_cpus() != 1)) { 1166 if ((num_online_cpus() != 1) || (num_possible_cpus() != 1)) {
1012 printk(KERN_ERR PFX "MP systems not supported by PSB BIOS structure\n"); 1167 printk(KERN_ERR PFX "MP systems not supported by PSB BIOS structure\n");
1013 kfree(data); 1168 kfree(data);
1014 return -ENODEV; 1169 return -ENODEV;
1015 } 1170 }
1016 if (pol->cpu != 0) { 1171 if (pol->cpu != 0) {
1017 printk(KERN_ERR PFX "init not cpu 0\n"); 1172 printk(KERN_ERR PFX "No _PSS objects for CPU other than CPU0\n");
1018 kfree(data); 1173 kfree(data);
1019 return -ENODEV; 1174 return -ENODEV;
1020 } 1175 }
@@ -1042,20 +1197,28 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1042 if (query_current_values_with_pending_wait(data)) 1197 if (query_current_values_with_pending_wait(data))
1043 goto err_out; 1198 goto err_out;
1044 1199
1045 fidvid_msr_init(); 1200 if (!cpu_family)
1201 fidvid_msr_init();
1046 1202
1047 /* run on any CPU again */ 1203 /* run on any CPU again */
1048 set_cpus_allowed(current, oldmask); 1204 set_cpus_allowed(current, oldmask);
1049 1205
1050 pol->governor = CPUFREQ_DEFAULT_GOVERNOR; 1206 pol->governor = CPUFREQ_DEFAULT_GOVERNOR;
1051 pol->cpus = cpu_core_map[pol->cpu]; 1207 if (cpu_family)
1208 pol->cpus = cpumask_of_cpu(pol->cpu);
1209 else
1210 pol->cpus = cpu_core_map[pol->cpu];
1211 data->available_cores = &(pol->cpus);
1052 1212
1053 /* Take a crude guess here. 1213 /* Take a crude guess here.
1054 * That guess was in microseconds, so multiply with 1000 */ 1214 * That guess was in microseconds, so multiply with 1000 */
1055 pol->cpuinfo.transition_latency = (((data->rvo + 8) * data->vstable * VST_UNITS_20US) 1215 pol->cpuinfo.transition_latency = (((data->rvo + 8) * data->vstable * VST_UNITS_20US)
1056 + (3 * (1 << data->irt) * 10)) * 1000; 1216 + (3 * (1 << data->irt) * 10)) * 1000;
1057 1217
1058 pol->cur = find_khz_freq_from_fid(data->currfid); 1218 if (cpu_family)
1219 pol->cur = find_khz_freq_from_fiddid(data->currfid, data->currdid);
1220 else
1221 pol->cur = find_khz_freq_from_fid(data->currfid);
1059 dprintk("policy current frequency %d kHz\n", pol->cur); 1222 dprintk("policy current frequency %d kHz\n", pol->cur);
1060 1223
1061 /* min/max the cpu is capable of */ 1224 /* min/max the cpu is capable of */
@@ -1069,8 +1232,12 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1069 1232
1070 cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu); 1233 cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu);
1071 1234
1072 printk("cpu_init done, current fid 0x%x, vid 0x%x\n", 1235 if (cpu_family)
1073 data->currfid, data->currvid); 1236 dprintk("cpu_init done, current fid 0x%x, did 0x%x\n",
1237 data->currfid, data->currdid);
1238 else
1239 dprintk("cpu_init done, current fid 0x%x, vid 0x%x\n",
1240 data->currfid, data->currvid);
1074 1241
1075 powernow_data[pol->cpu] = data; 1242 powernow_data[pol->cpu] = data;
1076 1243
@@ -1156,8 +1323,9 @@ static int __cpuinit powernowk8_init(void)
1156 } 1323 }
1157 1324
1158 if (supported_cpus == num_online_cpus()) { 1325 if (supported_cpus == num_online_cpus()) {
1159 printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron " 1326 printk(KERN_INFO PFX "Found %d %s "
1160 "processors (" VERSION ")\n", supported_cpus); 1327 "processors (" VERSION ")\n", supported_cpus,
1328 boot_cpu_data.x86_model_id);
1161 return cpufreq_register_driver(&cpufreq_amd64_driver); 1329 return cpufreq_register_driver(&cpufreq_amd64_driver);
1162 } 1330 }
1163 1331
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
index 79a7c5c87edc..bf8ad9e43da3 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * (c) 2003, 2004, 2005 Advanced Micro Devices, Inc. 2 * (c) 2003-2006 Advanced Micro Devices, Inc.
3 * Your use of this code is subject to the terms and conditions of the 3 * Your use of this code is subject to the terms and conditions of the
4 * GNU general public license version 2. See "COPYING" or 4 * GNU general public license version 2. See "COPYING" or
5 * http://www.gnu.org/licenses/gpl.html 5 * http://www.gnu.org/licenses/gpl.html
@@ -21,8 +21,8 @@ struct powernow_k8_data {
21 u32 plllock; /* pll lock time, units 1 us */ 21 u32 plllock; /* pll lock time, units 1 us */
22 u32 exttype; /* extended interface = 1 */ 22 u32 exttype; /* extended interface = 1 */
23 23
24 /* keep track of the current fid / vid */ 24 /* keep track of the current fid / vid or did */
25 u32 currvid, currfid; 25 u32 currvid, currfid, currdid;
26 26
27 /* the powernow_table includes all frequency and vid/fid pairings: 27 /* the powernow_table includes all frequency and vid/fid pairings:
28 * fid are the lower 8 bits of the index, vid are the upper 8 bits. 28 * fid are the lower 8 bits of the index, vid are the upper 8 bits.
@@ -34,6 +34,10 @@ struct powernow_k8_data {
34 * used to determine valid frequency/vid/fid states */ 34 * used to determine valid frequency/vid/fid states */
35 struct acpi_processor_performance acpi_data; 35 struct acpi_processor_performance acpi_data;
36#endif 36#endif
37 /* we need to keep track of associated cores, but let cpufreq
38 * handle hotplug events - so just point at cpufreq pol->cpus
39 * structure */
40 cpumask_t *available_cores;
37}; 41};
38 42
39 43
@@ -43,6 +47,7 @@ struct powernow_k8_data {
43#define CPUID_XFAM_K8 0 47#define CPUID_XFAM_K8 0
44#define CPUID_XMOD 0x000f0000 /* extended model */ 48#define CPUID_XMOD 0x000f0000 /* extended model */
45#define CPUID_XMOD_REV_G 0x00060000 49#define CPUID_XMOD_REV_G 0x00060000
50#define CPUID_XFAM_10H 0x00100000 /* family 0x10 */
46#define CPUID_USE_XFAM_XMOD 0x00000f00 51#define CPUID_USE_XFAM_XMOD 0x00000f00
47#define CPUID_GET_MAX_CAPABILITIES 0x80000000 52#define CPUID_GET_MAX_CAPABILITIES 0x80000000
48#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 53#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007
@@ -79,6 +84,32 @@ struct powernow_k8_data {
79#define MSR_S_HI_CURRENT_VID 0x0000003f 84#define MSR_S_HI_CURRENT_VID 0x0000003f
80#define MSR_C_HI_STP_GNT_BENIGN 0x00000001 85#define MSR_C_HI_STP_GNT_BENIGN 0x00000001
81 86
87
88/* Hardware Pstate _PSS and MSR definitions */
89#define USE_HW_PSTATE 0x00000080
90#define HW_PSTATE_FID_MASK 0x0000003f
91#define HW_PSTATE_DID_MASK 0x000001c0
92#define HW_PSTATE_DID_SHIFT 6
93#define HW_PSTATE_MASK 0x00000007
94#define HW_PSTATE_VALID_MASK 0x80000000
95#define HW_FID_INDEX_SHIFT 8
96#define HW_FID_INDEX_MASK 0x0000ff00
97#define HW_DID_INDEX_SHIFT 16
98#define HW_DID_INDEX_MASK 0x00ff0000
99#define HW_WATTS_MASK 0xff
100#define HW_PWR_DVR_MASK 0x300
101#define HW_PWR_DVR_SHIFT 8
102#define HW_PWR_MAX_MULT 3
103#define MAX_HW_PSTATE 8 /* hw pstate supports up to 8 */
104#define MSR_PSTATE_DEF_BASE 0xc0010064 /* base of Pstate MSRs */
105#define MSR_PSTATE_STATUS 0xc0010063 /* Pstate Status MSR */
106#define MSR_PSTATE_CTRL 0xc0010062 /* Pstate control MSR */
107
108/* define the two driver architectures */
109#define CPU_OPTERON 0
110#define CPU_HW_PSTATE 1
111
112
82/* 113/*
83 * There are restrictions frequencies have to follow: 114 * There are restrictions frequencies have to follow:
84 * - only 1 entry in the low fid table ( <=1.4GHz ) 115 * - only 1 entry in the low fid table ( <=1.4GHz )
@@ -182,6 +213,9 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);
182 213
183static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index); 214static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index);
184 215
216static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);
217static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);
218
185#ifdef CONFIG_SMP 219#ifdef CONFIG_SMP
186static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[]) 220static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[])
187{ 221{
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index b0ff9075708c..ce54ff12c15d 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -250,7 +250,7 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy)
250 250
251 if (model->cpu_id == NULL) { 251 if (model->cpu_id == NULL) {
252 /* No match at all */ 252 /* No match at all */
253 dprintk(KERN_INFO PFX "no support for CPU model \"%s\": " 253 dprintk("no support for CPU model \"%s\": "
254 "send /proc/cpuinfo to " MAINTAINER "\n", 254 "send /proc/cpuinfo to " MAINTAINER "\n",
255 cpu->x86_model_id); 255 cpu->x86_model_id);
256 return -ENOENT; 256 return -ENOENT;
@@ -258,10 +258,10 @@ static int centrino_cpu_init_table(struct cpufreq_policy *policy)
258 258
259 if (model->op_points == NULL) { 259 if (model->op_points == NULL) {
260 /* Matched a non-match */ 260 /* Matched a non-match */
261 dprintk(KERN_INFO PFX "no table support for CPU model \"%s\"\n", 261 dprintk("no table support for CPU model \"%s\"\n",
262 cpu->x86_model_id); 262 cpu->x86_model_id);
263#ifndef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI 263#ifndef CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI
264 dprintk(KERN_INFO PFX "try compiling with CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI enabled\n"); 264 dprintk("try compiling with CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI enabled\n");
265#endif 265#endif
266 return -ENOENT; 266 return -ENOENT;
267 } 267 }
@@ -368,7 +368,7 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
368 368
369 /* register with ACPI core */ 369 /* register with ACPI core */
370 if (acpi_processor_register_performance(&p, cpu)) { 370 if (acpi_processor_register_performance(&p, cpu)) {
371 dprintk(KERN_INFO PFX "obtaining ACPI data failed\n"); 371 dprintk("obtaining ACPI data failed\n");
372 return -EIO; 372 return -EIO;
373 } 373 }
374 374
@@ -465,7 +465,7 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
465 kfree(centrino_model[cpu]); 465 kfree(centrino_model[cpu]);
466 err_unreg: 466 err_unreg:
467 acpi_processor_unregister_performance(&p, cpu); 467 acpi_processor_unregister_performance(&p, cpu);
468 dprintk(KERN_INFO PFX "invalid ACPI data\n"); 468 dprintk("invalid ACPI data\n");
469 return (result); 469 return (result);
470} 470}
471#else 471#else
@@ -499,7 +499,7 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
499 centrino_cpu[policy->cpu] = &cpu_ids[i]; 499 centrino_cpu[policy->cpu] = &cpu_ids[i];
500 500
501 if (!centrino_cpu[policy->cpu]) { 501 if (!centrino_cpu[policy->cpu]) {
502 dprintk(KERN_INFO PFX "found unsupported CPU with " 502 dprintk("found unsupported CPU with "
503 "Enhanced SpeedStep: send /proc/cpuinfo to " 503 "Enhanced SpeedStep: send /proc/cpuinfo to "
504 MAINTAINER "\n"); 504 MAINTAINER "\n");
505 return -ENODEV; 505 return -ENODEV;
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index e8ff09fe73d9..35e038a974c6 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -119,6 +119,32 @@ config MIPS_MIRAGE
119 select SYS_HAS_CPU_MIPS32_R1 119 select SYS_HAS_CPU_MIPS32_R1
120 select SYS_SUPPORTS_LITTLE_ENDIAN 120 select SYS_SUPPORTS_LITTLE_ENDIAN
121 121
122config BASLER_EXCITE
123 bool "Basler eXcite smart camera support"
124 select DMA_COHERENT
125 select HW_HAS_PCI
126 select IRQ_CPU
127 select IRQ_CPU_RM7K
128 select IRQ_CPU_RM9K
129 select SERIAL_RM9000
130 select SYS_HAS_CPU_RM9000
131 select SYS_SUPPORTS_32BIT_KERNEL
132 select SYS_SUPPORTS_64BIT_KERNEL
133 select SYS_SUPPORTS_BIG_ENDIAN
134 help
135 The eXcite is a smart camera platform manufactured by
136 Basler Vision Technologies AG
137
138config BASLER_EXCITE_PROTOTYPE
139 bool "Support for pre-release units"
140 depends on BASLER_EXCITE
141 default n
142 help
143 Pre-series (prototype) units are different from later ones in
144 some ways. Select this option if you have one of these. Please
145 note that a kernel built with this option selected will not be
146 able to run on normal units.
147
122config MIPS_COBALT 148config MIPS_COBALT
123 bool "Cobalt Server" 149 bool "Cobalt Server"
124 select DMA_NONCOHERENT 150 select DMA_NONCOHERENT
@@ -142,6 +168,9 @@ config MACH_DECSTATION
142 select SYS_SUPPORTS_32BIT_KERNEL 168 select SYS_SUPPORTS_32BIT_KERNEL
143 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL 169 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
144 select SYS_SUPPORTS_LITTLE_ENDIAN 170 select SYS_SUPPORTS_LITTLE_ENDIAN
171 select SYS_SUPPORTS_128HZ
172 select SYS_SUPPORTS_256HZ
173 select SYS_SUPPORTS_1024HZ
145 help 174 help
146 This enables support for DEC's MIPS based workstations. For details 175 This enables support for DEC's MIPS based workstations. For details
147 see the Linux/MIPS FAQ on <http://www.linux-mips.org/> and the 176 see the Linux/MIPS FAQ on <http://www.linux-mips.org/> and the
@@ -239,6 +268,7 @@ config MACH_JAZZ
239 select SYS_HAS_CPU_R4X00 268 select SYS_HAS_CPU_R4X00
240 select SYS_SUPPORTS_32BIT_KERNEL 269 select SYS_SUPPORTS_32BIT_KERNEL
241 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL 270 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
271 select SYS_SUPPORTS_100HZ
242 help 272 help
243 This a family of machines based on the MIPS R4030 chipset which was 273 This a family of machines based on the MIPS R4030 chipset which was
244 used by several vendors to build RISC/os and Windows NT workstations. 274 used by several vendors to build RISC/os and Windows NT workstations.
@@ -327,6 +357,27 @@ config MIPS_SEAD
327 This enables support for the MIPS Technologies SEAD evaluation 357 This enables support for the MIPS Technologies SEAD evaluation
328 board. 358 board.
329 359
360config WR_PPMC
361 bool "Support for Wind River PPMC board"
362 select IRQ_CPU
363 select BOOT_ELF32
364 select DMA_NONCOHERENT
365 select HW_HAS_PCI
366 select MIPS_GT64120
367 select SWAP_IO_SPACE
368 select SYS_HAS_CPU_MIPS32_R1
369 select SYS_HAS_CPU_MIPS32_R2
370 select SYS_HAS_CPU_MIPS64_R1
371 select SYS_HAS_CPU_NEVADA
372 select SYS_HAS_CPU_RM7000
373 select SYS_SUPPORTS_32BIT_KERNEL
374 select SYS_SUPPORTS_64BIT_KERNEL
375 select SYS_SUPPORTS_BIG_ENDIAN
376 select SYS_SUPPORTS_LITTLE_ENDIAN
377 help
378 This enables support for the Wind River MIPS32 4KC PPMC evaluation
379 board, which is based on GT64120 bridge chip.
380
330config MIPS_SIM 381config MIPS_SIM
331 bool 'MIPS simulator (MIPSsim)' 382 bool 'MIPS simulator (MIPSsim)'
332 select DMA_NONCOHERENT 383 select DMA_NONCOHERENT
@@ -438,53 +489,16 @@ config MIPS_XXS1500
438 489
439config PNX8550_V2PCI 490config PNX8550_V2PCI
440 bool "Philips PNX8550 based Viper2-PCI board" 491 bool "Philips PNX8550 based Viper2-PCI board"
492 depends on BROKEN
441 select PNX8550 493 select PNX8550
442 select SYS_SUPPORTS_LITTLE_ENDIAN 494 select SYS_SUPPORTS_LITTLE_ENDIAN
443 495
444config PNX8550_JBS 496config PNX8550_JBS
445 bool "Philips PNX8550 based JBS board" 497 bool "Philips PNX8550 based JBS board"
498 depends on BROKEN
446 select PNX8550 499 select PNX8550
447 select SYS_SUPPORTS_LITTLE_ENDIAN 500 select SYS_SUPPORTS_LITTLE_ENDIAN
448 501
449config DDB5074
450 bool "NEC DDB Vrc-5074 (EXPERIMENTAL)"
451 depends on EXPERIMENTAL
452 select DDB5XXX_COMMON
453 select DMA_NONCOHERENT
454 select HAVE_STD_PC_SERIAL_PORT
455 select HW_HAS_PCI
456 select IRQ_CPU
457 select I8259
458 select ISA
459 select SYS_HAS_CPU_R5000
460 select SYS_SUPPORTS_32BIT_KERNEL
461 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
462 select SYS_SUPPORTS_LITTLE_ENDIAN
463 help
464 This enables support for the VR5000-based NEC DDB Vrc-5074
465 evaluation board.
466
467config DDB5476
468 bool "NEC DDB Vrc-5476"
469 select DDB5XXX_COMMON
470 select DMA_NONCOHERENT
471 select HAVE_STD_PC_SERIAL_PORT
472 select HW_HAS_PCI
473 select IRQ_CPU
474 select I8259
475 select ISA
476 select SYS_HAS_CPU_R5432
477 select SYS_SUPPORTS_32BIT_KERNEL
478 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
479 select SYS_SUPPORTS_LITTLE_ENDIAN
480 help
481 This enables support for the R5432-based NEC DDB Vrc-5476
482 evaluation board.
483
484 Features : kernel debugging, serial terminal, NFS root fs, on-board
485 ether port USB, AC97, PCI, PCI VGA card & framebuffer console,
486 IDE controller, PS2 keyboard, PS2 mouse, etc.
487
488config DDB5477 502config DDB5477
489 bool "NEC DDB Vrc-5477" 503 bool "NEC DDB Vrc-5477"
490 select DDB5XXX_COMMON 504 select DDB5XXX_COMMON
@@ -546,6 +560,20 @@ config QEMU
546 simulate actual MIPS hardware platforms. More information on Qemu 560 simulate actual MIPS hardware platforms. More information on Qemu
547 can be found at http://www.linux-mips.org/wiki/Qemu. 561 can be found at http://www.linux-mips.org/wiki/Qemu.
548 562
563config MARKEINS
564 bool "Support for NEC EMMA2RH Mark-eins"
565 select DMA_NONCOHERENT
566 select HW_HAS_PCI
567 select IRQ_CPU
568 select SWAP_IO_SPACE
569 select SYS_SUPPORTS_32BIT_KERNEL
570 select SYS_SUPPORTS_BIG_ENDIAN
571 select SYS_SUPPORTS_LITTLE_ENDIAN
572 select SYS_HAS_CPU_R5000
573 help
574 This enables support for the R5432-based NEC Mark-eins
575 boards with R5500 CPU.
576
549config SGI_IP22 577config SGI_IP22
550 bool "SGI IP22 (Indy/Indigo2)" 578 bool "SGI IP22 (Indy/Indigo2)"
551 select ARC 579 select ARC
@@ -555,6 +583,7 @@ config SGI_IP22
555 select HW_HAS_EISA 583 select HW_HAS_EISA
556 select IP22_CPU_SCACHE 584 select IP22_CPU_SCACHE
557 select IRQ_CPU 585 select IRQ_CPU
586 select NO_ISA if ISA
558 select SWAP_IO_SPACE 587 select SWAP_IO_SPACE
559 select SYS_HAS_CPU_R4X00 588 select SYS_HAS_CPU_R4X00
560 select SYS_HAS_CPU_R5000 589 select SYS_HAS_CPU_R5000
@@ -577,6 +606,7 @@ config SGI_IP27
577 select SYS_HAS_CPU_R10000 606 select SYS_HAS_CPU_R10000
578 select SYS_SUPPORTS_64BIT_KERNEL 607 select SYS_SUPPORTS_64BIT_KERNEL
579 select SYS_SUPPORTS_BIG_ENDIAN 608 select SYS_SUPPORTS_BIG_ENDIAN
609 select SYS_SUPPORTS_NUMA
580 help 610 help
581 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics 611 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
582 workstations. To compile a Linux kernel that runs on these, say Y 612 workstations. To compile a Linux kernel that runs on these, say Y
@@ -707,8 +737,8 @@ config SIBYTE_CRHONE
707 737
708config SNI_RM200_PCI 738config SNI_RM200_PCI
709 bool "SNI RM200 PCI" 739 bool "SNI RM200 PCI"
710 select ARC 740 select ARC if CPU_LITTLE_ENDIAN
711 select ARC32 741 select ARC32 if CPU_LITTLE_ENDIAN
712 select ARCH_MAY_HAVE_PC_FDC 742 select ARCH_MAY_HAVE_PC_FDC
713 select BOOT_ELF32 743 select BOOT_ELF32
714 select DMA_NONCOHERENT 744 select DMA_NONCOHERENT
@@ -719,10 +749,13 @@ config SNI_RM200_PCI
719 select I8253 749 select I8253
720 select I8259 750 select I8259
721 select ISA 751 select ISA
752 select SWAP_IO_SPACE if CPU_BIG_ENDIAN
722 select SYS_HAS_CPU_R4X00 753 select SYS_HAS_CPU_R4X00
754 select SYS_HAS_CPU_R5000
755 select R5000_CPU_SCACHE
723 select SYS_SUPPORTS_32BIT_KERNEL 756 select SYS_SUPPORTS_32BIT_KERNEL
724 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL 757 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
725 select SYS_SUPPORTS_BIG_ENDIAN if EXPERIMENTAL 758 select SYS_SUPPORTS_BIG_ENDIAN
726 select SYS_SUPPORTS_HIGHMEM 759 select SYS_SUPPORTS_HIGHMEM
727 select SYS_SUPPORTS_LITTLE_ENDIAN 760 select SYS_SUPPORTS_LITTLE_ENDIAN
728 help 761 help
@@ -979,6 +1012,11 @@ config SOC_PNX8550
979config SWAP_IO_SPACE 1012config SWAP_IO_SPACE
980 bool 1013 bool
981 1014
1015config EMMA2RH
1016 bool
1017 depends on MARKEINS
1018 default y
1019
982# 1020#
983# Unfortunately not all GT64120 systems run the chip at the same clock. 1021# Unfortunately not all GT64120 systems run the chip at the same clock.
984# As the user for the clock rate and try to minimize the available options. 1022# As the user for the clock rate and try to minimize the available options.
@@ -1607,6 +1645,28 @@ config ARCH_FLATMEM_ENABLE
1607 def_bool y 1645 def_bool y
1608 depends on !NUMA 1646 depends on !NUMA
1609 1647
1648config ARCH_DISCONTIGMEM_ENABLE
1649 bool
1650 default y if SGI_IP27
1651 help
1652 Say Y to upport efficient handling of discontiguous physical memory,
1653 for architectures which are either NUMA (Non-Uniform Memory Access)
1654 or have huge holes in the physical address space for other reasons.
1655 See <file:Documentation/vm/numa> for more.
1656
1657config NUMA
1658 bool "NUMA Support"
1659 depends on SYS_SUPPORTS_NUMA
1660 help
1661 Say Y to compile the kernel to support NUMA (Non-Uniform Memory
1662 Access). This option improves performance on systems with more
1663 than two nodes; on two node systems it is generally better to
1664 leave it disabled; on single node systems disable this option
1665 disabled.
1666
1667config SYS_SUPPORTS_NUMA
1668 bool
1669
1610config NODES_SHIFT 1670config NODES_SHIFT
1611 int 1671 int
1612 default "6" 1672 default "6"
@@ -1651,6 +1711,77 @@ config NR_CPUS
1651 This is purely to save memory - each supported CPU adds 1711 This is purely to save memory - each supported CPU adds
1652 approximately eight kilobytes to the kernel image. 1712 approximately eight kilobytes to the kernel image.
1653 1713
1714#
1715# Timer Interrupt Frequency Configuration
1716#
1717
1718choice
1719 prompt "Timer frequency"
1720 default HZ_250
1721 help
1722 Allows the configuration of the timer frequency.
1723
1724 config HZ_48
1725 bool "48 HZ" if SYS_SUPPORTS_48HZ
1726
1727 config HZ_100
1728 bool "100 HZ" if SYS_SUPPORTS_100HZ || SYS_SUPPORTS_ARBIT_HZ
1729
1730 config HZ_128
1731 bool "128 HZ" if SYS_SUPPORTS_128HZ || SYS_SUPPORTS_ARBIT_HZ
1732
1733 config HZ_250
1734 bool "250 HZ" if SYS_SUPPORTS_250HZ || SYS_SUPPORTS_ARBIT_HZ
1735
1736 config HZ_256
1737 bool "256 HZ" if SYS_SUPPORTS_256HZ || SYS_SUPPORTS_ARBIT_HZ
1738
1739 config HZ_1000
1740 bool "1000 HZ" if SYS_SUPPORTS_1000HZ || SYS_SUPPORTS_ARBIT_HZ
1741
1742 config HZ_1024
1743 bool "1024 HZ" if SYS_SUPPORTS_1024HZ || SYS_SUPPORTS_ARBIT_HZ
1744
1745endchoice
1746
1747config SYS_SUPPORTS_48HZ
1748 bool
1749
1750config SYS_SUPPORTS_100HZ
1751 bool
1752
1753config SYS_SUPPORTS_128HZ
1754 bool
1755
1756config SYS_SUPPORTS_250HZ
1757 bool
1758
1759config SYS_SUPPORTS_256HZ
1760 bool
1761
1762config SYS_SUPPORTS_1000HZ
1763 bool
1764
1765config SYS_SUPPORTS_1024HZ
1766 bool
1767
1768config SYS_SUPPORTS_ARBIT_HZ
1769 bool
1770 default y if !SYS_SUPPORTS_48HZ && !SYS_SUPPORTS_100HZ && \
1771 !SYS_SUPPORTS_128HZ && !SYS_SUPPORTS_250HZ && \
1772 !SYS_SUPPORTS_256HZ && !SYS_SUPPORTS_1000HZ && \
1773 !SYS_SUPPORTS_1024HZ
1774
1775config HZ
1776 int
1777 default 48 if HZ_48
1778 default 100 if HZ_100
1779 default 128 if HZ_128
1780 default 250 if HZ_250
1781 default 256 if HZ_256
1782 default 1000 if HZ_1000
1783 default 1024 if HZ_1024
1784
1654source "kernel/Kconfig.preempt" 1785source "kernel/Kconfig.preempt"
1655 1786
1656config RTC_DS1742 1787config RTC_DS1742
@@ -1710,6 +1841,9 @@ source "drivers/pci/Kconfig"
1710config ISA 1841config ISA
1711 bool 1842 bool
1712 1843
1844config NO_ISA
1845 bool
1846
1713config EISA 1847config EISA
1714 bool "EISA support" 1848 bool "EISA support"
1715 depends on HW_HAS_EISA 1849 depends on HW_HAS_EISA
@@ -1840,6 +1974,32 @@ config PM
1840 bool "Power Management support (EXPERIMENTAL)" 1974 bool "Power Management support (EXPERIMENTAL)"
1841 depends on EXPERIMENTAL && SOC_AU1X00 1975 depends on EXPERIMENTAL && SOC_AU1X00
1842 1976
1977config APM
1978 tristate "Advanced Power Management Emulation"
1979 depends on PM
1980 ---help---
1981 APM is a BIOS specification for saving power using several different
1982 techniques. This is mostly useful for battery powered systems with
1983 APM compliant BIOSes. If you say Y here, the system time will be
1984 reset after a RESUME operation, the /proc/apm device will provide
1985 battery status information, and user-space programs will receive
1986 notification of APM "events" (e.g. battery status change).
1987
1988 In order to use APM, you will need supporting software. For location
1989 and more information, read <file:Documentation/pm.txt> and the
1990 Battery Powered Linux mini-HOWTO, available from
1991 <http://www.tldp.org/docs.html#howto>.
1992
1993 This driver does not spin down disk drives (see the hdparm(8)
1994 manpage ("man 8 hdparm") for that), and it doesn't turn off
1995 VESA-compliant "green" monitors.
1996
1997 Generally, if you don't have a battery in your machine, there isn't
1998 much point in using this driver and you should say N. If you get
1999 random kernel OOPSes or reboots that don't seem to be related to
2000 anything, try disabling/enabling this option (or disabling/enabling
2001 APM in your BIOS).
2002
1843endmenu 2003endmenu
1844 2004
1845source "net/Kconfig" 2005source "net/Kconfig"
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 133900aca992..d5930148495a 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -83,6 +83,8 @@ cflags-y += -msoft-float
83LDFLAGS_vmlinux += -G 0 -static -n -nostdlib 83LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
84MODFLAGS += -mlong-calls 84MODFLAGS += -mlong-calls
85 85
86cflags-y += -ffreestanding
87
86# 88#
87# We explicitly add the endianness specifier if needed, this allows 89# We explicitly add the endianness specifier if needed, this allows
88# to compile kernels with a toolchain for the other endianness. We 90# to compile kernels with a toolchain for the other endianness. We
@@ -285,6 +287,13 @@ cflags-$(CONFIG_MIPS_EV96100) += -Iinclude/asm-mips/mach-ev96100
285load-$(CONFIG_MIPS_EV96100) += 0xffffffff80100000 287load-$(CONFIG_MIPS_EV96100) += 0xffffffff80100000
286 288
287# 289#
290# Wind River PPMC Board (4KC + GT64120)
291#
292core-$(CONFIG_WR_PPMC) += arch/mips/gt64120/wrppmc/
293cflags-$(CONFIG_WR_PPMC) += -Iinclude/asm-mips/mach-wrppmc
294load-$(CONFIG_WR_PPMC) += 0xffffffff80100000
295
296#
288# Globespan IVR eval board with QED 5231 CPU 297# Globespan IVR eval board with QED 5231 CPU
289# 298#
290core-$(CONFIG_ITE_BOARD_GEN) += arch/mips/ite-boards/generic/ 299core-$(CONFIG_ITE_BOARD_GEN) += arch/mips/ite-boards/generic/
@@ -379,6 +388,13 @@ cflags-$(CONFIG_MOMENCO_OCELOT_3) += -Iinclude/asm-mips/mach-ocelot3
379load-$(CONFIG_MOMENCO_OCELOT_3) += 0xffffffff80100000 388load-$(CONFIG_MOMENCO_OCELOT_3) += 0xffffffff80100000
380 389
381# 390#
391# Basler eXcite
392#
393core-$(CONFIG_BASLER_EXCITE) += arch/mips/basler/excite/
394cflags-$(CONFIG_BASLER_EXCITE) += -Iinclude/asm-mips/mach-excite
395load-$(CONFIG_BASLER_EXCITE) += 0x80100000
396
397#
382# Momentum Jaguar ATX 398# Momentum Jaguar ATX
383# 399#
384core-$(CONFIG_MOMENCO_JAGUAR_ATX) += arch/mips/momentum/jaguar_atx/ 400core-$(CONFIG_MOMENCO_JAGUAR_ATX) += arch/mips/momentum/jaguar_atx/
@@ -395,18 +411,6 @@ load-$(CONFIG_MOMENCO_JAGUAR_ATX) += 0xffffffff80100000
395core-$(CONFIG_DDB5XXX_COMMON) += arch/mips/ddb5xxx/common/ 411core-$(CONFIG_DDB5XXX_COMMON) += arch/mips/ddb5xxx/common/
396 412
397# 413#
398# NEC DDB Vrc-5074
399#
400core-$(CONFIG_DDB5074) += arch/mips/ddb5xxx/ddb5074/
401load-$(CONFIG_DDB5074) += 0xffffffff80080000
402
403#
404# NEC DDB Vrc-5476
405#
406core-$(CONFIG_DDB5476) += arch/mips/ddb5xxx/ddb5476/
407load-$(CONFIG_DDB5476) += 0xffffffff80080000
408
409#
410# NEC DDB Vrc-5477 414# NEC DDB Vrc-5477
411# 415#
412core-$(CONFIG_DDB5477) += arch/mips/ddb5xxx/ddb5477/ 416core-$(CONFIG_DDB5477) += arch/mips/ddb5xxx/ddb5477/
@@ -468,6 +472,15 @@ libs-$(CONFIG_PNX8550_JBS) += arch/mips/philips/pnx8550/jbs/
468#cflags-$(CONFIG_PNX8550_JBS) += -Iinclude/asm-mips/mach-pnx8550 472#cflags-$(CONFIG_PNX8550_JBS) += -Iinclude/asm-mips/mach-pnx8550
469load-$(CONFIG_PNX8550_JBS) += 0xffffffff80060000 473load-$(CONFIG_PNX8550_JBS) += 0xffffffff80060000
470 474
475# NEC EMMA2RH boards
476#
477core-$(CONFIG_EMMA2RH) += arch/mips/emma2rh/common/
478cflags-$(CONFIG_EMMA2RH) += -Iinclude/asm-mips/mach-emma2rh
479
480# NEC EMMA2RH Mark-eins
481core-$(CONFIG_MARKEINS) += arch/mips/emma2rh/markeins/
482load-$(CONFIG_MARKEINS) += 0xffffffff88100000
483
471# 484#
472# SGI IP22 (Indy/Indigo2) 485# SGI IP22 (Indy/Indigo2)
473# 486#
diff --git a/arch/mips/au1000/common/au1xxx_irqmap.c b/arch/mips/au1000/common/au1xxx_irqmap.c
index 0b2c03c52319..5a1e3687cafa 100644
--- a/arch/mips/au1000/common/au1xxx_irqmap.c
+++ b/arch/mips/au1000/common/au1xxx_irqmap.c
@@ -55,7 +55,7 @@
55 * Careful if you change match 2 request! 55 * Careful if you change match 2 request!
56 * The interrupt handler is called directly from the low level dispatch code. 56 * The interrupt handler is called directly from the low level dispatch code.
57 */ 57 */
58au1xxx_irq_map_t au1xxx_ic0_map[] = { 58au1xxx_irq_map_t __initdata au1xxx_ic0_map[] = {
59 59
60#if defined(CONFIG_SOC_AU1000) 60#if defined(CONFIG_SOC_AU1000)
61 { AU1000_UART0_INT, INTC_INT_HIGH_LEVEL, 0}, 61 { AU1000_UART0_INT, INTC_INT_HIGH_LEVEL, 0},
@@ -220,5 +220,5 @@ au1xxx_irq_map_t au1xxx_ic0_map[] = {
220 220
221}; 221};
222 222
223int au1xxx_ic0_nr_irqs = sizeof(au1xxx_ic0_map)/sizeof(au1xxx_irq_map_t); 223int __initdata au1xxx_ic0_nr_irqs = ARRAY_SIZE(au1xxx_ic0_map);
224 224
diff --git a/arch/mips/au1000/common/pci.c b/arch/mips/au1000/common/pci.c
index 4e5a6e1a9a6e..b1392abac809 100644
--- a/arch/mips/au1000/common/pci.c
+++ b/arch/mips/au1000/common/pci.c
@@ -40,17 +40,17 @@
40 40
41/* TBD */ 41/* TBD */
42static struct resource pci_io_resource = { 42static struct resource pci_io_resource = {
43 "pci IO space", 43 .start = PCI_IO_START,
44 (u32)PCI_IO_START, 44 .end = PCI_IO_END,
45 (u32)PCI_IO_END, 45 .name = "PCI IO space",
46 IORESOURCE_IO 46 .flags = IORESOURCE_IO
47}; 47};
48 48
49static struct resource pci_mem_resource = { 49static struct resource pci_mem_resource = {
50 "pci memory space", 50 .start = PCI_MEM_START,
51 (u32)PCI_MEM_START, 51 .end = PCI_MEM_END,
52 (u32)PCI_MEM_END, 52 .name = "PCI memory space",
53 IORESOURCE_MEM 53 .flags = IORESOURCE_MEM
54}; 54};
55 55
56extern struct pci_ops au1x_pci_ops; 56extern struct pci_ops au1x_pci_ops;
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
index 307e98c29ddc..97165b6b3894 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/au1000/common/setup.c
@@ -49,17 +49,13 @@ extern void __init board_setup(void);
49extern void au1000_restart(char *); 49extern void au1000_restart(char *);
50extern void au1000_halt(void); 50extern void au1000_halt(void);
51extern void au1000_power_off(void); 51extern void au1000_power_off(void);
52extern struct resource ioport_resource;
53extern struct resource iomem_resource;
54extern void (*board_time_init)(void);
55extern void au1x_time_init(void); 52extern void au1x_time_init(void);
56extern void (*board_timer_setup)(struct irqaction *irq);
57extern void au1x_timer_setup(struct irqaction *irq); 53extern void au1x_timer_setup(struct irqaction *irq);
58extern void au1xxx_time_init(void); 54extern void au1xxx_time_init(void);
59extern void au1xxx_timer_setup(struct irqaction *irq); 55extern void au1xxx_timer_setup(struct irqaction *irq);
60extern void set_cpuspec(void); 56extern void set_cpuspec(void);
61 57
62void __init plat_setup(void) 58void __init plat_mem_setup(void)
63{ 59{
64 struct cpu_spec *sp; 60 struct cpu_spec *sp;
65 char *argptr; 61 char *argptr;
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
index f74d66a58a21..842e1b5ac4a1 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/au1000/common/time.c
@@ -50,10 +50,6 @@
50#include <linux/mc146818rtc.h> 50#include <linux/mc146818rtc.h>
51#include <linux/timex.h> 51#include <linux/timex.h>
52 52
53extern void do_softirq(void);
54extern volatile unsigned long wall_jiffies;
55unsigned long missed_heart_beats = 0;
56
57static unsigned long r4k_offset; /* Amount to increment compare reg each time */ 53static unsigned long r4k_offset; /* Amount to increment compare reg each time */
58static unsigned long r4k_cur; /* What counter should be at next timer irq */ 54static unsigned long r4k_cur; /* What counter should be at next timer irq */
59int no_au1xxx_32khz; 55int no_au1xxx_32khz;
@@ -388,10 +384,9 @@ static unsigned long do_fast_pm_gettimeoffset(void)
388} 384}
389#endif 385#endif
390 386
391void au1xxx_timer_setup(struct irqaction *irq) 387void __init au1xxx_timer_setup(struct irqaction *irq)
392{ 388{
393 unsigned int est_freq; 389 unsigned int est_freq;
394 extern unsigned long (*do_gettimeoffset)(void);
395 390
396 printk("calculating r4koff... "); 391 printk("calculating r4koff... ");
397 r4k_offset = cal_r4koff(); 392 r4k_offset = cal_r4koff();
diff --git a/arch/mips/au1000/csb250/irqmap.c b/arch/mips/au1000/csb250/irqmap.c
index 5cb1166be35c..57d60401905e 100644
--- a/arch/mips/au1000/csb250/irqmap.c
+++ b/arch/mips/au1000/csb250/irqmap.c
@@ -47,7 +47,7 @@
47#include <asm/system.h> 47#include <asm/system.h>
48#include <asm/au1000.h> 48#include <asm/au1000.h>
49 49
50au1xxx_irq_map_t au1xxx_irq_map[] = { 50au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
51 51
52 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 52 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0},
53 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 53 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
@@ -57,4 +57,4 @@ au1xxx_irq_map_t au1xxx_irq_map[] = {
57 { AU1500_GPIO_207, INTC_INT_LOW_LEVEL, 0 }, 57 { AU1500_GPIO_207, INTC_INT_LOW_LEVEL, 0 },
58}; 58};
59 59
60int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 60int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/db1x00/irqmap.c b/arch/mips/au1000/db1x00/irqmap.c
index f63024a9893a..0138c5b7c860 100644
--- a/arch/mips/au1000/db1x00/irqmap.c
+++ b/arch/mips/au1000/db1x00/irqmap.c
@@ -80,7 +80,7 @@ char irq_tab_alchemy[][5] __initdata = {
80#endif 80#endif
81 81
82 82
83au1xxx_irq_map_t au1xxx_irq_map[] = { 83au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
84 84
85#ifndef CONFIG_MIPS_MIRAGE 85#ifndef CONFIG_MIPS_MIRAGE
86#ifdef CONFIG_MIPS_DB1550 86#ifdef CONFIG_MIPS_DB1550
@@ -101,4 +101,4 @@ au1xxx_irq_map_t au1xxx_irq_map[] = {
101 101
102}; 102};
103 103
104int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 104int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/hydrogen3/irqmap.c b/arch/mips/au1000/hydrogen3/irqmap.c
index 6eacaa0daa49..14e1ed37cf6b 100644
--- a/arch/mips/au1000/hydrogen3/irqmap.c
+++ b/arch/mips/au1000/hydrogen3/irqmap.c
@@ -47,10 +47,10 @@
47#include <asm/system.h> 47#include <asm/system.h>
48#include <asm/au1000.h> 48#include <asm/au1000.h>
49 49
50au1xxx_irq_map_t au1xxx_irq_map[] = { 50au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
51 51
52 /* { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 }, */ 52 /* { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 }, */
53 { AU1000_GPIO_21, INTC_INT_LOW_LEVEL, 0 }, 53 { AU1000_GPIO_21, INTC_INT_LOW_LEVEL, 0 },
54}; 54};
55 55
56int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 56int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/mtx-1/irqmap.c b/arch/mips/au1000/mtx-1/irqmap.c
index f9a0a8b9def2..4693a4eb2b82 100644
--- a/arch/mips/au1000/mtx-1/irqmap.c
+++ b/arch/mips/au1000/mtx-1/irqmap.c
@@ -58,7 +58,7 @@ char irq_tab_alchemy[][5] __initdata = {
58 [7] = { -1, INTD, INTC, INTX, INTX}, /* IDSEL 07 - AdapterD-Slot1 (bottom) */ 58 [7] = { -1, INTD, INTC, INTX, INTX}, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
59}; 59};
60 60
61au1xxx_irq_map_t au1xxx_irq_map[] = { 61au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
62 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 62 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0},
63 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 63 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
64 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 }, 64 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
@@ -66,4 +66,4 @@ au1xxx_irq_map_t au1xxx_irq_map[] = {
66 { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 }, 66 { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 },
67}; 67};
68 68
69int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 69int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/pb1000/irqmap.c b/arch/mips/au1000/pb1000/irqmap.c
index a3c460e3c23e..156500ba467f 100644
--- a/arch/mips/au1000/pb1000/irqmap.c
+++ b/arch/mips/au1000/pb1000/irqmap.c
@@ -47,8 +47,8 @@
47#include <asm/system.h> 47#include <asm/system.h>
48#include <asm/mach-au1x00/au1000.h> 48#include <asm/mach-au1x00/au1000.h>
49 49
50au1xxx_irq_map_t au1xxx_irq_map[] = { 50au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
51 { AU1000_GPIO_15, INTC_INT_LOW_LEVEL, 0 }, 51 { AU1000_GPIO_15, INTC_INT_LOW_LEVEL, 0 },
52}; 52};
53 53
54int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 54int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/pb1100/irqmap.c b/arch/mips/au1000/pb1100/irqmap.c
index 43be7158b9ab..d986916221b7 100644
--- a/arch/mips/au1000/pb1100/irqmap.c
+++ b/arch/mips/au1000/pb1100/irqmap.c
@@ -47,11 +47,11 @@
47#include <asm/system.h> 47#include <asm/system.h>
48#include <asm/mach-au1x00/au1000.h> 48#include <asm/mach-au1x00/au1000.h>
49 49
50au1xxx_irq_map_t au1xxx_irq_map[] = { 50au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
51 { AU1000_GPIO_9, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card Fully_Interted# 51 { AU1000_GPIO_9, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card Fully_Interted#
52 { AU1000_GPIO_10, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card STSCHG# 52 { AU1000_GPIO_10, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card STSCHG#
53 { AU1000_GPIO_11, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card IRQ# 53 { AU1000_GPIO_11, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card IRQ#
54 { AU1000_GPIO_13, INTC_INT_LOW_LEVEL, 0 }, // DC_IRQ# 54 { AU1000_GPIO_13, INTC_INT_LOW_LEVEL, 0 }, // DC_IRQ#
55}; 55};
56 56
57int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 57int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/pb1200/irqmap.c b/arch/mips/au1000/pb1200/irqmap.c
index 59e70e5cf325..bacc0c6bfe67 100644
--- a/arch/mips/au1000/pb1200/irqmap.c
+++ b/arch/mips/au1000/pb1200/irqmap.c
@@ -55,11 +55,11 @@
55#define PB1200_INT_END DB1200_INT_END 55#define PB1200_INT_END DB1200_INT_END
56#endif 56#endif
57 57
58au1xxx_irq_map_t au1xxx_irq_map[] = { 58au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
59 { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 }, // This is exteranl interrupt cascade 59 { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 }, // This is exteranl interrupt cascade
60}; 60};
61 61
62int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 62int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
63 63
64/* 64/*
65 * Support for External interrupts on the PbAu1200 Development platform. 65 * Support for External interrupts on the PbAu1200 Development platform.
diff --git a/arch/mips/au1000/pb1500/irqmap.c b/arch/mips/au1000/pb1500/irqmap.c
index 8cb76c2edb5e..409d1612bb63 100644
--- a/arch/mips/au1000/pb1500/irqmap.c
+++ b/arch/mips/au1000/pb1500/irqmap.c
@@ -52,7 +52,7 @@ char irq_tab_alchemy[][5] __initdata = {
52 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot */ 52 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot */
53}; 53};
54 54
55au1xxx_irq_map_t au1xxx_irq_map[] = { 55au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
56 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 56 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0},
57 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 57 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
58 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 }, 58 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
@@ -60,4 +60,4 @@ au1xxx_irq_map_t au1xxx_irq_map[] = {
60 { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 }, 60 { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 },
61}; 61};
62 62
63int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 63int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/pb1550/irqmap.c b/arch/mips/au1000/pb1550/irqmap.c
index 47c7a1c19f4b..24a9d186cf5a 100644
--- a/arch/mips/au1000/pb1550/irqmap.c
+++ b/arch/mips/au1000/pb1550/irqmap.c
@@ -52,9 +52,9 @@ char irq_tab_alchemy[][5] __initdata = {
52 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot 1 (right) */ 52 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot 1 (right) */
53}; 53};
54 54
55au1xxx_irq_map_t au1xxx_irq_map[] = { 55au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
56 { AU1000_GPIO_0, INTC_INT_LOW_LEVEL, 0 }, 56 { AU1000_GPIO_0, INTC_INT_LOW_LEVEL, 0 },
57 { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 }, 57 { AU1000_GPIO_1, INTC_INT_LOW_LEVEL, 0 },
58}; 58};
59 59
60int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 60int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/xxs1500/irqmap.c b/arch/mips/au1000/xxs1500/irqmap.c
index 52f2f7daeb05..3844c6429e27 100644
--- a/arch/mips/au1000/xxs1500/irqmap.c
+++ b/arch/mips/au1000/xxs1500/irqmap.c
@@ -47,7 +47,7 @@
47#include <asm/system.h> 47#include <asm/system.h>
48#include <asm/au1000.h> 48#include <asm/au1000.h>
49 49
50au1xxx_irq_map_t au1xxx_irq_map[] = { 50au1xxx_irq_map_t __initdata au1xxx_irq_map[] = {
51 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 51 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0},
52 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 52 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
53 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 }, 53 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
@@ -63,4 +63,4 @@ au1xxx_irq_map_t au1xxx_irq_map[] = {
63 { AU1000_GPIO_5, INTC_INT_LOW_LEVEL, 0 }, 63 { AU1000_GPIO_5, INTC_INT_LOW_LEVEL, 0 },
64}; 64};
65 65
66int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t); 66int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/basler/excite/Makefile b/arch/mips/basler/excite/Makefile
new file mode 100644
index 000000000000..519142c2e4ef
--- /dev/null
+++ b/arch/mips/basler/excite/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for Basler eXcite
3#
4
5obj-$(CONFIG_BASLER_EXCITE) += excite_irq.o excite_prom.o excite_setup.o \
6 excite_device.o excite_procfs.o
7
8obj-$(CONFIG_KGDB) += excite_dbg_io.o
9obj-m += excite_iodev.o
diff --git a/arch/mips/basler/excite/excite_dbg_io.c b/arch/mips/basler/excite/excite_dbg_io.c
new file mode 100644
index 000000000000..83f6bddf578b
--- /dev/null
+++ b/arch/mips/basler/excite/excite_dbg_io.c
@@ -0,0 +1,122 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/config.h>
21#include <linux/linkage.h>
22#include <linux/init.h>
23#include <linux/kernel.h>
24#include <asm/gdb-stub.h>
25#include <asm/rm9k-ocd.h>
26#include <excite.h>
27
28#if defined(CONFIG_SERIAL_8250) && CONFIG_SERIAL_8250_NR_UARTS > 1
29#error Debug port used by serial driver
30#endif
31
32#define UART_CLK 25000000
33#define BASE_BAUD (UART_CLK / 16)
34#define REGISTER_BASE_0 0x0208UL
35#define REGISTER_BASE_1 0x0238UL
36
37#define REGISTER_BASE_DBG REGISTER_BASE_1
38
39#define CPRR 0x0004
40#define UACFG 0x0200
41#define UAINTS 0x0204
42#define UARBR (REGISTER_BASE_DBG + 0x0000)
43#define UATHR (REGISTER_BASE_DBG + 0x0004)
44#define UADLL (REGISTER_BASE_DBG + 0x0008)
45#define UAIER (REGISTER_BASE_DBG + 0x000c)
46#define UADLH (REGISTER_BASE_DBG + 0x0010)
47#define UAIIR (REGISTER_BASE_DBG + 0x0014)
48#define UAFCR (REGISTER_BASE_DBG + 0x0018)
49#define UALCR (REGISTER_BASE_DBG + 0x001c)
50#define UAMCR (REGISTER_BASE_DBG + 0x0020)
51#define UALSR (REGISTER_BASE_DBG + 0x0024)
52#define UAMSR (REGISTER_BASE_DBG + 0x0028)
53#define UASCR (REGISTER_BASE_DBG + 0x002c)
54
55#define PARITY_NONE 0
56#define PARITY_ODD 0x08
57#define PARITY_EVEN 0x18
58#define PARITY_MARK 0x28
59#define PARITY_SPACE 0x38
60
61#define DATA_5BIT 0x0
62#define DATA_6BIT 0x1
63#define DATA_7BIT 0x2
64#define DATA_8BIT 0x3
65
66#define STOP_1BIT 0x0
67#define STOP_2BIT 0x4
68
69#define BAUD_DBG 57600
70#define PARITY_DBG PARITY_NONE
71#define DATA_DBG DATA_8BIT
72#define STOP_DBG STOP_1BIT
73
74/* Initialize the serial port for KGDB debugging */
75void __init excite_kgdb_init(void)
76{
77 const u32 divisor = BASE_BAUD / BAUD_DBG;
78
79 /* Take the UART out of reset */
80 titan_writel(0x00ff1cff, CPRR);
81 titan_writel(0x00000000, UACFG);
82 titan_writel(0x00000002, UACFG);
83
84 titan_writel(0x0, UALCR);
85 titan_writel(0x0, UAIER);
86
87 /* Disable FIFOs */
88 titan_writel(0x00, UAFCR);
89
90 titan_writel(0x80, UALCR);
91 titan_writel(divisor & 0xff, UADLL);
92 titan_writel((divisor & 0xff00) >> 8, UADLH);
93 titan_writel(0x0, UALCR);
94
95 titan_writel(DATA_DBG | PARITY_DBG | STOP_DBG, UALCR);
96
97 /* Enable receiver interrupt */
98 titan_readl(UARBR);
99 titan_writel(0x1, UAIER);
100}
101
102int getDebugChar(void)
103{
104 while (!(titan_readl(UALSR) & 0x1));
105 return titan_readl(UARBR);
106}
107
108int putDebugChar(int data)
109{
110 while (!(titan_readl(UALSR) & 0x20));
111 titan_writel(data, UATHR);
112 return 1;
113}
114
115/* KGDB interrupt handler */
116asmlinkage void excite_kgdb_inthdl(struct pt_regs *regs)
117{
118 if (unlikely(
119 ((titan_readl(UAIIR) & 0x7) == 4)
120 && ((titan_readl(UARBR) & 0xff) == 0x3)))
121 set_async_breakpoint(&regs->cp0_epc);
122}
diff --git a/arch/mips/basler/excite/excite_device.c b/arch/mips/basler/excite/excite_device.c
new file mode 100644
index 000000000000..34ec76716fa0
--- /dev/null
+++ b/arch/mips/basler/excite/excite_device.c
@@ -0,0 +1,404 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/config.h>
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/platform_device.h>
24#include <linux/ioport.h>
25#include <linux/err.h>
26#include <linux/jiffies.h>
27#include <linux/sched.h>
28#include <asm/types.h>
29#include <asm/rm9k-ocd.h>
30
31#include <excite.h>
32#include <rm9k_eth.h>
33#include <rm9k_wdt.h>
34#include <rm9k_xicap.h>
35#include <excite_nandflash.h>
36
37#include "excite_iodev.h"
38
39#define RM9K_GE_UNIT 0
40#define XICAP_UNIT 0
41#define NAND_UNIT 0
42
43#define DLL_TIMEOUT 3 /* seconds */
44
45
46#define RINIT(__start__, __end__, __name__, __parent__) { \
47 .name = __name__ "_0", \
48 .start = (__start__), \
49 .end = (__end__), \
50 .flags = 0, \
51 .parent = (__parent__) \
52}
53
54#define RINIT_IRQ(__irq__, __name__) { \
55 .name = __name__ "_0", \
56 .start = (__irq__), \
57 .end = (__irq__), \
58 .flags = IORESOURCE_IRQ, \
59 .parent = NULL \
60}
61
62
63
64enum {
65 slice_xicap,
66 slice_eth
67};
68
69
70
71static struct resource
72 excite_ctr_resource = {
73 .name = "GPI counters",
74 .start = 0,
75 .end = 5,
76 .flags = 0,
77 .parent = NULL,
78 .sibling = NULL,
79 .child = NULL
80 },
81 excite_gpislice_resource = {
82 .name = "GPI slices",
83 .start = 0,
84 .end = 1,
85 .flags = 0,
86 .parent = NULL,
87 .sibling = NULL,
88 .child = NULL
89 },
90 excite_mdio_channel_resource = {
91 .name = "MDIO channels",
92 .start = 0,
93 .end = 1,
94 .flags = 0,
95 .parent = NULL,
96 .sibling = NULL,
97 .child = NULL
98 },
99 excite_fifomem_resource = {
100 .name = "FIFO memory",
101 .start = 0,
102 .end = 767,
103 .flags = 0,
104 .parent = NULL,
105 .sibling = NULL,
106 .child = NULL
107 },
108 excite_scram_resource = {
109 .name = "Scratch RAM",
110 .start = EXCITE_PHYS_SCRAM,
111 .end = EXCITE_PHYS_SCRAM + EXCITE_SIZE_SCRAM - 1,
112 .flags = IORESOURCE_MEM,
113 .parent = NULL,
114 .sibling = NULL,
115 .child = NULL
116 },
117 excite_fpga_resource = {
118 .name = "System FPGA",
119 .start = EXCITE_PHYS_FPGA,
120 .end = EXCITE_PHYS_FPGA + EXCITE_SIZE_FPGA - 1,
121 .flags = IORESOURCE_MEM,
122 .parent = NULL,
123 .sibling = NULL,
124 .child = NULL
125 },
126 excite_nand_resource = {
127 .name = "NAND flash control",
128 .start = EXCITE_PHYS_NAND,
129 .end = EXCITE_PHYS_NAND + EXCITE_SIZE_NAND - 1,
130 .flags = IORESOURCE_MEM,
131 .parent = NULL,
132 .sibling = NULL,
133 .child = NULL
134 },
135 excite_titan_resource = {
136 .name = "TITAN registers",
137 .start = EXCITE_PHYS_TITAN,
138 .end = EXCITE_PHYS_TITAN + EXCITE_SIZE_TITAN - 1,
139 .flags = IORESOURCE_MEM,
140 .parent = NULL,
141 .sibling = NULL,
142 .child = NULL
143 };
144
145
146
147static void adjust_resources(struct resource *res, unsigned int n)
148{
149 struct resource *p;
150 const unsigned long mask = IORESOURCE_IO | IORESOURCE_MEM
151 | IORESOURCE_IRQ | IORESOURCE_DMA;
152
153 for (p = res; p < res + n; p++) {
154 const struct resource * const parent = p->parent;
155 if (parent) {
156 p->start += parent->start;
157 p->end += parent->start;
158 p->flags = parent->flags & mask;
159 }
160 }
161}
162
163
164
165#if defined(CONFIG_EXCITE_FCAP_GPI) || defined(CONFIG_EXCITE_FCAP_GPI_MODULE)
166static struct resource xicap_rsrc[] = {
167 RINIT(0x4840, 0x486f, XICAP_RESOURCE_FIFO_RX, &excite_titan_resource),
168 RINIT(0x4940, 0x494b, XICAP_RESOURCE_FIFO_TX, &excite_titan_resource),
169 RINIT(0x5040, 0x5127, XICAP_RESOURCE_XDMA, &excite_titan_resource),
170 RINIT(0x1000, 0x112f, XICAP_RESOURCE_PKTPROC, &excite_titan_resource),
171 RINIT(0x1100, 0x110f, XICAP_RESOURCE_PKT_STREAM, &excite_fpga_resource),
172 RINIT(0x0800, 0x0bff, XICAP_RESOURCE_DMADESC, &excite_scram_resource),
173 RINIT(slice_xicap, slice_xicap, XICAP_RESOURCE_GPI_SLICE, &excite_gpislice_resource),
174 RINIT(0x0100, 0x02ff, XICAP_RESOURCE_FIFO_BLK, &excite_fifomem_resource),
175 RINIT_IRQ(TITAN_IRQ, XICAP_RESOURCE_IRQ)
176};
177
178static struct platform_device xicap_pdev = {
179 .name = XICAP_NAME,
180 .id = XICAP_UNIT,
181 .num_resources = ARRAY_SIZE(xicap_rsrc),
182 .resource = xicap_rsrc
183};
184
185/*
186 * Create a platform device for the GPI port that receives the
187 * image data from the embedded camera.
188 */
189static int __init xicap_devinit(void)
190{
191 unsigned long tend;
192 u32 reg;
193 int retval;
194
195 adjust_resources(xicap_rsrc, ARRAY_SIZE(xicap_rsrc));
196
197 /* Power up the slice and configure it. */
198 reg = titan_readl(CPTC1R);
199 reg &= ~(0x11100 << slice_xicap);
200 titan_writel(reg, CPTC1R);
201
202 /* Enable slice & DLL. */
203 reg= titan_readl(CPRR);
204 reg &= ~(0x00030003 << (slice_xicap * 2));
205 titan_writel(reg, CPRR);
206
207 /* Wait for DLLs to lock */
208 tend = jiffies + DLL_TIMEOUT * HZ;
209 while (time_before(jiffies, tend)) {
210 if (!(~titan_readl(CPDSR) & (0x1 << (slice_xicap * 4))))
211 break;
212 yield();
213 }
214
215 if (~titan_readl(CPDSR) & (0x1 << (slice_xicap * 4))) {
216 printk(KERN_ERR "%s: DLL not locked after %u seconds\n",
217 xicap_pdev.name, DLL_TIMEOUT);
218 retval = -ETIME;
219 } else {
220 /* Register platform device */
221 retval = platform_device_register(&xicap_pdev);
222 }
223
224 return retval;
225}
226
227device_initcall(xicap_devinit);
228#endif /* defined(CONFIG_EXCITE_FCAP_GPI) || defined(CONFIG_EXCITE_FCAP_GPI_MODULE) */
229
230
231
232#if defined(CONFIG_WDT_RM9K_GPI) || defined(CONFIG_WDT_RM9K_GPI_MODULE)
233static struct resource wdt_rsrc[] = {
234 RINIT(0, 0, WDT_RESOURCE_COUNTER, &excite_ctr_resource),
235 RINIT(0x0084, 0x008f, WDT_RESOURCE_REGS, &excite_titan_resource),
236 RINIT_IRQ(TITAN_IRQ, WDT_RESOURCE_IRQ)
237};
238
239static struct platform_device wdt_pdev = {
240 .name = WDT_NAME,
241 .id = -1,
242 .num_resources = ARRAY_SIZE(wdt_rsrc),
243 .resource = wdt_rsrc
244};
245
246/*
247 * Create a platform device for the GPI port that receives the
248 * image data from the embedded camera.
249 */
250static int __init wdt_devinit(void)
251{
252 adjust_resources(wdt_rsrc, ARRAY_SIZE(wdt_rsrc));
253 return platform_device_register(&wdt_pdev);
254}
255
256device_initcall(wdt_devinit);
257#endif /* defined(CONFIG_WDT_RM9K_GPI) || defined(CONFIG_WDT_RM9K_GPI_MODULE) */
258
259
260
261static struct resource excite_nandflash_rsrc[] = {
262 RINIT(0x2000, 0x201f, EXCITE_NANDFLASH_RESOURCE_REGS, &excite_nand_resource)
263};
264
265static struct platform_device excite_nandflash_pdev = {
266 .name = "excite_nand",
267 .id = NAND_UNIT,
268 .num_resources = ARRAY_SIZE(excite_nandflash_rsrc),
269 .resource = excite_nandflash_rsrc
270};
271
272/*
273 * Create a platform device for the access to the nand-flash
274 * port
275 */
276static int __init excite_nandflash_devinit(void)
277{
278 adjust_resources(excite_nandflash_rsrc, ARRAY_SIZE(excite_nandflash_rsrc));
279
280 /* nothing to be done here */
281
282 /* Register platform device */
283 return platform_device_register(&excite_nandflash_pdev);
284}
285
286device_initcall(excite_nandflash_devinit);
287
288
289
290static struct resource iodev_rsrc[] = {
291 RINIT_IRQ(FPGA1_IRQ, IODEV_RESOURCE_IRQ)
292};
293
294static struct platform_device io_pdev = {
295 .name = IODEV_NAME,
296 .id = -1,
297 .num_resources = ARRAY_SIZE(iodev_rsrc),
298 .resource = iodev_rsrc
299};
300
301/*
302 * Create a platform device for the external I/O ports.
303 */
304static int __init io_devinit(void)
305{
306 adjust_resources(iodev_rsrc, ARRAY_SIZE(iodev_rsrc));
307 return platform_device_register(&io_pdev);
308}
309
310device_initcall(io_devinit);
311
312
313
314
315#if defined(CONFIG_RM9K_GE) || defined(CONFIG_RM9K_GE_MODULE)
316static struct resource rm9k_ge_rsrc[] = {
317 RINIT(0x2200, 0x27ff, RM9K_GE_RESOURCE_MAC, &excite_titan_resource),
318 RINIT(0x1800, 0x1fff, RM9K_GE_RESOURCE_MSTAT, &excite_titan_resource),
319 RINIT(0x2000, 0x212f, RM9K_GE_RESOURCE_PKTPROC, &excite_titan_resource),
320 RINIT(0x5140, 0x5227, RM9K_GE_RESOURCE_XDMA, &excite_titan_resource),
321 RINIT(0x4870, 0x489f, RM9K_GE_RESOURCE_FIFO_RX, &excite_titan_resource),
322 RINIT(0x494c, 0x4957, RM9K_GE_RESOURCE_FIFO_TX, &excite_titan_resource),
323 RINIT(0x0000, 0x007f, RM9K_GE_RESOURCE_FIFOMEM_RX, &excite_fifomem_resource),
324 RINIT(0x0080, 0x00ff, RM9K_GE_RESOURCE_FIFOMEM_TX, &excite_fifomem_resource),
325 RINIT(0x0180, 0x019f, RM9K_GE_RESOURCE_PHY, &excite_titan_resource),
326 RINIT(0x0000, 0x03ff, RM9K_GE_RESOURCE_DMADESC_RX, &excite_scram_resource),
327 RINIT(0x0400, 0x07ff, RM9K_GE_RESOURCE_DMADESC_TX, &excite_scram_resource),
328 RINIT(slice_eth, slice_eth, RM9K_GE_RESOURCE_GPI_SLICE, &excite_gpislice_resource),
329 RINIT(0, 0, RM9K_GE_RESOURCE_MDIO_CHANNEL, &excite_mdio_channel_resource),
330 RINIT_IRQ(TITAN_IRQ, RM9K_GE_RESOURCE_IRQ_MAIN),
331 RINIT_IRQ(PHY_IRQ, RM9K_GE_RESOURCE_IRQ_PHY)
332};
333
334static struct platform_device rm9k_ge_pdev = {
335 .name = RM9K_GE_NAME,
336 .id = RM9K_GE_UNIT,
337 .num_resources = ARRAY_SIZE(rm9k_ge_rsrc),
338 .resource = rm9k_ge_rsrc
339};
340
341
342
343/*
344 * Create a platform device for the Ethernet port.
345 */
346static int __init rm9k_ge_devinit(void)
347{
348 u32 reg;
349
350 adjust_resources(rm9k_ge_rsrc, ARRAY_SIZE(rm9k_ge_rsrc));
351
352 /* Power up the slice and configure it. */
353 reg = titan_readl(CPTC1R);
354 reg &= ~(0x11000 << slice_eth);
355 reg |= 0x100 << slice_eth;
356 titan_writel(reg, CPTC1R);
357
358 /* Take the MAC out of reset, reset the DLLs. */
359 reg = titan_readl(CPRR);
360 reg &= ~(0x00030000 << (slice_eth * 2));
361 reg |= 0x3 << (slice_eth * 2);
362 titan_writel(reg, CPRR);
363
364 return platform_device_register(&rm9k_ge_pdev);
365}
366
367device_initcall(rm9k_ge_devinit);
368#endif /* defined(CONFIG_RM9K_GE) || defined(CONFIG_RM9K_GE_MODULE) */
369
370
371
372static int __init excite_setup_devs(void)
373{
374 int res;
375 u32 reg;
376
377 /* Enable xdma and fifo interrupts */
378 reg = titan_readl(0x0050);
379 titan_writel(reg | 0x18000000, 0x0050);
380
381 res = request_resource(&iomem_resource, &excite_titan_resource);
382 if (res)
383 return res;
384 res = request_resource(&iomem_resource, &excite_scram_resource);
385 if (res)
386 return res;
387 res = request_resource(&iomem_resource, &excite_fpga_resource);
388 if (res)
389 return res;
390 res = request_resource(&iomem_resource, &excite_nand_resource);
391 if (res)
392 return res;
393 excite_fpga_resource.flags = excite_fpga_resource.parent->flags &
394 ( IORESOURCE_IO | IORESOURCE_MEM
395 | IORESOURCE_IRQ | IORESOURCE_DMA);
396 excite_nand_resource.flags = excite_nand_resource.parent->flags &
397 ( IORESOURCE_IO | IORESOURCE_MEM
398 | IORESOURCE_IRQ | IORESOURCE_DMA);
399
400 return 0;
401}
402
403arch_initcall(excite_setup_devs);
404
diff --git a/arch/mips/basler/excite/excite_flashtest.c b/arch/mips/basler/excite/excite_flashtest.c
new file mode 100644
index 000000000000..f0024a8e3294
--- /dev/null
+++ b/arch/mips/basler/excite/excite_flashtest.c
@@ -0,0 +1,294 @@
1/*
2* Copyright (C) 2005 by Basler Vision Technologies AG
3* Author: Thies Moeller <thies.moeller@baslerweb.com>
4*
5* This program is free software; you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation; either version 2 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program; if not, write to the Free Software
17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20#include <linux/module.h>
21#include <linux/types.h>
22#include <linux/init.h>
23#include <linux/kernel.h>
24#include <linux/string.h>
25#include <linux/ioport.h>
26#include <linux/device.h>
27#include <linux/delay.h>
28#include <linux/err.h>
29#include <linux/kernel.h>
30
31#include <excite.h>
32
33#include <asm/io.h>
34
35#include <linux/mtd/mtd.h>
36#include <linux/mtd/nand.h>
37#include <linux/mtd/nand_ecc.h>
38#include <linux/mtd/partitions.h>
39#include <asm/rm9k-ocd.h> // for ocd_write
40#include <linux/workqueue.h> // for queue
41
42#include "excite_nandflash.h"
43#include "nandflash.h"
44
45#define PFX "excite flashtest: "
46typedef void __iomem *io_reg_t;
47
48#define io_readb(__a__) __raw_readb((__a__))
49#define io_writeb(__v__, __a__) __raw_writeb((__v__), (__a__))
50
51
52
53static inline const struct resource *excite_nandflash_get_resource(
54 struct platform_device *d, unsigned long flags, const char *basename)
55{
56 const char fmt[] = "%s_%u";
57 char buf[80];
58
59 if (unlikely(snprintf(buf, sizeof buf, fmt, basename, d->id) >= sizeof buf))
60 return NULL;
61
62 return platform_get_resource_byname(d, flags, buf);
63}
64
65static inline io_reg_t
66excite_nandflash_map_regs(struct platform_device *d, const char *basename)
67{
68 void *result = NULL;
69 const struct resource *const r =
70 excite_nandflash_get_resource(d, IORESOURCE_MEM, basename);
71 if (r)
72 result = ioremap_nocache(r->start, r->end + 1 - r->start);
73 return result;
74}
75
76/* controller and mtd information */
77
78struct excite_nandflash_drvdata {
79 struct mtd_info board_mtd;
80 struct nand_chip board_chip;
81 io_reg_t regs;
82};
83
84
85/* command and control functions */
86static void excite_nandflash_hwcontrol(struct mtd_info *mtd, int cmd)
87{
88 struct nand_chip *this = mtd->priv;
89 io_reg_t regs = container_of(mtd,struct excite_nandflash_drvdata,board_mtd)->regs;
90
91 switch (cmd) {
92 /* Select the command latch */
93 case NAND_CTL_SETCLE: this->IO_ADDR_W = regs + EXCITE_NANDFLASH_CMD;
94 break;
95 /* Deselect the command latch */
96 case NAND_CTL_CLRCLE: this->IO_ADDR_W = regs + EXCITE_NANDFLASH_DATA;
97 break;
98 /* Select the address latch */
99 case NAND_CTL_SETALE: this->IO_ADDR_W = regs + EXCITE_NANDFLASH_ADDR;
100 break;
101 /* Deselect the address latch */
102 case NAND_CTL_CLRALE: this->IO_ADDR_W = regs + EXCITE_NANDFLASH_DATA;
103 break;
104 /* Select the chip -- not used */
105 case NAND_CTL_SETNCE:
106 break;
107 /* Deselect the chip -- not used */
108 case NAND_CTL_CLRNCE:
109 break;
110 }
111
112 this->IO_ADDR_R = this->IO_ADDR_W;
113}
114
115/* excite_nandflash_devready()
116 *
117 * returns 0 if the nand is busy, 1 if it is ready
118 */
119static int excite_nandflash_devready(struct mtd_info *mtd)
120{
121 struct excite_nandflash_drvdata *drvdata =
122 container_of(mtd, struct excite_nandflash_drvdata, board_mtd);
123
124 return io_readb(drvdata->regs + EXCITE_NANDFLASH_STATUS);
125}
126
127/* device management functions */
128
129/* excite_nandflash_remove
130 *
131 * called by device layer to remove the driver
132 * the binding to the mtd and all allocated
133 * resources are released
134 */
135static int excite_nandflash_remove(struct device *dev)
136{
137 struct excite_nandflash_drvdata *this = dev_get_drvdata(dev);
138
139 pr_info(PFX "remove");
140
141 dev_set_drvdata(dev, NULL);
142
143 if (this == NULL) {
144 pr_debug(PFX "call remove without private data!!");
145 return 0;
146 }
147
148
149 /* free the common resources */
150 if (this->regs != NULL) {
151 iounmap(this->regs);
152 this->regs = NULL;
153 }
154
155 kfree(this);
156
157 return 0;
158}
159
160static int elapsed;
161
162void my_workqueue_handler(void *arg)
163{
164 elapsed = 1;
165}
166
167DECLARE_WORK(sigElapsed, my_workqueue_handler, 0);
168
169
170/* excite_nandflash_probe
171 *
172 * called by device layer when it finds a device matching
173 * one our driver can handled. This code checks to see if
174 * it can allocate all necessary resources then calls the
175 * nand layer to look for devices
176*/
177static int excite_nandflash_probe(struct device *dev)
178{
179 struct platform_device *pdev = to_platform_device(dev);
180
181 struct excite_nandflash_drvdata *drvdata; /* private driver data */
182 struct nand_chip *board_chip; /* private flash chip data */
183 struct mtd_info *board_mtd; /* mtd info for this board */
184
185 int err = 0;
186 int count = 0;
187 struct timeval tv,endtv;
188 unsigned int dt;
189
190 pr_info(PFX "probe dev: (%p)\n", dev);
191
192 pr_info(PFX "adjust LB timing\n");
193 ocd_writel(0x00000330, LDP2);
194
195 drvdata = kmalloc(sizeof(*drvdata), GFP_KERNEL);
196 if (unlikely(!drvdata)) {
197 printk(KERN_ERR PFX "no memory for drvdata\n");
198 err = -ENOMEM;
199 goto mem_error;
200 }
201
202 /* Initialize structures */
203 memset(drvdata, 0, sizeof(*drvdata));
204
205 /* bind private data into driver */
206 dev_set_drvdata(dev, drvdata);
207
208 /* allocate and map the resource */
209 drvdata->regs =
210 excite_nandflash_map_regs(pdev, EXCITE_NANDFLASH_RESOURCE_REGS);
211
212 if (unlikely(!drvdata->regs)) {
213 printk(KERN_ERR PFX "cannot reserve register region\n");
214 err = -ENXIO;
215 goto io_error;
216 }
217
218 /* initialise our chip */
219 board_chip = &drvdata->board_chip;
220
221 board_chip->IO_ADDR_R = drvdata->regs + EXCITE_NANDFLASH_DATA;
222 board_chip->IO_ADDR_W = drvdata->regs + EXCITE_NANDFLASH_DATA;
223
224 board_chip->hwcontrol = excite_nandflash_hwcontrol;
225 board_chip->dev_ready = excite_nandflash_devready;
226
227 board_chip->chip_delay = 25;
228 #if 0
229 /* TODO: speedup the initial scan */
230 board_chip->options = NAND_USE_FLASH_BBT;
231 #endif
232 board_chip->eccmode = NAND_ECC_SOFT;
233
234 /* link chip to mtd */
235 board_mtd = &drvdata->board_mtd;
236 board_mtd->priv = board_chip;
237
238
239 pr_info(PFX "FlashTest\n");
240 elapsed = 0;
241/* schedule_delayed_work(&sigElapsed, 1*HZ);
242 while (!elapsed) {
243 io_readb(drvdata->regs + EXCITE_NANDFLASH_STATUS);
244 count++;
245 }
246 pr_info(PFX "reads in 1 sec --> %d\n",count);
247*/
248 do_gettimeofday(&tv);
249 for (count = 0 ; count < 1000000; count ++) {
250 io_readb(drvdata->regs + EXCITE_NANDFLASH_STATUS);
251 }
252 do_gettimeofday(&endtv);
253 dt = (endtv.tv_sec - tv.tv_sec) * 1000000 + endtv.tv_usec - tv.tv_usec;
254 pr_info(PFX "%8d us timeval\n",dt);
255 pr_info(PFX "EndFlashTest\n");
256
257/* return with error to unload everything
258*/
259io_error:
260 iounmap(drvdata->regs);
261
262mem_error:
263 kfree(drvdata);
264
265 if (err == 0)
266 err = -EINVAL;
267 return err;
268}
269
270static struct device_driver excite_nandflash_driver = {
271 .name = "excite_nand",
272 .bus = &platform_bus_type,
273 .probe = excite_nandflash_probe,
274 .remove = excite_nandflash_remove,
275};
276
277static int __init excite_nandflash_init(void)
278{
279 pr_info(PFX "register Driver (Rev: $Revision:$)\n");
280 return driver_register(&excite_nandflash_driver);
281}
282
283static void __exit excite_nandflash_exit(void)
284{
285 driver_unregister(&excite_nandflash_driver);
286 pr_info(PFX "Driver unregistered");
287}
288
289module_init(excite_nandflash_init);
290module_exit(excite_nandflash_exit);
291
292MODULE_AUTHOR("Thies Moeller <thies.moeller@baslerweb.com>");
293MODULE_DESCRIPTION("Basler eXcite NAND-Flash driver");
294MODULE_LICENSE("GPL");
diff --git a/arch/mips/basler/excite/excite_fpga.h b/arch/mips/basler/excite/excite_fpga.h
new file mode 100644
index 000000000000..38fcda703a0b
--- /dev/null
+++ b/arch/mips/basler/excite/excite_fpga.h
@@ -0,0 +1,80 @@
1#ifndef EXCITE_FPGA_H_INCLUDED
2#define EXCITE_FPGA_H_INCLUDED
3
4
5/**
6 * Adress alignment of the individual FPGA bytes.
7 * The address arrangement of the individual bytes of the FPGA is two
8 * byte aligned at the embedded MK2 platform.
9 */
10#ifdef EXCITE_CCI_FPGA_MK2
11typedef unsigned char excite_cci_fpga_align_t __attribute__ ((aligned(2)));
12#else
13typedef unsigned char excite_cci_fpga_align_t;
14#endif
15
16
17/**
18 * Size of Dual Ported RAM.
19 */
20#define EXCITE_DPR_SIZE 263
21
22
23/**
24 * Size of Reserved Status Fields in Dual Ported RAM.
25 */
26#define EXCITE_DPR_STATUS_SIZE 7
27
28
29
30/**
31 * FPGA.
32 * Hardware register layout of the FPGA interface. The FPGA must accessed
33 * byte wise solely.
34 * @see EXCITE_CCI_DPR_MK2
35 */
36typedef struct excite_fpga {
37
38 /**
39 * Dual Ported RAM.
40 */
41 excite_cci_fpga_align_t dpr[EXCITE_DPR_SIZE];
42
43 /**
44 * Status.
45 */
46 excite_cci_fpga_align_t status[EXCITE_DPR_STATUS_SIZE];
47
48#ifdef EXCITE_CCI_FPGA_MK2
49 /**
50 * RM9000 Interrupt.
51 * Write access initiates interrupt at the RM9000 (MIPS) processor of the eXcite.
52 */
53 excite_cci_fpga_align_t rm9k_int;
54#else
55 /**
56 * MK2 Interrupt.
57 * Write access initiates interrupt at the ARM processor of the MK2.
58 */
59 excite_cci_fpga_align_t mk2_int;
60
61 excite_cci_fpga_align_t gap[0x1000-0x10f];
62
63 /**
64 * IRQ Source/Acknowledge.
65 */
66 excite_cci_fpga_align_t rm9k_irq_src;
67
68 /**
69 * IRQ Mask.
70 * Set bits enable the related interrupt.
71 */
72 excite_cci_fpga_align_t rm9k_irq_mask;
73#endif
74
75
76} excite_fpga;
77
78
79
80#endif /* ndef EXCITE_FPGA_H_INCLUDED */
diff --git a/arch/mips/basler/excite/excite_iodev.c b/arch/mips/basler/excite/excite_iodev.c
new file mode 100644
index 000000000000..91121e523043
--- /dev/null
+++ b/arch/mips/basler/excite/excite_iodev.c
@@ -0,0 +1,183 @@
1/*
2 * Copyright (C) 2005 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/config.h>
21#include <linux/compiler.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/sched.h>
25#include <linux/wait.h>
26#include <linux/poll.h>
27#include <linux/interrupt.h>
28#include <linux/platform_device.h>
29#include <linux/miscdevice.h>
30
31#include "excite_iodev.h"
32
33
34
35static const struct resource *iodev_get_resource(struct platform_device *, const char *, unsigned int);
36static int __init iodev_probe(struct device *);
37static int __exit iodev_remove(struct device *);
38static int iodev_open(struct inode *, struct file *);
39static int iodev_release(struct inode *, struct file *);
40static ssize_t iodev_read(struct file *, char __user *, size_t s, loff_t *);
41static unsigned int iodev_poll(struct file *, struct poll_table_struct *);
42static irqreturn_t iodev_irqhdl(int, void *, struct pt_regs *);
43
44
45
46static const char iodev_name[] = "iodev";
47static unsigned int iodev_irq;
48static DECLARE_WAIT_QUEUE_HEAD(wq);
49
50
51
52static struct file_operations fops =
53{
54 .owner = THIS_MODULE,
55 .open = iodev_open,
56 .release = iodev_release,
57 .read = iodev_read,
58 .poll = iodev_poll
59};
60
61static struct miscdevice miscdev =
62{
63 .minor = MISC_DYNAMIC_MINOR,
64 .name = iodev_name,
65 .fops = &fops
66};
67
68static struct device_driver iodev_driver =
69{
70 .name = (char *) iodev_name,
71 .bus = &platform_bus_type,
72 .owner = THIS_MODULE,
73 .probe = iodev_probe,
74 .remove = __exit_p(iodev_remove)
75};
76
77
78
79static const struct resource *
80iodev_get_resource(struct platform_device *pdv, const char *name,
81 unsigned int type)
82{
83 char buf[80];
84 if (snprintf(buf, sizeof buf, "%s_0", name) >= sizeof buf)
85 return NULL;
86 return platform_get_resource_byname(pdv, type, buf);
87}
88
89
90
91/* No hotplugging on the platform bus - use __init */
92static int __init iodev_probe(struct device *dev)
93{
94 struct platform_device * const pdv = to_platform_device(dev);
95 const struct resource * const ri =
96 iodev_get_resource(pdv, IODEV_RESOURCE_IRQ, IORESOURCE_IRQ);
97
98 if (unlikely(!ri))
99 return -ENXIO;
100
101 iodev_irq = ri->start;
102 return misc_register(&miscdev);
103}
104
105
106
107static int __exit iodev_remove(struct device *dev)
108{
109 return misc_deregister(&miscdev);
110}
111
112
113
114static int iodev_open(struct inode *i, struct file *f)
115{
116 return request_irq(iodev_irq, iodev_irqhdl, SA_INTERRUPT,
117 iodev_name, &miscdev);
118}
119
120
121
122static int iodev_release(struct inode *i, struct file *f)
123{
124 free_irq(iodev_irq, &miscdev);
125 return 0;
126}
127
128
129
130
131static ssize_t
132iodev_read(struct file *f, char __user *d, size_t s, loff_t *o)
133{
134 ssize_t ret;
135 DEFINE_WAIT(w);
136
137 prepare_to_wait(&wq, &w, TASK_INTERRUPTIBLE);
138 if (!signal_pending(current))
139 schedule();
140 ret = signal_pending(current) ? -ERESTARTSYS : 0;
141 finish_wait(&wq, &w);
142 return ret;
143}
144
145
146static unsigned int iodev_poll(struct file *f, struct poll_table_struct *p)
147{
148 poll_wait(f, &wq, p);
149 return POLLOUT | POLLWRNORM;
150}
151
152
153
154
155static irqreturn_t iodev_irqhdl(int irq, void *ctxt, struct pt_regs *regs)
156{
157 wake_up(&wq);
158 return IRQ_HANDLED;
159}
160
161
162
163static int __init iodev_init_module(void)
164{
165 return driver_register(&iodev_driver);
166}
167
168
169
170static void __exit iodev_cleanup_module(void)
171{
172 driver_unregister(&iodev_driver);
173}
174
175module_init(iodev_init_module);
176module_exit(iodev_cleanup_module);
177
178
179
180MODULE_AUTHOR("Thomas Koeller <thomas.koeller@baslerweb.com>");
181MODULE_DESCRIPTION("Basler eXcite i/o interrupt handler");
182MODULE_VERSION("0.0");
183MODULE_LICENSE("GPL");
diff --git a/arch/mips/basler/excite/excite_iodev.h b/arch/mips/basler/excite/excite_iodev.h
new file mode 100644
index 000000000000..cbfbb5d2ee62
--- /dev/null
+++ b/arch/mips/basler/excite/excite_iodev.h
@@ -0,0 +1,10 @@
1#ifndef __EXCITE_IODEV_H__
2#define __EXCITE_IODEV_H__
3
4/* Device name */
5#define IODEV_NAME "iodev"
6
7/* Resource names */
8#define IODEV_RESOURCE_IRQ "excite_iodev_irq"
9
10#endif /* __EXCITE_IODEV_H__ */
diff --git a/arch/mips/basler/excite/excite_irq.c b/arch/mips/basler/excite/excite_irq.c
new file mode 100644
index 000000000000..511ad8730f54
--- /dev/null
+++ b/arch/mips/basler/excite/excite_irq.c
@@ -0,0 +1,129 @@
1/*
2 * Copyright (C) by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslereb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/kernel_stat.h>
23#include <linux/module.h>
24#include <linux/signal.h>
25#include <linux/sched.h>
26#include <linux/types.h>
27#include <linux/interrupt.h>
28#include <linux/ioport.h>
29#include <linux/timex.h>
30#include <linux/slab.h>
31#include <linux/random.h>
32#include <asm/bitops.h>
33#include <asm/bootinfo.h>
34#include <asm/io.h>
35#include <asm/irq.h>
36#include <asm/irq_cpu.h>
37#include <asm/mipsregs.h>
38#include <asm/system.h>
39#include <asm/rm9k-ocd.h>
40
41#include <excite.h>
42
43extern asmlinkage void excite_handle_int(void);
44
45/*
46 * Initialize the interrupt handler
47 */
48void __init arch_init_irq(void)
49{
50 mips_cpu_irq_init(0);
51 rm7k_cpu_irq_init(8);
52 rm9k_cpu_irq_init(12);
53
54#ifdef CONFIG_KGDB
55 excite_kgdb_init();
56#endif
57}
58
59asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
60{
61 const u32
62 interrupts = read_c0_cause() >> 8,
63 mask = ((read_c0_status() >> 8) & 0x000000ff) |
64 (read_c0_intcontrol() & 0x0000ff00),
65 pending = interrupts & mask;
66 u32 msgintflags, msgintmask, msgint;
67
68 /* process timer interrupt */
69 if (pending & (1 << TIMER_IRQ)) {
70 do_IRQ(TIMER_IRQ, regs);
71 return;
72 }
73
74 /* Process PCI interrupts */
75#if USB_IRQ < 10
76 msgintflags = ocd_readl(INTP0Status0 + (USB_MSGINT / 0x20 * 0x10));
77 msgintmask = ocd_readl(INTP0Mask0 + (USB_MSGINT / 0x20 * 0x10));
78 msgint = msgintflags & msgintmask & (0x1 << (USB_MSGINT % 0x20));
79 if ((pending & (1 << USB_IRQ)) && msgint) {
80#else
81 if (pending & (1 << USB_IRQ)) {
82#endif
83 do_IRQ(USB_IRQ, regs);
84 return;
85 }
86
87 /* Process TITAN interrupts */
88 msgintflags = ocd_readl(INTP0Status0 + (TITAN_MSGINT / 0x20 * 0x10));
89 msgintmask = ocd_readl(INTP0Mask0 + (TITAN_MSGINT / 0x20 * 0x10));
90 msgint = msgintflags & msgintmask & (0x1 << (TITAN_MSGINT % 0x20));
91 if ((pending & (1 << TITAN_IRQ)) && msgint) {
92 ocd_writel(msgint, INTP0Clear0 + (TITAN_MSGINT / 0x20 * 0x10));
93#if defined(CONFIG_KGDB)
94 excite_kgdb_inthdl(regs);
95#endif
96 do_IRQ(TITAN_IRQ, regs);
97 return;
98 }
99
100 /* Process FPGA line #0 interrupts */
101 msgintflags = ocd_readl(INTP0Status0 + (FPGA0_MSGINT / 0x20 * 0x10));
102 msgintmask = ocd_readl(INTP0Mask0 + (FPGA0_MSGINT / 0x20 * 0x10));
103 msgint = msgintflags & msgintmask & (0x1 << (FPGA0_MSGINT % 0x20));
104 if ((pending & (1 << FPGA0_IRQ)) && msgint) {
105 do_IRQ(FPGA0_IRQ, regs);
106 return;
107 }
108
109 /* Process FPGA line #1 interrupts */
110 msgintflags = ocd_readl(INTP0Status0 + (FPGA1_MSGINT / 0x20 * 0x10));
111 msgintmask = ocd_readl(INTP0Mask0 + (FPGA1_MSGINT / 0x20 * 0x10));
112 msgint = msgintflags & msgintmask & (0x1 << (FPGA1_MSGINT % 0x20));
113 if ((pending & (1 << FPGA1_IRQ)) && msgint) {
114 do_IRQ(FPGA1_IRQ, regs);
115 return;
116 }
117
118 /* Process PHY interrupts */
119 msgintflags = ocd_readl(INTP0Status0 + (PHY_MSGINT / 0x20 * 0x10));
120 msgintmask = ocd_readl(INTP0Mask0 + (PHY_MSGINT / 0x20 * 0x10));
121 msgint = msgintflags & msgintmask & (0x1 << (PHY_MSGINT % 0x20));
122 if ((pending & (1 << PHY_IRQ)) && msgint) {
123 do_IRQ(PHY_IRQ, regs);
124 return;
125 }
126
127 /* Process spurious interrupts */
128 spurious_interrupt(regs);
129}
diff --git a/arch/mips/basler/excite/excite_procfs.c b/arch/mips/basler/excite/excite_procfs.c
new file mode 100644
index 000000000000..c62be0341fb8
--- /dev/null
+++ b/arch/mips/basler/excite/excite_procfs.c
@@ -0,0 +1,81 @@
1/*
2 * Copyright (C) 2004, 2005 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * Procfs support for Basler eXcite
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/config.h>
23#include <linux/proc_fs.h>
24#include <linux/stat.h>
25#include <asm/page.h>
26#include <asm/io.h>
27#include <asm/system.h>
28#include <asm/rm9k-ocd.h>
29
30#include <excite.h>
31
32static int excite_get_unit_id(char *buf, char **addr, off_t offs, int size)
33{
34 const int len = snprintf(buf, PAGE_SIZE, "%06x", unit_id);
35 const int w = len - offs;
36 *addr = buf + offs;
37 return w < size ? w : size;
38}
39
40static int
41excite_bootrom_read(char *page, char **start, off_t off, int count,
42 int *eof, void *data)
43{
44 void __iomem * src;
45
46 if (off >= EXCITE_SIZE_BOOTROM) {
47 *eof = 1;
48 return 0;
49 }
50
51 if ((off + count) > EXCITE_SIZE_BOOTROM)
52 count = EXCITE_SIZE_BOOTROM - off;
53
54 src = ioremap(EXCITE_PHYS_BOOTROM + off, count);
55 if (src) {
56 memcpy_fromio(page, src, count);
57 iounmap(src);
58 *start = page;
59 } else {
60 count = -ENOMEM;
61 }
62
63 return count;
64}
65
66void excite_procfs_init(void)
67{
68 /* Create & populate /proc/excite */
69 struct proc_dir_entry * const pdir = proc_mkdir("excite", &proc_root);
70 if (pdir) {
71 struct proc_dir_entry * e;
72
73 e = create_proc_info_entry("unit_id", S_IRUGO, pdir,
74 excite_get_unit_id);
75 if (e) e->size = 6;
76
77 e = create_proc_read_entry("bootrom", S_IRUGO, pdir,
78 excite_bootrom_read, NULL);
79 if (e) e->size = EXCITE_SIZE_BOOTROM;
80 }
81}
diff --git a/arch/mips/basler/excite/excite_prom.c b/arch/mips/basler/excite/excite_prom.c
new file mode 100644
index 000000000000..84724b270753
--- /dev/null
+++ b/arch/mips/basler/excite/excite_prom.c
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2004, 2005 by Thomas Koeller (thomas.koeller@baslerweb.com)
3 * Based on the PMC-Sierra Yosemite board support by Ralf Baechle and
4 * Manish Lachwani.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/config.h>
22#include <linux/init.h>
23#include <linux/sched.h>
24#include <linux/mm.h>
25#include <linux/delay.h>
26#include <linux/smp.h>
27#include <linux/module.h>
28#include <asm/io.h>
29#include <asm/pgtable.h>
30#include <asm/processor.h>
31#include <asm/reboot.h>
32#include <asm/system.h>
33#include <asm/bootinfo.h>
34#include <asm/string.h>
35
36#include <excite.h>
37
38/* This struct is used by Redboot to pass arguments to the kernel */
39typedef struct
40{
41 char *name;
42 char *val;
43} t_env_var;
44
45struct parmblock {
46 t_env_var memsize;
47 t_env_var modetty0;
48 t_env_var ethaddr;
49 t_env_var env_end;
50 char *argv[2];
51 char text[0];
52};
53
54static unsigned int prom_argc;
55static const char ** prom_argv;
56static const t_env_var * prom_env;
57
58static void prom_halt(void) __attribute__((noreturn));
59static void prom_exit(void) __attribute__((noreturn));
60
61
62
63const char *get_system_type(void)
64{
65 return "Basler eXcite";
66}
67
68/*
69 * Halt the system
70 */
71static void prom_halt(void)
72{
73 printk(KERN_NOTICE "\n** System halted.\n");
74 while (1)
75 asm volatile (
76 "\t.set\tmips3\n"
77 "\twait\n"
78 "\t.set\tmips0\n"
79 );
80}
81
82/*
83 * Reset the CPU and re-enter Redboot
84 */
85static void prom_exit(void)
86{
87 unsigned int i;
88 volatile unsigned char * const flg =
89 (volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_DPR);
90
91 /* Clear the watchdog reset flag, set the reboot flag */
92 *flg &= ~0x01;
93 *flg |= 0x80;
94
95 for (i = 0; i < 10; i++) {
96 *(volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_SYSCTL) = 0x02;
97 iob();
98 mdelay(1000);
99 }
100
101 printk(KERN_NOTICE "Reset failed\n");
102 prom_halt();
103}
104
105static const char __init *prom_getenv(char *name)
106{
107 const t_env_var * p;
108 for (p = prom_env; p->name != NULL; p++)
109 if(strcmp(name, p->name) == 0)
110 break;
111 return p->val;
112}
113
114/*
115 * Init routine which accepts the variables from Redboot
116 */
117void __init prom_init(void)
118{
119 const struct parmblock * const pb = (struct parmblock *) fw_arg2;
120
121 prom_argc = fw_arg0;
122 prom_argv = (const char **) fw_arg1;
123 prom_env = &pb->memsize;
124
125 /* Callbacks for halt, restart */
126 _machine_restart = (void (*)(char *)) prom_exit;
127 _machine_halt = prom_halt;
128
129#ifdef CONFIG_32BIT
130 /* copy command line */
131 strcpy(arcs_cmdline, prom_argv[1]);
132 memsize = simple_strtol(prom_getenv("memsize"), NULL, 16);
133 strcpy(modetty, prom_getenv("modetty0"));
134#endif /* CONFIG_32BIT */
135
136#ifdef CONFIG_64BIT
137# error 64 bit support not implemented
138#endif /* CONFIG_64BIT */
139
140 mips_machgroup = MACH_GROUP_TITAN;
141 mips_machtype = MACH_TITAN_EXCITE;
142}
143
144/* This is called from free_initmem(), so we need to provide it */
145void __init prom_free_prom_memory(void)
146{
147 /* Nothing to do */
148}
diff --git a/arch/mips/basler/excite/excite_setup.c b/arch/mips/basler/excite/excite_setup.c
new file mode 100644
index 000000000000..005b025605e6
--- /dev/null
+++ b/arch/mips/basler/excite/excite_setup.c
@@ -0,0 +1,307 @@
1/*
2 * Copyright (C) 2004, 2005 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 * Based on the PMC-Sierra Yosemite board support by Ralf Baechle and
5 * Manish Lachwani.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/config.h>
23#include <linux/types.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/string.h>
27#include <linux/tty.h>
28#include <linux/serial_core.h>
29#include <linux/serial.h>
30#include <linux/ioport.h>
31#include <linux/spinlock.h>
32#include <asm/bootinfo.h>
33#include <asm/mipsregs.h>
34#include <asm/pgtable-32.h>
35#include <asm/io.h>
36#include <asm/time.h>
37#include <asm/rm9k-ocd.h>
38
39#include <excite.h>
40
41#define TITAN_UART_CLK 25000000
42
43#if 1
44/* normal serial port assignment */
45#define REGBASE_SER0 0x0208
46#define REGBASE_SER1 0x0238
47#define MASK_SER0 0x1
48#define MASK_SER1 0x2
49#else
50/* serial ports swapped */
51#define REGBASE_SER0 0x0238
52#define REGBASE_SER1 0x0208
53#define MASK_SER0 0x2
54#define MASK_SER1 0x1
55#endif
56
57unsigned long memsize;
58char modetty[30];
59unsigned int titan_irq = TITAN_IRQ;
60static void __iomem * ctl_regs;
61u32 unit_id;
62
63volatile void __iomem * const ocd_base = (void *) (EXCITE_ADDR_OCD);
64volatile void __iomem * const titan_base = (void *) (EXCITE_ADDR_TITAN);
65
66/* Protect access to shared GPI registers */
67spinlock_t titan_lock = SPIN_LOCK_UNLOCKED;
68int titan_irqflags;
69
70
71static void excite_timer_init(void)
72{
73 const u32 modebit5 = ocd_readl(0x00e4);
74 unsigned int
75 mult = ((modebit5 >> 11) & 0x1f) + 2,
76 div = ((modebit5 >> 16) & 0x1f) + 2;
77
78 if (div == 33) div = 1;
79 mips_hpt_frequency = EXCITE_CPU_EXT_CLOCK * mult / div / 2;
80}
81
82static void excite_timer_setup(struct irqaction *irq)
83{
84 /* The eXcite platform uses the alternate timer interrupt */
85 set_c0_intcontrol(0x80);
86 setup_irq(TIMER_IRQ, irq);
87}
88
89static int __init excite_init_console(void)
90{
91#if defined(CONFIG_SERIAL_8250)
92 static __initdata char serr[] =
93 KERN_ERR "Serial port #%u setup failed\n";
94 struct uart_port up;
95
96 /* Take the DUART out of reset */
97 titan_writel(0x00ff1cff, CPRR);
98
99#if defined(CONFIG_KGDB) || (CONFIG_SERIAL_8250_NR_UARTS > 1)
100 /* Enable both ports */
101 titan_writel(MASK_SER0 | MASK_SER1, UACFG);
102#else
103 /* Enable port #0 only */
104 titan_writel(MASK_SER0, UACFG);
105#endif /* defined(CONFIG_KGDB) */
106
107 /*
108 * Set up serial port #0. Do not use autodetection; the result is
109 * not what we want.
110 */
111 memset(&up, 0, sizeof(up));
112 up.membase = (char *) titan_addr(REGBASE_SER0);
113 up.irq = TITAN_IRQ;
114 up.uartclk = TITAN_UART_CLK;
115 up.regshift = 0;
116 up.iotype = UPIO_MEM32;
117 up.type = PORT_RM9000;
118 up.flags = UPF_SHARE_IRQ;
119 up.line = 0;
120 if (early_serial_setup(&up))
121 printk(serr, up.line);
122
123#if CONFIG_SERIAL_8250_NR_UARTS > 1
124 /* And now for port #1. */
125 up.membase = (char *) titan_addr(REGBASE_SER1);
126 up.line = 1;
127 if (early_serial_setup(&up))
128 printk(serr, up.line);
129#endif /* CONFIG_SERIAL_8250_NR_UARTS > 1 */
130#else
131 /* Leave the DUART in reset */
132 titan_writel(0x00ff3cff, CPRR);
133#endif /* defined(CONFIG_SERIAL_8250) */
134
135 return 0;
136}
137
138static int __init excite_platform_init(void)
139{
140 unsigned int i;
141 unsigned char buf[3];
142 u8 reg;
143 void __iomem * dpr;
144
145 /* BIU buffer allocations */
146 ocd_writel(8, CPURSLMT); /* CPU */
147 titan_writel(4, CPGRWL); /* GPI / Ethernet */
148
149 /* Map control registers located in FPGA */
150 ctl_regs = ioremap_nocache(EXCITE_PHYS_FPGA + EXCITE_FPGA_SYSCTL, 16);
151 if (!ctl_regs)
152 panic("eXcite: failed to map platform control registers\n");
153 memcpy_fromio(buf, ctl_regs + 2, ARRAY_SIZE(buf));
154 unit_id = buf[0] | (buf[1] << 8) | (buf[2] << 16);
155
156 /* Clear the reboot flag */
157 dpr = ioremap_nocache(EXCITE_PHYS_FPGA + EXCITE_FPGA_DPR, 1);
158 reg = __raw_readb(dpr);
159 __raw_writeb(reg & 0x7f, dpr);
160 iounmap(dpr);
161
162 /* Interrupt controller setup */
163 for (i = INTP0Status0; i < INTP0Status0 + 0x80; i += 0x10) {
164 ocd_writel(0x00000000, i + 0x04);
165 ocd_writel(0xffffffff, i + 0x0c);
166 }
167 ocd_writel(0x2, NMICONFIG);
168
169 ocd_writel(0x1 << (TITAN_MSGINT % 0x20),
170 INTP0Mask0 + (0x10 * (TITAN_MSGINT / 0x20)));
171 ocd_writel((0x1 << (FPGA0_MSGINT % 0x20))
172 | ocd_readl(INTP0Mask0 + (0x10 * (FPGA0_MSGINT / 0x20))),
173 INTP0Mask0 + (0x10 * (FPGA0_MSGINT / 0x20)));
174 ocd_writel((0x1 << (FPGA1_MSGINT % 0x20))
175 | ocd_readl(INTP0Mask0 + (0x10 * (FPGA1_MSGINT / 0x20))),
176 INTP0Mask0 + (0x10 * (FPGA1_MSGINT / 0x20)));
177 ocd_writel((0x1 << (PHY_MSGINT % 0x20))
178 | ocd_readl(INTP0Mask0 + (0x10 * (PHY_MSGINT / 0x20))),
179 INTP0Mask0 + (0x10 * (PHY_MSGINT / 0x20)));
180#if USB_IRQ < 10
181 ocd_writel((0x1 << (USB_MSGINT % 0x20))
182 | ocd_readl(INTP0Mask0 + (0x10 * (USB_MSGINT / 0x20))),
183 INTP0Mask0 + (0x10 * (USB_MSGINT / 0x20)));
184#endif
185 /* Enable the packet FIFO, XDMA and XDMA arbiter */
186 titan_writel(0x00ff18ff, CPRR);
187
188 /*
189 * Set up the PADMUX. Power down all ethernet slices,
190 * they will be powered up and configured at device startup.
191 */
192 titan_writel(0x00878206, CPTC1R);
193 titan_writel(0x00001100, CPTC0R); /* latch PADMUX, enable WCIMODE */
194
195 /* Reset and enable the FIFO block */
196 titan_writel(0x00000001, SDRXFCIE);
197 titan_writel(0x00000001, SDTXFCIE);
198 titan_writel(0x00000100, SDRXFCIE);
199 titan_writel(0x00000000, SDTXFCIE);
200
201 /*
202 * Initialize the common interrupt shared by all components of
203 * the GPI/Ethernet subsystem.
204 */
205 titan_writel((EXCITE_PHYS_OCD >> 12), CPCFG0);
206 titan_writel(TITAN_MSGINT, CPCFG1);
207
208 /*
209 * XDMA configuration.
210 * In order for the XDMA to be sharable among multiple drivers,
211 * the setup must be done here in the platform. The reason is that
212 * this setup can only be done while the XDMA is in reset. If this
213 * were done in a driver, it would interrupt all other drivers
214 * using the XDMA.
215 */
216 titan_writel(0x80021dff, GXCFG); /* XDMA reset */
217 titan_writel(0x00000000, CPXCISRA);
218 titan_writel(0x00000000, CPXCISRB); /* clear pending interrupts */
219#if defined (CONFIG_HIGHMEM)
220# error change for HIGHMEM support!
221#else
222 titan_writel(0x00000000, GXDMADRPFX); /* buffer address prefix */
223#endif
224 titan_writel(0, GXDMA_DESCADR);
225
226 for (i = 0x5040; i <= 0x5300; i += 0x0040)
227 titan_writel(0x80080000, i); /* reset channel */
228
229 titan_writel((0x1 << 29) /* no sparse tx descr. */
230 | (0x1 << 28) /* no sparse rx descr. */
231 | (0x1 << 23) | (0x1 << 24) /* descriptor coherency */
232 | (0x1 << 21) | (0x1 << 22) /* data coherency */
233 | (0x1 << 17)
234 | 0x1dff,
235 GXCFG);
236
237#if defined(CONFIG_SMP)
238# error No SMP support
239#else
240 /* All interrupts go to core #0 only. */
241 titan_writel(0x1f007fff, CPDST0A);
242 titan_writel(0x00000000, CPDST0B);
243 titan_writel(0x0000ff3f, CPDST1A);
244 titan_writel(0x00000000, CPDST1B);
245 titan_writel(0x00ffffff, CPXDSTA);
246 titan_writel(0x00000000, CPXDSTB);
247#endif
248
249 /* Enable DUART interrupts, disable everything else. */
250 titan_writel(0x04000000, CPGIG0ER);
251 titan_writel(0x000000c0, CPGIG1ER);
252
253 excite_procfs_init();
254 return 0;
255}
256
257void __init plat_setup(void)
258{
259 volatile u32 * const boot_ocd_base = (u32 *) 0xbf7fc000;
260
261 /* Announce RAM to system */
262 add_memory_region(0x00000000, memsize, BOOT_MEM_RAM);
263
264 /* Set up timer initialization hooks */
265 board_time_init = excite_timer_init;
266 board_timer_setup = excite_timer_setup;
267
268 /* Set up the peripheral address map */
269 *(boot_ocd_base + (LKB9 / sizeof (u32))) = 0;
270 *(boot_ocd_base + (LKB10 / sizeof (u32))) = 0;
271 *(boot_ocd_base + (LKB11 / sizeof (u32))) = 0;
272 *(boot_ocd_base + (LKB12 / sizeof (u32))) = 0;
273 wmb();
274 *(boot_ocd_base + (LKB0 / sizeof (u32))) = EXCITE_PHYS_OCD >> 4;
275 wmb();
276
277 ocd_writel((EXCITE_PHYS_TITAN >> 4) | 0x1UL, LKB5);
278 ocd_writel(((EXCITE_SIZE_TITAN >> 4) & 0x7fffff00) - 0x100, LKM5);
279 ocd_writel((EXCITE_PHYS_SCRAM >> 4) | 0x1UL, LKB13);
280 ocd_writel(((EXCITE_SIZE_SCRAM >> 4) & 0xffffff00) - 0x100, LKM13);
281
282 /* Local bus slot #0 */
283 ocd_writel(0x00040510, LDP0);
284 ocd_writel((EXCITE_PHYS_BOOTROM >> 4) | 0x1UL, LKB9);
285 ocd_writel(((EXCITE_SIZE_BOOTROM >> 4) & 0x03ffff00) - 0x100, LKM9);
286
287 /* Local bus slot #2 */
288 ocd_writel(0x00000330, LDP2);
289 ocd_writel((EXCITE_PHYS_FPGA >> 4) | 0x1, LKB11);
290 ocd_writel(((EXCITE_SIZE_FPGA >> 4) - 0x100) & 0x03ffff00, LKM11);
291
292 /* Local bus slot #3 */
293 ocd_writel(0x00123413, LDP3);
294 ocd_writel((EXCITE_PHYS_NAND >> 4) | 0x1, LKB12);
295 ocd_writel(((EXCITE_SIZE_NAND >> 4) - 0x100) & 0x03ffff00, LKM12);
296}
297
298
299
300console_initcall(excite_init_console);
301arch_initcall(excite_platform_init);
302
303EXPORT_SYMBOL(titan_lock);
304EXPORT_SYMBOL(titan_irqflags);
305EXPORT_SYMBOL(titan_irq);
306EXPORT_SYMBOL(ocd_base);
307EXPORT_SYMBOL(titan_base);
diff --git a/arch/mips/cobalt/console.c b/arch/mips/cobalt/console.c
index 45c2d27c7564..300797d5f558 100644
--- a/arch/mips/cobalt/console.c
+++ b/arch/mips/cobalt/console.c
@@ -41,3 +41,8 @@ void __init cobalt_early_console(void)
41 41
42 printk("Cobalt: early console registered\n"); 42 printk("Cobalt: early console registered\n");
43} 43}
44
45void __init disable_early_printk(void)
46{
47 unregister_console(&cons_info);
48}
diff --git a/arch/mips/cobalt/setup.c b/arch/mips/cobalt/setup.c
index 4f9ea1210023..ca719d6398bd 100644
--- a/arch/mips/cobalt/setup.c
+++ b/arch/mips/cobalt/setup.c
@@ -68,19 +68,46 @@ static void __init cobalt_timer_setup(struct irqaction *irq)
68extern struct pci_ops gt64111_pci_ops; 68extern struct pci_ops gt64111_pci_ops;
69 69
70static struct resource cobalt_mem_resource = { 70static struct resource cobalt_mem_resource = {
71 "PCI memory", GT64111_MEM_BASE, GT64111_MEM_END, IORESOURCE_MEM 71 .start = GT64111_MEM_BASE,
72 .end = GT64111_MEM_END,
73 .name = "PCI memory",
74 .flags = IORESOURCE_MEM
72}; 75};
73 76
74static struct resource cobalt_io_resource = { 77static struct resource cobalt_io_resource = {
75 "PCI I/O", 0x1000, 0xffff, IORESOURCE_IO 78 .start = 0x1000,
79 .end = 0xffff,
80 .name = "PCI I/O",
81 .flags = IORESOURCE_IO
76}; 82};
77 83
78static struct resource cobalt_io_resources[] = { 84static struct resource cobalt_io_resources[] = {
79 { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, 85 {
80 { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, 86 .start = 0x00,
81 { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY }, 87 .end = 0x1f,
82 { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, 88 .name = "dma1",
83 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, 89 .flags = IORESOURCE_BUSY
90 }, {
91 .start = 0x40,
92 .end = 0x5f,
93 .name = "timer",
94 .flags = IORESOURCE_BUSY
95 }, {
96 .start = 0x60,
97 .end = 0x6f,
98 .name = "keyboard",
99 .flags = IORESOURCE_BUSY
100 }, {
101 .start = 0x80,
102 .end = 0x8f,
103 .name = "dma page reg",
104 .flags = IORESOURCE_BUSY
105 }, {
106 .start = 0xc0,
107 .end = 0xdf,
108 .name = "dma2",
109 .flags = IORESOURCE_BUSY
110 },
84}; 111};
85 112
86#define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource)) 113#define COBALT_IO_RESOURCES (sizeof(cobalt_io_resources)/sizeof(struct resource))
@@ -93,7 +120,7 @@ static struct pci_controller cobalt_pci_controller = {
93 .io_offset = 0 - GT64111_IO_BASE 120 .io_offset = 0 - GT64111_IO_BASE
94}; 121};
95 122
96void __init plat_setup(void) 123void __init plat_mem_setup(void)
97{ 124{
98 static struct uart_port uart; 125 static struct uart_port uart;
99 unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0); 126 unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
diff --git a/arch/mips/configs/atlas_defconfig b/arch/mips/configs/atlas_defconfig
index 4b080bcb258f..0cc1b3c51959 100644
--- a/arch/mips/configs/atlas_defconfig
+++ b/arch/mips/configs/atlas_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_ATLAS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -143,6 +141,15 @@ CONFIG_FLATMEM=y
143CONFIG_FLAT_NODE_MEM_MAP=y 141CONFIG_FLAT_NODE_MEM_MAP=y
144# CONFIG_SPARSEMEM_STATIC is not set 142# CONFIG_SPARSEMEM_STATIC is not set
145CONFIG_SPLIT_PTLOCK_CPUS=4 143CONFIG_SPLIT_PTLOCK_CPUS=4
144# CONFIG_HZ_48 is not set
145CONFIG_HZ_100=y
146# CONFIG_HZ_128 is not set
147# CONFIG_HZ_250 is not set
148# CONFIG_HZ_256 is not set
149# CONFIG_HZ_1000 is not set
150# CONFIG_HZ_1024 is not set
151CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
152CONFIG_HZ=100
146CONFIG_PREEMPT_NONE=y 153CONFIG_PREEMPT_NONE=y
147# CONFIG_PREEMPT_VOLUNTARY is not set 154# CONFIG_PREEMPT_VOLUNTARY is not set
148# CONFIG_PREEMPT is not set 155# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index d85cda58d650..dabf90a94b21 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -145,6 +143,15 @@ CONFIG_FLATMEM=y
145CONFIG_FLAT_NODE_MEM_MAP=y 143CONFIG_FLAT_NODE_MEM_MAP=y
146# CONFIG_SPARSEMEM_STATIC is not set 144# CONFIG_SPARSEMEM_STATIC is not set
147CONFIG_SPLIT_PTLOCK_CPUS=4 145CONFIG_SPLIT_PTLOCK_CPUS=4
146# CONFIG_HZ_48 is not set
147# CONFIG_HZ_100 is not set
148# CONFIG_HZ_128 is not set
149# CONFIG_HZ_250 is not set
150# CONFIG_HZ_256 is not set
151CONFIG_HZ_1000=y
152# CONFIG_HZ_1024 is not set
153CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
154CONFIG_HZ=1000
148CONFIG_SMP=y 155CONFIG_SMP=y
149CONFIG_NR_CPUS=4 156CONFIG_NR_CPUS=4
150CONFIG_PREEMPT_NONE=y 157CONFIG_PREEMPT_NONE=y
diff --git a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
index ca0af1683a00..aeb7be804799 100644
--- a/arch/mips/configs/capcella_defconfig
+++ b/arch/mips/configs/capcella_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -132,6 +130,15 @@ CONFIG_FLATMEM=y
132CONFIG_FLAT_NODE_MEM_MAP=y 130CONFIG_FLAT_NODE_MEM_MAP=y
133# CONFIG_SPARSEMEM_STATIC is not set 131# CONFIG_SPARSEMEM_STATIC is not set
134CONFIG_SPLIT_PTLOCK_CPUS=4 132CONFIG_SPLIT_PTLOCK_CPUS=4
133# CONFIG_HZ_48 is not set
134# CONFIG_HZ_100 is not set
135# CONFIG_HZ_128 is not set
136# CONFIG_HZ_250 is not set
137# CONFIG_HZ_256 is not set
138CONFIG_HZ_1000=y
139# CONFIG_HZ_1024 is not set
140CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
141CONFIG_HZ=1000
135CONFIG_PREEMPT_NONE=y 142CONFIG_PREEMPT_NONE=y
136# CONFIG_PREEMPT_VOLUNTARY is not set 143# CONFIG_PREEMPT_VOLUNTARY is not set
137# CONFIG_PREEMPT is not set 144# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
index 7d269e609282..d680d3e17112 100644
--- a/arch/mips/configs/cobalt_defconfig
+++ b/arch/mips/configs/cobalt_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_COBALT=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -129,6 +127,15 @@ CONFIG_FLATMEM=y
129CONFIG_FLAT_NODE_MEM_MAP=y 127CONFIG_FLAT_NODE_MEM_MAP=y
130# CONFIG_SPARSEMEM_STATIC is not set 128# CONFIG_SPARSEMEM_STATIC is not set
131CONFIG_SPLIT_PTLOCK_CPUS=4 129CONFIG_SPLIT_PTLOCK_CPUS=4
130# CONFIG_HZ_48 is not set
131# CONFIG_HZ_100 is not set
132# CONFIG_HZ_128 is not set
133# CONFIG_HZ_250 is not set
134# CONFIG_HZ_256 is not set
135CONFIG_HZ_1000=y
136# CONFIG_HZ_1024 is not set
137CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
138CONFIG_HZ=1000
132CONFIG_PREEMPT_NONE=y 139CONFIG_PREEMPT_NONE=y
133# CONFIG_PREEMPT_VOLUNTARY is not set 140# CONFIG_PREEMPT_VOLUNTARY is not set
134# CONFIG_PREEMPT is not set 141# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
index 579b665e3339..6a7aa401462f 100644
--- a/arch/mips/configs/db1000_defconfig
+++ b/arch/mips/configs/db1000_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_DB1000=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/db1100_defconfig b/arch/mips/configs/db1100_defconfig
index e5eb53867422..5c2da563e528 100644
--- a/arch/mips/configs/db1100_defconfig
+++ b/arch/mips/configs/db1100_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_DB1100=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/db1200_defconfig b/arch/mips/configs/db1200_defconfig
index a43fb2329fd5..85ef90ce0944 100644
--- a/arch/mips/configs/db1200_defconfig
+++ b/arch/mips/configs/db1200_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_DB1200=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/db1500_defconfig b/arch/mips/configs/db1500_defconfig
index ad632d87c4ef..6f757d8a5a6c 100644
--- a/arch/mips/configs/db1500_defconfig
+++ b/arch/mips/configs/db1500_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_DB1500=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -132,6 +130,15 @@ CONFIG_FLATMEM=y
132CONFIG_FLAT_NODE_MEM_MAP=y 130CONFIG_FLAT_NODE_MEM_MAP=y
133# CONFIG_SPARSEMEM_STATIC is not set 131# CONFIG_SPARSEMEM_STATIC is not set
134CONFIG_SPLIT_PTLOCK_CPUS=4 132CONFIG_SPLIT_PTLOCK_CPUS=4
133# CONFIG_HZ_48 is not set
134# CONFIG_HZ_100 is not set
135# CONFIG_HZ_128 is not set
136# CONFIG_HZ_250 is not set
137# CONFIG_HZ_256 is not set
138CONFIG_HZ_1000=y
139# CONFIG_HZ_1024 is not set
140CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
141CONFIG_HZ=1000
135CONFIG_PREEMPT_NONE=y 142CONFIG_PREEMPT_NONE=y
136# CONFIG_PREEMPT_VOLUNTARY is not set 143# CONFIG_PREEMPT_VOLUNTARY is not set
137# CONFIG_PREEMPT is not set 144# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/db1550_defconfig b/arch/mips/configs/db1550_defconfig
index 8130e23dc255..da4c7e811bef 100644
--- a/arch/mips/configs/db1550_defconfig
+++ b/arch/mips/configs/db1550_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_DB1550=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -131,6 +129,15 @@ CONFIG_FLATMEM=y
131CONFIG_FLAT_NODE_MEM_MAP=y 129CONFIG_FLAT_NODE_MEM_MAP=y
132# CONFIG_SPARSEMEM_STATIC is not set 130# CONFIG_SPARSEMEM_STATIC is not set
133CONFIG_SPLIT_PTLOCK_CPUS=4 131CONFIG_SPLIT_PTLOCK_CPUS=4
132# CONFIG_HZ_48 is not set
133# CONFIG_HZ_100 is not set
134# CONFIG_HZ_128 is not set
135# CONFIG_HZ_250 is not set
136# CONFIG_HZ_256 is not set
137CONFIG_HZ_1000=y
138# CONFIG_HZ_1024 is not set
139CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
140CONFIG_HZ=1000
134CONFIG_PREEMPT_NONE=y 141CONFIG_PREEMPT_NONE=y
135# CONFIG_PREEMPT_VOLUNTARY is not set 142# CONFIG_PREEMPT_VOLUNTARY is not set
136# CONFIG_PREEMPT is not set 143# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ddb5477_defconfig b/arch/mips/configs/ddb5477_defconfig
index 8c911b671415..c1c6bfee970e 100644
--- a/arch/mips/configs/ddb5477_defconfig
+++ b/arch/mips/configs/ddb5477_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46CONFIG_DDB5477=y 44CONFIG_DDB5477=y
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -129,6 +127,15 @@ CONFIG_FLATMEM=y
129CONFIG_FLAT_NODE_MEM_MAP=y 127CONFIG_FLAT_NODE_MEM_MAP=y
130# CONFIG_SPARSEMEM_STATIC is not set 128# CONFIG_SPARSEMEM_STATIC is not set
131CONFIG_SPLIT_PTLOCK_CPUS=4 129CONFIG_SPLIT_PTLOCK_CPUS=4
130# CONFIG_HZ_48 is not set
131# CONFIG_HZ_100 is not set
132# CONFIG_HZ_128 is not set
133# CONFIG_HZ_250 is not set
134# CONFIG_HZ_256 is not set
135CONFIG_HZ_1000=y
136# CONFIG_HZ_1024 is not set
137CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
138CONFIG_HZ=1000
132CONFIG_PREEMPT_NONE=y 139CONFIG_PREEMPT_NONE=y
133# CONFIG_PREEMPT_VOLUNTARY is not set 140# CONFIG_PREEMPT_VOLUNTARY is not set
134# CONFIG_PREEMPT is not set 141# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/decstation_defconfig b/arch/mips/configs/decstation_defconfig
index d838496e114f..d5d0d3faae94 100644
--- a/arch/mips/configs/decstation_defconfig
+++ b/arch/mips/configs/decstation_defconfig
@@ -41,8 +41,6 @@ CONFIG_MACH_DECSTATION=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -128,6 +126,17 @@ CONFIG_FLATMEM=y
128CONFIG_FLAT_NODE_MEM_MAP=y 126CONFIG_FLAT_NODE_MEM_MAP=y
129# CONFIG_SPARSEMEM_STATIC is not set 127# CONFIG_SPARSEMEM_STATIC is not set
130CONFIG_SPLIT_PTLOCK_CPUS=4 128CONFIG_SPLIT_PTLOCK_CPUS=4
129# CONFIG_HZ_48 is not set
130# CONFIG_HZ_100 is not set
131CONFIG_HZ_128=y
132# CONFIG_HZ_250 is not set
133# CONFIG_HZ_256 is not set
134# CONFIG_HZ_1000 is not set
135# CONFIG_HZ_1024 is not set
136CONFIG_SYS_SUPPORTS_128HZ=y
137CONFIG_SYS_SUPPORTS_256HZ=y
138CONFIG_SYS_SUPPORTS_1024HZ=y
139CONFIG_HZ=128
131CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
132# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
133# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
index 0760f4318910..439677ba751c 100644
--- a/arch/mips/configs/e55_defconfig
+++ b/arch/mips/configs/e55_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/emma2rh_defconfig b/arch/mips/configs/emma2rh_defconfig
new file mode 100644
index 000000000000..01f29f44f3e8
--- /dev/null
+++ b/arch/mips/configs/emma2rh_defconfig
@@ -0,0 +1,1207 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17
4# Sun Jun 18 13:46:53 2006
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11# CONFIG_MIPS_MTX1 is not set
12# CONFIG_MIPS_BOSPORUS is not set
13# CONFIG_MIPS_PB1000 is not set
14# CONFIG_MIPS_PB1100 is not set
15# CONFIG_MIPS_PB1500 is not set
16# CONFIG_MIPS_PB1550 is not set
17# CONFIG_MIPS_PB1200 is not set
18# CONFIG_MIPS_DB1000 is not set
19# CONFIG_MIPS_DB1100 is not set
20# CONFIG_MIPS_DB1500 is not set
21# CONFIG_MIPS_DB1550 is not set
22# CONFIG_MIPS_DB1200 is not set
23# CONFIG_MIPS_MIRAGE is not set
24# CONFIG_MIPS_COBALT is not set
25# CONFIG_MACH_DECSTATION is not set
26# CONFIG_MIPS_EV64120 is not set
27# CONFIG_MIPS_EV96100 is not set
28# CONFIG_MIPS_IVR is not set
29# CONFIG_MIPS_ITE8172 is not set
30# CONFIG_MACH_JAZZ is not set
31# CONFIG_LASAT is not set
32# CONFIG_MIPS_ATLAS is not set
33# CONFIG_MIPS_MALTA is not set
34# CONFIG_MIPS_SEAD is not set
35# CONFIG_WR_PPMC is not set
36# CONFIG_MIPS_SIM is not set
37# CONFIG_MOMENCO_JAGUAR_ATX is not set
38# CONFIG_MOMENCO_OCELOT is not set
39# CONFIG_MOMENCO_OCELOT_3 is not set
40# CONFIG_MOMENCO_OCELOT_C is not set
41# CONFIG_MOMENCO_OCELOT_G is not set
42# CONFIG_MIPS_XXS1500 is not set
43# CONFIG_PNX8550_V2PCI is not set
44# CONFIG_PNX8550_JBS is not set
45# CONFIG_DDB5477 is not set
46# CONFIG_MACH_VR41XX is not set
47# CONFIG_PMC_YOSEMITE is not set
48# CONFIG_QEMU is not set
49CONFIG_MARKEINS=y
50# CONFIG_SGI_IP22 is not set
51# CONFIG_SGI_IP27 is not set
52# CONFIG_SGI_IP32 is not set
53# CONFIG_SIBYTE_BIGSUR is not set
54# CONFIG_SIBYTE_SWARM is not set
55# CONFIG_SIBYTE_SENTOSA is not set
56# CONFIG_SIBYTE_RHONE is not set
57# CONFIG_SIBYTE_CARMEL is not set
58# CONFIG_SIBYTE_PTSWARM is not set
59# CONFIG_SIBYTE_LITTLESUR is not set
60# CONFIG_SIBYTE_CRHINE is not set
61# CONFIG_SIBYTE_CRHONE is not set
62# CONFIG_SNI_RM200_PCI is not set
63# CONFIG_TOSHIBA_JMR3927 is not set
64# CONFIG_TOSHIBA_RBTX4927 is not set
65# CONFIG_TOSHIBA_RBTX4938 is not set
66CONFIG_RWSEM_GENERIC_SPINLOCK=y
67CONFIG_GENERIC_FIND_NEXT_BIT=y
68CONFIG_GENERIC_HWEIGHT=y
69CONFIG_GENERIC_CALIBRATE_DELAY=y
70CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
71CONFIG_DMA_NONCOHERENT=y
72CONFIG_DMA_NEED_PCI_MAP_STATE=y
73CONFIG_CPU_BIG_ENDIAN=y
74# CONFIG_CPU_LITTLE_ENDIAN is not set
75CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
76CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
77CONFIG_IRQ_CPU=y
78CONFIG_SWAP_IO_SPACE=y
79CONFIG_EMMA2RH=y
80CONFIG_MIPS_L1_CACHE_SHIFT=5
81
82#
83# CPU selection
84#
85# CONFIG_CPU_MIPS32_R1 is not set
86# CONFIG_CPU_MIPS32_R2 is not set
87# CONFIG_CPU_MIPS64_R1 is not set
88# CONFIG_CPU_MIPS64_R2 is not set
89# CONFIG_CPU_R3000 is not set
90# CONFIG_CPU_TX39XX is not set
91# CONFIG_CPU_VR41XX is not set
92# CONFIG_CPU_R4300 is not set
93# CONFIG_CPU_R4X00 is not set
94# CONFIG_CPU_TX49XX is not set
95CONFIG_CPU_R5000=y
96# CONFIG_CPU_R5432 is not set
97# CONFIG_CPU_R6000 is not set
98# CONFIG_CPU_NEVADA is not set
99# CONFIG_CPU_R8000 is not set
100# CONFIG_CPU_R10000 is not set
101# CONFIG_CPU_RM7000 is not set
102# CONFIG_CPU_RM9000 is not set
103# CONFIG_CPU_SB1 is not set
104CONFIG_SYS_HAS_CPU_R5000=y
105CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
106CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
107CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
108
109#
110# Kernel type
111#
112CONFIG_32BIT=y
113# CONFIG_64BIT is not set
114CONFIG_PAGE_SIZE_4KB=y
115# CONFIG_PAGE_SIZE_8KB is not set
116# CONFIG_PAGE_SIZE_16KB is not set
117# CONFIG_PAGE_SIZE_64KB is not set
118CONFIG_MIPS_MT_DISABLED=y
119# CONFIG_MIPS_MT_SMTC is not set
120# CONFIG_MIPS_MT_SMP is not set
121# CONFIG_MIPS_VPE_LOADER is not set
122# CONFIG_64BIT_PHYS_ADDR is not set
123CONFIG_CPU_HAS_LLSC=y
124CONFIG_CPU_HAS_SYNC=y
125CONFIG_GENERIC_HARDIRQS=y
126CONFIG_GENERIC_IRQ_PROBE=y
127CONFIG_ARCH_FLATMEM_ENABLE=y
128CONFIG_SELECT_MEMORY_MODEL=y
129CONFIG_FLATMEM_MANUAL=y
130# CONFIG_DISCONTIGMEM_MANUAL is not set
131# CONFIG_SPARSEMEM_MANUAL is not set
132CONFIG_FLATMEM=y
133CONFIG_FLAT_NODE_MEM_MAP=y
134# CONFIG_SPARSEMEM_STATIC is not set
135CONFIG_SPLIT_PTLOCK_CPUS=4
136# CONFIG_HZ_48 is not set
137# CONFIG_HZ_100 is not set
138# CONFIG_HZ_128 is not set
139# CONFIG_HZ_250 is not set
140# CONFIG_HZ_256 is not set
141CONFIG_HZ_1000=y
142# CONFIG_HZ_1024 is not set
143CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
144CONFIG_HZ=1000
145# CONFIG_PREEMPT_NONE is not set
146# CONFIG_PREEMPT_VOLUNTARY is not set
147CONFIG_PREEMPT=y
148CONFIG_PREEMPT_BKL=y
149
150#
151# Code maturity level options
152#
153CONFIG_EXPERIMENTAL=y
154CONFIG_BROKEN_ON_SMP=y
155CONFIG_LOCK_KERNEL=y
156CONFIG_INIT_ENV_ARG_LIMIT=32
157
158#
159# General setup
160#
161CONFIG_LOCALVERSION=""
162CONFIG_LOCALVERSION_AUTO=y
163CONFIG_SWAP=y
164CONFIG_SYSVIPC=y
165CONFIG_POSIX_MQUEUE=y
166CONFIG_BSD_PROCESS_ACCT=y
167# CONFIG_BSD_PROCESS_ACCT_V3 is not set
168CONFIG_SYSCTL=y
169# CONFIG_AUDIT is not set
170CONFIG_IKCONFIG=y
171CONFIG_IKCONFIG_PROC=y
172# CONFIG_RELAY is not set
173CONFIG_INITRAMFS_SOURCE=""
174# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
175CONFIG_EMBEDDED=y
176CONFIG_KALLSYMS=y
177# CONFIG_KALLSYMS_EXTRA_PASS is not set
178CONFIG_HOTPLUG=y
179CONFIG_PRINTK=y
180CONFIG_BUG=y
181CONFIG_ELF_CORE=y
182CONFIG_BASE_FULL=y
183CONFIG_FUTEX=y
184CONFIG_EPOLL=y
185CONFIG_SHMEM=y
186CONFIG_SLAB=y
187# CONFIG_TINY_SHMEM is not set
188CONFIG_BASE_SMALL=0
189# CONFIG_SLOB is not set
190CONFIG_OBSOLETE_INTERMODULE=y
191
192#
193# Loadable module support
194#
195CONFIG_MODULES=y
196CONFIG_MODULE_UNLOAD=y
197CONFIG_MODULE_FORCE_UNLOAD=y
198CONFIG_MODVERSIONS=y
199# CONFIG_MODULE_SRCVERSION_ALL is not set
200CONFIG_KMOD=y
201
202#
203# Block layer
204#
205CONFIG_LBD=y
206# CONFIG_BLK_DEV_IO_TRACE is not set
207# CONFIG_LSF is not set
208
209#
210# IO Schedulers
211#
212CONFIG_IOSCHED_NOOP=y
213CONFIG_IOSCHED_AS=y
214CONFIG_IOSCHED_DEADLINE=y
215CONFIG_IOSCHED_CFQ=y
216CONFIG_DEFAULT_AS=y
217# CONFIG_DEFAULT_DEADLINE is not set
218# CONFIG_DEFAULT_CFQ is not set
219# CONFIG_DEFAULT_NOOP is not set
220CONFIG_DEFAULT_IOSCHED="anticipatory"
221
222#
223# Bus options (PCI, PCMCIA, EISA, ISA, TC)
224#
225CONFIG_HW_HAS_PCI=y
226CONFIG_PCI=y
227CONFIG_MMU=y
228
229#
230# PCCARD (PCMCIA/CardBus) support
231#
232# CONFIG_PCCARD is not set
233
234#
235# PCI Hotplug Support
236#
237# CONFIG_HOTPLUG_PCI is not set
238
239#
240# Executable file formats
241#
242CONFIG_BINFMT_ELF=y
243# CONFIG_BINFMT_MISC is not set
244CONFIG_TRAD_SIGNALS=y
245
246#
247# Networking
248#
249CONFIG_NET=y
250
251#
252# Networking options
253#
254# CONFIG_NETDEBUG is not set
255CONFIG_PACKET=y
256CONFIG_PACKET_MMAP=y
257CONFIG_UNIX=y
258CONFIG_XFRM=y
259# CONFIG_XFRM_USER is not set
260CONFIG_NET_KEY=y
261CONFIG_INET=y
262CONFIG_IP_MULTICAST=y
263CONFIG_IP_ADVANCED_ROUTER=y
264CONFIG_ASK_IP_FIB_HASH=y
265# CONFIG_IP_FIB_TRIE is not set
266CONFIG_IP_FIB_HASH=y
267CONFIG_IP_MULTIPLE_TABLES=y
268# CONFIG_IP_ROUTE_FWMARK is not set
269CONFIG_IP_ROUTE_MULTIPATH=y
270# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
271CONFIG_IP_ROUTE_VERBOSE=y
272CONFIG_IP_PNP=y
273# CONFIG_IP_PNP_DHCP is not set
274CONFIG_IP_PNP_BOOTP=y
275# CONFIG_IP_PNP_RARP is not set
276# CONFIG_NET_IPIP is not set
277# CONFIG_NET_IPGRE is not set
278# CONFIG_IP_MROUTE is not set
279# CONFIG_ARPD is not set
280CONFIG_SYN_COOKIES=y
281# CONFIG_INET_AH is not set
282# CONFIG_INET_ESP is not set
283# CONFIG_INET_IPCOMP is not set
284# CONFIG_INET_XFRM_TUNNEL is not set
285# CONFIG_INET_TUNNEL is not set
286CONFIG_INET_DIAG=y
287CONFIG_INET_TCP_DIAG=y
288# CONFIG_TCP_CONG_ADVANCED is not set
289CONFIG_TCP_CONG_BIC=y
290
291#
292# IP: Virtual Server Configuration
293#
294# CONFIG_IP_VS is not set
295CONFIG_IPV6=m
296# CONFIG_IPV6_PRIVACY is not set
297# CONFIG_IPV6_ROUTER_PREF is not set
298# CONFIG_INET6_AH is not set
299# CONFIG_INET6_ESP is not set
300# CONFIG_INET6_IPCOMP is not set
301# CONFIG_INET6_XFRM_TUNNEL is not set
302# CONFIG_INET6_TUNNEL is not set
303# CONFIG_IPV6_TUNNEL is not set
304CONFIG_NETFILTER=y
305# CONFIG_NETFILTER_DEBUG is not set
306
307#
308# Core Netfilter Configuration
309#
310# CONFIG_NETFILTER_NETLINK is not set
311# CONFIG_NF_CONNTRACK is not set
312# CONFIG_NETFILTER_XTABLES is not set
313
314#
315# IP: Netfilter Configuration
316#
317# CONFIG_IP_NF_CONNTRACK is not set
318# CONFIG_IP_NF_QUEUE is not set
319
320#
321# IPv6: Netfilter Configuration (EXPERIMENTAL)
322#
323# CONFIG_IP6_NF_QUEUE is not set
324
325#
326# DCCP Configuration (EXPERIMENTAL)
327#
328# CONFIG_IP_DCCP is not set
329
330#
331# SCTP Configuration (EXPERIMENTAL)
332#
333CONFIG_IP_SCTP=m
334# CONFIG_SCTP_DBG_MSG is not set
335# CONFIG_SCTP_DBG_OBJCNT is not set
336# CONFIG_SCTP_HMAC_NONE is not set
337# CONFIG_SCTP_HMAC_SHA1 is not set
338CONFIG_SCTP_HMAC_MD5=y
339
340#
341# TIPC Configuration (EXPERIMENTAL)
342#
343# CONFIG_TIPC is not set
344# CONFIG_ATM is not set
345# CONFIG_BRIDGE is not set
346# CONFIG_VLAN_8021Q is not set
347# CONFIG_DECNET is not set
348# CONFIG_LLC2 is not set
349# CONFIG_IPX is not set
350# CONFIG_ATALK is not set
351# CONFIG_X25 is not set
352# CONFIG_LAPB is not set
353# CONFIG_NET_DIVERT is not set
354# CONFIG_ECONET is not set
355# CONFIG_WAN_ROUTER is not set
356
357#
358# QoS and/or fair queueing
359#
360# CONFIG_NET_SCHED is not set
361
362#
363# Network testing
364#
365# CONFIG_NET_PKTGEN is not set
366# CONFIG_HAMRADIO is not set
367# CONFIG_IRDA is not set
368# CONFIG_BT is not set
369# CONFIG_IEEE80211 is not set
370
371#
372# Device Drivers
373#
374
375#
376# Generic Driver Options
377#
378CONFIG_STANDALONE=y
379CONFIG_PREVENT_FIRMWARE_BUILD=y
380# CONFIG_FW_LOADER is not set
381
382#
383# Connector - unified userspace <-> kernelspace linker
384#
385# CONFIG_CONNECTOR is not set
386
387#
388# Memory Technology Devices (MTD)
389#
390CONFIG_MTD=y
391# CONFIG_MTD_DEBUG is not set
392# CONFIG_MTD_CONCAT is not set
393CONFIG_MTD_PARTITIONS=y
394# CONFIG_MTD_REDBOOT_PARTS is not set
395CONFIG_MTD_CMDLINE_PARTS=y
396
397#
398# User Modules And Translation Layers
399#
400CONFIG_MTD_CHAR=y
401CONFIG_MTD_BLOCK=y
402# CONFIG_FTL is not set
403# CONFIG_NFTL is not set
404# CONFIG_INFTL is not set
405# CONFIG_RFD_FTL is not set
406
407#
408# RAM/ROM/Flash chip drivers
409#
410CONFIG_MTD_CFI=y
411# CONFIG_MTD_JEDECPROBE is not set
412CONFIG_MTD_GEN_PROBE=y
413# CONFIG_MTD_CFI_ADV_OPTIONS is not set
414CONFIG_MTD_MAP_BANK_WIDTH_1=y
415CONFIG_MTD_MAP_BANK_WIDTH_2=y
416CONFIG_MTD_MAP_BANK_WIDTH_4=y
417# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
418# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
419# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
420CONFIG_MTD_CFI_I1=y
421CONFIG_MTD_CFI_I2=y
422# CONFIG_MTD_CFI_I4 is not set
423# CONFIG_MTD_CFI_I8 is not set
424# CONFIG_MTD_CFI_INTELEXT is not set
425CONFIG_MTD_CFI_AMDSTD=y
426# CONFIG_MTD_CFI_STAA is not set
427CONFIG_MTD_CFI_UTIL=y
428# CONFIG_MTD_RAM is not set
429# CONFIG_MTD_ROM is not set
430# CONFIG_MTD_ABSENT is not set
431# CONFIG_MTD_OBSOLETE_CHIPS is not set
432
433#
434# Mapping drivers for chip access
435#
436# CONFIG_MTD_COMPLEX_MAPPINGS is not set
437CONFIG_MTD_PHYSMAP=y
438CONFIG_MTD_PHYSMAP_START=0x1e000000
439CONFIG_MTD_PHYSMAP_LEN=0x02000000
440CONFIG_MTD_PHYSMAP_BANKWIDTH=2
441# CONFIG_MTD_PLATRAM is not set
442
443#
444# Self-contained MTD device drivers
445#
446# CONFIG_MTD_PMC551 is not set
447# CONFIG_MTD_SLRAM is not set
448# CONFIG_MTD_PHRAM is not set
449# CONFIG_MTD_MTDRAM is not set
450# CONFIG_MTD_BLOCK2MTD is not set
451
452#
453# Disk-On-Chip Device Drivers
454#
455# CONFIG_MTD_DOC2000 is not set
456# CONFIG_MTD_DOC2001 is not set
457# CONFIG_MTD_DOC2001PLUS is not set
458
459#
460# NAND Flash Device Drivers
461#
462# CONFIG_MTD_NAND is not set
463
464#
465# OneNAND Flash Device Drivers
466#
467# CONFIG_MTD_ONENAND is not set
468
469#
470# Parallel port support
471#
472# CONFIG_PARPORT is not set
473
474#
475# Plug and Play support
476#
477
478#
479# Block devices
480#
481# CONFIG_BLK_CPQ_DA is not set
482# CONFIG_BLK_CPQ_CISS_DA is not set
483# CONFIG_BLK_DEV_DAC960 is not set
484# CONFIG_BLK_DEV_UMEM is not set
485# CONFIG_BLK_DEV_COW_COMMON is not set
486CONFIG_BLK_DEV_LOOP=m
487CONFIG_BLK_DEV_CRYPTOLOOP=m
488# CONFIG_BLK_DEV_NBD is not set
489# CONFIG_BLK_DEV_SX8 is not set
490# CONFIG_BLK_DEV_RAM is not set
491# CONFIG_BLK_DEV_INITRD is not set
492# CONFIG_CDROM_PKTCDVD is not set
493# CONFIG_ATA_OVER_ETH is not set
494
495#
496# ATA/ATAPI/MFM/RLL support
497#
498# CONFIG_IDE is not set
499
500#
501# SCSI device support
502#
503# CONFIG_RAID_ATTRS is not set
504CONFIG_SCSI=m
505# CONFIG_SCSI_PROC_FS is not set
506
507#
508# SCSI support type (disk, tape, CD-ROM)
509#
510CONFIG_BLK_DEV_SD=m
511# CONFIG_CHR_DEV_ST is not set
512# CONFIG_CHR_DEV_OSST is not set
513# CONFIG_BLK_DEV_SR is not set
514CONFIG_CHR_DEV_SG=m
515# CONFIG_CHR_DEV_SCH is not set
516
517#
518# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
519#
520# CONFIG_SCSI_MULTI_LUN is not set
521# CONFIG_SCSI_CONSTANTS is not set
522# CONFIG_SCSI_LOGGING is not set
523
524#
525# SCSI Transport Attributes
526#
527# CONFIG_SCSI_SPI_ATTRS is not set
528# CONFIG_SCSI_FC_ATTRS is not set
529# CONFIG_SCSI_ISCSI_ATTRS is not set
530# CONFIG_SCSI_SAS_ATTRS is not set
531
532#
533# SCSI low-level drivers
534#
535# CONFIG_ISCSI_TCP is not set
536# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
537# CONFIG_SCSI_3W_9XXX is not set
538# CONFIG_SCSI_ACARD is not set
539# CONFIG_SCSI_AACRAID is not set
540# CONFIG_SCSI_AIC7XXX is not set
541# CONFIG_SCSI_AIC7XXX_OLD is not set
542# CONFIG_SCSI_AIC79XX is not set
543# CONFIG_SCSI_DPT_I2O is not set
544# CONFIG_MEGARAID_NEWGEN is not set
545# CONFIG_MEGARAID_LEGACY is not set
546# CONFIG_MEGARAID_SAS is not set
547# CONFIG_SCSI_SATA is not set
548# CONFIG_SCSI_DMX3191D is not set
549# CONFIG_SCSI_FUTURE_DOMAIN is not set
550# CONFIG_SCSI_IPS is not set
551# CONFIG_SCSI_INITIO is not set
552# CONFIG_SCSI_INIA100 is not set
553# CONFIG_SCSI_SYM53C8XX_2 is not set
554# CONFIG_SCSI_IPR is not set
555# CONFIG_SCSI_QLOGIC_1280 is not set
556# CONFIG_SCSI_QLA_FC is not set
557# CONFIG_SCSI_LPFC is not set
558# CONFIG_SCSI_DC395x is not set
559# CONFIG_SCSI_DC390T is not set
560# CONFIG_SCSI_NSP32 is not set
561# CONFIG_SCSI_DEBUG is not set
562
563#
564# Multi-device support (RAID and LVM)
565#
566# CONFIG_MD is not set
567
568#
569# Fusion MPT device support
570#
571# CONFIG_FUSION is not set
572# CONFIG_FUSION_SPI is not set
573# CONFIG_FUSION_FC is not set
574# CONFIG_FUSION_SAS is not set
575
576#
577# IEEE 1394 (FireWire) support
578#
579# CONFIG_IEEE1394 is not set
580
581#
582# I2O device support
583#
584# CONFIG_I2O is not set
585
586#
587# Network device support
588#
589CONFIG_NETDEVICES=y
590# CONFIG_DUMMY is not set
591# CONFIG_BONDING is not set
592# CONFIG_EQUALIZER is not set
593CONFIG_TUN=m
594
595#
596# ARCnet devices
597#
598# CONFIG_ARCNET is not set
599
600#
601# PHY device support
602#
603# CONFIG_PHYLIB is not set
604
605#
606# Ethernet (10 or 100Mbit)
607#
608CONFIG_NET_ETHERNET=y
609CONFIG_MII=y
610# CONFIG_HAPPYMEAL is not set
611# CONFIG_SUNGEM is not set
612# CONFIG_CASSINI is not set
613# CONFIG_NET_VENDOR_3COM is not set
614# CONFIG_DM9000 is not set
615
616#
617# Tulip family network device support
618#
619# CONFIG_NET_TULIP is not set
620# CONFIG_HP100 is not set
621CONFIG_NET_PCI=y
622# CONFIG_PCNET32 is not set
623# CONFIG_AMD8111_ETH is not set
624# CONFIG_ADAPTEC_STARFIRE is not set
625# CONFIG_B44 is not set
626# CONFIG_FORCEDETH is not set
627# CONFIG_DGRS is not set
628# CONFIG_EEPRO100 is not set
629# CONFIG_E100 is not set
630# CONFIG_FEALNX is not set
631CONFIG_NATSEMI=y
632# CONFIG_NE2K_PCI is not set
633# CONFIG_8139CP is not set
634# CONFIG_8139TOO is not set
635# CONFIG_SIS900 is not set
636# CONFIG_EPIC100 is not set
637# CONFIG_SUNDANCE is not set
638# CONFIG_TLAN is not set
639# CONFIG_VIA_RHINE is not set
640# CONFIG_LAN_SAA9730 is not set
641
642#
643# Ethernet (1000 Mbit)
644#
645# CONFIG_ACENIC is not set
646# CONFIG_DL2K is not set
647# CONFIG_E1000 is not set
648# CONFIG_NS83820 is not set
649# CONFIG_HAMACHI is not set
650# CONFIG_YELLOWFIN is not set
651# CONFIG_R8169 is not set
652# CONFIG_SIS190 is not set
653# CONFIG_SKGE is not set
654# CONFIG_SKY2 is not set
655# CONFIG_SK98LIN is not set
656# CONFIG_VIA_VELOCITY is not set
657# CONFIG_TIGON3 is not set
658# CONFIG_BNX2 is not set
659
660#
661# Ethernet (10000 Mbit)
662#
663# CONFIG_CHELSIO_T1 is not set
664# CONFIG_IXGB is not set
665# CONFIG_S2IO is not set
666
667#
668# Token Ring devices
669#
670# CONFIG_TR is not set
671
672#
673# Wireless LAN (non-hamradio)
674#
675# CONFIG_NET_RADIO is not set
676
677#
678# Wan interfaces
679#
680# CONFIG_WAN is not set
681# CONFIG_FDDI is not set
682# CONFIG_HIPPI is not set
683CONFIG_PPP=m
684# CONFIG_PPP_MULTILINK is not set
685# CONFIG_PPP_FILTER is not set
686CONFIG_PPP_ASYNC=m
687CONFIG_PPP_SYNC_TTY=m
688CONFIG_PPP_DEFLATE=m
689# CONFIG_PPP_BSDCOMP is not set
690# CONFIG_PPP_MPPE is not set
691# CONFIG_PPPOE is not set
692# CONFIG_SLIP is not set
693# CONFIG_NET_FC is not set
694# CONFIG_SHAPER is not set
695# CONFIG_NETCONSOLE is not set
696# CONFIG_NETPOLL is not set
697# CONFIG_NET_POLL_CONTROLLER is not set
698
699#
700# ISDN subsystem
701#
702# CONFIG_ISDN is not set
703
704#
705# Telephony Support
706#
707# CONFIG_PHONE is not set
708
709#
710# Input device support
711#
712CONFIG_INPUT=y
713
714#
715# Userland interfaces
716#
717# CONFIG_INPUT_MOUSEDEV is not set
718# CONFIG_INPUT_JOYDEV is not set
719# CONFIG_INPUT_TSDEV is not set
720CONFIG_INPUT_EVDEV=m
721# CONFIG_INPUT_EVBUG is not set
722
723#
724# Input Device Drivers
725#
726# CONFIG_INPUT_KEYBOARD is not set
727# CONFIG_INPUT_MOUSE is not set
728# CONFIG_INPUT_JOYSTICK is not set
729# CONFIG_INPUT_TOUCHSCREEN is not set
730# CONFIG_INPUT_MISC is not set
731
732#
733# Hardware I/O ports
734#
735# CONFIG_SERIO is not set
736# CONFIG_GAMEPORT is not set
737
738#
739# Character devices
740#
741# CONFIG_VT is not set
742# CONFIG_SERIAL_NONSTANDARD is not set
743
744#
745# Serial drivers
746#
747CONFIG_SERIAL_8250=y
748CONFIG_SERIAL_8250_CONSOLE=y
749CONFIG_SERIAL_8250_PCI=y
750CONFIG_SERIAL_8250_NR_UARTS=4
751CONFIG_SERIAL_8250_RUNTIME_UARTS=4
752# CONFIG_SERIAL_8250_EXTENDED is not set
753
754#
755# Non-8250 serial port support
756#
757CONFIG_SERIAL_CORE=y
758CONFIG_SERIAL_CORE_CONSOLE=y
759# CONFIG_SERIAL_JSM is not set
760CONFIG_UNIX98_PTYS=y
761CONFIG_LEGACY_PTYS=y
762CONFIG_LEGACY_PTY_COUNT=256
763
764#
765# IPMI
766#
767# CONFIG_IPMI_HANDLER is not set
768
769#
770# Watchdog Cards
771#
772# CONFIG_WATCHDOG is not set
773CONFIG_RTC=m
774CONFIG_GEN_RTC=m
775CONFIG_GEN_RTC_X=y
776# CONFIG_DTLK is not set
777# CONFIG_R3964 is not set
778# CONFIG_APPLICOM is not set
779
780#
781# Ftape, the floppy tape device driver
782#
783# CONFIG_DRM is not set
784# CONFIG_RAW_DRIVER is not set
785
786#
787# TPM devices
788#
789# CONFIG_TCG_TPM is not set
790# CONFIG_TELCLOCK is not set
791
792#
793# I2C support
794#
795CONFIG_I2C=y
796CONFIG_I2C_CHARDEV=y
797
798#
799# I2C Algorithms
800#
801# CONFIG_I2C_ALGOBIT is not set
802# CONFIG_I2C_ALGOPCF is not set
803# CONFIG_I2C_ALGOPCA is not set
804
805#
806# I2C Hardware Bus support
807#
808# CONFIG_I2C_ALI1535 is not set
809# CONFIG_I2C_ALI1563 is not set
810# CONFIG_I2C_ALI15X3 is not set
811# CONFIG_I2C_AMD756 is not set
812# CONFIG_I2C_AMD8111 is not set
813# CONFIG_I2C_I801 is not set
814# CONFIG_I2C_I810 is not set
815# CONFIG_I2C_PIIX4 is not set
816# CONFIG_I2C_NFORCE2 is not set
817# CONFIG_I2C_PARPORT_LIGHT is not set
818# CONFIG_I2C_PROSAVAGE is not set
819# CONFIG_I2C_SAVAGE4 is not set
820# CONFIG_I2C_SIS5595 is not set
821# CONFIG_I2C_SIS630 is not set
822# CONFIG_I2C_SIS96X is not set
823# CONFIG_I2C_STUB is not set
824# CONFIG_I2C_VIA is not set
825# CONFIG_I2C_VIAPRO is not set
826# CONFIG_I2C_VOODOO3 is not set
827# CONFIG_I2C_PCA_ISA is not set
828
829#
830# Miscellaneous I2C Chip support
831#
832# CONFIG_SENSORS_DS1337 is not set
833# CONFIG_SENSORS_DS1374 is not set
834# CONFIG_SENSORS_EEPROM is not set
835# CONFIG_SENSORS_PCF8574 is not set
836# CONFIG_SENSORS_PCA9539 is not set
837# CONFIG_SENSORS_PCF8591 is not set
838# CONFIG_SENSORS_MAX6875 is not set
839CONFIG_I2C_DEBUG_CORE=y
840# CONFIG_I2C_DEBUG_ALGO is not set
841CONFIG_I2C_DEBUG_BUS=y
842# CONFIG_I2C_DEBUG_CHIP is not set
843
844#
845# SPI support
846#
847# CONFIG_SPI is not set
848# CONFIG_SPI_MASTER is not set
849
850#
851# Dallas's 1-wire bus
852#
853# CONFIG_W1 is not set
854
855#
856# Hardware Monitoring support
857#
858CONFIG_HWMON=y
859# CONFIG_HWMON_VID is not set
860# CONFIG_SENSORS_ADM1021 is not set
861# CONFIG_SENSORS_ADM1025 is not set
862# CONFIG_SENSORS_ADM1026 is not set
863# CONFIG_SENSORS_ADM1031 is not set
864# CONFIG_SENSORS_ADM9240 is not set
865# CONFIG_SENSORS_ASB100 is not set
866# CONFIG_SENSORS_ATXP1 is not set
867# CONFIG_SENSORS_DS1621 is not set
868# CONFIG_SENSORS_F71805F is not set
869# CONFIG_SENSORS_FSCHER is not set
870# CONFIG_SENSORS_FSCPOS is not set
871# CONFIG_SENSORS_GL518SM is not set
872# CONFIG_SENSORS_GL520SM is not set
873# CONFIG_SENSORS_IT87 is not set
874# CONFIG_SENSORS_LM63 is not set
875# CONFIG_SENSORS_LM75 is not set
876# CONFIG_SENSORS_LM77 is not set
877# CONFIG_SENSORS_LM78 is not set
878# CONFIG_SENSORS_LM80 is not set
879# CONFIG_SENSORS_LM83 is not set
880# CONFIG_SENSORS_LM85 is not set
881# CONFIG_SENSORS_LM87 is not set
882# CONFIG_SENSORS_LM90 is not set
883# CONFIG_SENSORS_LM92 is not set
884# CONFIG_SENSORS_MAX1619 is not set
885# CONFIG_SENSORS_PC87360 is not set
886# CONFIG_SENSORS_SIS5595 is not set
887# CONFIG_SENSORS_SMSC47M1 is not set
888# CONFIG_SENSORS_SMSC47B397 is not set
889# CONFIG_SENSORS_VIA686A is not set
890# CONFIG_SENSORS_VT8231 is not set
891# CONFIG_SENSORS_W83781D is not set
892# CONFIG_SENSORS_W83792D is not set
893# CONFIG_SENSORS_W83L785TS is not set
894# CONFIG_SENSORS_W83627HF is not set
895# CONFIG_SENSORS_W83627EHF is not set
896# CONFIG_HWMON_DEBUG_CHIP is not set
897
898#
899# Misc devices
900#
901
902#
903# Multimedia devices
904#
905# CONFIG_VIDEO_DEV is not set
906CONFIG_VIDEO_V4L2=y
907
908#
909# Digital Video Broadcasting Devices
910#
911# CONFIG_DVB is not set
912
913#
914# Graphics support
915#
916# CONFIG_FB is not set
917
918#
919# Sound
920#
921# CONFIG_SOUND is not set
922
923#
924# USB support
925#
926CONFIG_USB_ARCH_HAS_HCD=y
927CONFIG_USB_ARCH_HAS_OHCI=y
928CONFIG_USB_ARCH_HAS_EHCI=y
929# CONFIG_USB is not set
930
931#
932# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
933#
934
935#
936# USB Gadget Support
937#
938# CONFIG_USB_GADGET is not set
939
940#
941# MMC/SD Card support
942#
943# CONFIG_MMC is not set
944
945#
946# LED devices
947#
948# CONFIG_NEW_LEDS is not set
949
950#
951# LED drivers
952#
953
954#
955# LED Triggers
956#
957
958#
959# InfiniBand support
960#
961# CONFIG_INFINIBAND is not set
962
963#
964# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
965#
966
967#
968# Real Time Clock
969#
970# CONFIG_RTC_CLASS is not set
971
972#
973# File systems
974#
975CONFIG_EXT2_FS=y
976CONFIG_EXT2_FS_XATTR=y
977CONFIG_EXT2_FS_POSIX_ACL=y
978CONFIG_EXT2_FS_SECURITY=y
979# CONFIG_EXT2_FS_XIP is not set
980CONFIG_EXT3_FS=m
981CONFIG_EXT3_FS_XATTR=y
982# CONFIG_EXT3_FS_POSIX_ACL is not set
983# CONFIG_EXT3_FS_SECURITY is not set
984CONFIG_JBD=m
985# CONFIG_JBD_DEBUG is not set
986CONFIG_FS_MBCACHE=y
987# CONFIG_REISERFS_FS is not set
988# CONFIG_JFS_FS is not set
989CONFIG_FS_POSIX_ACL=y
990CONFIG_XFS_FS=m
991CONFIG_XFS_EXPORT=y
992# CONFIG_XFS_QUOTA is not set
993# CONFIG_XFS_SECURITY is not set
994# CONFIG_XFS_POSIX_ACL is not set
995# CONFIG_XFS_RT is not set
996# CONFIG_OCFS2_FS is not set
997# CONFIG_MINIX_FS is not set
998# CONFIG_ROMFS_FS is not set
999CONFIG_INOTIFY=y
1000# CONFIG_QUOTA is not set
1001# CONFIG_DNOTIFY is not set
1002# CONFIG_AUTOFS_FS is not set
1003CONFIG_AUTOFS4_FS=m
1004# CONFIG_FUSE_FS is not set
1005
1006#
1007# CD-ROM/DVD Filesystems
1008#
1009# CONFIG_ISO9660_FS is not set
1010# CONFIG_UDF_FS is not set
1011
1012#
1013# DOS/FAT/NT Filesystems
1014#
1015CONFIG_FAT_FS=y
1016CONFIG_MSDOS_FS=y
1017CONFIG_VFAT_FS=y
1018CONFIG_FAT_DEFAULT_CODEPAGE=437
1019CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1020CONFIG_NTFS_FS=m
1021# CONFIG_NTFS_DEBUG is not set
1022# CONFIG_NTFS_RW is not set
1023
1024#
1025# Pseudo filesystems
1026#
1027CONFIG_PROC_FS=y
1028CONFIG_PROC_KCORE=y
1029CONFIG_SYSFS=y
1030CONFIG_TMPFS=y
1031# CONFIG_HUGETLB_PAGE is not set
1032CONFIG_RAMFS=y
1033# CONFIG_CONFIGFS_FS is not set
1034
1035#
1036# Miscellaneous filesystems
1037#
1038# CONFIG_ADFS_FS is not set
1039# CONFIG_AFFS_FS is not set
1040# CONFIG_HFS_FS is not set
1041# CONFIG_HFSPLUS_FS is not set
1042# CONFIG_BEFS_FS is not set
1043# CONFIG_BFS_FS is not set
1044# CONFIG_EFS_FS is not set
1045# CONFIG_JFFS_FS is not set
1046CONFIG_JFFS2_FS=y
1047CONFIG_JFFS2_FS_DEBUG=0
1048CONFIG_JFFS2_FS_WRITEBUFFER=y
1049# CONFIG_JFFS2_SUMMARY is not set
1050CONFIG_JFFS2_COMPRESSION_OPTIONS=y
1051CONFIG_JFFS2_ZLIB=y
1052CONFIG_JFFS2_RTIME=y
1053# CONFIG_JFFS2_RUBIN is not set
1054# CONFIG_JFFS2_CMODE_NONE is not set
1055CONFIG_JFFS2_CMODE_PRIORITY=y
1056# CONFIG_JFFS2_CMODE_SIZE is not set
1057CONFIG_CRAMFS=y
1058# CONFIG_VXFS_FS is not set
1059# CONFIG_HPFS_FS is not set
1060# CONFIG_QNX4FS_FS is not set
1061# CONFIG_SYSV_FS is not set
1062# CONFIG_UFS_FS is not set
1063
1064#
1065# Network File Systems
1066#
1067CONFIG_NFS_FS=y
1068CONFIG_NFS_V3=y
1069# CONFIG_NFS_V3_ACL is not set
1070CONFIG_NFS_V4=y
1071CONFIG_NFS_DIRECTIO=y
1072CONFIG_NFSD=m
1073CONFIG_NFSD_V3=y
1074# CONFIG_NFSD_V3_ACL is not set
1075# CONFIG_NFSD_V4 is not set
1076CONFIG_NFSD_TCP=y
1077CONFIG_ROOT_NFS=y
1078CONFIG_LOCKD=y
1079CONFIG_LOCKD_V4=y
1080CONFIG_EXPORTFS=m
1081CONFIG_NFS_COMMON=y
1082CONFIG_SUNRPC=y
1083CONFIG_SUNRPC_GSS=y
1084CONFIG_RPCSEC_GSS_KRB5=y
1085# CONFIG_RPCSEC_GSS_SPKM3 is not set
1086CONFIG_SMB_FS=m
1087# CONFIG_SMB_NLS_DEFAULT is not set
1088# CONFIG_CIFS is not set
1089# CONFIG_NCP_FS is not set
1090# CONFIG_CODA_FS is not set
1091# CONFIG_AFS_FS is not set
1092# CONFIG_9P_FS is not set
1093
1094#
1095# Partition Types
1096#
1097# CONFIG_PARTITION_ADVANCED is not set
1098CONFIG_MSDOS_PARTITION=y
1099
1100#
1101# Native Language Support
1102#
1103CONFIG_NLS=y
1104CONFIG_NLS_DEFAULT=""
1105CONFIG_NLS_CODEPAGE_437=m
1106# CONFIG_NLS_CODEPAGE_737 is not set
1107# CONFIG_NLS_CODEPAGE_775 is not set
1108# CONFIG_NLS_CODEPAGE_850 is not set
1109# CONFIG_NLS_CODEPAGE_852 is not set
1110# CONFIG_NLS_CODEPAGE_855 is not set
1111# CONFIG_NLS_CODEPAGE_857 is not set
1112# CONFIG_NLS_CODEPAGE_860 is not set
1113# CONFIG_NLS_CODEPAGE_861 is not set
1114# CONFIG_NLS_CODEPAGE_862 is not set
1115# CONFIG_NLS_CODEPAGE_863 is not set
1116# CONFIG_NLS_CODEPAGE_864 is not set
1117# CONFIG_NLS_CODEPAGE_865 is not set
1118# CONFIG_NLS_CODEPAGE_866 is not set
1119# CONFIG_NLS_CODEPAGE_869 is not set
1120# CONFIG_NLS_CODEPAGE_936 is not set
1121# CONFIG_NLS_CODEPAGE_950 is not set
1122# CONFIG_NLS_CODEPAGE_932 is not set
1123# CONFIG_NLS_CODEPAGE_949 is not set
1124# CONFIG_NLS_CODEPAGE_874 is not set
1125# CONFIG_NLS_ISO8859_8 is not set
1126# CONFIG_NLS_CODEPAGE_1250 is not set
1127# CONFIG_NLS_CODEPAGE_1251 is not set
1128CONFIG_NLS_ASCII=m
1129CONFIG_NLS_ISO8859_1=m
1130# CONFIG_NLS_ISO8859_2 is not set
1131# CONFIG_NLS_ISO8859_3 is not set
1132# CONFIG_NLS_ISO8859_4 is not set
1133# CONFIG_NLS_ISO8859_5 is not set
1134# CONFIG_NLS_ISO8859_6 is not set
1135# CONFIG_NLS_ISO8859_7 is not set
1136# CONFIG_NLS_ISO8859_9 is not set
1137# CONFIG_NLS_ISO8859_13 is not set
1138# CONFIG_NLS_ISO8859_14 is not set
1139# CONFIG_NLS_ISO8859_15 is not set
1140# CONFIG_NLS_KOI8_R is not set
1141# CONFIG_NLS_KOI8_U is not set
1142CONFIG_NLS_UTF8=m
1143
1144#
1145# Profiling support
1146#
1147# CONFIG_PROFILING is not set
1148
1149#
1150# Kernel hacking
1151#
1152# CONFIG_PRINTK_TIME is not set
1153# CONFIG_MAGIC_SYSRQ is not set
1154# CONFIG_DEBUG_KERNEL is not set
1155CONFIG_LOG_BUF_SHIFT=14
1156# CONFIG_DEBUG_FS is not set
1157CONFIG_CROSSCOMPILE=y
1158CONFIG_CMDLINE="console=ttyS0,115200 mem=192m ip=bootp root=/dev/nfs rw"
1159
1160#
1161# Security options
1162#
1163# CONFIG_KEYS is not set
1164# CONFIG_SECURITY is not set
1165
1166#
1167# Cryptographic options
1168#
1169CONFIG_CRYPTO=y
1170CONFIG_CRYPTO_HMAC=y
1171# CONFIG_CRYPTO_NULL is not set
1172# CONFIG_CRYPTO_MD4 is not set
1173CONFIG_CRYPTO_MD5=y
1174# CONFIG_CRYPTO_SHA1 is not set
1175# CONFIG_CRYPTO_SHA256 is not set
1176# CONFIG_CRYPTO_SHA512 is not set
1177# CONFIG_CRYPTO_WP512 is not set
1178# CONFIG_CRYPTO_TGR192 is not set
1179CONFIG_CRYPTO_DES=y
1180# CONFIG_CRYPTO_BLOWFISH is not set
1181# CONFIG_CRYPTO_TWOFISH is not set
1182# CONFIG_CRYPTO_SERPENT is not set
1183# CONFIG_CRYPTO_AES is not set
1184# CONFIG_CRYPTO_CAST5 is not set
1185# CONFIG_CRYPTO_CAST6 is not set
1186# CONFIG_CRYPTO_TEA is not set
1187# CONFIG_CRYPTO_ARC4 is not set
1188# CONFIG_CRYPTO_KHAZAD is not set
1189# CONFIG_CRYPTO_ANUBIS is not set
1190# CONFIG_CRYPTO_DEFLATE is not set
1191# CONFIG_CRYPTO_MICHAEL_MIC is not set
1192# CONFIG_CRYPTO_CRC32C is not set
1193# CONFIG_CRYPTO_TEST is not set
1194
1195#
1196# Hardware crypto devices
1197#
1198
1199#
1200# Library routines
1201#
1202CONFIG_CRC_CCITT=m
1203# CONFIG_CRC16 is not set
1204CONFIG_CRC32=y
1205# CONFIG_LIBCRC32C is not set
1206CONFIG_ZLIB_INFLATE=y
1207CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/mips/configs/ev64120_defconfig b/arch/mips/configs/ev64120_defconfig
index 7067f608b22c..5248a1d8131d 100644
--- a/arch/mips/configs/ev64120_defconfig
+++ b/arch/mips/configs/ev64120_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_EV64120=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -131,6 +129,15 @@ CONFIG_FLATMEM=y
131CONFIG_FLAT_NODE_MEM_MAP=y 129CONFIG_FLAT_NODE_MEM_MAP=y
132# CONFIG_SPARSEMEM_STATIC is not set 130# CONFIG_SPARSEMEM_STATIC is not set
133CONFIG_SPLIT_PTLOCK_CPUS=4 131CONFIG_SPLIT_PTLOCK_CPUS=4
132# CONFIG_HZ_48 is not set
133# CONFIG_HZ_100 is not set
134# CONFIG_HZ_128 is not set
135# CONFIG_HZ_250 is not set
136# CONFIG_HZ_256 is not set
137CONFIG_HZ_1000=y
138# CONFIG_HZ_1024 is not set
139CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
140CONFIG_HZ=1000
134CONFIG_PREEMPT_NONE=y 141CONFIG_PREEMPT_NONE=y
135# CONFIG_PREEMPT_VOLUNTARY is not set 142# CONFIG_PREEMPT_VOLUNTARY is not set
136# CONFIG_PREEMPT is not set 143# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ev96100_defconfig b/arch/mips/configs/ev96100_defconfig
index 00b56ed0e638..4858491ce669 100644
--- a/arch/mips/configs/ev96100_defconfig
+++ b/arch/mips/configs/ev96100_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_EV96100=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -135,6 +133,15 @@ CONFIG_FLATMEM=y
135CONFIG_FLAT_NODE_MEM_MAP=y 133CONFIG_FLAT_NODE_MEM_MAP=y
136# CONFIG_SPARSEMEM_STATIC is not set 134# CONFIG_SPARSEMEM_STATIC is not set
137CONFIG_SPLIT_PTLOCK_CPUS=4 135CONFIG_SPLIT_PTLOCK_CPUS=4
136# CONFIG_HZ_48 is not set
137# CONFIG_HZ_100 is not set
138# CONFIG_HZ_128 is not set
139# CONFIG_HZ_250 is not set
140# CONFIG_HZ_256 is not set
141CONFIG_HZ_1000=y
142# CONFIG_HZ_1024 is not set
143CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
144CONFIG_HZ=1000
138CONFIG_PREEMPT_NONE=y 145CONFIG_PREEMPT_NONE=y
139# CONFIG_PREEMPT_VOLUNTARY is not set 146# CONFIG_PREEMPT_VOLUNTARY is not set
140# CONFIG_PREEMPT is not set 147# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/excite_defconfig b/arch/mips/configs/excite_defconfig
new file mode 100644
index 000000000000..f2ce64cb41a8
--- /dev/null
+++ b/arch/mips/configs/excite_defconfig
@@ -0,0 +1,1220 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.16-rc4
4# Thu Feb 23 13:15:27 2006
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11# CONFIG_MIPS_MTX1 is not set
12# CONFIG_MIPS_BOSPORUS is not set
13# CONFIG_MIPS_PB1000 is not set
14# CONFIG_MIPS_PB1100 is not set
15# CONFIG_MIPS_PB1500 is not set
16# CONFIG_MIPS_PB1550 is not set
17# CONFIG_MIPS_PB1200 is not set
18# CONFIG_MIPS_DB1000 is not set
19# CONFIG_MIPS_DB1100 is not set
20# CONFIG_MIPS_DB1500 is not set
21# CONFIG_MIPS_DB1550 is not set
22# CONFIG_MIPS_DB1200 is not set
23# CONFIG_MIPS_MIRAGE is not set
24# CONFIG_MIPS_COBALT is not set
25# CONFIG_MACH_DECSTATION is not set
26# CONFIG_MIPS_EV64120 is not set
27# CONFIG_MIPS_EV96100 is not set
28# CONFIG_MIPS_IVR is not set
29# CONFIG_MIPS_ITE8172 is not set
30# CONFIG_MACH_JAZZ is not set
31# CONFIG_LASAT is not set
32# CONFIG_MIPS_ATLAS is not set
33# CONFIG_MIPS_MALTA is not set
34# CONFIG_MIPS_SEAD is not set
35# CONFIG_MIPS_SIM is not set
36# CONFIG_MOMENCO_JAGUAR_ATX is not set
37# CONFIG_MOMENCO_OCELOT is not set
38# CONFIG_MOMENCO_OCELOT_3 is not set
39# CONFIG_MOMENCO_OCELOT_C is not set
40# CONFIG_MOMENCO_OCELOT_G is not set
41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set
44CONFIG_BASLER_EXCITE=y
45# CONFIG_BASLER_EXCITE_PROTOTYPE is not set
46# CONFIG_DDB5074 is not set
47# CONFIG_DDB5476 is not set
48# CONFIG_DDB5477 is not set
49# CONFIG_MACH_VR41XX is not set
50# CONFIG_PMC_YOSEMITE is not set
51# CONFIG_QEMU is not set
52# CONFIG_SGI_IP22 is not set
53# CONFIG_SGI_IP27 is not set
54# CONFIG_SGI_IP32 is not set
55# CONFIG_SIBYTE_BIGSUR is not set
56# CONFIG_SIBYTE_SWARM is not set
57# CONFIG_SIBYTE_SENTOSA is not set
58# CONFIG_SIBYTE_RHONE is not set
59# CONFIG_SIBYTE_CARMEL is not set
60# CONFIG_SIBYTE_PTSWARM is not set
61# CONFIG_SIBYTE_LITTLESUR is not set
62# CONFIG_SIBYTE_CRHINE is not set
63# CONFIG_SIBYTE_CRHONE is not set
64# CONFIG_SNI_RM200_PCI is not set
65# CONFIG_TOSHIBA_JMR3927 is not set
66# CONFIG_TOSHIBA_RBTX4927 is not set
67# CONFIG_TOSHIBA_RBTX4938 is not set
68CONFIG_RWSEM_GENERIC_SPINLOCK=y
69CONFIG_GENERIC_CALIBRATE_DELAY=y
70CONFIG_DMA_COHERENT=y
71CONFIG_SERIAL_RM9000=y
72CONFIG_CPU_BIG_ENDIAN=y
73# CONFIG_CPU_LITTLE_ENDIAN is not set
74CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
75CONFIG_IRQ_CPU=y
76CONFIG_IRQ_CPU_RM7K=y
77CONFIG_IRQ_CPU_RM9K=y
78CONFIG_MIPS_L1_CACHE_SHIFT=5
79
80#
81# CPU selection
82#
83# CONFIG_CPU_MIPS32_R1 is not set
84# CONFIG_CPU_MIPS32_R2 is not set
85# CONFIG_CPU_MIPS64_R1 is not set
86# CONFIG_CPU_MIPS64_R2 is not set
87# CONFIG_CPU_R3000 is not set
88# CONFIG_CPU_TX39XX is not set
89# CONFIG_CPU_VR41XX is not set
90# CONFIG_CPU_R4300 is not set
91# CONFIG_CPU_R4X00 is not set
92# CONFIG_CPU_TX49XX is not set
93# CONFIG_CPU_R5000 is not set
94# CONFIG_CPU_R5432 is not set
95# CONFIG_CPU_R6000 is not set
96# CONFIG_CPU_NEVADA is not set
97# CONFIG_CPU_R8000 is not set
98# CONFIG_CPU_R10000 is not set
99# CONFIG_CPU_RM7000 is not set
100CONFIG_CPU_RM9000=y
101# CONFIG_CPU_SB1 is not set
102CONFIG_SYS_HAS_CPU_RM9000=y
103CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
104CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
105CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
106CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
107
108#
109# Kernel type
110#
111CONFIG_32BIT=y
112# CONFIG_64BIT is not set
113CONFIG_PAGE_SIZE_4KB=y
114# CONFIG_PAGE_SIZE_8KB is not set
115# CONFIG_PAGE_SIZE_16KB is not set
116# CONFIG_PAGE_SIZE_64KB is not set
117CONFIG_CPU_HAS_PREFETCH=y
118# CONFIG_MIPS_MT is not set
119# CONFIG_64BIT_PHYS_ADDR is not set
120# CONFIG_CPU_ADVANCED is not set
121CONFIG_CPU_HAS_LLSC=y
122CONFIG_CPU_HAS_SYNC=y
123CONFIG_GENERIC_HARDIRQS=y
124CONFIG_GENERIC_IRQ_PROBE=y
125CONFIG_CPU_SUPPORTS_HIGHMEM=y
126CONFIG_ARCH_FLATMEM_ENABLE=y
127CONFIG_SELECT_MEMORY_MODEL=y
128CONFIG_FLATMEM_MANUAL=y
129# CONFIG_DISCONTIGMEM_MANUAL is not set
130# CONFIG_SPARSEMEM_MANUAL is not set
131CONFIG_FLATMEM=y
132CONFIG_FLAT_NODE_MEM_MAP=y
133# CONFIG_SPARSEMEM_STATIC is not set
134CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_HZ_48 is not set
136# CONFIG_HZ_100 is not set
137# CONFIG_HZ_128 is not set
138# CONFIG_HZ_250 is not set
139# CONFIG_HZ_256 is not set
140CONFIG_HZ_1000=y
141# CONFIG_HZ_1024 is not set
142CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
143CONFIG_HZ=1000
144# CONFIG_SMP is not set
145# CONFIG_PREEMPT_NONE is not set
146# CONFIG_PREEMPT_VOLUNTARY is not set
147CONFIG_PREEMPT=y
148CONFIG_PREEMPT_BKL=y
149
150#
151# Code maturity level options
152#
153CONFIG_EXPERIMENTAL=y
154CONFIG_BROKEN_ON_SMP=y
155CONFIG_LOCK_KERNEL=y
156CONFIG_INIT_ENV_ARG_LIMIT=32
157
158#
159# General setup
160#
161CONFIG_LOCALVERSION=""
162# CONFIG_LOCALVERSION_AUTO is not set
163CONFIG_SWAP=y
164CONFIG_SYSVIPC=y
165CONFIG_POSIX_MQUEUE=y
166# CONFIG_BSD_PROCESS_ACCT is not set
167CONFIG_SYSCTL=y
168# CONFIG_AUDIT is not set
169# CONFIG_IKCONFIG is not set
170CONFIG_INITRAMFS_SOURCE=""
171CONFIG_CC_OPTIMIZE_FOR_SIZE=y
172CONFIG_EMBEDDED=y
173CONFIG_KALLSYMS=y
174# CONFIG_KALLSYMS_EXTRA_PASS is not set
175CONFIG_HOTPLUG=y
176CONFIG_PRINTK=y
177CONFIG_BUG=y
178CONFIG_ELF_CORE=y
179CONFIG_BASE_FULL=y
180CONFIG_FUTEX=y
181CONFIG_EPOLL=y
182CONFIG_SHMEM=y
183CONFIG_CC_ALIGN_FUNCTIONS=0
184CONFIG_CC_ALIGN_LABELS=0
185CONFIG_CC_ALIGN_LOOPS=0
186CONFIG_CC_ALIGN_JUMPS=0
187CONFIG_SLAB=y
188# CONFIG_TINY_SHMEM is not set
189CONFIG_BASE_SMALL=0
190# CONFIG_SLOB is not set
191
192#
193# Loadable module support
194#
195CONFIG_MODULES=y
196CONFIG_MODULE_UNLOAD=y
197# CONFIG_MODULE_FORCE_UNLOAD is not set
198CONFIG_OBSOLETE_MODPARM=y
199# CONFIG_MODVERSIONS is not set
200# CONFIG_MODULE_SRCVERSION_ALL is not set
201CONFIG_KMOD=y
202
203#
204# Block layer
205#
206# CONFIG_LBD is not set
207
208#
209# IO Schedulers
210#
211CONFIG_IOSCHED_NOOP=y
212CONFIG_IOSCHED_AS=y
213CONFIG_IOSCHED_DEADLINE=y
214CONFIG_IOSCHED_CFQ=y
215CONFIG_DEFAULT_AS=y
216# CONFIG_DEFAULT_DEADLINE is not set
217# CONFIG_DEFAULT_CFQ is not set
218# CONFIG_DEFAULT_NOOP is not set
219CONFIG_DEFAULT_IOSCHED="anticipatory"
220
221#
222# Bus options (PCI, PCMCIA, EISA, ISA, TC)
223#
224CONFIG_HW_HAS_PCI=y
225CONFIG_PCI=y
226# CONFIG_PCI_LEGACY_PROC is not set
227CONFIG_MMU=y
228
229#
230# PCCARD (PCMCIA/CardBus) support
231#
232# CONFIG_PCCARD is not set
233
234#
235# PCI Hotplug Support
236#
237# CONFIG_HOTPLUG_PCI is not set
238
239#
240# Executable file formats
241#
242CONFIG_BINFMT_ELF=y
243# CONFIG_BINFMT_MISC is not set
244CONFIG_TRAD_SIGNALS=y
245
246#
247# Networking
248#
249CONFIG_NET=y
250
251#
252# Networking options
253#
254# CONFIG_NETDEBUG is not set
255CONFIG_PACKET=y
256CONFIG_PACKET_MMAP=y
257CONFIG_UNIX=y
258# CONFIG_NET_KEY is not set
259CONFIG_INET=y
260# CONFIG_IP_MULTICAST is not set
261# CONFIG_IP_ADVANCED_ROUTER is not set
262CONFIG_IP_FIB_HASH=y
263CONFIG_IP_PNP=y
264CONFIG_IP_PNP_DHCP=y
265# CONFIG_IP_PNP_BOOTP is not set
266# CONFIG_IP_PNP_RARP is not set
267# CONFIG_NET_IPIP is not set
268# CONFIG_NET_IPGRE is not set
269# CONFIG_ARPD is not set
270# CONFIG_SYN_COOKIES is not set
271# CONFIG_INET_AH is not set
272# CONFIG_INET_ESP is not set
273# CONFIG_INET_IPCOMP is not set
274# CONFIG_INET_TUNNEL is not set
275CONFIG_INET_DIAG=y
276CONFIG_INET_TCP_DIAG=y
277# CONFIG_TCP_CONG_ADVANCED is not set
278CONFIG_TCP_CONG_BIC=y
279# CONFIG_IPV6 is not set
280# CONFIG_NETFILTER is not set
281
282#
283# DCCP Configuration (EXPERIMENTAL)
284#
285# CONFIG_IP_DCCP is not set
286
287#
288# SCTP Configuration (EXPERIMENTAL)
289#
290# CONFIG_IP_SCTP is not set
291
292#
293# TIPC Configuration (EXPERIMENTAL)
294#
295# CONFIG_TIPC is not set
296# CONFIG_ATM is not set
297# CONFIG_BRIDGE is not set
298# CONFIG_VLAN_8021Q is not set
299# CONFIG_DECNET is not set
300# CONFIG_LLC2 is not set
301# CONFIG_IPX is not set
302# CONFIG_ATALK is not set
303# CONFIG_X25 is not set
304# CONFIG_LAPB is not set
305# CONFIG_NET_DIVERT is not set
306# CONFIG_ECONET is not set
307# CONFIG_WAN_ROUTER is not set
308
309#
310# QoS and/or fair queueing
311#
312# CONFIG_NET_SCHED is not set
313
314#
315# Network testing
316#
317# CONFIG_NET_PKTGEN is not set
318# CONFIG_HAMRADIO is not set
319# CONFIG_IRDA is not set
320# CONFIG_BT is not set
321# CONFIG_IEEE80211 is not set
322
323#
324# Device Drivers
325#
326
327#
328# Generic Driver Options
329#
330CONFIG_STANDALONE=y
331CONFIG_PREVENT_FIRMWARE_BUILD=y
332# CONFIG_FW_LOADER is not set
333
334#
335# Connector - unified userspace <-> kernelspace linker
336#
337# CONFIG_CONNECTOR is not set
338
339#
340# Memory Technology Devices (MTD)
341#
342CONFIG_MTD=y
343# CONFIG_MTD_DEBUG is not set
344# CONFIG_MTD_CONCAT is not set
345CONFIG_MTD_PARTITIONS=y
346# CONFIG_MTD_REDBOOT_PARTS is not set
347# CONFIG_MTD_CMDLINE_PARTS is not set
348
349#
350# User Modules And Translation Layers
351#
352CONFIG_MTD_CHAR=y
353CONFIG_MTD_BLOCK=y
354# CONFIG_FTL is not set
355# CONFIG_NFTL is not set
356# CONFIG_INFTL is not set
357# CONFIG_RFD_FTL is not set
358
359#
360# RAM/ROM/Flash chip drivers
361#
362# CONFIG_MTD_CFI is not set
363# CONFIG_MTD_JEDECPROBE is not set
364CONFIG_MTD_MAP_BANK_WIDTH_1=y
365CONFIG_MTD_MAP_BANK_WIDTH_2=y
366CONFIG_MTD_MAP_BANK_WIDTH_4=y
367# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
368# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
369# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
370CONFIG_MTD_CFI_I1=y
371CONFIG_MTD_CFI_I2=y
372# CONFIG_MTD_CFI_I4 is not set
373# CONFIG_MTD_CFI_I8 is not set
374# CONFIG_MTD_RAM is not set
375# CONFIG_MTD_ROM is not set
376# CONFIG_MTD_ABSENT is not set
377# CONFIG_MTD_OBSOLETE_CHIPS is not set
378
379#
380# Mapping drivers for chip access
381#
382# CONFIG_MTD_COMPLEX_MAPPINGS is not set
383# CONFIG_MTD_PLATRAM is not set
384
385#
386# Self-contained MTD device drivers
387#
388# CONFIG_MTD_PMC551 is not set
389# CONFIG_MTD_SLRAM is not set
390# CONFIG_MTD_PHRAM is not set
391# CONFIG_MTD_MTDRAM is not set
392# CONFIG_MTD_BLKMTD is not set
393# CONFIG_MTD_BLOCK2MTD is not set
394
395#
396# Disk-On-Chip Device Drivers
397#
398# CONFIG_MTD_DOC2000 is not set
399# CONFIG_MTD_DOC2001 is not set
400# CONFIG_MTD_DOC2001PLUS is not set
401
402#
403# NAND Flash Device Drivers
404#
405CONFIG_MTD_NAND=y
406CONFIG_MTD_NAND_VERIFY_WRITE=y
407CONFIG_MTD_NAND_IDS=y
408# CONFIG_MTD_NAND_DISKONCHIP is not set
409CONFIG_MTD_NAND_BASLER_EXCITE=y
410# CONFIG_MTD_NAND_BASLER_EXCITE_RDNBY is not set
411# CONFIG_MTD_NAND_BASLER_EXCITE_PERF is not set
412# CONFIG_MTD_NAND_NANDSIM is not set
413
414#
415# OneNAND Flash Device Drivers
416#
417# CONFIG_MTD_ONENAND is not set
418
419#
420# Parallel port support
421#
422# CONFIG_PARPORT is not set
423
424#
425# Plug and Play support
426#
427
428#
429# Block devices
430#
431# CONFIG_BLK_CPQ_DA is not set
432# CONFIG_BLK_CPQ_CISS_DA is not set
433# CONFIG_BLK_DEV_DAC960 is not set
434# CONFIG_BLK_DEV_UMEM is not set
435# CONFIG_BLK_DEV_COW_COMMON is not set
436CONFIG_BLK_DEV_LOOP=m
437# CONFIG_BLK_DEV_CRYPTOLOOP is not set
438# CONFIG_BLK_DEV_NBD is not set
439# CONFIG_BLK_DEV_SX8 is not set
440# CONFIG_BLK_DEV_UB is not set
441# CONFIG_BLK_DEV_RAM is not set
442CONFIG_BLK_DEV_RAM_COUNT=16
443# CONFIG_CDROM_PKTCDVD is not set
444# CONFIG_ATA_OVER_ETH is not set
445
446#
447# ATA/ATAPI/MFM/RLL support
448#
449# CONFIG_IDE is not set
450
451#
452# SCSI device support
453#
454# CONFIG_RAID_ATTRS is not set
455CONFIG_SCSI=y
456# CONFIG_SCSI_PROC_FS is not set
457
458#
459# SCSI support type (disk, tape, CD-ROM)
460#
461CONFIG_BLK_DEV_SD=y
462# CONFIG_CHR_DEV_ST is not set
463# CONFIG_CHR_DEV_OSST is not set
464# CONFIG_BLK_DEV_SR is not set
465# CONFIG_CHR_DEV_SG is not set
466# CONFIG_CHR_DEV_SCH is not set
467
468#
469# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
470#
471# CONFIG_SCSI_MULTI_LUN is not set
472# CONFIG_SCSI_CONSTANTS is not set
473# CONFIG_SCSI_LOGGING is not set
474
475#
476# SCSI Transport Attributes
477#
478# CONFIG_SCSI_SPI_ATTRS is not set
479# CONFIG_SCSI_FC_ATTRS is not set
480# CONFIG_SCSI_ISCSI_ATTRS is not set
481# CONFIG_SCSI_SAS_ATTRS is not set
482
483#
484# SCSI low-level drivers
485#
486# CONFIG_ISCSI_TCP is not set
487# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
488# CONFIG_SCSI_3W_9XXX is not set
489# CONFIG_SCSI_ACARD is not set
490# CONFIG_SCSI_AACRAID is not set
491# CONFIG_SCSI_AIC7XXX is not set
492# CONFIG_SCSI_AIC7XXX_OLD is not set
493# CONFIG_SCSI_AIC79XX is not set
494# CONFIG_SCSI_DPT_I2O is not set
495# CONFIG_MEGARAID_NEWGEN is not set
496# CONFIG_MEGARAID_LEGACY is not set
497# CONFIG_MEGARAID_SAS is not set
498# CONFIG_SCSI_SATA is not set
499# CONFIG_SCSI_DMX3191D is not set
500# CONFIG_SCSI_FUTURE_DOMAIN is not set
501# CONFIG_SCSI_IPS is not set
502# CONFIG_SCSI_INITIO is not set
503# CONFIG_SCSI_INIA100 is not set
504# CONFIG_SCSI_SYM53C8XX_2 is not set
505# CONFIG_SCSI_IPR is not set
506# CONFIG_SCSI_QLOGIC_FC is not set
507# CONFIG_SCSI_QLOGIC_1280 is not set
508# CONFIG_SCSI_QLA_FC is not set
509# CONFIG_SCSI_LPFC is not set
510# CONFIG_SCSI_DC395x is not set
511# CONFIG_SCSI_DC390T is not set
512# CONFIG_SCSI_NSP32 is not set
513# CONFIG_SCSI_DEBUG is not set
514
515#
516# Multi-device support (RAID and LVM)
517#
518# CONFIG_MD is not set
519
520#
521# Fusion MPT device support
522#
523# CONFIG_FUSION is not set
524# CONFIG_FUSION_SPI is not set
525# CONFIG_FUSION_FC is not set
526# CONFIG_FUSION_SAS is not set
527
528#
529# IEEE 1394 (FireWire) support
530#
531# CONFIG_IEEE1394 is not set
532
533#
534# I2O device support
535#
536# CONFIG_I2O is not set
537
538#
539# Network device support
540#
541CONFIG_NETDEVICES=y
542# CONFIG_DUMMY is not set
543# CONFIG_BONDING is not set
544# CONFIG_EQUALIZER is not set
545# CONFIG_TUN is not set
546
547#
548# ARCnet devices
549#
550# CONFIG_ARCNET is not set
551
552#
553# PHY device support
554#
555
556#
557# Ethernet (10 or 100Mbit)
558#
559# CONFIG_NET_ETHERNET is not set
560
561#
562# Ethernet (1000 Mbit)
563#
564# CONFIG_ACENIC is not set
565# CONFIG_DL2K is not set
566# CONFIG_E1000 is not set
567# CONFIG_NS83820 is not set
568# CONFIG_HAMACHI is not set
569# CONFIG_YELLOWFIN is not set
570# CONFIG_R8169 is not set
571# CONFIG_SIS190 is not set
572# CONFIG_SKGE is not set
573# CONFIG_SKY2 is not set
574# CONFIG_SK98LIN is not set
575# CONFIG_TIGON3 is not set
576# CONFIG_BNX2 is not set
577# CONFIG_TITAN_GE is not set
578CONFIG_RM9K_GE=m
579
580#
581# Ethernet (10000 Mbit)
582#
583# CONFIG_CHELSIO_T1 is not set
584# CONFIG_IXGB is not set
585# CONFIG_S2IO is not set
586
587#
588# Token Ring devices
589#
590# CONFIG_TR is not set
591
592#
593# Wireless LAN (non-hamradio)
594#
595# CONFIG_NET_RADIO is not set
596
597#
598# Wan interfaces
599#
600# CONFIG_WAN is not set
601# CONFIG_FDDI is not set
602# CONFIG_HIPPI is not set
603# CONFIG_PPP is not set
604# CONFIG_SLIP is not set
605# CONFIG_NET_FC is not set
606# CONFIG_SHAPER is not set
607# CONFIG_NETCONSOLE is not set
608# CONFIG_NETPOLL is not set
609# CONFIG_NET_POLL_CONTROLLER is not set
610
611#
612# ISDN subsystem
613#
614# CONFIG_ISDN is not set
615
616#
617# Telephony Support
618#
619# CONFIG_PHONE is not set
620
621#
622# Input device support
623#
624CONFIG_INPUT=y
625
626#
627# Userland interfaces
628#
629CONFIG_INPUT_MOUSEDEV=m
630CONFIG_INPUT_MOUSEDEV_PSAUX=y
631CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
632CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
633# CONFIG_INPUT_JOYDEV is not set
634# CONFIG_INPUT_TSDEV is not set
635CONFIG_INPUT_EVDEV=m
636# CONFIG_INPUT_EVBUG is not set
637
638#
639# Input Device Drivers
640#
641# CONFIG_INPUT_KEYBOARD is not set
642# CONFIG_INPUT_MOUSE is not set
643# CONFIG_INPUT_JOYSTICK is not set
644# CONFIG_INPUT_TOUCHSCREEN is not set
645# CONFIG_INPUT_MISC is not set
646
647#
648# Hardware I/O ports
649#
650# CONFIG_SERIO is not set
651# CONFIG_GAMEPORT is not set
652
653#
654# Character devices
655#
656CONFIG_VT=y
657CONFIG_VT_CONSOLE=y
658CONFIG_HW_CONSOLE=y
659# CONFIG_SERIAL_NONSTANDARD is not set
660
661#
662# Serial drivers
663#
664CONFIG_SERIAL_8250=y
665CONFIG_SERIAL_8250_CONSOLE=y
666CONFIG_SERIAL_8250_NR_UARTS=2
667CONFIG_SERIAL_8250_RUNTIME_UARTS=2
668CONFIG_SERIAL_8250_EXTENDED=y
669# CONFIG_SERIAL_8250_MANY_PORTS is not set
670CONFIG_SERIAL_8250_SHARE_IRQ=y
671# CONFIG_SERIAL_8250_DETECT_IRQ is not set
672# CONFIG_SERIAL_8250_RSA is not set
673
674#
675# Non-8250 serial port support
676#
677CONFIG_SERIAL_CORE=y
678CONFIG_SERIAL_CORE_CONSOLE=y
679# CONFIG_SERIAL_JSM is not set
680CONFIG_UNIX98_PTYS=y
681# CONFIG_LEGACY_PTYS is not set
682
683#
684# IPMI
685#
686# CONFIG_IPMI_HANDLER is not set
687
688#
689# Watchdog Cards
690#
691CONFIG_WATCHDOG=y
692# CONFIG_WATCHDOG_NOWAYOUT is not set
693
694#
695# Watchdog Device Drivers
696#
697# CONFIG_SOFT_WATCHDOG is not set
698CONFIG_WDT_RM9K_GPI=m
699
700#
701# PCI-based Watchdog Cards
702#
703# CONFIG_PCIPCWATCHDOG is not set
704# CONFIG_WDTPCI is not set
705
706#
707# USB-based Watchdog Cards
708#
709# CONFIG_USBPCWATCHDOG is not set
710# CONFIG_RTC is not set
711# CONFIG_GEN_RTC is not set
712# CONFIG_DTLK is not set
713# CONFIG_R3964 is not set
714# CONFIG_APPLICOM is not set
715
716#
717# Ftape, the floppy tape device driver
718#
719# CONFIG_DRM is not set
720# CONFIG_RAW_DRIVER is not set
721
722#
723# TPM devices
724#
725# CONFIG_TCG_TPM is not set
726# CONFIG_TELCLOCK is not set
727
728#
729# I2C support
730#
731# CONFIG_I2C is not set
732
733#
734# SPI support
735#
736# CONFIG_SPI is not set
737# CONFIG_SPI_MASTER is not set
738
739#
740# Dallas's 1-wire bus
741#
742# CONFIG_W1 is not set
743
744#
745# Hardware Monitoring support
746#
747# CONFIG_HWMON is not set
748# CONFIG_HWMON_VID is not set
749
750#
751# Misc devices
752#
753
754#
755# Multimedia Capabilities Port drivers
756#
757
758#
759# Multimedia devices
760#
761# CONFIG_VIDEO_DEV is not set
762
763#
764# Digital Video Broadcasting Devices
765#
766# CONFIG_DVB is not set
767
768#
769# Graphics support
770#
771CONFIG_FB=y
772CONFIG_FB_CFB_FILLRECT=y
773CONFIG_FB_CFB_COPYAREA=y
774CONFIG_FB_CFB_IMAGEBLIT=y
775# CONFIG_FB_MACMODES is not set
776# CONFIG_FB_MODE_HELPERS is not set
777# CONFIG_FB_TILEBLITTING is not set
778# CONFIG_FB_CIRRUS is not set
779# CONFIG_FB_PM2 is not set
780# CONFIG_FB_CYBER2000 is not set
781# CONFIG_FB_ASILIANT is not set
782# CONFIG_FB_IMSTT is not set
783# CONFIG_FB_S1D13XXX is not set
784# CONFIG_FB_NVIDIA is not set
785# CONFIG_FB_RIVA is not set
786# CONFIG_FB_MATROX is not set
787# CONFIG_FB_RADEON_OLD is not set
788# CONFIG_FB_RADEON is not set
789# CONFIG_FB_ATY128 is not set
790# CONFIG_FB_ATY is not set
791# CONFIG_FB_SAVAGE is not set
792# CONFIG_FB_SIS is not set
793# CONFIG_FB_NEOMAGIC is not set
794# CONFIG_FB_KYRO is not set
795# CONFIG_FB_3DFX is not set
796# CONFIG_FB_VOODOO1 is not set
797# CONFIG_FB_SMIVGX is not set
798# CONFIG_FB_TRIDENT is not set
799# CONFIG_FB_VIRTUAL is not set
800CONFIG_FB_DD=y
801
802#
803# Console display driver support
804#
805# CONFIG_VGA_CONSOLE is not set
806CONFIG_DUMMY_CONSOLE=y
807CONFIG_FRAMEBUFFER_CONSOLE=m
808# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
809# CONFIG_FONTS is not set
810CONFIG_FONT_8x8=y
811CONFIG_FONT_8x16=y
812
813#
814# Logo configuration
815#
816# CONFIG_LOGO is not set
817# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
818
819#
820# Sound
821#
822# CONFIG_SOUND is not set
823
824#
825# USB support
826#
827CONFIG_USB_ARCH_HAS_HCD=y
828CONFIG_USB_ARCH_HAS_OHCI=y
829CONFIG_USB=y
830# CONFIG_USB_DEBUG is not set
831
832#
833# Miscellaneous USB options
834#
835CONFIG_USB_DEVICEFS=y
836# CONFIG_USB_BANDWIDTH is not set
837# CONFIG_USB_DYNAMIC_MINORS is not set
838# CONFIG_USB_OTG is not set
839
840#
841# USB Host Controller Drivers
842#
843CONFIG_USB_EHCI_HCD=y
844# CONFIG_USB_EHCI_SPLIT_ISO is not set
845# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
846# CONFIG_USB_ISP116X_HCD is not set
847CONFIG_USB_OHCI_HCD=y
848# CONFIG_USB_OHCI_BIG_ENDIAN is not set
849CONFIG_USB_OHCI_LITTLE_ENDIAN=y
850# CONFIG_USB_UHCI_HCD is not set
851# CONFIG_USB_SL811_HCD is not set
852
853#
854# USB Device Class drivers
855#
856# CONFIG_USB_ACM is not set
857# CONFIG_USB_PRINTER is not set
858
859#
860# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
861#
862
863#
864# may also be needed; see USB_STORAGE Help for more information
865#
866CONFIG_USB_STORAGE=y
867# CONFIG_USB_STORAGE_DEBUG is not set
868# CONFIG_USB_STORAGE_DATAFAB is not set
869# CONFIG_USB_STORAGE_FREECOM is not set
870# CONFIG_USB_STORAGE_DPCM is not set
871# CONFIG_USB_STORAGE_USBAT is not set
872# CONFIG_USB_STORAGE_SDDR09 is not set
873# CONFIG_USB_STORAGE_SDDR55 is not set
874# CONFIG_USB_STORAGE_JUMPSHOT is not set
875# CONFIG_USB_STORAGE_ALAUDA is not set
876# CONFIG_USB_STORAGE_ONETOUCH is not set
877# CONFIG_USB_LIBUSUAL is not set
878
879#
880# USB Input Devices
881#
882CONFIG_USB_HID=m
883CONFIG_USB_HIDINPUT=y
884# CONFIG_USB_HIDINPUT_POWERBOOK is not set
885# CONFIG_HID_FF is not set
886# CONFIG_USB_HIDDEV is not set
887
888#
889# USB HID Boot Protocol drivers
890#
891# CONFIG_USB_KBD is not set
892# CONFIG_USB_MOUSE is not set
893# CONFIG_USB_AIPTEK is not set
894# CONFIG_USB_WACOM is not set
895# CONFIG_USB_ACECAD is not set
896# CONFIG_USB_KBTAB is not set
897# CONFIG_USB_POWERMATE is not set
898# CONFIG_USB_MTOUCH is not set
899# CONFIG_USB_ITMTOUCH is not set
900# CONFIG_USB_EGALAX is not set
901# CONFIG_USB_YEALINK is not set
902# CONFIG_USB_XPAD is not set
903# CONFIG_USB_ATI_REMOTE is not set
904# CONFIG_USB_ATI_REMOTE2 is not set
905# CONFIG_USB_KEYSPAN_REMOTE is not set
906# CONFIG_USB_APPLETOUCH is not set
907
908#
909# USB Imaging devices
910#
911# CONFIG_USB_MDC800 is not set
912# CONFIG_USB_MICROTEK is not set
913
914#
915# USB Multimedia devices
916#
917# CONFIG_USB_DABUSB is not set
918
919#
920# Video4Linux support is needed for USB Multimedia device support
921#
922
923#
924# USB Network Adapters
925#
926# CONFIG_USB_CATC is not set
927# CONFIG_USB_KAWETH is not set
928# CONFIG_USB_PEGASUS is not set
929# CONFIG_USB_RTL8150 is not set
930# CONFIG_USB_USBNET is not set
931# CONFIG_USB_MON is not set
932
933#
934# USB port drivers
935#
936
937#
938# USB Serial Converter support
939#
940# CONFIG_USB_SERIAL is not set
941
942#
943# USB Miscellaneous drivers
944#
945# CONFIG_USB_EMI62 is not set
946# CONFIG_USB_EMI26 is not set
947# CONFIG_USB_AUERSWALD is not set
948# CONFIG_USB_RIO500 is not set
949CONFIG_USB_ARTTFT=m
950# CONFIG_USB_ARTTOUCH is not set
951# CONFIG_USB_LEGOTOWER is not set
952# CONFIG_USB_LCD is not set
953# CONFIG_USB_LED is not set
954# CONFIG_USB_CYTHERM is not set
955# CONFIG_USB_PHIDGETKIT is not set
956# CONFIG_USB_PHIDGETSERVO is not set
957# CONFIG_USB_IDMOUSE is not set
958# CONFIG_USB_SISUSBVGA is not set
959# CONFIG_USB_LD is not set
960# CONFIG_USB_TEST is not set
961
962#
963# USB DSL modem support
964#
965
966#
967# USB Gadget Support
968#
969# CONFIG_USB_GADGET is not set
970
971#
972# MMC/SD Card support
973#
974# CONFIG_MMC is not set
975
976#
977# InfiniBand support
978#
979# CONFIG_INFINIBAND is not set
980
981#
982# SN Devices
983#
984
985#
986# EDAC - error detection and reporting (RAS)
987#
988
989#
990# eXcite frame capture support
991#
992CONFIG_EXCITE_FCAP=m
993CONFIG_EXCITE_FCAP_GPI=m
994
995#
996# File systems
997#
998CONFIG_EXT2_FS=y
999# CONFIG_EXT2_FS_XATTR is not set
1000# CONFIG_EXT2_FS_XIP is not set
1001# CONFIG_EXT3_FS is not set
1002# CONFIG_REISERFS_FS is not set
1003# CONFIG_JFS_FS is not set
1004# CONFIG_FS_POSIX_ACL is not set
1005# CONFIG_XFS_FS is not set
1006# CONFIG_OCFS2_FS is not set
1007# CONFIG_MINIX_FS is not set
1008# CONFIG_ROMFS_FS is not set
1009CONFIG_INOTIFY=y
1010# CONFIG_QUOTA is not set
1011# CONFIG_DNOTIFY is not set
1012# CONFIG_AUTOFS_FS is not set
1013# CONFIG_AUTOFS4_FS is not set
1014# CONFIG_FUSE_FS is not set
1015
1016#
1017# CD-ROM/DVD Filesystems
1018#
1019# CONFIG_ISO9660_FS is not set
1020# CONFIG_UDF_FS is not set
1021
1022#
1023# DOS/FAT/NT Filesystems
1024#
1025CONFIG_FAT_FS=m
1026CONFIG_MSDOS_FS=m
1027CONFIG_VFAT_FS=m
1028CONFIG_FAT_DEFAULT_CODEPAGE=437
1029CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1030# CONFIG_NTFS_FS is not set
1031
1032#
1033# Pseudo filesystems
1034#
1035CONFIG_PROC_FS=y
1036CONFIG_PROC_KCORE=y
1037CONFIG_SYSFS=y
1038CONFIG_TMPFS=y
1039# CONFIG_HUGETLB_PAGE is not set
1040CONFIG_RAMFS=y
1041# CONFIG_RELAYFS_FS is not set
1042# CONFIG_CONFIGFS_FS is not set
1043
1044#
1045# Miscellaneous filesystems
1046#
1047# CONFIG_ADFS_FS is not set
1048# CONFIG_AFFS_FS is not set
1049# CONFIG_HFS_FS is not set
1050# CONFIG_HFSPLUS_FS is not set
1051# CONFIG_BEFS_FS is not set
1052# CONFIG_BFS_FS is not set
1053# CONFIG_EFS_FS is not set
1054# CONFIG_JFFS_FS is not set
1055CONFIG_JFFS2_FS=y
1056CONFIG_JFFS2_FS_DEBUG=0
1057CONFIG_JFFS2_FS_WRITEBUFFER=y
1058# CONFIG_JFFS2_SUMMARY is not set
1059# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1060CONFIG_JFFS2_ZLIB=y
1061CONFIG_JFFS2_RTIME=y
1062# CONFIG_JFFS2_RUBIN is not set
1063# CONFIG_CRAMFS is not set
1064# CONFIG_VXFS_FS is not set
1065# CONFIG_HPFS_FS is not set
1066# CONFIG_QNX4FS_FS is not set
1067# CONFIG_SYSV_FS is not set
1068# CONFIG_UFS_FS is not set
1069
1070#
1071# Network File Systems
1072#
1073CONFIG_NFS_FS=y
1074CONFIG_NFS_V3=y
1075# CONFIG_NFS_V3_ACL is not set
1076# CONFIG_NFS_V4 is not set
1077# CONFIG_NFS_DIRECTIO is not set
1078# CONFIG_NFSD is not set
1079CONFIG_ROOT_NFS=y
1080CONFIG_LOCKD=y
1081CONFIG_LOCKD_V4=y
1082CONFIG_NFS_COMMON=y
1083CONFIG_SUNRPC=y
1084# CONFIG_RPCSEC_GSS_KRB5 is not set
1085# CONFIG_RPCSEC_GSS_SPKM3 is not set
1086# CONFIG_SMB_FS is not set
1087# CONFIG_CIFS is not set
1088# CONFIG_NCP_FS is not set
1089# CONFIG_CODA_FS is not set
1090# CONFIG_AFS_FS is not set
1091# CONFIG_9P_FS is not set
1092
1093#
1094# Partition Types
1095#
1096CONFIG_PARTITION_ADVANCED=y
1097# CONFIG_ACORN_PARTITION is not set
1098# CONFIG_OSF_PARTITION is not set
1099# CONFIG_AMIGA_PARTITION is not set
1100# CONFIG_ATARI_PARTITION is not set
1101# CONFIG_MAC_PARTITION is not set
1102CONFIG_MSDOS_PARTITION=y
1103# CONFIG_BSD_DISKLABEL is not set
1104# CONFIG_MINIX_SUBPARTITION is not set
1105# CONFIG_SOLARIS_X86_PARTITION is not set
1106# CONFIG_UNIXWARE_DISKLABEL is not set
1107# CONFIG_LDM_PARTITION is not set
1108# CONFIG_SGI_PARTITION is not set
1109# CONFIG_ULTRIX_PARTITION is not set
1110# CONFIG_SUN_PARTITION is not set
1111# CONFIG_KARMA_PARTITION is not set
1112# CONFIG_EFI_PARTITION is not set
1113
1114#
1115# Native Language Support
1116#
1117CONFIG_NLS=y
1118CONFIG_NLS_DEFAULT="iso8859-1"
1119CONFIG_NLS_CODEPAGE_437=m
1120# CONFIG_NLS_CODEPAGE_737 is not set
1121# CONFIG_NLS_CODEPAGE_775 is not set
1122CONFIG_NLS_CODEPAGE_850=m
1123# CONFIG_NLS_CODEPAGE_852 is not set
1124# CONFIG_NLS_CODEPAGE_855 is not set
1125# CONFIG_NLS_CODEPAGE_857 is not set
1126# CONFIG_NLS_CODEPAGE_860 is not set
1127# CONFIG_NLS_CODEPAGE_861 is not set
1128# CONFIG_NLS_CODEPAGE_862 is not set
1129# CONFIG_NLS_CODEPAGE_863 is not set
1130# CONFIG_NLS_CODEPAGE_864 is not set
1131# CONFIG_NLS_CODEPAGE_865 is not set
1132# CONFIG_NLS_CODEPAGE_866 is not set
1133# CONFIG_NLS_CODEPAGE_869 is not set
1134# CONFIG_NLS_CODEPAGE_936 is not set
1135# CONFIG_NLS_CODEPAGE_950 is not set
1136# CONFIG_NLS_CODEPAGE_932 is not set
1137# CONFIG_NLS_CODEPAGE_949 is not set
1138# CONFIG_NLS_CODEPAGE_874 is not set
1139# CONFIG_NLS_ISO8859_8 is not set
1140# CONFIG_NLS_CODEPAGE_1250 is not set
1141# CONFIG_NLS_CODEPAGE_1251 is not set
1142# CONFIG_NLS_ASCII is not set
1143CONFIG_NLS_ISO8859_1=m
1144# CONFIG_NLS_ISO8859_2 is not set
1145# CONFIG_NLS_ISO8859_3 is not set
1146# CONFIG_NLS_ISO8859_4 is not set
1147# CONFIG_NLS_ISO8859_5 is not set
1148# CONFIG_NLS_ISO8859_6 is not set
1149# CONFIG_NLS_ISO8859_7 is not set
1150# CONFIG_NLS_ISO8859_9 is not set
1151# CONFIG_NLS_ISO8859_13 is not set
1152# CONFIG_NLS_ISO8859_14 is not set
1153# CONFIG_NLS_ISO8859_15 is not set
1154# CONFIG_NLS_KOI8_R is not set
1155# CONFIG_NLS_KOI8_U is not set
1156# CONFIG_NLS_UTF8 is not set
1157
1158#
1159# Profiling support
1160#
1161# CONFIG_PROFILING is not set
1162
1163#
1164# Kernel hacking
1165#
1166# CONFIG_PRINTK_TIME is not set
1167# CONFIG_MAGIC_SYSRQ is not set
1168# CONFIG_DEBUG_KERNEL is not set
1169CONFIG_LOG_BUF_SHIFT=14
1170CONFIG_CROSSCOMPILE=y
1171CONFIG_CMDLINE=""
1172
1173#
1174# Security options
1175#
1176# CONFIG_KEYS is not set
1177# CONFIG_SECURITY is not set
1178
1179#
1180# Cryptographic options
1181#
1182CONFIG_CRYPTO=y
1183# CONFIG_CRYPTO_HMAC is not set
1184# CONFIG_CRYPTO_NULL is not set
1185# CONFIG_CRYPTO_MD4 is not set
1186# CONFIG_CRYPTO_MD5 is not set
1187# CONFIG_CRYPTO_SHA1 is not set
1188# CONFIG_CRYPTO_SHA256 is not set
1189# CONFIG_CRYPTO_SHA512 is not set
1190# CONFIG_CRYPTO_WP512 is not set
1191# CONFIG_CRYPTO_TGR192 is not set
1192# CONFIG_CRYPTO_DES is not set
1193# CONFIG_CRYPTO_BLOWFISH is not set
1194# CONFIG_CRYPTO_TWOFISH is not set
1195# CONFIG_CRYPTO_SERPENT is not set
1196# CONFIG_CRYPTO_AES is not set
1197# CONFIG_CRYPTO_CAST5 is not set
1198# CONFIG_CRYPTO_CAST6 is not set
1199# CONFIG_CRYPTO_TEA is not set
1200# CONFIG_CRYPTO_ARC4 is not set
1201# CONFIG_CRYPTO_KHAZAD is not set
1202# CONFIG_CRYPTO_ANUBIS is not set
1203# CONFIG_CRYPTO_DEFLATE is not set
1204# CONFIG_CRYPTO_MICHAEL_MIC is not set
1205# CONFIG_CRYPTO_CRC32C is not set
1206# CONFIG_CRYPTO_TEST is not set
1207
1208#
1209# Hardware crypto devices
1210#
1211
1212#
1213# Library routines
1214#
1215# CONFIG_CRC_CCITT is not set
1216# CONFIG_CRC16 is not set
1217CONFIG_CRC32=y
1218# CONFIG_LIBCRC32C is not set
1219CONFIG_ZLIB_INFLATE=y
1220CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
index 607e2985ffe3..879ba1ad99ca 100644
--- a/arch/mips/configs/ip22_defconfig
+++ b/arch/mips/configs/ip22_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -136,6 +134,15 @@ CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
139# CONFIG_PREEMPT_NONE is not set 146# CONFIG_PREEMPT_NONE is not set
140CONFIG_PREEMPT_VOLUNTARY=y 147CONFIG_PREEMPT_VOLUNTARY=y
141# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index f724b4b2ecf2..bb1426806430 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -63,7 +61,7 @@ CONFIG_SGI_IP27=y
63# CONFIG_TOSHIBA_JMR3927 is not set 61# CONFIG_TOSHIBA_JMR3927 is not set
64# CONFIG_TOSHIBA_RBTX4927 is not set 62# CONFIG_TOSHIBA_RBTX4927 is not set
65# CONFIG_TOSHIBA_RBTX4938 is not set 63# CONFIG_TOSHIBA_RBTX4938 is not set
66# CONFIG_SGI_SN0_N_MODE is not set 64# CONFIG_SGI_SN_N_MODE is not set
67CONFIG_ARCH_DISCONTIGMEM_ENABLE=y 65CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
68CONFIG_NUMA=y 66CONFIG_NUMA=y
69# CONFIG_MAPPED_KERNEL is not set 67# CONFIG_MAPPED_KERNEL is not set
@@ -135,6 +133,15 @@ CONFIG_FLAT_NODE_MEM_MAP=y
135CONFIG_NEED_MULTIPLE_NODES=y 133CONFIG_NEED_MULTIPLE_NODES=y
136# CONFIG_SPARSEMEM_STATIC is not set 134# CONFIG_SPARSEMEM_STATIC is not set
137CONFIG_SPLIT_PTLOCK_CPUS=4 135CONFIG_SPLIT_PTLOCK_CPUS=4
136# CONFIG_HZ_48 is not set
137# CONFIG_HZ_100 is not set
138# CONFIG_HZ_128 is not set
139# CONFIG_HZ_250 is not set
140# CONFIG_HZ_256 is not set
141CONFIG_HZ_1000=y
142# CONFIG_HZ_1024 is not set
143CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
144CONFIG_HZ=1000
138CONFIG_MIGRATION=y 145CONFIG_MIGRATION=y
139CONFIG_SMP=y 146CONFIG_SMP=y
140CONFIG_NR_CPUS=64 147CONFIG_NR_CPUS=64
diff --git a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
index 8f11d3565b2d..31b3c92a3841 100644
--- a/arch/mips/configs/ip32_defconfig
+++ b/arch/mips/configs/ip32_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -136,6 +134,15 @@ CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
139# CONFIG_PREEMPT_NONE is not set 146# CONFIG_PREEMPT_NONE is not set
140CONFIG_PREEMPT_VOLUNTARY=y 147CONFIG_PREEMPT_VOLUNTARY=y
141# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/it8172_defconfig b/arch/mips/configs/it8172_defconfig
index 757adf23853d..809bae9013ac 100644
--- a/arch/mips/configs/it8172_defconfig
+++ b/arch/mips/configs/it8172_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_ITE8172=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ivr_defconfig b/arch/mips/configs/ivr_defconfig
index 021761a8a237..55108fd67844 100644
--- a/arch/mips/configs/ivr_defconfig
+++ b/arch/mips/configs/ivr_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_IVR=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -127,6 +125,15 @@ CONFIG_FLATMEM=y
127CONFIG_FLAT_NODE_MEM_MAP=y 125CONFIG_FLAT_NODE_MEM_MAP=y
128# CONFIG_SPARSEMEM_STATIC is not set 126# CONFIG_SPARSEMEM_STATIC is not set
129CONFIG_SPLIT_PTLOCK_CPUS=4 127CONFIG_SPLIT_PTLOCK_CPUS=4
128# CONFIG_HZ_48 is not set
129# CONFIG_HZ_100 is not set
130# CONFIG_HZ_128 is not set
131# CONFIG_HZ_250 is not set
132# CONFIG_HZ_256 is not set
133CONFIG_HZ_1000=y
134# CONFIG_HZ_1024 is not set
135CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
136CONFIG_HZ=1000
130CONFIG_PREEMPT_NONE=y 137CONFIG_PREEMPT_NONE=y
131# CONFIG_PREEMPT_VOLUNTARY is not set 138# CONFIG_PREEMPT_VOLUNTARY is not set
132# CONFIG_PREEMPT is not set 139# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/jaguar-atx_defconfig b/arch/mips/configs/jaguar-atx_defconfig
index 08f6c30b0abc..ef2843436057 100644
--- a/arch/mips/configs/jaguar-atx_defconfig
+++ b/arch/mips/configs/jaguar-atx_defconfig
@@ -41,8 +41,6 @@ CONFIG_MOMENCO_JAGUAR_ATX=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -136,6 +134,15 @@ CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
139# CONFIG_SMP is not set 146# CONFIG_SMP is not set
140CONFIG_PREEMPT_NONE=y 147CONFIG_PREEMPT_NONE=y
141# CONFIG_PREEMPT_VOLUNTARY is not set 148# CONFIG_PREEMPT_VOLUNTARY is not set
diff --git a/arch/mips/configs/jmr3927_defconfig b/arch/mips/configs/jmr3927_defconfig
index 38b1e026e10d..5ef5a08289a5 100644
--- a/arch/mips/configs/jmr3927_defconfig
+++ b/arch/mips/configs/jmr3927_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -125,6 +123,15 @@ CONFIG_FLATMEM=y
125CONFIG_FLAT_NODE_MEM_MAP=y 123CONFIG_FLAT_NODE_MEM_MAP=y
126# CONFIG_SPARSEMEM_STATIC is not set 124# CONFIG_SPARSEMEM_STATIC is not set
127CONFIG_SPLIT_PTLOCK_CPUS=4 125CONFIG_SPLIT_PTLOCK_CPUS=4
126# CONFIG_HZ_48 is not set
127# CONFIG_HZ_100 is not set
128# CONFIG_HZ_128 is not set
129# CONFIG_HZ_250 is not set
130# CONFIG_HZ_256 is not set
131CONFIG_HZ_1000=y
132# CONFIG_HZ_1024 is not set
133CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
134CONFIG_HZ=1000
128CONFIG_PREEMPT_NONE=y 135CONFIG_PREEMPT_NONE=y
129# CONFIG_PREEMPT_VOLUNTARY is not set 136# CONFIG_PREEMPT_VOLUNTARY is not set
130# CONFIG_PREEMPT is not set 137# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/lasat200_defconfig b/arch/mips/configs/lasat200_defconfig
index 4d25990a0a05..eabcff26fc0e 100644
--- a/arch/mips/configs/lasat200_defconfig
+++ b/arch/mips/configs/lasat200_defconfig
@@ -41,8 +41,6 @@ CONFIG_LASAT=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -134,6 +132,15 @@ CONFIG_FLATMEM=y
134CONFIG_FLAT_NODE_MEM_MAP=y 132CONFIG_FLAT_NODE_MEM_MAP=y
135# CONFIG_SPARSEMEM_STATIC is not set 133# CONFIG_SPARSEMEM_STATIC is not set
136CONFIG_SPLIT_PTLOCK_CPUS=4 134CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_HZ_48 is not set
136# CONFIG_HZ_100 is not set
137# CONFIG_HZ_128 is not set
138# CONFIG_HZ_250 is not set
139# CONFIG_HZ_256 is not set
140CONFIG_HZ_1000=y
141# CONFIG_HZ_1024 is not set
142CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
143CONFIG_HZ=1000
137CONFIG_PREEMPT_NONE=y 144CONFIG_PREEMPT_NONE=y
138# CONFIG_PREEMPT_VOLUNTARY is not set 145# CONFIG_PREEMPT_VOLUNTARY is not set
139# CONFIG_PREEMPT is not set 146# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 977f52be51dc..b73cff0d83ca 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_MALTA=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -154,6 +152,15 @@ CONFIG_FLATMEM=y
154CONFIG_FLAT_NODE_MEM_MAP=y 152CONFIG_FLAT_NODE_MEM_MAP=y
155# CONFIG_SPARSEMEM_STATIC is not set 153# CONFIG_SPARSEMEM_STATIC is not set
156CONFIG_SPLIT_PTLOCK_CPUS=4 154CONFIG_SPLIT_PTLOCK_CPUS=4
155# CONFIG_HZ_48 is not set
156CONFIG_HZ_100=y
157# CONFIG_HZ_128 is not set
158# CONFIG_HZ_250 is not set
159# CONFIG_HZ_256 is not set
160# CONFIG_HZ_1000 is not set
161# CONFIG_HZ_1024 is not set
162CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
163CONFIG_HZ=100
157CONFIG_PREEMPT_NONE=y 164CONFIG_PREEMPT_NONE=y
158# CONFIG_PREEMPT_VOLUNTARY is not set 165# CONFIG_PREEMPT_VOLUNTARY is not set
159# CONFIG_PREEMPT is not set 166# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/mipssim_defconfig b/arch/mips/configs/mipssim_defconfig
index 00560e0143f1..8dd27b55413d 100644
--- a/arch/mips/configs/mipssim_defconfig
+++ b/arch/mips/configs/mipssim_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_SIM=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -138,6 +136,15 @@ CONFIG_FLATMEM=y
138CONFIG_FLAT_NODE_MEM_MAP=y 136CONFIG_FLAT_NODE_MEM_MAP=y
139# CONFIG_SPARSEMEM_STATIC is not set 137# CONFIG_SPARSEMEM_STATIC is not set
140CONFIG_SPLIT_PTLOCK_CPUS=4 138CONFIG_SPLIT_PTLOCK_CPUS=4
139# CONFIG_HZ_48 is not set
140# CONFIG_HZ_100 is not set
141# CONFIG_HZ_128 is not set
142# CONFIG_HZ_250 is not set
143# CONFIG_HZ_256 is not set
144CONFIG_HZ_1000=y
145# CONFIG_HZ_1024 is not set
146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
147CONFIG_HZ=1000
141CONFIG_PREEMPT_NONE=y 148CONFIG_PREEMPT_NONE=y
142# CONFIG_PREEMPT_VOLUNTARY is not set 149# CONFIG_PREEMPT_VOLUNTARY is not set
143# CONFIG_PREEMPT is not set 150# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
index 286a018375b2..5d6ff3c352c9 100644
--- a/arch/mips/configs/mpc30x_defconfig
+++ b/arch/mips/configs/mpc30x_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -132,6 +130,15 @@ CONFIG_FLATMEM=y
132CONFIG_FLAT_NODE_MEM_MAP=y 130CONFIG_FLAT_NODE_MEM_MAP=y
133# CONFIG_SPARSEMEM_STATIC is not set 131# CONFIG_SPARSEMEM_STATIC is not set
134CONFIG_SPLIT_PTLOCK_CPUS=4 132CONFIG_SPLIT_PTLOCK_CPUS=4
133# CONFIG_HZ_48 is not set
134# CONFIG_HZ_100 is not set
135# CONFIG_HZ_128 is not set
136# CONFIG_HZ_250 is not set
137# CONFIG_HZ_256 is not set
138CONFIG_HZ_1000=y
139# CONFIG_HZ_1024 is not set
140CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
141CONFIG_HZ=1000
135CONFIG_PREEMPT_NONE=y 142CONFIG_PREEMPT_NONE=y
136# CONFIG_PREEMPT_VOLUNTARY is not set 143# CONFIG_PREEMPT_VOLUNTARY is not set
137# CONFIG_PREEMPT is not set 144# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ocelot_3_defconfig b/arch/mips/configs/ocelot_3_defconfig
index 1ce4310fd92a..fe5e3dd915f5 100644
--- a/arch/mips/configs/ocelot_3_defconfig
+++ b/arch/mips/configs/ocelot_3_defconfig
@@ -41,8 +41,6 @@ CONFIG_MOMENCO_OCELOT_3=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -136,6 +134,15 @@ CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
139# CONFIG_SMP is not set 146# CONFIG_SMP is not set
140CONFIG_PREEMPT_NONE=y 147CONFIG_PREEMPT_NONE=y
141# CONFIG_PREEMPT_VOLUNTARY is not set 148# CONFIG_PREEMPT_VOLUNTARY is not set
diff --git a/arch/mips/configs/ocelot_c_defconfig b/arch/mips/configs/ocelot_c_defconfig
index 8a6aa5012f89..f4a33ce47e50 100644
--- a/arch/mips/configs/ocelot_c_defconfig
+++ b/arch/mips/configs/ocelot_c_defconfig
@@ -41,8 +41,6 @@ CONFIG_MOMENCO_OCELOT_C=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -133,6 +131,15 @@ CONFIG_FLATMEM=y
133CONFIG_FLAT_NODE_MEM_MAP=y 131CONFIG_FLAT_NODE_MEM_MAP=y
134# CONFIG_SPARSEMEM_STATIC is not set 132# CONFIG_SPARSEMEM_STATIC is not set
135CONFIG_SPLIT_PTLOCK_CPUS=4 133CONFIG_SPLIT_PTLOCK_CPUS=4
134# CONFIG_HZ_48 is not set
135# CONFIG_HZ_100 is not set
136# CONFIG_HZ_128 is not set
137# CONFIG_HZ_250 is not set
138# CONFIG_HZ_256 is not set
139CONFIG_HZ_1000=y
140# CONFIG_HZ_1024 is not set
141CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
142CONFIG_HZ=1000
136CONFIG_PREEMPT_NONE=y 143CONFIG_PREEMPT_NONE=y
137# CONFIG_PREEMPT_VOLUNTARY is not set 144# CONFIG_PREEMPT_VOLUNTARY is not set
138# CONFIG_PREEMPT is not set 145# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ocelot_defconfig b/arch/mips/configs/ocelot_defconfig
index f9ee35eeb762..21dea9549feb 100644
--- a/arch/mips/configs/ocelot_defconfig
+++ b/arch/mips/configs/ocelot_defconfig
@@ -41,8 +41,6 @@ CONFIG_MOMENCO_OCELOT=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -137,6 +135,15 @@ CONFIG_FLATMEM=y
137CONFIG_FLAT_NODE_MEM_MAP=y 135CONFIG_FLAT_NODE_MEM_MAP=y
138# CONFIG_SPARSEMEM_STATIC is not set 136# CONFIG_SPARSEMEM_STATIC is not set
139CONFIG_SPLIT_PTLOCK_CPUS=4 137CONFIG_SPLIT_PTLOCK_CPUS=4
138# CONFIG_HZ_48 is not set
139# CONFIG_HZ_100 is not set
140# CONFIG_HZ_128 is not set
141# CONFIG_HZ_250 is not set
142# CONFIG_HZ_256 is not set
143CONFIG_HZ_1000=y
144# CONFIG_HZ_1024 is not set
145CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
146CONFIG_HZ=1000
140CONFIG_PREEMPT_NONE=y 147CONFIG_PREEMPT_NONE=y
141# CONFIG_PREEMPT_VOLUNTARY is not set 148# CONFIG_PREEMPT_VOLUNTARY is not set
142# CONFIG_PREEMPT is not set 149# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ocelot_g_defconfig b/arch/mips/configs/ocelot_g_defconfig
index b48bdee2411f..c63b1ca8c8b3 100644
--- a/arch/mips/configs/ocelot_g_defconfig
+++ b/arch/mips/configs/ocelot_g_defconfig
@@ -41,8 +41,6 @@ CONFIG_MOMENCO_OCELOT_G=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -136,6 +134,15 @@ CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
139CONFIG_PREEMPT_NONE=y 146CONFIG_PREEMPT_NONE=y
140# CONFIG_PREEMPT_VOLUNTARY is not set 147# CONFIG_PREEMPT_VOLUNTARY is not set
141# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig
index 01aac40634b4..6f5c7261e9de 100644
--- a/arch/mips/configs/pb1100_defconfig
+++ b/arch/mips/configs/pb1100_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_PB1100=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -132,6 +130,15 @@ CONFIG_FLATMEM=y
132CONFIG_FLAT_NODE_MEM_MAP=y 130CONFIG_FLAT_NODE_MEM_MAP=y
133# CONFIG_SPARSEMEM_STATIC is not set 131# CONFIG_SPARSEMEM_STATIC is not set
134CONFIG_SPLIT_PTLOCK_CPUS=4 132CONFIG_SPLIT_PTLOCK_CPUS=4
133# CONFIG_HZ_48 is not set
134# CONFIG_HZ_100 is not set
135# CONFIG_HZ_128 is not set
136# CONFIG_HZ_250 is not set
137# CONFIG_HZ_256 is not set
138CONFIG_HZ_1000=y
139# CONFIG_HZ_1024 is not set
140CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
141CONFIG_HZ=1000
135CONFIG_PREEMPT_NONE=y 142CONFIG_PREEMPT_NONE=y
136# CONFIG_PREEMPT_VOLUNTARY is not set 143# CONFIG_PREEMPT_VOLUNTARY is not set
137# CONFIG_PREEMPT is not set 144# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig
index 398c3c265b9f..5676f3747fd5 100644
--- a/arch/mips/configs/pb1500_defconfig
+++ b/arch/mips/configs/pb1500_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_PB1500=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -131,6 +129,15 @@ CONFIG_FLATMEM=y
131CONFIG_FLAT_NODE_MEM_MAP=y 129CONFIG_FLAT_NODE_MEM_MAP=y
132# CONFIG_SPARSEMEM_STATIC is not set 130# CONFIG_SPARSEMEM_STATIC is not set
133CONFIG_SPLIT_PTLOCK_CPUS=4 131CONFIG_SPLIT_PTLOCK_CPUS=4
132# CONFIG_HZ_48 is not set
133# CONFIG_HZ_100 is not set
134# CONFIG_HZ_128 is not set
135# CONFIG_HZ_250 is not set
136# CONFIG_HZ_256 is not set
137CONFIG_HZ_1000=y
138# CONFIG_HZ_1024 is not set
139CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
140CONFIG_HZ=1000
134CONFIG_PREEMPT_NONE=y 141CONFIG_PREEMPT_NONE=y
135# CONFIG_PREEMPT_VOLUNTARY is not set 142# CONFIG_PREEMPT_VOLUNTARY is not set
136# CONFIG_PREEMPT is not set 143# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/pb1550_defconfig b/arch/mips/configs/pb1550_defconfig
index ea282a53bb66..a1c479fa613b 100644
--- a/arch/mips/configs/pb1550_defconfig
+++ b/arch/mips/configs/pb1550_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_PB1550=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -131,6 +129,15 @@ CONFIG_FLATMEM=y
131CONFIG_FLAT_NODE_MEM_MAP=y 129CONFIG_FLAT_NODE_MEM_MAP=y
132# CONFIG_SPARSEMEM_STATIC is not set 130# CONFIG_SPARSEMEM_STATIC is not set
133CONFIG_SPLIT_PTLOCK_CPUS=4 131CONFIG_SPLIT_PTLOCK_CPUS=4
132# CONFIG_HZ_48 is not set
133# CONFIG_HZ_100 is not set
134# CONFIG_HZ_128 is not set
135# CONFIG_HZ_250 is not set
136# CONFIG_HZ_256 is not set
137CONFIG_HZ_1000=y
138# CONFIG_HZ_1024 is not set
139CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
140CONFIG_HZ=1000
134CONFIG_PREEMPT_NONE=y 141CONFIG_PREEMPT_NONE=y
135# CONFIG_PREEMPT_VOLUNTARY is not set 142# CONFIG_PREEMPT_VOLUNTARY is not set
136# CONFIG_PREEMPT is not set 143# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/pnx8550-jbs_defconfig b/arch/mips/configs/pnx8550-jbs_defconfig
index 4c57e564db0b..b2d991b80309 100644
--- a/arch/mips/configs/pnx8550-jbs_defconfig
+++ b/arch/mips/configs/pnx8550-jbs_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43CONFIG_PNX8550_JBS=y 43CONFIG_PNX8550_JBS=y
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/pnx8550-v2pci_defconfig b/arch/mips/configs/pnx8550-v2pci_defconfig
index 3c8f35162fec..fe092ac92e89 100644
--- a/arch/mips/configs/pnx8550-v2pci_defconfig
+++ b/arch/mips/configs/pnx8550-v2pci_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42CONFIG_PNX8550_V2PCI=y 42CONFIG_PNX8550_V2PCI=y
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/qemu_defconfig b/arch/mips/configs/qemu_defconfig
index 4bcc01dea041..db8701344cee 100644
--- a/arch/mips/configs/qemu_defconfig
+++ b/arch/mips/configs/qemu_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -128,6 +126,15 @@ CONFIG_FLAT_NODE_MEM_MAP=y
128# CONFIG_SPARSEMEM_STATIC is not set 126# CONFIG_SPARSEMEM_STATIC is not set
129CONFIG_SPLIT_PTLOCK_CPUS=4 127CONFIG_SPLIT_PTLOCK_CPUS=4
130# CONFIG_SMP is not set 128# CONFIG_SMP is not set
129# CONFIG_HZ_48 is not set
130CONFIG_HZ_100=y
131# CONFIG_HZ_128 is not set
132# CONFIG_HZ_250 is not set
133# CONFIG_HZ_256 is not set
134# CONFIG_HZ_1000 is not set
135# CONFIG_HZ_1024 is not set
136CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
137CONFIG_HZ=100
131CONFIG_PREEMPT_NONE=y 138CONFIG_PREEMPT_NONE=y
132# CONFIG_PREEMPT_VOLUNTARY is not set 139# CONFIG_PREEMPT_VOLUNTARY is not set
133# CONFIG_PREEMPT is not set 140# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/rbhma4500_defconfig b/arch/mips/configs/rbhma4500_defconfig
index 3d441932e43a..b16731f3684b 100644
--- a/arch/mips/configs/rbhma4500_defconfig
+++ b/arch/mips/configs/rbhma4500_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -138,6 +136,15 @@ CONFIG_FLATMEM=y
138CONFIG_FLAT_NODE_MEM_MAP=y 136CONFIG_FLAT_NODE_MEM_MAP=y
139# CONFIG_SPARSEMEM_STATIC is not set 137# CONFIG_SPARSEMEM_STATIC is not set
140CONFIG_SPLIT_PTLOCK_CPUS=4 138CONFIG_SPLIT_PTLOCK_CPUS=4
139# CONFIG_HZ_48 is not set
140# CONFIG_HZ_100 is not set
141# CONFIG_HZ_128 is not set
142# CONFIG_HZ_250 is not set
143# CONFIG_HZ_256 is not set
144CONFIG_HZ_1000=y
145# CONFIG_HZ_1024 is not set
146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
147CONFIG_HZ=1000
141CONFIG_PREEMPT_NONE=y 148CONFIG_PREEMPT_NONE=y
142# CONFIG_PREEMPT_VOLUNTARY is not set 149# CONFIG_PREEMPT_VOLUNTARY is not set
143# CONFIG_PREEMPT is not set 150# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
index edfb9679a25a..8b0dd8651264 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -138,6 +136,15 @@ CONFIG_FLATMEM=y
138CONFIG_FLAT_NODE_MEM_MAP=y 136CONFIG_FLAT_NODE_MEM_MAP=y
139# CONFIG_SPARSEMEM_STATIC is not set 137# CONFIG_SPARSEMEM_STATIC is not set
140CONFIG_SPLIT_PTLOCK_CPUS=4 138CONFIG_SPLIT_PTLOCK_CPUS=4
139# CONFIG_HZ_48 is not set
140# CONFIG_HZ_100 is not set
141# CONFIG_HZ_128 is not set
142# CONFIG_HZ_250 is not set
143# CONFIG_HZ_256 is not set
144CONFIG_HZ_1000=y
145# CONFIG_HZ_1024 is not set
146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
147CONFIG_HZ=1000
141# CONFIG_PREEMPT_NONE is not set 148# CONFIG_PREEMPT_NONE is not set
142CONFIG_PREEMPT_VOLUNTARY=y 149CONFIG_PREEMPT_VOLUNTARY=y
143# CONFIG_PREEMPT is not set 150# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/sb1250-swarm_defconfig b/arch/mips/configs/sb1250-swarm_defconfig
index e388a3dae0a9..ff34ed66fe65 100644
--- a/arch/mips/configs/sb1250-swarm_defconfig
+++ b/arch/mips/configs/sb1250-swarm_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -149,6 +147,15 @@ CONFIG_FLATMEM=y
149CONFIG_FLAT_NODE_MEM_MAP=y 147CONFIG_FLAT_NODE_MEM_MAP=y
150# CONFIG_SPARSEMEM_STATIC is not set 148# CONFIG_SPARSEMEM_STATIC is not set
151CONFIG_SPLIT_PTLOCK_CPUS=4 149CONFIG_SPLIT_PTLOCK_CPUS=4
150# CONFIG_HZ_48 is not set
151# CONFIG_HZ_100 is not set
152# CONFIG_HZ_128 is not set
153# CONFIG_HZ_250 is not set
154# CONFIG_HZ_256 is not set
155CONFIG_HZ_1000=y
156# CONFIG_HZ_1024 is not set
157CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
158CONFIG_HZ=1000
152CONFIG_SMP=y 159CONFIG_SMP=y
153CONFIG_NR_CPUS=2 160CONFIG_NR_CPUS=2
154CONFIG_PREEMPT_NONE=y 161CONFIG_PREEMPT_NONE=y
diff --git a/arch/mips/configs/sead_defconfig b/arch/mips/configs/sead_defconfig
index 6b8a6a416a25..77edeae7f018 100644
--- a/arch/mips/configs/sead_defconfig
+++ b/arch/mips/configs/sead_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS_SEAD=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -134,6 +132,15 @@ CONFIG_FLATMEM=y
134CONFIG_FLAT_NODE_MEM_MAP=y 132CONFIG_FLAT_NODE_MEM_MAP=y
135# CONFIG_SPARSEMEM_STATIC is not set 133# CONFIG_SPARSEMEM_STATIC is not set
136CONFIG_SPLIT_PTLOCK_CPUS=4 134CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_HZ_48 is not set
136# CONFIG_HZ_100 is not set
137# CONFIG_HZ_128 is not set
138# CONFIG_HZ_250 is not set
139# CONFIG_HZ_256 is not set
140CONFIG_HZ_1000=y
141# CONFIG_HZ_1024 is not set
142CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
143CONFIG_HZ=1000
137CONFIG_PREEMPT_NONE=y 144CONFIG_PREEMPT_NONE=y
138# CONFIG_PREEMPT_VOLUNTARY is not set 145# CONFIG_PREEMPT_VOLUNTARY is not set
139# CONFIG_PREEMPT is not set 146# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/tb0226_defconfig b/arch/mips/configs/tb0226_defconfig
index dba0bdcdcf29..6aa229d54851 100644
--- a/arch/mips/configs/tb0226_defconfig
+++ b/arch/mips/configs/tb0226_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -134,6 +132,15 @@ CONFIG_FLATMEM=y
134CONFIG_FLAT_NODE_MEM_MAP=y 132CONFIG_FLAT_NODE_MEM_MAP=y
135# CONFIG_SPARSEMEM_STATIC is not set 133# CONFIG_SPARSEMEM_STATIC is not set
136CONFIG_SPLIT_PTLOCK_CPUS=4 134CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_HZ_48 is not set
136# CONFIG_HZ_100 is not set
137# CONFIG_HZ_128 is not set
138# CONFIG_HZ_250 is not set
139# CONFIG_HZ_256 is not set
140CONFIG_HZ_1000=y
141# CONFIG_HZ_1024 is not set
142CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
143CONFIG_HZ=1000
137CONFIG_PREEMPT_NONE=y 144CONFIG_PREEMPT_NONE=y
138# CONFIG_PREEMPT_VOLUNTARY is not set 145# CONFIG_PREEMPT_VOLUNTARY is not set
139# CONFIG_PREEMPT is not set 146# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/tb0229_defconfig b/arch/mips/configs/tb0229_defconfig
index 5a924c1a5803..a187b1f0004c 100644
--- a/arch/mips/configs/tb0229_defconfig
+++ b/arch/mips/configs/tb0229_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -134,6 +132,15 @@ CONFIG_FLATMEM=y
134CONFIG_FLAT_NODE_MEM_MAP=y 132CONFIG_FLAT_NODE_MEM_MAP=y
135# CONFIG_SPARSEMEM_STATIC is not set 133# CONFIG_SPARSEMEM_STATIC is not set
136CONFIG_SPLIT_PTLOCK_CPUS=4 134CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_HZ_48 is not set
136# CONFIG_HZ_100 is not set
137# CONFIG_HZ_128 is not set
138# CONFIG_HZ_250 is not set
139# CONFIG_HZ_256 is not set
140CONFIG_HZ_1000=y
141# CONFIG_HZ_1024 is not set
142CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
143CONFIG_HZ=1000
137CONFIG_PREEMPT_NONE=y 144CONFIG_PREEMPT_NONE=y
138# CONFIG_PREEMPT_VOLUNTARY is not set 145# CONFIG_PREEMPT_VOLUNTARY is not set
139# CONFIG_PREEMPT is not set 146# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig
index 9f215ea350dc..258457fcbe11 100644
--- a/arch/mips/configs/tb0287_defconfig
+++ b/arch/mips/configs/tb0287_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -135,6 +133,15 @@ CONFIG_FLATMEM=y
135CONFIG_FLAT_NODE_MEM_MAP=y 133CONFIG_FLAT_NODE_MEM_MAP=y
136# CONFIG_SPARSEMEM_STATIC is not set 134# CONFIG_SPARSEMEM_STATIC is not set
137CONFIG_SPLIT_PTLOCK_CPUS=4 135CONFIG_SPLIT_PTLOCK_CPUS=4
136# CONFIG_HZ_48 is not set
137# CONFIG_HZ_100 is not set
138# CONFIG_HZ_128 is not set
139# CONFIG_HZ_250 is not set
140# CONFIG_HZ_256 is not set
141CONFIG_HZ_1000=y
142# CONFIG_HZ_1024 is not set
143CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
144CONFIG_HZ=1000
138CONFIG_PREEMPT_NONE=y 145CONFIG_PREEMPT_NONE=y
139# CONFIG_PREEMPT_VOLUNTARY is not set 146# CONFIG_PREEMPT_VOLUNTARY is not set
140# CONFIG_PREEMPT is not set 147# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/workpad_defconfig b/arch/mips/configs/workpad_defconfig
index ac7765eb8da7..68af54f746e1 100644
--- a/arch/mips/configs/workpad_defconfig
+++ b/arch/mips/configs/workpad_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47CONFIG_MACH_VR41XX=y 45CONFIG_MACH_VR41XX=y
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_PREEMPT_NONE=y 140CONFIG_PREEMPT_NONE=y
134# CONFIG_PREEMPT_VOLUNTARY is not set 141# CONFIG_PREEMPT_VOLUNTARY is not set
135# CONFIG_PREEMPT is not set 142# CONFIG_PREEMPT is not set
diff --git a/arch/mips/configs/ddb5476_defconfig b/arch/mips/configs/wrppmc_defconfig
index 8d88ac1bbfeb..40572a3c8cac 100644
--- a/arch/mips/configs/ddb5476_defconfig
+++ b/arch/mips/configs/wrppmc_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17-rc2 3# Linux kernel version: 2.6.16.11
4# Mon Apr 24 14:51:00 2006 4# Fri May 5 17:11:22 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -32,6 +32,7 @@ CONFIG_MIPS=y
32# CONFIG_MIPS_ATLAS is not set 32# CONFIG_MIPS_ATLAS is not set
33# CONFIG_MIPS_MALTA is not set 33# CONFIG_MIPS_MALTA is not set
34# CONFIG_MIPS_SEAD is not set 34# CONFIG_MIPS_SEAD is not set
35CONFIG_WR_PPMC=y
35# CONFIG_MIPS_SIM is not set 36# CONFIG_MIPS_SIM is not set
36# CONFIG_MOMENCO_JAGUAR_ATX is not set 37# CONFIG_MOMENCO_JAGUAR_ATX is not set
37# CONFIG_MOMENCO_OCELOT is not set 38# CONFIG_MOMENCO_OCELOT is not set
@@ -41,8 +42,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 42# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 43# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 44# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45CONFIG_DDB5476=y
46# CONFIG_DDB5477 is not set 45# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 46# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 47# CONFIG_PMC_YOSEMITE is not set
@@ -64,24 +63,23 @@ CONFIG_DDB5476=y
64# CONFIG_TOSHIBA_RBTX4927 is not set 63# CONFIG_TOSHIBA_RBTX4927 is not set
65# CONFIG_TOSHIBA_RBTX4938 is not set 64# CONFIG_TOSHIBA_RBTX4938 is not set
66CONFIG_RWSEM_GENERIC_SPINLOCK=y 65CONFIG_RWSEM_GENERIC_SPINLOCK=y
67CONFIG_GENERIC_FIND_NEXT_BIT=y
68CONFIG_GENERIC_HWEIGHT=y
69CONFIG_GENERIC_CALIBRATE_DELAY=y 66CONFIG_GENERIC_CALIBRATE_DELAY=y
70CONFIG_DMA_NONCOHERENT=y 67CONFIG_DMA_NONCOHERENT=y
71CONFIG_DMA_NEED_PCI_MAP_STATE=y 68CONFIG_DMA_NEED_PCI_MAP_STATE=y
72CONFIG_I8259=y 69CONFIG_CPU_BIG_ENDIAN=y
73# CONFIG_CPU_BIG_ENDIAN is not set 70# CONFIG_CPU_LITTLE_ENDIAN is not set
74CONFIG_CPU_LITTLE_ENDIAN=y 71CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
75CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y 72CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
76CONFIG_IRQ_CPU=y 73CONFIG_IRQ_CPU=y
77CONFIG_DDB5XXX_COMMON=y 74CONFIG_MIPS_GT64120=y
75CONFIG_SWAP_IO_SPACE=y
76CONFIG_BOOT_ELF32=y
78CONFIG_MIPS_L1_CACHE_SHIFT=5 77CONFIG_MIPS_L1_CACHE_SHIFT=5
79CONFIG_HAVE_STD_PC_SERIAL_PORT=y
80 78
81# 79#
82# CPU selection 80# CPU selection
83# 81#
84# CONFIG_CPU_MIPS32_R1 is not set 82CONFIG_CPU_MIPS32_R1=y
85# CONFIG_CPU_MIPS32_R2 is not set 83# CONFIG_CPU_MIPS32_R2 is not set
86# CONFIG_CPU_MIPS64_R1 is not set 84# CONFIG_CPU_MIPS64_R1 is not set
87# CONFIG_CPU_MIPS64_R2 is not set 85# CONFIG_CPU_MIPS64_R2 is not set
@@ -92,7 +90,7 @@ CONFIG_HAVE_STD_PC_SERIAL_PORT=y
92# CONFIG_CPU_R4X00 is not set 90# CONFIG_CPU_R4X00 is not set
93# CONFIG_CPU_TX49XX is not set 91# CONFIG_CPU_TX49XX is not set
94# CONFIG_CPU_R5000 is not set 92# CONFIG_CPU_R5000 is not set
95CONFIG_CPU_R5432=y 93# CONFIG_CPU_R5432 is not set
96# CONFIG_CPU_R6000 is not set 94# CONFIG_CPU_R6000 is not set
97# CONFIG_CPU_NEVADA is not set 95# CONFIG_CPU_NEVADA is not set
98# CONFIG_CPU_R8000 is not set 96# CONFIG_CPU_R8000 is not set
@@ -100,11 +98,16 @@ CONFIG_CPU_R5432=y
100# CONFIG_CPU_RM7000 is not set 98# CONFIG_CPU_RM7000 is not set
101# CONFIG_CPU_RM9000 is not set 99# CONFIG_CPU_RM9000 is not set
102# CONFIG_CPU_SB1 is not set 100# CONFIG_CPU_SB1 is not set
103CONFIG_SYS_HAS_CPU_R5432=y 101CONFIG_SYS_HAS_CPU_MIPS32_R1=y
102CONFIG_SYS_HAS_CPU_MIPS32_R2=y
103CONFIG_SYS_HAS_CPU_MIPS64_R1=y
104CONFIG_SYS_HAS_CPU_NEVADA=y
105CONFIG_SYS_HAS_CPU_RM7000=y
106CONFIG_CPU_MIPS32=y
107CONFIG_CPU_MIPSR1=y
104CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y 108CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
105CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y 109CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
106CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y 110CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
107CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
108 111
109# 112#
110# Kernel type 113# Kernel type
@@ -115,11 +118,15 @@ CONFIG_PAGE_SIZE_4KB=y
115# CONFIG_PAGE_SIZE_8KB is not set 118# CONFIG_PAGE_SIZE_8KB is not set
116# CONFIG_PAGE_SIZE_16KB is not set 119# CONFIG_PAGE_SIZE_16KB is not set
117# CONFIG_PAGE_SIZE_64KB is not set 120# CONFIG_PAGE_SIZE_64KB is not set
121CONFIG_CPU_HAS_PREFETCH=y
118# CONFIG_MIPS_MT is not set 122# CONFIG_MIPS_MT is not set
123# CONFIG_64BIT_PHYS_ADDR is not set
124# CONFIG_CPU_ADVANCED is not set
119CONFIG_CPU_HAS_LLSC=y 125CONFIG_CPU_HAS_LLSC=y
120CONFIG_CPU_HAS_SYNC=y 126CONFIG_CPU_HAS_SYNC=y
121CONFIG_GENERIC_HARDIRQS=y 127CONFIG_GENERIC_HARDIRQS=y
122CONFIG_GENERIC_IRQ_PROBE=y 128CONFIG_GENERIC_IRQ_PROBE=y
129CONFIG_CPU_SUPPORTS_HIGHMEM=y
123CONFIG_ARCH_FLATMEM_ENABLE=y 130CONFIG_ARCH_FLATMEM_ENABLE=y
124CONFIG_SELECT_MEMORY_MODEL=y 131CONFIG_SELECT_MEMORY_MODEL=y
125CONFIG_FLATMEM_MANUAL=y 132CONFIG_FLATMEM_MANUAL=y
@@ -129,6 +136,15 @@ CONFIG_FLATMEM=y
129CONFIG_FLAT_NODE_MEM_MAP=y 136CONFIG_FLAT_NODE_MEM_MAP=y
130# CONFIG_SPARSEMEM_STATIC is not set 137# CONFIG_SPARSEMEM_STATIC is not set
131CONFIG_SPLIT_PTLOCK_CPUS=4 138CONFIG_SPLIT_PTLOCK_CPUS=4
139# CONFIG_HZ_48 is not set
140# CONFIG_HZ_100 is not set
141# CONFIG_HZ_128 is not set
142# CONFIG_HZ_250 is not set
143# CONFIG_HZ_256 is not set
144CONFIG_HZ_1000=y
145# CONFIG_HZ_1024 is not set
146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
147CONFIG_HZ=1000
132CONFIG_PREEMPT_NONE=y 148CONFIG_PREEMPT_NONE=y
133# CONFIG_PREEMPT_VOLUNTARY is not set 149# CONFIG_PREEMPT_VOLUNTARY is not set
134# CONFIG_PREEMPT is not set 150# CONFIG_PREEMPT is not set
@@ -145,27 +161,31 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
145# 161#
146CONFIG_LOCALVERSION="" 162CONFIG_LOCALVERSION=""
147CONFIG_LOCALVERSION_AUTO=y 163CONFIG_LOCALVERSION_AUTO=y
148CONFIG_SWAP=y 164# CONFIG_SWAP is not set
149CONFIG_SYSVIPC=y 165CONFIG_SYSVIPC=y
150# CONFIG_POSIX_MQUEUE is not set 166# CONFIG_POSIX_MQUEUE is not set
151# CONFIG_BSD_PROCESS_ACCT is not set 167CONFIG_BSD_PROCESS_ACCT=y
168# CONFIG_BSD_PROCESS_ACCT_V3 is not set
152CONFIG_SYSCTL=y 169CONFIG_SYSCTL=y
153# CONFIG_AUDIT is not set 170# CONFIG_AUDIT is not set
154# CONFIG_IKCONFIG is not set 171# CONFIG_IKCONFIG is not set
155CONFIG_RELAY=y
156CONFIG_INITRAMFS_SOURCE="" 172CONFIG_INITRAMFS_SOURCE=""
157# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 173# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
158CONFIG_EMBEDDED=y 174CONFIG_EMBEDDED=y
159CONFIG_KALLSYMS=y 175CONFIG_KALLSYMS=y
160# CONFIG_KALLSYMS_EXTRA_PASS is not set 176CONFIG_KALLSYMS_EXTRA_PASS=y
161CONFIG_HOTPLUG=y 177CONFIG_HOTPLUG=y
162CONFIG_PRINTK=y 178CONFIG_PRINTK=y
163CONFIG_BUG=y 179CONFIG_BUG=y
164CONFIG_ELF_CORE=y 180CONFIG_ELF_CORE=y
165CONFIG_BASE_FULL=y 181CONFIG_BASE_FULL=y
166CONFIG_FUTEX=y 182CONFIG_FUTEX=y
167CONFIG_EPOLL=y 183# CONFIG_EPOLL is not set
168CONFIG_SHMEM=y 184CONFIG_SHMEM=y
185CONFIG_CC_ALIGN_FUNCTIONS=0
186CONFIG_CC_ALIGN_LABELS=0
187CONFIG_CC_ALIGN_LOOPS=0
188CONFIG_CC_ALIGN_JUMPS=0
169CONFIG_SLAB=y 189CONFIG_SLAB=y
170# CONFIG_TINY_SHMEM is not set 190# CONFIG_TINY_SHMEM is not set
171CONFIG_BASE_SMALL=0 191CONFIG_BASE_SMALL=0
@@ -174,14 +194,18 @@ CONFIG_BASE_SMALL=0
174# 194#
175# Loadable module support 195# Loadable module support
176# 196#
177# CONFIG_MODULES is not set 197CONFIG_MODULES=y
198CONFIG_MODULE_UNLOAD=y
199# CONFIG_MODULE_FORCE_UNLOAD is not set
200CONFIG_OBSOLETE_MODPARM=y
201CONFIG_MODVERSIONS=y
202CONFIG_MODULE_SRCVERSION_ALL=y
203# CONFIG_KMOD is not set
178 204
179# 205#
180# Block layer 206# Block layer
181# 207#
182# CONFIG_LBD is not set 208# CONFIG_LBD is not set
183# CONFIG_BLK_DEV_IO_TRACE is not set
184# CONFIG_LSF is not set
185 209
186# 210#
187# IO Schedulers 211# IO Schedulers
@@ -201,7 +225,7 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
201# 225#
202CONFIG_HW_HAS_PCI=y 226CONFIG_HW_HAS_PCI=y
203CONFIG_PCI=y 227CONFIG_PCI=y
204CONFIG_ISA=y 228CONFIG_PCI_LEGACY_PROC=y
205CONFIG_MMU=y 229CONFIG_MMU=y
206 230
207# 231#
@@ -212,13 +236,16 @@ CONFIG_MMU=y
212# 236#
213# PCI Hotplug Support 237# PCI Hotplug Support
214# 238#
215# CONFIG_HOTPLUG_PCI is not set 239CONFIG_HOTPLUG_PCI=y
240# CONFIG_HOTPLUG_PCI_FAKE is not set
241# CONFIG_HOTPLUG_PCI_CPCI is not set
242# CONFIG_HOTPLUG_PCI_SHPC is not set
216 243
217# 244#
218# Executable file formats 245# Executable file formats
219# 246#
220CONFIG_BINFMT_ELF=y 247CONFIG_BINFMT_ELF=y
221# CONFIG_BINFMT_MISC is not set 248CONFIG_BINFMT_MISC=y
222CONFIG_TRAD_SIGNALS=y 249CONFIG_TRAD_SIGNALS=y
223 250
224# 251#
@@ -231,35 +258,33 @@ CONFIG_NET=y
231# 258#
232# CONFIG_NETDEBUG is not set 259# CONFIG_NETDEBUG is not set
233CONFIG_PACKET=y 260CONFIG_PACKET=y
234# CONFIG_PACKET_MMAP is not set 261CONFIG_PACKET_MMAP=y
235CONFIG_UNIX=y 262CONFIG_UNIX=y
236CONFIG_XFRM=y 263# CONFIG_NET_KEY is not set
237CONFIG_XFRM_USER=y
238CONFIG_NET_KEY=y
239CONFIG_INET=y 264CONFIG_INET=y
240# CONFIG_IP_MULTICAST is not set 265CONFIG_IP_MULTICAST=y
241# CONFIG_IP_ADVANCED_ROUTER is not set 266# CONFIG_IP_ADVANCED_ROUTER is not set
242CONFIG_IP_FIB_HASH=y 267CONFIG_IP_FIB_HASH=y
243CONFIG_IP_PNP=y 268CONFIG_IP_PNP=y
244# CONFIG_IP_PNP_DHCP is not set 269CONFIG_IP_PNP_DHCP=y
245CONFIG_IP_PNP_BOOTP=y 270CONFIG_IP_PNP_BOOTP=y
246# CONFIG_IP_PNP_RARP is not set 271CONFIG_IP_PNP_RARP=y
247# CONFIG_NET_IPIP is not set 272# CONFIG_NET_IPIP is not set
248# CONFIG_NET_IPGRE is not set 273# CONFIG_NET_IPGRE is not set
249# CONFIG_ARPD is not set 274CONFIG_IP_MROUTE=y
275# CONFIG_IP_PIMSM_V1 is not set
276# CONFIG_IP_PIMSM_V2 is not set
277CONFIG_ARPD=y
250# CONFIG_SYN_COOKIES is not set 278# CONFIG_SYN_COOKIES is not set
251# CONFIG_INET_AH is not set 279# CONFIG_INET_AH is not set
252# CONFIG_INET_ESP is not set 280# CONFIG_INET_ESP is not set
253# CONFIG_INET_IPCOMP is not set 281# CONFIG_INET_IPCOMP is not set
254# CONFIG_INET_XFRM_TUNNEL is not set
255# CONFIG_INET_TUNNEL is not set 282# CONFIG_INET_TUNNEL is not set
256CONFIG_INET_DIAG=y 283CONFIG_INET_DIAG=y
257CONFIG_INET_TCP_DIAG=y 284CONFIG_INET_TCP_DIAG=y
258# CONFIG_TCP_CONG_ADVANCED is not set 285# CONFIG_TCP_CONG_ADVANCED is not set
259CONFIG_TCP_CONG_BIC=y 286CONFIG_TCP_CONG_BIC=y
260# CONFIG_IPV6 is not set 287# CONFIG_IPV6 is not set
261# CONFIG_INET6_XFRM_TUNNEL is not set
262# CONFIG_INET6_TUNNEL is not set
263# CONFIG_NETFILTER is not set 288# CONFIG_NETFILTER is not set
264 289
265# 290#
@@ -301,13 +326,7 @@ CONFIG_TCP_CONG_BIC=y
301# CONFIG_HAMRADIO is not set 326# CONFIG_HAMRADIO is not set
302# CONFIG_IRDA is not set 327# CONFIG_IRDA is not set
303# CONFIG_BT is not set 328# CONFIG_BT is not set
304CONFIG_IEEE80211=y 329# CONFIG_IEEE80211 is not set
305# CONFIG_IEEE80211_DEBUG is not set
306CONFIG_IEEE80211_CRYPT_WEP=y
307CONFIG_IEEE80211_CRYPT_CCMP=y
308CONFIG_IEEE80211_SOFTMAC=y
309# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
310CONFIG_WIRELESS_EXT=y
311 330
312# 331#
313# Device Drivers 332# Device Drivers
@@ -318,13 +337,12 @@ CONFIG_WIRELESS_EXT=y
318# 337#
319CONFIG_STANDALONE=y 338CONFIG_STANDALONE=y
320CONFIG_PREVENT_FIRMWARE_BUILD=y 339CONFIG_PREVENT_FIRMWARE_BUILD=y
321CONFIG_FW_LOADER=y 340# CONFIG_FW_LOADER is not set
322 341
323# 342#
324# Connector - unified userspace <-> kernelspace linker 343# Connector - unified userspace <-> kernelspace linker
325# 344#
326CONFIG_CONNECTOR=y 345# CONFIG_CONNECTOR is not set
327CONFIG_PROC_EVENTS=y
328 346
329# 347#
330# Memory Technology Devices (MTD) 348# Memory Technology Devices (MTD)
@@ -339,7 +357,6 @@ CONFIG_PROC_EVENTS=y
339# 357#
340# Plug and Play support 358# Plug and Play support
341# 359#
342# CONFIG_PNP is not set
343 360
344# 361#
345# Block devices 362# Block devices
@@ -352,53 +369,25 @@ CONFIG_PROC_EVENTS=y
352# CONFIG_BLK_DEV_LOOP is not set 369# CONFIG_BLK_DEV_LOOP is not set
353# CONFIG_BLK_DEV_NBD is not set 370# CONFIG_BLK_DEV_NBD is not set
354# CONFIG_BLK_DEV_SX8 is not set 371# CONFIG_BLK_DEV_SX8 is not set
355# CONFIG_BLK_DEV_RAM is not set 372CONFIG_BLK_DEV_RAM=y
356# CONFIG_BLK_DEV_INITRD is not set 373CONFIG_BLK_DEV_RAM_COUNT=16
357CONFIG_CDROM_PKTCDVD=y 374CONFIG_BLK_DEV_RAM_SIZE=4096
358CONFIG_CDROM_PKTCDVD_BUFFERS=8 375CONFIG_BLK_DEV_INITRD=y
359# CONFIG_CDROM_PKTCDVD_WCACHE is not set 376# CONFIG_CDROM_PKTCDVD is not set
360CONFIG_ATA_OVER_ETH=y 377# CONFIG_ATA_OVER_ETH is not set
361 378
362# 379#
363# ATA/ATAPI/MFM/RLL support 380# ATA/ATAPI/MFM/RLL support
364# 381#
365CONFIG_IDE=y 382# CONFIG_IDE is not set
366CONFIG_BLK_DEV_IDE=y
367
368#
369# Please see Documentation/ide.txt for help/info on IDE drives
370#
371# CONFIG_BLK_DEV_IDE_SATA is not set
372CONFIG_BLK_DEV_IDEDISK=y
373# CONFIG_IDEDISK_MULTI_MODE is not set
374# CONFIG_BLK_DEV_IDECD is not set
375# CONFIG_BLK_DEV_IDETAPE is not set
376# CONFIG_BLK_DEV_IDEFLOPPY is not set
377# CONFIG_IDE_TASK_IOCTL is not set
378
379#
380# IDE chipset support/bugfixes
381#
382CONFIG_IDE_GENERIC=y
383# CONFIG_BLK_DEV_IDEPCI is not set
384# CONFIG_IDE_ARM is not set
385# CONFIG_IDE_CHIPSETS is not set
386# CONFIG_BLK_DEV_IDEDMA is not set
387# CONFIG_IDEDMA_AUTO is not set
388# CONFIG_BLK_DEV_HD is not set
389 383
390# 384#
391# SCSI device support 385# SCSI device support
392# 386#
393CONFIG_RAID_ATTRS=y 387# CONFIG_RAID_ATTRS is not set
394# CONFIG_SCSI is not set 388# CONFIG_SCSI is not set
395 389
396# 390#
397# Old CD-ROM drivers (not SCSI, not IDE)
398#
399# CONFIG_CD_NO_IDESCSI is not set
400
401#
402# Multi-device support (RAID and LVM) 391# Multi-device support (RAID and LVM)
403# 392#
404# CONFIG_MD is not set 393# CONFIG_MD is not set
@@ -440,34 +429,48 @@ CONFIG_PHYLIB=y
440# 429#
441# MII PHY device drivers 430# MII PHY device drivers
442# 431#
443CONFIG_MARVELL_PHY=y 432# CONFIG_MARVELL_PHY is not set
444CONFIG_DAVICOM_PHY=y 433# CONFIG_DAVICOM_PHY is not set
445CONFIG_QSEMI_PHY=y 434# CONFIG_QSEMI_PHY is not set
446CONFIG_LXT_PHY=y 435# CONFIG_LXT_PHY is not set
447CONFIG_CICADA_PHY=y 436# CONFIG_CICADA_PHY is not set
448 437
449# 438#
450# Ethernet (10 or 100Mbit) 439# Ethernet (10 or 100Mbit)
451# 440#
452CONFIG_NET_ETHERNET=y 441CONFIG_NET_ETHERNET=y
453# CONFIG_MII is not set 442CONFIG_MII=y
454# CONFIG_HAPPYMEAL is not set 443# CONFIG_HAPPYMEAL is not set
455# CONFIG_SUNGEM is not set 444# CONFIG_SUNGEM is not set
456# CONFIG_CASSINI is not set 445# CONFIG_CASSINI is not set
457# CONFIG_NET_VENDOR_3COM is not set 446# CONFIG_NET_VENDOR_3COM is not set
458# CONFIG_NET_VENDOR_SMC is not set
459# CONFIG_DM9000 is not set 447# CONFIG_DM9000 is not set
460# CONFIG_NET_VENDOR_RACAL is not set
461 448
462# 449#
463# Tulip family network device support 450# Tulip family network device support
464# 451#
465# CONFIG_NET_TULIP is not set 452# CONFIG_NET_TULIP is not set
466# CONFIG_AT1700 is not set
467# CONFIG_DEPCA is not set
468# CONFIG_HP100 is not set 453# CONFIG_HP100 is not set
469# CONFIG_NET_ISA is not set 454CONFIG_NET_PCI=y
470# CONFIG_NET_PCI is not set 455# CONFIG_PCNET32 is not set
456# CONFIG_AMD8111_ETH is not set
457# CONFIG_ADAPTEC_STARFIRE is not set
458# CONFIG_B44 is not set
459# CONFIG_FORCEDETH is not set
460# CONFIG_DGRS is not set
461# CONFIG_EEPRO100 is not set
462CONFIG_E100=y
463# CONFIG_FEALNX is not set
464# CONFIG_NATSEMI is not set
465# CONFIG_NE2K_PCI is not set
466# CONFIG_8139CP is not set
467# CONFIG_8139TOO is not set
468# CONFIG_SIS900 is not set
469# CONFIG_EPIC100 is not set
470# CONFIG_SUNDANCE is not set
471# CONFIG_TLAN is not set
472# CONFIG_VIA_RHINE is not set
473# CONFIG_LAN_SAA9730 is not set
471 474
472# 475#
473# Ethernet (1000 Mbit) 476# Ethernet (1000 Mbit)
@@ -483,6 +486,7 @@ CONFIG_NET_ETHERNET=y
483# CONFIG_SKGE is not set 486# CONFIG_SKGE is not set
484# CONFIG_SKY2 is not set 487# CONFIG_SKY2 is not set
485# CONFIG_SK98LIN is not set 488# CONFIG_SK98LIN is not set
489# CONFIG_VIA_VELOCITY is not set
486# CONFIG_TIGON3 is not set 490# CONFIG_TIGON3 is not set
487# CONFIG_BNX2 is not set 491# CONFIG_BNX2 is not set
488 492
@@ -529,46 +533,18 @@ CONFIG_NET_ETHERNET=y
529# 533#
530# Input device support 534# Input device support
531# 535#
532CONFIG_INPUT=y 536# CONFIG_INPUT is not set
533
534#
535# Userland interfaces
536#
537CONFIG_INPUT_MOUSEDEV=y
538CONFIG_INPUT_MOUSEDEV_PSAUX=y
539CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
540CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
541# CONFIG_INPUT_JOYDEV is not set
542# CONFIG_INPUT_TSDEV is not set
543# CONFIG_INPUT_EVDEV is not set
544# CONFIG_INPUT_EVBUG is not set
545
546#
547# Input Device Drivers
548#
549# CONFIG_INPUT_KEYBOARD is not set
550# CONFIG_INPUT_MOUSE is not set
551# CONFIG_INPUT_JOYSTICK is not set
552# CONFIG_INPUT_TOUCHSCREEN is not set
553# CONFIG_INPUT_MISC is not set
554 537
555# 538#
556# Hardware I/O ports 539# Hardware I/O ports
557# 540#
558CONFIG_SERIO=y 541# CONFIG_SERIO is not set
559# CONFIG_SERIO_I8042 is not set
560CONFIG_SERIO_SERPORT=y
561# CONFIG_SERIO_PCIPS2 is not set
562# CONFIG_SERIO_LIBPS2 is not set
563CONFIG_SERIO_RAW=y
564# CONFIG_GAMEPORT is not set 542# CONFIG_GAMEPORT is not set
565 543
566# 544#
567# Character devices 545# Character devices
568# 546#
569CONFIG_VT=y 547# CONFIG_VT is not set
570CONFIG_VT_CONSOLE=y
571CONFIG_HW_CONSOLE=y
572# CONFIG_SERIAL_NONSTANDARD is not set 548# CONFIG_SERIAL_NONSTANDARD is not set
573 549
574# 550#
@@ -576,9 +552,8 @@ CONFIG_HW_CONSOLE=y
576# 552#
577CONFIG_SERIAL_8250=y 553CONFIG_SERIAL_8250=y
578CONFIG_SERIAL_8250_CONSOLE=y 554CONFIG_SERIAL_8250_CONSOLE=y
579CONFIG_SERIAL_8250_PCI=y 555CONFIG_SERIAL_8250_NR_UARTS=1
580CONFIG_SERIAL_8250_NR_UARTS=4 556CONFIG_SERIAL_8250_RUNTIME_UARTS=1
581CONFIG_SERIAL_8250_RUNTIME_UARTS=4
582# CONFIG_SERIAL_8250_EXTENDED is not set 557# CONFIG_SERIAL_8250_EXTENDED is not set
583 558
584# 559#
@@ -600,8 +575,7 @@ CONFIG_LEGACY_PTY_COUNT=256
600# Watchdog Cards 575# Watchdog Cards
601# 576#
602# CONFIG_WATCHDOG is not set 577# CONFIG_WATCHDOG is not set
603# CONFIG_RTC is not set 578CONFIG_RTC=y
604# CONFIG_GEN_RTC is not set
605# CONFIG_DTLK is not set 579# CONFIG_DTLK is not set
606# CONFIG_R3964 is not set 580# CONFIG_R3964 is not set
607# CONFIG_APPLICOM is not set 581# CONFIG_APPLICOM is not set
@@ -637,14 +611,20 @@ CONFIG_LEGACY_PTY_COUNT=256
637# 611#
638# Hardware Monitoring support 612# Hardware Monitoring support
639# 613#
640# CONFIG_HWMON is not set 614CONFIG_HWMON=y
641# CONFIG_HWMON_VID is not set 615# CONFIG_HWMON_VID is not set
616# CONFIG_SENSORS_F71805F is not set
617# CONFIG_HWMON_DEBUG_CHIP is not set
642 618
643# 619#
644# Misc devices 620# Misc devices
645# 621#
646 622
647# 623#
624# Multimedia Capabilities Port drivers
625#
626
627#
648# Multimedia devices 628# Multimedia devices
649# 629#
650# CONFIG_VIDEO_DEV is not set 630# CONFIG_VIDEO_DEV is not set
@@ -657,49 +637,7 @@ CONFIG_LEGACY_PTY_COUNT=256
657# 637#
658# Graphics support 638# Graphics support
659# 639#
660CONFIG_FB=y 640# CONFIG_FB is not set
661# CONFIG_FB_CFB_FILLRECT is not set
662# CONFIG_FB_CFB_COPYAREA is not set
663# CONFIG_FB_CFB_IMAGEBLIT is not set
664# CONFIG_FB_MACMODES is not set
665CONFIG_FB_FIRMWARE_EDID=y
666# CONFIG_FB_MODE_HELPERS is not set
667# CONFIG_FB_TILEBLITTING is not set
668# CONFIG_FB_CIRRUS is not set
669# CONFIG_FB_PM2 is not set
670# CONFIG_FB_CYBER2000 is not set
671# CONFIG_FB_ASILIANT is not set
672# CONFIG_FB_IMSTT is not set
673# CONFIG_FB_S1D13XXX is not set
674# CONFIG_FB_NVIDIA is not set
675# CONFIG_FB_RIVA is not set
676# CONFIG_FB_MATROX is not set
677# CONFIG_FB_RADEON is not set
678# CONFIG_FB_ATY128 is not set
679# CONFIG_FB_ATY is not set
680# CONFIG_FB_SAVAGE is not set
681# CONFIG_FB_SIS is not set
682# CONFIG_FB_NEOMAGIC is not set
683# CONFIG_FB_KYRO is not set
684# CONFIG_FB_3DFX is not set
685# CONFIG_FB_VOODOO1 is not set
686# CONFIG_FB_SMIVGX is not set
687# CONFIG_FB_TRIDENT is not set
688# CONFIG_FB_VIRTUAL is not set
689
690#
691# Console display driver support
692#
693# CONFIG_VGA_CONSOLE is not set
694# CONFIG_MDA_CONSOLE is not set
695CONFIG_DUMMY_CONSOLE=y
696# CONFIG_FRAMEBUFFER_CONSOLE is not set
697
698#
699# Logo configuration
700#
701# CONFIG_LOGO is not set
702# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
703 641
704# 642#
705# Sound 643# Sound
@@ -711,7 +649,6 @@ CONFIG_DUMMY_CONSOLE=y
711# 649#
712CONFIG_USB_ARCH_HAS_HCD=y 650CONFIG_USB_ARCH_HAS_HCD=y
713CONFIG_USB_ARCH_HAS_OHCI=y 651CONFIG_USB_ARCH_HAS_OHCI=y
714CONFIG_USB_ARCH_HAS_EHCI=y
715# CONFIG_USB is not set 652# CONFIG_USB is not set
716 653
717# 654#
@@ -729,19 +666,6 @@ CONFIG_USB_ARCH_HAS_EHCI=y
729# CONFIG_MMC is not set 666# CONFIG_MMC is not set
730 667
731# 668#
732# LED devices
733#
734# CONFIG_NEW_LEDS is not set
735
736#
737# LED drivers
738#
739
740#
741# LED Triggers
742#
743
744#
745# InfiniBand support 669# InfiniBand support
746# 670#
747# CONFIG_INFINIBAND is not set 671# CONFIG_INFINIBAND is not set
@@ -751,16 +675,9 @@ CONFIG_USB_ARCH_HAS_EHCI=y
751# 675#
752 676
753# 677#
754# Real Time Clock
755#
756# CONFIG_RTC_CLASS is not set
757
758#
759# File systems 678# File systems
760# 679#
761CONFIG_EXT2_FS=y 680# CONFIG_EXT2_FS is not set
762# CONFIG_EXT2_FS_XATTR is not set
763# CONFIG_EXT2_FS_XIP is not set
764# CONFIG_EXT3_FS is not set 681# CONFIG_EXT3_FS is not set
765# CONFIG_REISERFS_FS is not set 682# CONFIG_REISERFS_FS is not set
766# CONFIG_JFS_FS is not set 683# CONFIG_JFS_FS is not set
@@ -774,7 +691,7 @@ CONFIG_INOTIFY=y
774CONFIG_DNOTIFY=y 691CONFIG_DNOTIFY=y
775# CONFIG_AUTOFS_FS is not set 692# CONFIG_AUTOFS_FS is not set
776# CONFIG_AUTOFS4_FS is not set 693# CONFIG_AUTOFS4_FS is not set
777CONFIG_FUSE_FS=y 694# CONFIG_FUSE_FS is not set
778 695
779# 696#
780# CD-ROM/DVD Filesystems 697# CD-ROM/DVD Filesystems
@@ -795,9 +712,10 @@ CONFIG_FUSE_FS=y
795CONFIG_PROC_FS=y 712CONFIG_PROC_FS=y
796CONFIG_PROC_KCORE=y 713CONFIG_PROC_KCORE=y
797CONFIG_SYSFS=y 714CONFIG_SYSFS=y
798# CONFIG_TMPFS is not set 715CONFIG_TMPFS=y
799# CONFIG_HUGETLB_PAGE is not set 716# CONFIG_HUGETLB_PAGE is not set
800CONFIG_RAMFS=y 717CONFIG_RAMFS=y
718# CONFIG_RELAYFS_FS is not set
801# CONFIG_CONFIGFS_FS is not set 719# CONFIG_CONFIGFS_FS is not set
802 720
803# 721#
@@ -821,12 +739,14 @@ CONFIG_RAMFS=y
821# Network File Systems 739# Network File Systems
822# 740#
823CONFIG_NFS_FS=y 741CONFIG_NFS_FS=y
824# CONFIG_NFS_V3 is not set 742CONFIG_NFS_V3=y
743# CONFIG_NFS_V3_ACL is not set
825# CONFIG_NFS_V4 is not set 744# CONFIG_NFS_V4 is not set
826# CONFIG_NFS_DIRECTIO is not set 745# CONFIG_NFS_DIRECTIO is not set
827# CONFIG_NFSD is not set 746# CONFIG_NFSD is not set
828CONFIG_ROOT_NFS=y 747CONFIG_ROOT_NFS=y
829CONFIG_LOCKD=y 748CONFIG_LOCKD=y
749CONFIG_LOCKD_V4=y
830CONFIG_NFS_COMMON=y 750CONFIG_NFS_COMMON=y
831CONFIG_SUNRPC=y 751CONFIG_SUNRPC=y
832# CONFIG_RPCSEC_GSS_KRB5 is not set 752# CONFIG_RPCSEC_GSS_KRB5 is not set
@@ -861,46 +781,19 @@ CONFIG_MSDOS_PARTITION=y
861# CONFIG_MAGIC_SYSRQ is not set 781# CONFIG_MAGIC_SYSRQ is not set
862# CONFIG_DEBUG_KERNEL is not set 782# CONFIG_DEBUG_KERNEL is not set
863CONFIG_LOG_BUF_SHIFT=14 783CONFIG_LOG_BUF_SHIFT=14
864# CONFIG_DEBUG_FS is not set
865# CONFIG_UNWIND_INFO is not set
866CONFIG_CROSSCOMPILE=y 784CONFIG_CROSSCOMPILE=y
867CONFIG_CMDLINE="ip=any" 785CONFIG_CMDLINE="console=ttyS0,115200n8"
868 786
869# 787#
870# Security options 788# Security options
871# 789#
872CONFIG_KEYS=y 790# CONFIG_KEYS is not set
873CONFIG_KEYS_DEBUG_PROC_KEYS=y
874# CONFIG_SECURITY is not set 791# CONFIG_SECURITY is not set
875 792
876# 793#
877# Cryptographic options 794# Cryptographic options
878# 795#
879CONFIG_CRYPTO=y 796# CONFIG_CRYPTO is not set
880CONFIG_CRYPTO_HMAC=y
881CONFIG_CRYPTO_NULL=y
882CONFIG_CRYPTO_MD4=y
883CONFIG_CRYPTO_MD5=y
884CONFIG_CRYPTO_SHA1=y
885CONFIG_CRYPTO_SHA256=y
886CONFIG_CRYPTO_SHA512=y
887CONFIG_CRYPTO_WP512=y
888CONFIG_CRYPTO_TGR192=y
889CONFIG_CRYPTO_DES=y
890CONFIG_CRYPTO_BLOWFISH=y
891CONFIG_CRYPTO_TWOFISH=y
892CONFIG_CRYPTO_SERPENT=y
893CONFIG_CRYPTO_AES=y
894CONFIG_CRYPTO_CAST5=y
895CONFIG_CRYPTO_CAST6=y
896CONFIG_CRYPTO_TEA=y
897CONFIG_CRYPTO_ARC4=y
898CONFIG_CRYPTO_KHAZAD=y
899CONFIG_CRYPTO_ANUBIS=y
900CONFIG_CRYPTO_DEFLATE=y
901CONFIG_CRYPTO_MICHAEL_MIC=y
902CONFIG_CRYPTO_CRC32C=y
903# CONFIG_CRYPTO_TEST is not set
904 797
905# 798#
906# Hardware crypto devices 799# Hardware crypto devices
@@ -909,9 +802,7 @@ CONFIG_CRYPTO_CRC32C=y
909# 802#
910# Library routines 803# Library routines
911# 804#
912# CONFIG_CRC_CCITT is not set 805CONFIG_CRC_CCITT=y
913CONFIG_CRC16=y 806CONFIG_CRC16=y
914CONFIG_CRC32=y 807CONFIG_CRC32=y
915CONFIG_LIBCRC32C=y 808CONFIG_LIBCRC32C=y
916CONFIG_ZLIB_INFLATE=y
917CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig
index b52d709de962..7ece2c008e9b 100644
--- a/arch/mips/configs/yosemite_defconfig
+++ b/arch/mips/configs/yosemite_defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48CONFIG_PMC_YOSEMITE=y 46CONFIG_PMC_YOSEMITE=y
@@ -130,6 +128,15 @@ CONFIG_FLATMEM=y
130CONFIG_FLAT_NODE_MEM_MAP=y 128CONFIG_FLAT_NODE_MEM_MAP=y
131# CONFIG_SPARSEMEM_STATIC is not set 129# CONFIG_SPARSEMEM_STATIC is not set
132CONFIG_SPLIT_PTLOCK_CPUS=4 130CONFIG_SPLIT_PTLOCK_CPUS=4
131# CONFIG_HZ_48 is not set
132# CONFIG_HZ_100 is not set
133# CONFIG_HZ_128 is not set
134# CONFIG_HZ_250 is not set
135# CONFIG_HZ_256 is not set
136CONFIG_HZ_1000=y
137# CONFIG_HZ_1024 is not set
138CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
139CONFIG_HZ=1000
133CONFIG_SMP=y 140CONFIG_SMP=y
134CONFIG_NR_CPUS=2 141CONFIG_NR_CPUS=2
135CONFIG_PREEMPT_NONE=y 142CONFIG_PREEMPT_NONE=y
diff --git a/arch/mips/ddb5xxx/common/prom.c b/arch/mips/ddb5xxx/common/prom.c
index b8d1f7489f3b..00c62c1c28a3 100644
--- a/arch/mips/ddb5xxx/common/prom.c
+++ b/arch/mips/ddb5xxx/common/prom.c
@@ -56,13 +56,7 @@ void __init prom_init(void)
56 56
57 mips_machgroup = MACH_GROUP_NEC_DDB; 57 mips_machgroup = MACH_GROUP_NEC_DDB;
58 58
59#if defined(CONFIG_DDB5074) 59#if defined(CONFIG_DDB5477)
60 mips_machtype = MACH_NEC_DDB5074;
61 add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM);
62#elif defined(CONFIG_DDB5476)
63 mips_machtype = MACH_NEC_DDB5476;
64 add_memory_region(0, DDB_SDRAM_SIZE, BOOT_MEM_RAM);
65#elif defined(CONFIG_DDB5477)
66 ddb5477_runtime_detection(); 60 ddb5477_runtime_detection();
67 add_memory_region(0, board_ram_size, BOOT_MEM_RAM); 61 add_memory_region(0, board_ram_size, BOOT_MEM_RAM);
68#endif 62#endif
diff --git a/arch/mips/ddb5xxx/ddb5074/Makefile b/arch/mips/ddb5xxx/ddb5074/Makefile
deleted file mode 100644
index 304c02107b46..000000000000
--- a/arch/mips/ddb5xxx/ddb5074/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for the NEC DDB Vrc-5074 specific kernel interface routines
3# under Linux.
4#
5
6obj-y += setup.o irq.o nile4_pic.o
7
8EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/ddb5xxx/ddb5074/irq.c b/arch/mips/ddb5xxx/ddb5074/irq.c
deleted file mode 100644
index 60c087b7738c..000000000000
--- a/arch/mips/ddb5xxx/ddb5074/irq.c
+++ /dev/null
@@ -1,169 +0,0 @@
1/*
2 * arch/mips/ddb5074/irq.c -- NEC DDB Vrc-5074 interrupt routines
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 */
7#include <linux/init.h>
8#include <linux/irq.h>
9#include <linux/signal.h>
10#include <linux/sched.h>
11#include <linux/types.h>
12#include <linux/interrupt.h>
13#include <linux/ioport.h>
14
15#include <asm/i8259.h>
16#include <asm/io.h>
17#include <asm/irq_cpu.h>
18#include <asm/ptrace.h>
19#include <asm/nile4.h>
20#include <asm/ddb5xxx/ddb5xxx.h>
21#include <asm/ddb5xxx/ddb5074.h>
22
23
24static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
25
26#define M1543_PNP_CONFIG 0x03f0 /* PnP Config Port */
27#define M1543_PNP_INDEX 0x03f0 /* PnP Index Port */
28#define M1543_PNP_DATA 0x03f1 /* PnP Data Port */
29
30#define M1543_PNP_ALT_CONFIG 0x0370 /* Alternative PnP Config Port */
31#define M1543_PNP_ALT_INDEX 0x0370 /* Alternative PnP Index Port */
32#define M1543_PNP_ALT_DATA 0x0371 /* Alternative PnP Data Port */
33
34#define M1543_INT1_MASTER_CTRL 0x0020 /* INT_1 (master) Control Register */
35#define M1543_INT1_MASTER_MASK 0x0021 /* INT_1 (master) Mask Register */
36
37#define M1543_INT1_SLAVE_CTRL 0x00a0 /* INT_1 (slave) Control Register */
38#define M1543_INT1_SLAVE_MASK 0x00a1 /* INT_1 (slave) Mask Register */
39
40#define M1543_INT1_MASTER_ELCR 0x04d0 /* INT_1 (master) Edge/Level Control */
41#define M1543_INT1_SLAVE_ELCR 0x04d1 /* INT_1 (slave) Edge/Level Control */
42
43
44static void m1543_irq_setup(void)
45{
46 /*
47 * The ALI M1543 has 13 interrupt inputs, IRQ1..IRQ13. Not all
48 * the possible IO sources in the M1543 are in use by us. We will
49 * use the following mapping:
50 *
51 * IRQ1 - keyboard (default set by M1543)
52 * IRQ3 - reserved for UART B (default set by M1543) (note that
53 * the schematics for the DDB Vrc-5074 board seem to
54 * indicate that IRQ3 is connected to the DS1386
55 * watchdog timer interrupt output so we might have
56 * a conflict)
57 * IRQ4 - reserved for UART A (default set by M1543)
58 * IRQ5 - parallel (default set by M1543)
59 * IRQ8 - DS1386 time of day (RTC) interrupt
60 * IRQ12 - mouse
61 */
62
63 /*
64 * Assing mouse interrupt to IRQ12
65 */
66
67 /* Enter configuration mode */
68 outb(0x51, M1543_PNP_CONFIG);
69 outb(0x23, M1543_PNP_CONFIG);
70
71 /* Select logical device 7 (Keyboard) */
72 outb(0x07, M1543_PNP_INDEX);
73 outb(0x07, M1543_PNP_DATA);
74
75 /* Select IRQ12 */
76 outb(0x72, M1543_PNP_INDEX);
77 outb(0x0c, M1543_PNP_DATA);
78
79 outb(0x30, M1543_PNP_INDEX);
80 printk("device 7, 0x30: %02x\n",inb(M1543_PNP_DATA));
81
82 outb(0x70, M1543_PNP_INDEX);
83 printk("device 7, 0x70: %02x\n",inb(M1543_PNP_DATA));
84
85 /* Leave configration mode */
86 outb(0xbb, M1543_PNP_CONFIG);
87
88
89}
90
91static void ddb_local0_irqdispatch(struct pt_regs *regs)
92{
93 u32 mask;
94 int nile4_irq;
95
96 mask = nile4_get_irq_stat(0);
97
98 /* Handle the timer interrupt first */
99#if 0
100 if (mask & (1 << NILE4_INT_GPT)) {
101 do_IRQ(nile4_to_irq(NILE4_INT_GPT), regs);
102 mask &= ~(1 << NILE4_INT_GPT);
103 }
104#endif
105 for (nile4_irq = 0; mask; nile4_irq++, mask >>= 1)
106 if (mask & 1) {
107 if (nile4_irq == NILE4_INT_INTE) {
108 int i8259_irq;
109
110 nile4_clear_irq(NILE4_INT_INTE);
111 i8259_irq = nile4_i8259_iack();
112 do_IRQ(i8259_irq, regs);
113 } else
114 do_IRQ(nile4_to_irq(nile4_irq), regs);
115
116 }
117}
118
119static void ddb_local1_irqdispatch(void)
120{
121 printk("ddb_local1_irqdispatch called\n");
122}
123
124static void ddb_buserror_irq(void)
125{
126 printk("ddb_buserror_irq called\n");
127}
128
129static void ddb_8254timer_irq(void)
130{
131 printk("ddb_8254timer_irq called\n");
132}
133
134asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
135{
136 unsigned int pending = read_c0_cause() & read_c0_status();
137
138 if (pending & CAUSEF_IP2)
139 ddb_local0_irqdispatch(regs);
140 else if (pending & CAUSEF_IP3)
141 ddb_local1_irqdispatch();
142 else if (pending & CAUSEF_IP6)
143 ddb_buserror_irq();
144 else if (pending & (CAUSEF_IP4 | CAUSEF_IP5))
145 ddb_8254timer_irq();
146}
147
148void __init arch_init_irq(void)
149{
150 /* setup cascade interrupts */
151 setup_irq(NILE4_IRQ_BASE + NILE4_INT_INTE, &irq_cascade);
152 setup_irq(CPU_IRQ_BASE + CPU_NILE4_CASCADE, &irq_cascade);
153
154 nile4_irq_setup(NILE4_IRQ_BASE);
155 m1543_irq_setup();
156 init_i8259_irqs();
157
158
159 printk("CPU_IRQ_BASE: %d\n",CPU_IRQ_BASE);
160
161 mips_cpu_irq_init(CPU_IRQ_BASE);
162
163 printk("enabling 8259 cascade\n");
164
165 ddb5074_led_hex(0);
166
167 /* Enable the interrupt cascade */
168 nile4_enable_irq(NILE4_IRQ_BASE+IRQ_I8259_CASCADE);
169}
diff --git a/arch/mips/ddb5xxx/ddb5074/nile4_pic.c b/arch/mips/ddb5xxx/ddb5074/nile4_pic.c
deleted file mode 100644
index 8743ffce8653..000000000000
--- a/arch/mips/ddb5xxx/ddb5074/nile4_pic.c
+++ /dev/null
@@ -1,286 +0,0 @@
1/*
2 * arch/mips/ddb5476/nile4.c --
3 * low-level PIC code for NEC Vrc-5476 (Nile 4)
4 *
5 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
6 * Sony Software Development Center Europe (SDCE), Brussels
7 *
8 * Copyright 2001 MontaVista Software Inc.
9 * Author: jsun@mvista.com or jsun@junsun.net
10 *
11 */
12#include <linux/config.h>
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/ioport.h>
17
18#include <asm/addrspace.h>
19
20#include <asm/ddb5xxx/ddb5xxx.h>
21
22static int irq_base;
23
24/*
25 * Interrupt Programming
26 */
27void nile4_map_irq(int nile4_irq, int cpu_irq)
28{
29 u32 offset, t;
30
31 offset = DDB_INTCTRL;
32 if (nile4_irq >= 8) {
33 offset += 4;
34 nile4_irq -= 8;
35 }
36 t = ddb_in32(offset);
37 t &= ~(7 << (nile4_irq * 4));
38 t |= cpu_irq << (nile4_irq * 4);
39 ddb_out32(offset, t);
40}
41
42void nile4_map_irq_all(int cpu_irq)
43{
44 u32 all, t;
45
46 all = cpu_irq;
47 all |= all << 4;
48 all |= all << 8;
49 all |= all << 16;
50 t = ddb_in32(DDB_INTCTRL);
51 t &= 0x88888888;
52 t |= all;
53 ddb_out32(DDB_INTCTRL, t);
54 t = ddb_in32(DDB_INTCTRL + 4);
55 t &= 0x88888888;
56 t |= all;
57 ddb_out32(DDB_INTCTRL + 4, t);
58}
59
60void nile4_enable_irq(unsigned int nile4_irq)
61{
62 u32 offset, t;
63
64 nile4_irq-=irq_base;
65
66 ddb5074_led_hex(8);
67
68 offset = DDB_INTCTRL;
69 if (nile4_irq >= 8) {
70 offset += 4;
71 nile4_irq -= 8;
72 }
73 ddb5074_led_hex(9);
74 t = ddb_in32(offset);
75 ddb5074_led_hex(0xa);
76 t |= 8 << (nile4_irq * 4);
77 ddb_out32(offset, t);
78 ddb5074_led_hex(0xb);
79}
80
81void nile4_disable_irq(unsigned int nile4_irq)
82{
83 u32 offset, t;
84
85 nile4_irq-=irq_base;
86
87 offset = DDB_INTCTRL;
88 if (nile4_irq >= 8) {
89 offset += 4;
90 nile4_irq -= 8;
91 }
92 t = ddb_in32(offset);
93 t &= ~(8 << (nile4_irq * 4));
94 ddb_out32(offset, t);
95}
96
97void nile4_disable_irq_all(void)
98{
99 ddb_out32(DDB_INTCTRL, 0);
100 ddb_out32(DDB_INTCTRL + 4, 0);
101}
102
103u16 nile4_get_irq_stat(int cpu_irq)
104{
105 return ddb_in16(DDB_INTSTAT0 + cpu_irq * 2);
106}
107
108void nile4_enable_irq_output(int cpu_irq)
109{
110 u32 t;
111
112 t = ddb_in32(DDB_INTSTAT1 + 4);
113 t |= 1 << (16 + cpu_irq);
114 ddb_out32(DDB_INTSTAT1, t);
115}
116
117void nile4_disable_irq_output(int cpu_irq)
118{
119 u32 t;
120
121 t = ddb_in32(DDB_INTSTAT1 + 4);
122 t &= ~(1 << (16 + cpu_irq));
123 ddb_out32(DDB_INTSTAT1, t);
124}
125
126void nile4_set_pci_irq_polarity(int pci_irq, int high)
127{
128 u32 t;
129
130 t = ddb_in32(DDB_INTPPES);
131 if (high)
132 t &= ~(1 << (pci_irq * 2));
133 else
134 t |= 1 << (pci_irq * 2);
135 ddb_out32(DDB_INTPPES, t);
136}
137
138void nile4_set_pci_irq_level_or_edge(int pci_irq, int level)
139{
140 u32 t;
141
142 t = ddb_in32(DDB_INTPPES);
143 if (level)
144 t |= 2 << (pci_irq * 2);
145 else
146 t &= ~(2 << (pci_irq * 2));
147 ddb_out32(DDB_INTPPES, t);
148}
149
150void nile4_clear_irq(int nile4_irq)
151{
152 nile4_irq-=irq_base;
153 ddb_out32(DDB_INTCLR, 1 << nile4_irq);
154}
155
156void nile4_clear_irq_mask(u32 mask)
157{
158 ddb_out32(DDB_INTCLR, mask);
159}
160
161u8 nile4_i8259_iack(void)
162{
163 u8 irq;
164 u32 reg;
165
166 /* Set window 0 for interrupt acknowledge */
167 reg = ddb_in32(DDB_PCIINIT0);
168
169 ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IACK, 0, DDB_PCI_ACCESS_32);
170 irq = *(volatile u8 *) KSEG1ADDR(DDB_PCI_IACK_BASE);
171 /* restore window 0 for PCI I/O space */
172 // ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
173 ddb_out32(DDB_PCIINIT0, reg);
174
175 /* i8269.c set the base vector to be 0x0 */
176 return irq ;
177}
178
179static unsigned int nile4_irq_startup(unsigned int irq) {
180
181 nile4_enable_irq(irq);
182 return 0;
183
184}
185
186static void nile4_ack_irq(unsigned int irq) {
187
188 ddb5074_led_hex(4);
189
190 nile4_clear_irq(irq);
191 ddb5074_led_hex(2);
192 nile4_disable_irq(irq);
193
194 ddb5074_led_hex(0);
195}
196
197static void nile4_irq_end(unsigned int irq) {
198
199 ddb5074_led_hex(3);
200 if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
201 ddb5074_led_hex(5);
202 nile4_enable_irq(irq);
203 ddb5074_led_hex(7);
204 }
205
206 ddb5074_led_hex(1);
207}
208
209#define nile4_irq_shutdown nile4_disable_irq
210
211static hw_irq_controller nile4_irq_controller = {
212 .typename = "nile4",
213 .startup = nile4_irq_startup,
214 .shutdown = nile4_irq_shutdown,
215 .enable = nile4_enable_irq,
216 .disable = nile4_disable_irq,
217 .ack = nile4_ack_irq,
218 .end = nile4_irq_end,
219};
220
221void nile4_irq_setup(u32 base) {
222
223 int i;
224
225 irq_base=base;
226
227 /* Map all interrupts to CPU int #0 */
228 nile4_map_irq_all(0);
229
230 /* PCI INTA#-E# must be level triggered */
231 nile4_set_pci_irq_level_or_edge(0, 1);
232 nile4_set_pci_irq_level_or_edge(1, 1);
233 nile4_set_pci_irq_level_or_edge(2, 1);
234 nile4_set_pci_irq_level_or_edge(3, 1);
235 nile4_set_pci_irq_level_or_edge(4, 1);
236
237 /* PCI INTA#-D# must be active low, INTE# must be active high */
238 nile4_set_pci_irq_polarity(0, 0);
239 nile4_set_pci_irq_polarity(1, 0);
240 nile4_set_pci_irq_polarity(2, 0);
241 nile4_set_pci_irq_polarity(3, 0);
242 nile4_set_pci_irq_polarity(4, 1);
243
244
245 for (i = 0; i < 16; i++) {
246 nile4_clear_irq(i);
247 nile4_disable_irq(i);
248 }
249
250 /* Enable CPU int #0 */
251 nile4_enable_irq_output(0);
252
253 for (i= base; i< base + NUM_NILE4_INTERRUPTS; i++) {
254 irq_desc[i].status = IRQ_DISABLED;
255 irq_desc[i].action = NULL;
256 irq_desc[i].depth = 1;
257 irq_desc[i].handler = &nile4_irq_controller;
258 }
259}
260
261#if defined(CONFIG_RUNTIME_DEBUG)
262void nile4_dump_irq_status(void)
263{
264 printk(KERN_DEBUG "
265 CPUSTAT = %p:%p\n", (void *) ddb_in32(DDB_CPUSTAT + 4),
266 (void *) ddb_in32(DDB_CPUSTAT));
267 printk(KERN_DEBUG "
268 INTCTRL = %p:%p\n", (void *) ddb_in32(DDB_INTCTRL + 4),
269 (void *) ddb_in32(DDB_INTCTRL));
270 printk(KERN_DEBUG
271 "INTSTAT0 = %p:%p\n",
272 (void *) ddb_in32(DDB_INTSTAT0 + 4),
273 (void *) ddb_in32(DDB_INTSTAT0));
274 printk(KERN_DEBUG
275 "INTSTAT1 = %p:%p\n",
276 (void *) ddb_in32(DDB_INTSTAT1 + 4),
277 (void *) ddb_in32(DDB_INTSTAT1));
278 printk(KERN_DEBUG
279 "INTCLR = %p:%p\n", (void *) ddb_in32(DDB_INTCLR + 4),
280 (void *) ddb_in32(DDB_INTCLR));
281 printk(KERN_DEBUG
282 "INTPPES = %p:%p\n", (void *) ddb_in32(DDB_INTPPES + 4),
283 (void *) ddb_in32(DDB_INTPPES));
284}
285
286#endif
diff --git a/arch/mips/ddb5xxx/ddb5074/setup.c b/arch/mips/ddb5xxx/ddb5074/setup.c
deleted file mode 100644
index 91456b068c2e..000000000000
--- a/arch/mips/ddb5xxx/ddb5074/setup.c
+++ /dev/null
@@ -1,234 +0,0 @@
1/*
2 * arch/mips/ddb5074/setup.c -- NEC DDB Vrc-5074 setup routines
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 */
7#include <linux/init.h>
8#include <linux/kbd_ll.h>
9#include <linux/kernel.h>
10#include <linux/kdev_t.h>
11#include <linux/types.h>
12#include <linux/sched.h>
13#include <linux/pci.h>
14#include <linux/ide.h>
15#include <linux/ioport.h>
16#include <linux/irq.h>
17#include <linux/pm.h>
18
19#include <asm/addrspace.h>
20#include <asm/bcache.h>
21#include <asm/irq.h>
22#include <asm/reboot.h>
23#include <asm/gdb-stub.h>
24#include <asm/time.h>
25#include <asm/nile4.h>
26#include <asm/ddb5xxx/ddb5074.h>
27#include <asm/ddb5xxx/ddb5xxx.h>
28
29static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
30
31static void ddb_machine_restart(char *command)
32{
33 u32 t;
34
35 /* PCI cold reset */
36 t = nile4_in32(NILE4_PCICTRL + 4);
37 t |= 0x40000000;
38 nile4_out32(NILE4_PCICTRL + 4, t);
39 /* CPU cold reset */
40 t = nile4_in32(NILE4_CPUSTAT);
41 t |= 1;
42 nile4_out32(NILE4_CPUSTAT, t);
43 /* Call the PROM */
44 back_to_prom();
45}
46
47static void ddb_machine_halt(void)
48{
49 printk("DDB Vrc-5074 halted.\n");
50 do {
51 } while (1);
52}
53
54static void ddb_machine_power_off(void)
55{
56 printk("DDB Vrc-5074 halted. Please turn off the power.\n");
57 do {
58 } while (1);
59}
60
61extern void rtc_ds1386_init(unsigned long base);
62
63extern void (*board_timer_setup) (struct irqaction * irq);
64
65static void __init ddb_timer_init(struct irqaction *irq)
66{
67 /* set the clock to 1 Hz */
68 nile4_out32(NILE4_T2CTRL, 1000000);
69 /* enable the General-Purpose Timer */
70 nile4_out32(NILE4_T2CTRL + 4, 0x00000001);
71 /* reset timer */
72 nile4_out32(NILE4_T2CNTR, 0);
73 /* enable interrupt */
74 setup_irq(nile4_to_irq(NILE4_INT_GPT), irq);
75 nile4_enable_irq(nile4_to_irq(NILE4_INT_GPT));
76 change_c0_status(ST0_IM,
77 IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4);
78
79}
80
81static void __init ddb_time_init(void)
82{
83 /* we have ds1396 RTC chip */
84 rtc_ds1386_init(KSEG1ADDR(DDB_PCI_MEM_BASE));
85}
86
87
88
89void __init plat_setup(void)
90{
91 set_io_port_base(NILE4_PCI_IO_BASE);
92 isa_slot_offset = NILE4_PCI_MEM_BASE;
93 board_timer_setup = ddb_timer_init;
94 board_time_init = ddb_time_init;
95
96
97 _machine_restart = ddb_machine_restart;
98 _machine_halt = ddb_machine_halt;
99 pm_power_off = ddb_machine_power_off;
100
101 ddb_out32(DDB_BAR0, 0);
102
103 ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, 0x10);
104 ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE , 0x10);
105
106 /* Reboot on panic */
107 panic_timeout = 180;
108}
109
110#define USE_NILE4_SERIAL 0
111
112#if USE_NILE4_SERIAL
113#define ns16550_in(reg) nile4_in8((reg)*8)
114#define ns16550_out(reg, val) nile4_out8((reg)*8, (val))
115#else
116#define NS16550_BASE (NILE4_PCI_IO_BASE+0x03f8)
117static inline u8 ns16550_in(u32 reg)
118{
119 return *(volatile u8 *) (NS16550_BASE + reg);
120}
121
122static inline void ns16550_out(u32 reg, u8 val)
123{
124 *(volatile u8 *) (NS16550_BASE + reg) = val;
125}
126#endif
127
128#define NS16550_RBR 0
129#define NS16550_THR 0
130#define NS16550_DLL 0
131#define NS16550_IER 1
132#define NS16550_DLM 1
133#define NS16550_FCR 2
134#define NS16550_IIR 2
135#define NS16550_LCR 3
136#define NS16550_MCR 4
137#define NS16550_LSR 5
138#define NS16550_MSR 6
139#define NS16550_SCR 7
140
141#define NS16550_LSR_DR 0x01 /* Data ready */
142#define NS16550_LSR_OE 0x02 /* Overrun */
143#define NS16550_LSR_PE 0x04 /* Parity error */
144#define NS16550_LSR_FE 0x08 /* Framing error */
145#define NS16550_LSR_BI 0x10 /* Break */
146#define NS16550_LSR_THRE 0x20 /* Xmit holding register empty */
147#define NS16550_LSR_TEMT 0x40 /* Xmitter empty */
148#define NS16550_LSR_ERR 0x80 /* Error */
149
150
151void _serinit(void)
152{
153#if USE_NILE4_SERIAL
154 ns16550_out(NS16550_LCR, 0x80);
155 ns16550_out(NS16550_DLM, 0x00);
156 ns16550_out(NS16550_DLL, 0x36); /* 9600 baud */
157 ns16550_out(NS16550_LCR, 0x00);
158 ns16550_out(NS16550_LCR, 0x03);
159 ns16550_out(NS16550_FCR, 0x47);
160#else
161 /* done by PMON */
162#endif
163}
164
165void _putc(char c)
166{
167 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_THRE));
168 ns16550_out(NS16550_THR, c);
169 if (c == '\n') {
170 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_THRE));
171 ns16550_out(NS16550_THR, '\r');
172 }
173}
174
175void _puts(const char *s)
176{
177 char c;
178 while ((c = *s++))
179 _putc(c);
180}
181
182char _getc(void)
183{
184 while (!(ns16550_in(NS16550_LSR) & NS16550_LSR_DR));
185 return ns16550_in(NS16550_RBR);
186}
187
188int _testc(void)
189{
190 return (ns16550_in(NS16550_LSR) & NS16550_LSR_DR) != 0;
191}
192
193
194/*
195 * Hexadecimal 7-segment LED
196 */
197void ddb5074_led_hex(int hex)
198{
199 outb(hex, 0x80);
200}
201
202
203/*
204 * LEDs D2 and D3, connected to the GPIO pins of the PMU in the ALi M1543
205 */
206struct pci_dev *pci_pmu = NULL;
207
208void ddb5074_led_d2(int on)
209{
210 u8 t;
211
212 if (pci_pmu) {
213 pci_read_config_byte(pci_pmu, 0x7e, &t);
214 if (on)
215 t &= 0x7f;
216 else
217 t |= 0x80;
218 pci_write_config_byte(pci_pmu, 0x7e, t);
219 }
220}
221
222void ddb5074_led_d3(int on)
223{
224 u8 t;
225
226 if (pci_pmu) {
227 pci_read_config_byte(pci_pmu, 0x7e, &t);
228 if (on)
229 t &= 0xbf;
230 else
231 t |= 0x40;
232 pci_write_config_byte(pci_pmu, 0x7e, t);
233 }
234}
diff --git a/arch/mips/ddb5xxx/ddb5476/Makefile b/arch/mips/ddb5xxx/ddb5476/Makefile
deleted file mode 100644
index ab0312cb47b4..000000000000
--- a/arch/mips/ddb5xxx/ddb5476/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for the NEC DDB Vrc-5476 specific kernel interface routines
3# under Linux.
4#
5
6obj-y += setup.o irq.o nile4_pic.o vrc5476_irq.o
7obj-$(CONFIG_KGDB) += dbg_io.o
8
9EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/ddb5xxx/ddb5476/dbg_io.c b/arch/mips/ddb5xxx/ddb5476/dbg_io.c
deleted file mode 100644
index f2296a999953..000000000000
--- a/arch/mips/ddb5xxx/ddb5476/dbg_io.c
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * kgdb io functions for DDB5476. We use the second serial port.
3 *
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: jsun@mvista.com or jsun@junsun.net
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14/* ======================= CONFIG ======================== */
15
16/* [jsun] we use the second serial port for kdb */
17#define BASE 0xa60002f8
18#define MAX_BAUD 115200
19
20/* distance in bytes between two serial registers */
21#define REG_OFFSET 1
22
23/*
24 * 0 - kgdb does serial init
25 * 1 - kgdb skip serial init
26 */
27static int remoteDebugInitialized = 0;
28
29/*
30 * the default baud rate *if* kgdb does serial init
31 */
32#define BAUD_DEFAULT UART16550_BAUD_38400
33
34/* ======================= END OF CONFIG ======================== */
35
36typedef unsigned char uint8;
37typedef unsigned int uint32;
38
39#define UART16550_BAUD_2400 2400
40#define UART16550_BAUD_4800 4800
41#define UART16550_BAUD_9600 9600
42#define UART16550_BAUD_19200 19200
43#define UART16550_BAUD_38400 38400
44#define UART16550_BAUD_57600 57600
45#define UART16550_BAUD_115200 115200
46
47#define UART16550_PARITY_NONE 0
48#define UART16550_PARITY_ODD 0x08
49#define UART16550_PARITY_EVEN 0x18
50#define UART16550_PARITY_MARK 0x28
51#define UART16550_PARITY_SPACE 0x38
52
53#define UART16550_DATA_5BIT 0x0
54#define UART16550_DATA_6BIT 0x1
55#define UART16550_DATA_7BIT 0x2
56#define UART16550_DATA_8BIT 0x3
57
58#define UART16550_STOP_1BIT 0x0
59#define UART16550_STOP_2BIT 0x4
60
61/* register offset */
62#define OFS_RCV_BUFFER 0
63#define OFS_TRANS_HOLD 0
64#define OFS_SEND_BUFFER 0
65#define OFS_INTR_ENABLE (1*REG_OFFSET)
66#define OFS_INTR_ID (2*REG_OFFSET)
67#define OFS_DATA_FORMAT (3*REG_OFFSET)
68#define OFS_LINE_CONTROL (3*REG_OFFSET)
69#define OFS_MODEM_CONTROL (4*REG_OFFSET)
70#define OFS_RS232_OUTPUT (4*REG_OFFSET)
71#define OFS_LINE_STATUS (5*REG_OFFSET)
72#define OFS_MODEM_STATUS (6*REG_OFFSET)
73#define OFS_RS232_INPUT (6*REG_OFFSET)
74#define OFS_SCRATCH_PAD (7*REG_OFFSET)
75
76#define OFS_DIVISOR_LSB (0*REG_OFFSET)
77#define OFS_DIVISOR_MSB (1*REG_OFFSET)
78
79
80/* memory-mapped read/write of the port */
81#define UART16550_READ(y) (*((volatile uint8*)(BASE + y)))
82#define UART16550_WRITE(y, z) ((*((volatile uint8*)(BASE + y))) = z)
83
84void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
85{
86 /* disable interrupts */
87 UART16550_WRITE(OFS_INTR_ENABLE, 0);
88
89 /* set up baud rate */
90 {
91 uint32 divisor;
92
93 /* set DIAB bit */
94 UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
95
96 /* set divisor */
97 divisor = MAX_BAUD / baud;
98 UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
99 UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
100
101 /* clear DIAB bit */
102 UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
103 }
104
105 /* set data format */
106 UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
107}
108
109
110uint8 getDebugChar(void)
111{
112 if (!remoteDebugInitialized) {
113 remoteDebugInitialized = 1;
114 debugInit(BAUD_DEFAULT,
115 UART16550_DATA_8BIT,
116 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
117 }
118
119 while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
120 return UART16550_READ(OFS_RCV_BUFFER);
121}
122
123
124int putDebugChar(uint8 byte)
125{
126 if (!remoteDebugInitialized) {
127 remoteDebugInitialized = 1;
128 debugInit(BAUD_DEFAULT,
129 UART16550_DATA_8BIT,
130 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
131 }
132
133 while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
134 UART16550_WRITE(OFS_SEND_BUFFER, byte);
135 return 1;
136}
diff --git a/arch/mips/ddb5xxx/ddb5476/irq.c b/arch/mips/ddb5xxx/ddb5476/irq.c
deleted file mode 100644
index 7583a1f30711..000000000000
--- a/arch/mips/ddb5xxx/ddb5476/irq.c
+++ /dev/null
@@ -1,165 +0,0 @@
1/*
2 * arch/mips/ddb5476/irq.c -- NEC DDB Vrc-5476 interrupt routines
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 *
7 * Re-write the whole thing to use new irq.c file.
8 * Copyright (C) 2001 MontaVista Software Inc.
9 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
10 *
11 */
12#include <linux/init.h>
13#include <linux/sched.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16
17#include <asm/i8259.h>
18#include <asm/io.h>
19#include <asm/ptrace.h>
20
21#include <asm/ddb5xxx/ddb5xxx.h>
22
23#define M1543_PNP_CONFIG 0x03f0 /* PnP Config Port */
24#define M1543_PNP_INDEX 0x03f0 /* PnP Index Port */
25#define M1543_PNP_DATA 0x03f1 /* PnP Data Port */
26
27#define M1543_PNP_ALT_CONFIG 0x0370 /* Alternative PnP Config Port */
28#define M1543_PNP_ALT_INDEX 0x0370 /* Alternative PnP Index Port */
29#define M1543_PNP_ALT_DATA 0x0371 /* Alternative PnP Data Port */
30
31#define M1543_INT1_MASTER_CTRL 0x0020 /* INT_1 (master) Control Register */
32#define M1543_INT1_MASTER_MASK 0x0021 /* INT_1 (master) Mask Register */
33
34#define M1543_INT1_SLAVE_CTRL 0x00a0 /* INT_1 (slave) Control Register */
35#define M1543_INT1_SLAVE_MASK 0x00a1 /* INT_1 (slave) Mask Register */
36
37#define M1543_INT1_MASTER_ELCR 0x04d0 /* INT_1 (master) Edge/Level Control */
38#define M1543_INT1_SLAVE_ELCR 0x04d1 /* INT_1 (slave) Edge/Level Control */
39
40static void m1543_irq_setup(void)
41{
42 /*
43 * The ALI M1543 has 13 interrupt inputs, IRQ1..IRQ13. Not all
44 * the possible IO sources in the M1543 are in use by us. We will
45 * use the following mapping:
46 *
47 * IRQ1 - keyboard (default set by M1543)
48 * IRQ3 - reserved for UART B (default set by M1543) (note that
49 * the schematics for the DDB Vrc-5476 board seem to
50 * indicate that IRQ3 is connected to the DS1386
51 * watchdog timer interrupt output so we might have
52 * a conflict)
53 * IRQ4 - reserved for UART A (default set by M1543)
54 * IRQ5 - parallel (default set by M1543)
55 * IRQ8 - DS1386 time of day (RTC) interrupt
56 * IRQ9 - USB (hardwired in ddb_setup)
57 * IRQ10 - PMU (hardwired in ddb_setup)
58 * IRQ12 - mouse
59 * IRQ14,15 - IDE controller (need to be confirmed, jsun)
60 */
61
62 /*
63 * Assing mouse interrupt to IRQ12
64 */
65
66 /* Enter configuration mode */
67 outb(0x51, M1543_PNP_CONFIG);
68 outb(0x23, M1543_PNP_CONFIG);
69
70 /* Select logical device 7 (Keyboard) */
71 outb(0x07, M1543_PNP_INDEX);
72 outb(0x07, M1543_PNP_DATA);
73
74 /* Select IRQ12 */
75 outb(0x72, M1543_PNP_INDEX);
76 outb(0x0c, M1543_PNP_DATA);
77
78 /* Leave configration mode */
79 outb(0xbb, M1543_PNP_CONFIG);
80}
81
82static void nile4_irq_setup(void)
83{
84 int i;
85
86 /* Map all interrupts to CPU int #0 (IP2) */
87 nile4_map_irq_all(0);
88
89 /* PCI INTA#-E# must be level triggered */
90 nile4_set_pci_irq_level_or_edge(0, 1);
91 nile4_set_pci_irq_level_or_edge(1, 1);
92 nile4_set_pci_irq_level_or_edge(2, 1);
93 nile4_set_pci_irq_level_or_edge(3, 1);
94
95 /* PCI INTA#, B#, D# must be active low, INTC# must be active high */
96 nile4_set_pci_irq_polarity(0, 0);
97 nile4_set_pci_irq_polarity(1, 0);
98 nile4_set_pci_irq_polarity(2, 1);
99 nile4_set_pci_irq_polarity(3, 0);
100
101 for (i = 0; i < 16; i++)
102 nile4_clear_irq(i);
103
104 /* Enable CPU int #0 */
105 nile4_enable_irq_output(0);
106
107 /* memory resource acquire in ddb_setup */
108}
109
110static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
111static struct irqaction irq_error = { no_action, 0, CPU_MASK_NONE, "error", NULL, NULL };
112
113extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
114extern void mips_cpu_irq_init(u32 irq_base);
115extern void vrc5476_irq_init(u32 irq_base);
116
117extern void vrc5476_irq_dispatch(struct pt_regs *regs);
118
119asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
120{
121 unsigned int pending = read_c0_cause() & read_c0_status();
122
123 if (pending & STATUSF_IP7)
124 do_IRQ(CPU_IRQ_BASE + 7, regs);
125 else if (pending & STATUSF_IP2)
126 vrc5476_irq_dispatch(regs);
127 else if (pending & STATUSF_IP3)
128 do_IRQ(CPU_IRQ_BASE + 3, regs);
129 else if (pending & STATUSF_IP4)
130 do_IRQ(CPU_IRQ_BASE + 4, regs);
131 else if (pending & STATUSF_IP5)
132 do_IRQ(CPU_IRQ_BASE + 5, regs);
133 else if (pending & STATUSF_IP6)
134 do_IRQ(CPU_IRQ_BASE + 6, regs);
135 else if (pending & STATUSF_IP0)
136 do_IRQ(CPU_IRQ_BASE, regs);
137 else if (pending & STATUSF_IP1)
138 do_IRQ(CPU_IRQ_BASE + 1, regs);
139
140 vrc5476_irq_dispatch(regs);
141}
142
143void __init arch_init_irq(void)
144{
145 /* hardware initialization */
146 nile4_irq_setup();
147 m1543_irq_setup();
148
149 /* controller setup */
150 init_i8259_irqs();
151 vrc5476_irq_init(VRC5476_IRQ_BASE);
152 mips_cpu_irq_init(CPU_IRQ_BASE);
153
154 /* setup cascade interrupts */
155 setup_irq(VRC5476_IRQ_BASE + VRC5476_I8259_CASCADE, &irq_cascade);
156 setup_irq(CPU_IRQ_BASE + CPU_VRC5476_CASCADE, &irq_cascade);
157
158 /* setup error interrupts for debugging */
159 setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_CPCE, &irq_error);
160 setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_CNTD, &irq_error);
161 setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_MCE, &irq_error);
162 setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_LBRT, &irq_error);
163 setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_PCIS, &irq_error);
164 setup_irq(VRC5476_IRQ_BASE + VRC5476_IRQ_PCI, &irq_error);
165}
diff --git a/arch/mips/ddb5xxx/ddb5476/nile4_pic.c b/arch/mips/ddb5xxx/ddb5476/nile4_pic.c
deleted file mode 100644
index e930cee7944f..000000000000
--- a/arch/mips/ddb5xxx/ddb5476/nile4_pic.c
+++ /dev/null
@@ -1,190 +0,0 @@
1/*
2 * arch/mips/ddb5476/nile4.c --
3 * low-level PIC code for NEC Vrc-5476 (Nile 4)
4 *
5 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
6 * Sony Software Development Center Europe (SDCE), Brussels
7 *
8 * Copyright 2001 MontaVista Software Inc.
9 * Author: jsun@mvista.com or jsun@junsun.net
10 *
11 */
12#include <linux/config.h>
13#include <linux/kernel.h>
14#include <linux/types.h>
15
16#include <asm/addrspace.h>
17
18#include <asm/ddb5xxx/ddb5xxx.h>
19
20
21/*
22 * Interrupt Programming
23 */
24void nile4_map_irq(int nile4_irq, int cpu_irq)
25{
26 u32 offset, t;
27
28 offset = DDB_INTCTRL;
29 if (nile4_irq >= 8) {
30 offset += 4;
31 nile4_irq -= 8;
32 }
33 t = ddb_in32(offset);
34 t &= ~(7 << (nile4_irq * 4));
35 t |= cpu_irq << (nile4_irq * 4);
36 ddb_out32(offset, t);
37}
38
39void nile4_map_irq_all(int cpu_irq)
40{
41 u32 all, t;
42
43 all = cpu_irq;
44 all |= all << 4;
45 all |= all << 8;
46 all |= all << 16;
47 t = ddb_in32(DDB_INTCTRL);
48 t &= 0x88888888;
49 t |= all;
50 ddb_out32(DDB_INTCTRL, t);
51 t = ddb_in32(DDB_INTCTRL + 4);
52 t &= 0x88888888;
53 t |= all;
54 ddb_out32(DDB_INTCTRL + 4, t);
55}
56
57void nile4_enable_irq(int nile4_irq)
58{
59 u32 offset, t;
60
61 offset = DDB_INTCTRL;
62 if (nile4_irq >= 8) {
63 offset += 4;
64 nile4_irq -= 8;
65 }
66 t = ddb_in32(offset);
67 t |= 8 << (nile4_irq * 4);
68 ddb_out32(offset, t);
69}
70
71void nile4_disable_irq(int nile4_irq)
72{
73 u32 offset, t;
74
75 offset = DDB_INTCTRL;
76 if (nile4_irq >= 8) {
77 offset += 4;
78 nile4_irq -= 8;
79 }
80 t = ddb_in32(offset);
81 t &= ~(8 << (nile4_irq * 4));
82 ddb_out32(offset, t);
83}
84
85void nile4_disable_irq_all(void)
86{
87 ddb_out32(DDB_INTCTRL, 0);
88 ddb_out32(DDB_INTCTRL + 4, 0);
89}
90
91u16 nile4_get_irq_stat(int cpu_irq)
92{
93 return ddb_in16(DDB_INTSTAT0 + cpu_irq * 2);
94}
95
96void nile4_enable_irq_output(int cpu_irq)
97{
98 u32 t;
99
100 t = ddb_in32(DDB_INTSTAT1 + 4);
101 t |= 1 << (16 + cpu_irq);
102 ddb_out32(DDB_INTSTAT1, t);
103}
104
105void nile4_disable_irq_output(int cpu_irq)
106{
107 u32 t;
108
109 t = ddb_in32(DDB_INTSTAT1 + 4);
110 t &= ~(1 << (16 + cpu_irq));
111 ddb_out32(DDB_INTSTAT1, t);
112}
113
114void nile4_set_pci_irq_polarity(int pci_irq, int high)
115{
116 u32 t;
117
118 t = ddb_in32(DDB_INTPPES);
119 if (high)
120 t &= ~(1 << (pci_irq * 2));
121 else
122 t |= 1 << (pci_irq * 2);
123 ddb_out32(DDB_INTPPES, t);
124}
125
126void nile4_set_pci_irq_level_or_edge(int pci_irq, int level)
127{
128 u32 t;
129
130 t = ddb_in32(DDB_INTPPES);
131 if (level)
132 t |= 2 << (pci_irq * 2);
133 else
134 t &= ~(2 << (pci_irq * 2));
135 ddb_out32(DDB_INTPPES, t);
136}
137
138void nile4_clear_irq(int nile4_irq)
139{
140 ddb_out32(DDB_INTCLR, 1 << nile4_irq);
141}
142
143void nile4_clear_irq_mask(u32 mask)
144{
145 ddb_out32(DDB_INTCLR, mask);
146}
147
148u8 nile4_i8259_iack(void)
149{
150 u8 irq;
151 u32 reg;
152
153 /* Set window 0 for interrupt acknowledge */
154 reg = ddb_in32(DDB_PCIINIT0);
155
156 ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IACK, 0, DDB_PCI_ACCESS_32);
157 irq = *(volatile u8 *) KSEG1ADDR(DDB_PCI_IACK_BASE);
158 /* restore window 0 for PCI I/O space */
159 // ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
160 ddb_out32(DDB_PCIINIT0, reg);
161
162 /* i8269.c set the base vector to be 0x0 */
163 return irq + I8259_IRQ_BASE;
164}
165
166#if defined(CONFIG_RUNTIME_DEBUG)
167void nile4_dump_irq_status(void)
168{
169 printk(KERN_DEBUG "
170 CPUSTAT = %p:%p\n", (void *) ddb_in32(DDB_CPUSTAT + 4),
171 (void *) ddb_in32(DDB_CPUSTAT));
172 printk(KERN_DEBUG "
173 INTCTRL = %p:%p\n", (void *) ddb_in32(DDB_INTCTRL + 4),
174 (void *) ddb_in32(DDB_INTCTRL));
175 printk(KERN_DEBUG
176 "INTSTAT0 = %p:%p\n",
177 (void *) ddb_in32(DDB_INTSTAT0 + 4),
178 (void *) ddb_in32(DDB_INTSTAT0));
179 printk(KERN_DEBUG
180 "INTSTAT1 = %p:%p\n",
181 (void *) ddb_in32(DDB_INTSTAT1 + 4),
182 (void *) ddb_in32(DDB_INTSTAT1));
183 printk(KERN_DEBUG
184 "INTCLR = %p:%p\n", (void *) ddb_in32(DDB_INTCLR + 4),
185 (void *) ddb_in32(DDB_INTCLR));
186 printk(KERN_DEBUG
187 "INTPPES = %p:%p\n", (void *) ddb_in32(DDB_INTPPES + 4),
188 (void *) ddb_in32(DDB_INTPPES));
189}
190#endif
diff --git a/arch/mips/ddb5xxx/ddb5476/setup.c b/arch/mips/ddb5xxx/ddb5476/setup.c
deleted file mode 100644
index c902adef5942..000000000000
--- a/arch/mips/ddb5xxx/ddb5476/setup.c
+++ /dev/null
@@ -1,296 +0,0 @@
1/*
2 * arch/mips/ddb5476/setup.c -- NEC DDB Vrc-5476 setup routines
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 */
7#include <linux/init.h>
8#include <linux/kbd_ll.h>
9#include <linux/kernel.h>
10#include <linux/kdev_t.h>
11#include <linux/types.h>
12#include <linux/sched.h>
13#include <linux/pci.h>
14#include <linux/pm.h>
15
16#include <asm/addrspace.h>
17#include <asm/bcache.h>
18#include <asm/irq.h>
19#include <asm/reboot.h>
20#include <asm/gdb-stub.h>
21#include <asm/time.h>
22#include <asm/debug.h>
23#include <asm/traps.h>
24
25#include <asm/ddb5xxx/ddb5xxx.h>
26
27// #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */
28
29#ifdef USE_CPU_COUNTER_TIMER
30
31#define CPU_COUNTER_FREQUENCY 83000000
32#else
33/* otherwise we use general purpose timer */
34#define TIMER_FREQUENCY 83000000
35#define TIMER_BASE DDB_T2CTRL
36#define TIMER_IRQ (VRC5476_IRQ_BASE + VRC5476_IRQ_GPT)
37#endif
38
39static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
40
41static void ddb_machine_restart(char *command)
42{
43 u32 t;
44
45 /* PCI cold reset */
46 t = ddb_in32(DDB_PCICTRL + 4);
47 t |= 0x40000000;
48 ddb_out32(DDB_PCICTRL + 4, t);
49 /* CPU cold reset */
50 t = ddb_in32(DDB_CPUSTAT);
51 t |= 1;
52 ddb_out32(DDB_CPUSTAT, t);
53 /* Call the PROM */
54 back_to_prom();
55}
56
57static void ddb_machine_halt(void)
58{
59 printk(KERN_NOTICE "DDB Vrc-5476 halted.\n");
60 while (1);
61}
62
63static void ddb_machine_power_off(void)
64{
65 printk(KERN_NOTICE "DDB Vrc-5476 halted. Please turn off the power.\n");
66 while (1);
67}
68
69extern void rtc_ds1386_init(unsigned long base);
70
71static void __init ddb_time_init(void)
72{
73#if defined(USE_CPU_COUNTER_TIMER)
74 mips_hpt_frequency = CPU_COUNTER_FREQUENCY;
75#endif
76
77 /* we have ds1396 RTC chip */
78 rtc_ds1386_init(KSEG1ADDR(DDB_PCI_MEM_BASE));
79}
80
81
82extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
83static void __init ddb_timer_setup(struct irqaction *irq)
84{
85#if defined(USE_CPU_COUNTER_TIMER)
86
87 unsigned int count;
88
89 /* we are using the cpu counter for timer interrupts */
90 setup_irq(CPU_IRQ_BASE + 7, irq);
91
92 /* to generate the first timer interrupt */
93 count = read_c0_count();
94 write_c0_compare(count + 1000);
95
96#else
97
98 ddb_out32(TIMER_BASE, TIMER_FREQUENCY/HZ);
99 ddb_out32(TIMER_BASE+4, 0x1); /* enable timer */
100 setup_irq(TIMER_IRQ, irq);
101#endif
102}
103
104static struct {
105 struct resource dma1;
106 struct resource timer;
107 struct resource rtc;
108 struct resource dma_page_reg;
109 struct resource dma2;
110} ddb5476_ioport = {
111 {
112 "dma1", 0x00, 0x1f, IORESOURCE_BUSY}, {
113 "timer", 0x40, 0x5f, IORESOURCE_BUSY}, {
114 "rtc", 0x70, 0x7f, IORESOURCE_BUSY}, {
115 "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY}, {
116 "dma2", 0xc0, 0xdf, IORESOURCE_BUSY}
117};
118
119static struct {
120 struct resource nile4;
121} ddb5476_iomem = {
122 { "Nile 4", DDB_BASE, DDB_BASE + DDB_SIZE - 1, IORESOURCE_BUSY}
123};
124
125
126static void ddb5476_board_init(void);
127
128void __init plat_setup(void)
129{
130 set_io_port_base(KSEG1ADDR(DDB_PCI_IO_BASE));
131
132 board_time_init = ddb_time_init;
133 board_timer_setup = ddb_timer_setup;
134
135 _machine_restart = ddb_machine_restart;
136 _machine_halt = ddb_machine_halt;
137 pm_power_off = ddb_machine_power_off;
138
139 /* request io port/mem resources */
140 if (request_resource(&ioport_resource, &ddb5476_ioport.dma1) ||
141 request_resource(&ioport_resource, &ddb5476_ioport.timer) ||
142 request_resource(&ioport_resource, &ddb5476_ioport.rtc) ||
143 request_resource(&ioport_resource,
144 &ddb5476_ioport.dma_page_reg)
145 || request_resource(&ioport_resource, &ddb5476_ioport.dma2)
146 || request_resource(&iomem_resource, &ddb5476_iomem.nile4)) {
147 printk
148 ("ddb_setup - requesting oo port resources failed.\n");
149 for (;;);
150 }
151
152 /* Reboot on panic */
153 panic_timeout = 180;
154
155 /* [jsun] we need to set BAR0 so that SDRAM 0 appears at 0x0 in PCI */
156 /* *(long*)0xbfa00218 = 0x8; */
157
158 /* board initialization stuff */
159 ddb5476_board_init();
160}
161
162/*
163 * We don't trust bios. We essentially does hardware re-initialization
164 * as complete as possible, as far as we know we can safely do.
165 */
166static void ddb5476_board_init(void)
167{
168 /* ----------- setup PDARs ------------ */
169 /* check SDRAM0, whether we are on MEM bus does not matter */
170 db_assert((ddb_in32(DDB_SDRAM0) & 0xffffffef) ==
171 ddb_calc_pdar(DDB_SDRAM_BASE, DDB_SDRAM_SIZE, 32, 0, 1));
172
173 /* SDRAM1 should be turned off. What is this for anyway ? */
174 db_assert( (ddb_in32(DDB_SDRAM1) & 0xf) == 0);
175
176 /* flash 1&2, DDB status, DDB control */
177 ddb_set_pdar(DDB_DCS2, DDB_DCS2_BASE, DDB_DCS2_SIZE, 16, 0, 0);
178 ddb_set_pdar(DDB_DCS3, DDB_DCS3_BASE, DDB_DCS3_SIZE, 16, 0, 0);
179 ddb_set_pdar(DDB_DCS4, DDB_DCS4_BASE, DDB_DCS4_SIZE, 8, 0, 0);
180 ddb_set_pdar(DDB_DCS5, DDB_DCS5_BASE, DDB_DCS5_SIZE, 8, 0, 0);
181
182 /* shut off other pdar so they don't accidentally get into the way */
183 ddb_set_pdar(DDB_DCS6, 0xffffffff, 0, 32, 0, 0);
184 ddb_set_pdar(DDB_DCS7, 0xffffffff, 0, 32, 0, 0);
185 ddb_set_pdar(DDB_DCS8, 0xffffffff, 0, 32, 0, 0);
186
187 /* verify VRC5477 base addr */
188 /* don't care about some details */
189 db_assert((ddb_in32(DDB_INTCS) & 0xffffff0f) ==
190 ddb_calc_pdar(DDB_INTCS_BASE, DDB_INTCS_SIZE, 8, 0, 0));
191
192 /* verify BOOT ROM addr */
193 /* don't care about some details */
194 db_assert((ddb_in32(DDB_BOOTCS) & 0xffffff0f) ==
195 ddb_calc_pdar(DDB_BOOTCS_BASE, DDB_BOOTCS_SIZE, 8, 0, 0));
196
197 /* setup PCI windows - window1 for MEM/config, window0 for IO */
198 ddb_set_pdar(DDB_PCIW0, DDB_PCI_IO_BASE, DDB_PCI_IO_SIZE, 32, 0, 1);
199 ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
200
201 ddb_set_pdar(DDB_PCIW1, DDB_PCI_MEM_BASE, DDB_PCI_MEM_SIZE, 32, 0, 1);
202 ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE, DDB_PCI_ACCESS_32);
203
204 /* ----------- setup PDARs ------------ */
205 /* this is problematic - it will reset Aladin which cause we loose
206 * serial port, and we don't know how to set up Aladin chip again.
207 */
208 // ddb_pci_reset_bus();
209
210 ddb_out32(DDB_BAR0, 0x00000008);
211
212 ddb_out32(DDB_BARC, 0xffffffff);
213 ddb_out32(DDB_BARB, 0xffffffff);
214 ddb_out32(DDB_BAR1, 0xffffffff);
215 ddb_out32(DDB_BAR2, 0xffffffff);
216 ddb_out32(DDB_BAR3, 0xffffffff);
217 ddb_out32(DDB_BAR4, 0xffffffff);
218 ddb_out32(DDB_BAR5, 0xffffffff);
219 ddb_out32(DDB_BAR6, 0xffffffff);
220 ddb_out32(DDB_BAR7, 0xffffffff);
221 ddb_out32(DDB_BAR8, 0xffffffff);
222
223 /* ----------- switch PCI1 to PCI CONFIG space ------------ */
224 ddb_set_pdar(DDB_PCIW1, DDB_PCI_CONFIG_BASE, DDB_PCI_CONFIG_SIZE, 32, 0, 1);
225 ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_CFG, 0x0, DDB_PCI_ACCESS_32);
226
227 /* ----- M1543 PCI setup ------ */
228
229 /* we know M1543 PCI-ISA controller is at addr:18 */
230 /* xxxx1010 makes USB at addr:13 and PMU at addr:14 */
231 *(volatile unsigned char *) 0xa8040072 &= 0xf0;
232 *(volatile unsigned char *) 0xa8040072 |= 0xa;
233
234 /* setup USB interrupt to IRQ 9, (bit 0:3 - 0001)
235 * no IOCHRDY signal, (bit 7 - 1)
236 * M1543C & M7101 VID and Subsys Device ID are read-only (bit 6 - 1)
237 * Make USB Master INTAJ level to edge conversion (bit 4 - 1)
238 */
239 *(unsigned char *) 0xa8040074 = 0xd1;
240
241 /* setup PMU(SCI to IRQ 10 (bit 0:3 - 0011)
242 * SCI routing to IRQ 13 disabled (bit 7 - 1)
243 * SCI interrupt level to edge conversion bypassed (bit 4 - 0)
244 */
245 *(unsigned char *) 0xa8040076 = 0x83;
246
247 /* setup IDE controller
248 * enable IDE controller (bit 6 - 1)
249 * IDE IDSEL to be addr:24 (bit 4:5 - 11)
250 * no IDE ATA Secondary Bus Signal Pad Control (bit 3 - 0)
251 * no IDE ATA Primary Bus Signal Pad Control (bit 2 - 0)
252 * primary IRQ is 14, secondary is 15 (bit 1:0 - 01
253 */
254 // *(unsigned char*)0xa8040058 = 0x71;
255 // *(unsigned char*)0xa8040058 = 0x79;
256 // *(unsigned char*)0xa8040058 = 0x74; // use SIRQ, primary tri-state
257 *(unsigned char *) 0xa8040058 = 0x75; // primary tri-state
258
259#if 0
260 /* this is not necessary if M5229 does not use SIRQ */
261 *(unsigned char *) 0xa8040044 = 0x0d; // primary to IRQ 14
262 *(unsigned char *) 0xa8040075 = 0x0d; // secondary to IRQ 14
263#endif
264
265 /* enable IDE in the M5229 config register 0x50 (bit 0 - 1) */
266 /* M5229 IDSEL is addr:24; see above setting */
267 *(unsigned char *) 0xa9000050 |= 0x1;
268
269 /* enable bus master (bit 2) and IO decoding (bit 0) */
270 *(unsigned char *) 0xa9000004 |= 0x5;
271
272 /* enable native, copied from arch/ppc/k2boot/head.S */
273 /* TODO - need volatile, need to be portable */
274 *(unsigned char *) 0xa9000009 = 0xff;
275
276 /* ----- end of M1543 PCI setup ------ */
277
278 /* ----- reset on-board ether chip ------ */
279 *((volatile u32 *) 0xa8020004) |= 1; /* decode I/O */
280 *((volatile u32 *) 0xa8020010) = 0; /* set BAR address */
281
282 /* send reset command */
283 *((volatile u32 *) 0xa6000000) = 1; /* do a soft reset */
284
285 /* disable ether chip */
286 *((volatile u32 *) 0xa8020004) = 0; /* disable any decoding */
287
288 /* put it into sleep */
289 *((volatile u32 *) 0xa8020040) = 0x80000000;
290
291 /* ----- end of reset on-board ether chip ------ */
292
293 /* ----------- switch PCI1 back to PCI MEM space ------------ */
294 ddb_set_pdar(DDB_PCIW1, DDB_PCI_MEM_BASE, DDB_PCI_MEM_SIZE, 32, 0, 1);
295 ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE, DDB_PCI_ACCESS_32);
296}
diff --git a/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c b/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c
deleted file mode 100644
index a3c5e7b18018..000000000000
--- a/arch/mips/ddb5xxx/ddb5476/vrc5476_irq.c
+++ /dev/null
@@ -1,109 +0,0 @@
1/*
2 * The irq controller for vrc5476.
3 *
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: jsun@mvista.com or jsun@junsun.net
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/irq.h>
16#include <linux/types.h>
17#include <linux/ptrace.h>
18
19#include <asm/system.h>
20
21#include <asm/ddb5xxx/ddb5xxx.h>
22
23static int irq_base;
24
25static void vrc5476_irq_enable(uint irq)
26{
27 nile4_enable_irq(irq - irq_base);
28}
29
30static void vrc5476_irq_disable(uint irq)
31{
32 nile4_disable_irq(irq - irq_base);
33}
34
35static unsigned int vrc5476_irq_startup(uint irq)
36{
37 nile4_enable_irq(irq - irq_base);
38 return 0;
39}
40
41#define vrc5476_irq_shutdown vrc5476_irq_disable
42
43static void vrc5476_irq_ack(uint irq)
44{
45 nile4_clear_irq(irq - irq_base);
46 nile4_disable_irq(irq - irq_base);
47}
48
49static void vrc5476_irq_end(uint irq)
50{
51 if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
52 vrc5476_irq_enable(irq);
53}
54
55static hw_irq_controller vrc5476_irq_controller = {
56 .typename = "vrc5476",
57 .startup = vrc5476_irq_startup,
58 .shutdown = vrc5476_irq_shutdown,
59 .enable = vrc5476_irq_enable,
60 .disable = vrc5476_irq_disable,
61 .ack = vrc5476_irq_ack,
62 .end = vrc5476_irq_end
63};
64
65void __init
66vrc5476_irq_init(u32 base)
67{
68 u32 i;
69
70 irq_base = base;
71 for (i= base; i< base + NUM_VRC5476_IRQ; i++) {
72 irq_desc[i].status = IRQ_DISABLED;
73 irq_desc[i].action = NULL;
74 irq_desc[i].depth = 1;
75 irq_desc[i].handler = &vrc5476_irq_controller;
76 }
77}
78
79
80void
81vrc5476_irq_dispatch(struct pt_regs *regs)
82{
83 u32 mask;
84 int nile4_irq;
85
86 mask = nile4_get_irq_stat(0);
87
88 /* quick check for possible time interrupt */
89 if (mask & (1 << VRC5476_IRQ_GPT)) {
90 do_IRQ(VRC5476_IRQ_BASE + VRC5476_IRQ_GPT, regs);
91 return;
92 }
93
94 /* check for i8259 interrupts */
95 if (mask & (1 << VRC5476_I8259_CASCADE)) {
96 int i8259_irq = nile4_i8259_iack();
97 do_IRQ(I8259_IRQ_BASE + i8259_irq, regs);
98 return;
99 }
100
101 /* regular nile4 interrupts (we should not really have any */
102 for (nile4_irq = 0; mask; nile4_irq++, mask >>= 1) {
103 if (mask & 1) {
104 do_IRQ(VRC5476_IRQ_BASE + nile4_irq, regs);
105 return;
106 }
107 }
108 spurious_interrupt(regs);
109}
diff --git a/arch/mips/ddb5xxx/ddb5477/setup.c b/arch/mips/ddb5xxx/ddb5477/setup.c
index 2f566034cc44..93167ecdb424 100644
--- a/arch/mips/ddb5xxx/ddb5477/setup.c
+++ b/arch/mips/ddb5xxx/ddb5477/setup.c
@@ -171,7 +171,7 @@ static void ddb5477_board_init(void);
171extern struct pci_controller ddb5477_ext_controller; 171extern struct pci_controller ddb5477_ext_controller;
172extern struct pci_controller ddb5477_io_controller; 172extern struct pci_controller ddb5477_io_controller;
173 173
174void __init plat_setup(void) 174void __init plat_mem_setup(void)
175{ 175{
176 /* initialize board - we don't trust the loader */ 176 /* initialize board - we don't trust the loader */
177 ddb5477_board_init(); 177 ddb5477_board_init();
diff --git a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c
index ad5d436d80c1..9c707b9ceb65 100644
--- a/arch/mips/dec/setup.c
+++ b/arch/mips/dec/setup.c
@@ -147,7 +147,7 @@ static void __init dec_be_init(void)
147extern void dec_time_init(void); 147extern void dec_time_init(void);
148extern void dec_timer_setup(struct irqaction *); 148extern void dec_timer_setup(struct irqaction *);
149 149
150void __init plat_setup(void) 150void __init plat_mem_setup(void)
151{ 151{
152 board_be_init = dec_be_init; 152 board_be_init = dec_be_init;
153 board_time_init = dec_time_init; 153 board_time_init = dec_time_init;
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index 74cb055d4bf6..76e4d09ff4d2 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -181,7 +181,7 @@ void __init dec_time_init(void)
181 } 181 }
182 182
183 /* Set up the rate of periodic DS1287 interrupts. */ 183 /* Set up the rate of periodic DS1287 interrupts. */
184 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - LOG_2_HZ), RTC_REG_A); 184 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A);
185} 185}
186 186
187EXPORT_SYMBOL(do_settimeofday); 187EXPORT_SYMBOL(do_settimeofday);
diff --git a/arch/mips/defconfig b/arch/mips/defconfig
index 607e2985ffe3..879ba1ad99ca 100644
--- a/arch/mips/defconfig
+++ b/arch/mips/defconfig
@@ -41,8 +41,6 @@ CONFIG_MIPS=y
41# CONFIG_MIPS_XXS1500 is not set 41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_V2PCI is not set 42# CONFIG_PNX8550_V2PCI is not set
43# CONFIG_PNX8550_JBS is not set 43# CONFIG_PNX8550_JBS is not set
44# CONFIG_DDB5074 is not set
45# CONFIG_DDB5476 is not set
46# CONFIG_DDB5477 is not set 44# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set 45# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set 46# CONFIG_PMC_YOSEMITE is not set
@@ -136,6 +134,15 @@ CONFIG_FLATMEM=y
136CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
137# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
138CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
139# CONFIG_PREEMPT_NONE is not set 146# CONFIG_PREEMPT_NONE is not set
140CONFIG_PREEMPT_VOLUNTARY=y 147CONFIG_PREEMPT_VOLUNTARY=y
141# CONFIG_PREEMPT is not set 148# CONFIG_PREEMPT is not set
diff --git a/arch/mips/emma2rh/common/Makefile b/arch/mips/emma2rh/common/Makefile
new file mode 100644
index 000000000000..859121b3867d
--- /dev/null
+++ b/arch/mips/emma2rh/common/Makefile
@@ -0,0 +1,13 @@
1#
2# arch/mips/emma2rh/common/Makefile
3# Makefile for the common code of NEC EMMA2RH based board.
4#
5# Copyright (C) NEC Electronics Corporation 2005-2006
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13obj-$(CONFIG_MARKEINS) += irq.o irq_emma2rh.o prom.o
diff --git a/arch/mips/emma2rh/common/irq.c b/arch/mips/emma2rh/common/irq.c
new file mode 100644
index 000000000000..b075281e50e9
--- /dev/null
+++ b/arch/mips/emma2rh/common/irq.c
@@ -0,0 +1,108 @@
1/*
2 * arch/mips/emma2rh/common/irq.c
3 * This file is common irq dispatcher.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25#include <linux/config.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/irq.h>
29#include <linux/types.h>
30
31#include <asm/i8259.h>
32#include <asm/system.h>
33#include <asm/mipsregs.h>
34#include <asm/debug.h>
35#include <asm/addrspace.h>
36#include <asm/bootinfo.h>
37
38#include <asm/emma2rh/emma2rh.h>
39
40/*
41 * the first level int-handler will jump here if it is a emma2rh irq
42 */
43asmlinkage void emma2rh_irq_dispatch(struct pt_regs *regs)
44{
45 u32 intStatus;
46 u32 bitmask;
47 u32 i;
48
49 intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_0)
50 & emma2rh_in32(EMMA2RH_BHIF_INT_EN_0);
51
52#ifdef EMMA2RH_SW_CASCADE
53 if (intStatus &
54 (1 << ((EMMA2RH_SW_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) {
55 u32 swIntStatus;
56 swIntStatus = emma2rh_in32(EMMA2RH_BHIF_SW_INT)
57 & emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
58 for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) {
59 if (swIntStatus & bitmask) {
60 do_IRQ(EMMA2RH_SW_IRQ_BASE + i, regs);
61 return;
62 }
63 }
64 }
65#endif
66
67 for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) {
68 if (intStatus & bitmask) {
69 do_IRQ(EMMA2RH_IRQ_BASE + i, regs);
70 return;
71 }
72 }
73
74 intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_1)
75 & emma2rh_in32(EMMA2RH_BHIF_INT_EN_1);
76
77#ifdef EMMA2RH_GPIO_CASCADE
78 if (intStatus &
79 (1 << ((EMMA2RH_GPIO_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) {
80 u32 gpioIntStatus;
81 gpioIntStatus = emma2rh_in32(EMMA2RH_GPIO_INT_ST)
82 & emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
83 for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) {
84 if (gpioIntStatus & bitmask) {
85 do_IRQ(EMMA2RH_GPIO_IRQ_BASE + i, regs);
86 return;
87 }
88 }
89 }
90#endif
91
92 for (i = 32, bitmask = 1; i < 64; i++, bitmask <<= 1) {
93 if (intStatus & bitmask) {
94 do_IRQ(EMMA2RH_IRQ_BASE + i, regs);
95 return;
96 }
97 }
98
99 intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_2)
100 & emma2rh_in32(EMMA2RH_BHIF_INT_EN_2);
101
102 for (i = 64, bitmask = 1; i < 96; i++, bitmask <<= 1) {
103 if (intStatus & bitmask) {
104 do_IRQ(EMMA2RH_IRQ_BASE + i, regs);
105 return;
106 }
107 }
108}
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c
new file mode 100644
index 000000000000..b886aa94ca90
--- /dev/null
+++ b/arch/mips/emma2rh/common/irq_emma2rh.c
@@ -0,0 +1,134 @@
1/*
2 * arch/mips/emma2rh/common/irq_emma2rh.c
3 * This file defines the irq handler for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq_5477.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26/*
27 * EMMA2RH defines 64 IRQs.
28 *
29 * This file exports one function:
30 * emma2rh_irq_init(u32 irq_base);
31 */
32
33#include <linux/interrupt.h>
34#include <linux/types.h>
35#include <linux/ptrace.h>
36
37#include <asm/debug.h>
38
39#include <asm/emma2rh/emma2rh.h>
40
41/* number of total irqs supported by EMMA2RH */
42#define NUM_EMMA2RH_IRQ 96
43
44static int emma2rh_irq_base = -1;
45
46void ll_emma2rh_irq_enable(int);
47void ll_emma2rh_irq_disable(int);
48
49static void emma2rh_irq_enable(unsigned int irq)
50{
51 ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
52}
53
54static void emma2rh_irq_disable(unsigned int irq)
55{
56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
57}
58
59static unsigned int emma2rh_irq_startup(unsigned int irq)
60{
61 emma2rh_irq_enable(irq);
62 return 0;
63}
64
65#define emma2rh_irq_shutdown emma2rh_irq_disable
66
67static void emma2rh_irq_ack(unsigned int irq)
68{
69 /* disable interrupt - some handler will re-enable the irq
70 * and if the interrupt is leveled, we will have infinite loop
71 */
72 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
73}
74
75static void emma2rh_irq_end(unsigned int irq)
76{
77 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
78 ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
79}
80
81hw_irq_controller emma2rh_irq_controller = {
82 .typename = "emma2rh_irq",
83 .startup = emma2rh_irq_startup,
84 .shutdown = emma2rh_irq_shutdown,
85 .enable = emma2rh_irq_enable,
86 .disable = emma2rh_irq_disable,
87 .ack = emma2rh_irq_ack,
88 .end = emma2rh_irq_end,
89 .set_affinity = NULL /* no affinity stuff for UP */
90};
91
92void emma2rh_irq_init(u32 irq_base)
93{
94 u32 i;
95
96 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ; i++) {
97 irq_desc[i].status = IRQ_DISABLED;
98 irq_desc[i].action = NULL;
99 irq_desc[i].depth = 1;
100 irq_desc[i].handler = &emma2rh_irq_controller;
101 }
102
103 emma2rh_irq_base = irq_base;
104}
105
106void ll_emma2rh_irq_enable(int emma2rh_irq)
107{
108 u32 reg_value;
109 u32 reg_bitmask;
110 u32 reg_index;
111
112 reg_index = EMMA2RH_BHIF_INT_EN_0
113 + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0)
114 * (emma2rh_irq / 32);
115 reg_value = emma2rh_in32(reg_index);
116 reg_bitmask = 0x1 << (emma2rh_irq % 32);
117 db_assert((reg_value & reg_bitmask) == 0);
118 emma2rh_out32(reg_index, reg_value | reg_bitmask);
119}
120
121void ll_emma2rh_irq_disable(int emma2rh_irq)
122{
123 u32 reg_value;
124 u32 reg_bitmask;
125 u32 reg_index;
126
127 reg_index = EMMA2RH_BHIF_INT_EN_0
128 + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0)
129 * (emma2rh_irq / 32);
130 reg_value = emma2rh_in32(reg_index);
131 reg_bitmask = 0x1 << (emma2rh_irq % 32);
132 db_assert((reg_value & reg_bitmask) != 0);
133 emma2rh_out32(reg_index, reg_value & ~reg_bitmask);
134}
diff --git a/arch/mips/emma2rh/common/prom.c b/arch/mips/emma2rh/common/prom.c
new file mode 100644
index 000000000000..8bba0b02a204
--- /dev/null
+++ b/arch/mips/emma2rh/common/prom.c
@@ -0,0 +1,77 @@
1/*
2 * arch/mips/emma2rh/common/prom.c
3 * This file is prom file.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/common/prom.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25#include <linux/config.h>
26#include <linux/init.h>
27#include <linux/mm.h>
28#include <linux/sched.h>
29#include <linux/bootmem.h>
30
31#include <asm/addrspace.h>
32#include <asm/bootinfo.h>
33#include <asm/emma2rh/emma2rh.h>
34#include <asm/debug.h>
35
36const char *get_system_type(void)
37{
38 switch (mips_machtype) {
39 case MACH_NEC_MARKEINS:
40 return "NEC EMMA2RH Mark-eins";
41 default:
42 return "Unknown NEC board";
43 }
44}
45
46/* [jsun@junsun.net] PMON passes arguments in C main() style */
47void __init prom_init(void)
48{
49 int argc = fw_arg0;
50 char **arg = (char **)fw_arg1;
51 int i;
52
53 /* if user passes kernel args, ignore the default one */
54 if (argc > 1)
55 arcs_cmdline[0] = '\0';
56
57 /* arg[0] is "g", the rest is boot parameters */
58 for (i = 1; i < argc; i++) {
59 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
60 >= sizeof(arcs_cmdline))
61 break;
62 strcat(arcs_cmdline, arg[i]);
63 strcat(arcs_cmdline, " ");
64 }
65
66 mips_machgroup = MACH_GROUP_NEC_EMMA2RH;
67
68#if defined(CONFIG_MARKEINS)
69 mips_machtype = MACH_NEC_MARKEINS;
70 add_memory_region(0, EMMA2RH_RAM_SIZE, BOOT_MEM_RAM);
71#endif
72
73}
74
75void __init prom_free_prom_memory(void)
76{
77}
diff --git a/arch/mips/emma2rh/markeins/Makefile b/arch/mips/emma2rh/markeins/Makefile
new file mode 100644
index 000000000000..14fc268b175c
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/Makefile
@@ -0,0 +1,13 @@
1#
2# arch/mips/emma2rh/markeins/Makefile
3# Makefile for the common code of NEC EMMA2RH based board.
4#
5# Copyright (C) NEC Electronics Corporation 2005-2006
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13obj-$(CONFIG_MARKEINS) += irq.o irq_markeins.o setup.o led.o platform.o
diff --git a/arch/mips/emma2rh/markeins/irq.c b/arch/mips/emma2rh/markeins/irq.c
new file mode 100644
index 000000000000..76dc3faeaf4e
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/irq.c
@@ -0,0 +1,134 @@
1/*
2 * arch/mips/emma2rh/markeins/irq.c
3 * This file defines the irq handler for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25#include <linux/config.h>
26#include <linux/init.h>
27#include <linux/interrupt.h>
28#include <linux/irq.h>
29#include <linux/types.h>
30#include <linux/ptrace.h>
31#include <linux/delay.h>
32
33#include <asm/i8259.h>
34#include <asm/irq_cpu.h>
35#include <asm/system.h>
36#include <asm/mipsregs.h>
37#include <asm/debug.h>
38#include <asm/addrspace.h>
39#include <asm/bootinfo.h>
40
41#include <asm/emma2rh/emma2rh.h>
42
43/*
44 * IRQ mapping
45 *
46 * 0-7: 8 CPU interrupts
47 * 0 - software interrupt 0
48 * 1 - software interrupt 1
49 * 2 - most Vrc5477 interrupts are routed to this pin
50 * 3 - (optional) some other interrupts routed to this pin for debugg
51 * 4 - not used
52 * 5 - not used
53 * 6 - not used
54 * 7 - cpu timer (used by default)
55 *
56 */
57
58extern void emma2rh_sw_irq_init(u32 base);
59extern void emma2rh_gpio_irq_init(u32 base);
60extern void emma2rh_irq_init(u32 base);
61extern asmlinkage void emma2rh_irq_dispatch(struct pt_regs *regs);
62
63static struct irqaction irq_cascade = {
64 .handler = no_action,
65 .flags = 0,
66 .mask = CPU_MASK_NONE,
67 .name = "cascade",
68 .dev_id = NULL,
69 .next = NULL,
70};
71
72void __init arch_init_irq(void)
73{
74 u32 reg;
75
76 db_run(printk("markeins_irq_setup invoked.\n"));
77
78 /* by default, interrupts are disabled. */
79 emma2rh_out32(EMMA2RH_BHIF_INT_EN_0, 0);
80 emma2rh_out32(EMMA2RH_BHIF_INT_EN_1, 0);
81 emma2rh_out32(EMMA2RH_BHIF_INT_EN_2, 0);
82 emma2rh_out32(EMMA2RH_BHIF_INT1_EN_0, 0);
83 emma2rh_out32(EMMA2RH_BHIF_INT1_EN_1, 0);
84 emma2rh_out32(EMMA2RH_BHIF_INT1_EN_2, 0);
85 emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, 0);
86
87 clear_c0_status(0xff00);
88 set_c0_status(0x0400);
89
90#define GPIO_PCI (0xf<<15)
91 /* setup GPIO interrupt for PCI interface */
92 /* direction input */
93 reg = emma2rh_in32(EMMA2RH_GPIO_DIR);
94 emma2rh_out32(EMMA2RH_GPIO_DIR, reg & ~GPIO_PCI);
95 /* disable interrupt */
96 reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
97 emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg & ~GPIO_PCI);
98 /* level triggerd */
99 reg = emma2rh_in32(EMMA2RH_GPIO_INT_MODE);
100 emma2rh_out32(EMMA2RH_GPIO_INT_MODE, reg | GPIO_PCI);
101 reg = emma2rh_in32(EMMA2RH_GPIO_INT_CND_A);
102 emma2rh_out32(EMMA2RH_GPIO_INT_CND_A, reg & (~GPIO_PCI));
103 /* interrupt clear */
104 emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~GPIO_PCI);
105
106 /* init all controllers */
107 emma2rh_irq_init(EMMA2RH_IRQ_BASE);
108 emma2rh_sw_irq_init(EMMA2RH_SW_IRQ_BASE);
109 emma2rh_gpio_irq_init(EMMA2RH_GPIO_IRQ_BASE);
110 mips_cpu_irq_init(CPU_IRQ_BASE);
111
112 /* setup cascade interrupts */
113 setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_SW_CASCADE, &irq_cascade);
114 setup_irq(EMMA2RH_IRQ_BASE + EMMA2RH_GPIO_CASCADE, &irq_cascade);
115 setup_irq(CPU_IRQ_BASE + CPU_EMMA2RH_CASCADE, &irq_cascade);
116}
117
118asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
119{
120 unsigned int pending = read_c0_status() & read_c0_cause();
121
122 if (pending & STATUSF_IP7)
123 do_IRQ(CPU_IRQ_BASE + 7, regs);
124 else if (pending & STATUSF_IP2)
125 emma2rh_irq_dispatch(regs);
126 else if (pending & STATUSF_IP1)
127 do_IRQ(CPU_IRQ_BASE + 1, regs);
128 else if (pending & STATUSF_IP0)
129 do_IRQ(CPU_IRQ_BASE + 0, regs);
130 else
131 spurious_interrupt(regs);
132}
133
134
diff --git a/arch/mips/emma2rh/markeins/irq_markeins.c b/arch/mips/emma2rh/markeins/irq_markeins.c
new file mode 100644
index 000000000000..1783fdab6459
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/irq_markeins.c
@@ -0,0 +1,197 @@
1/*
2 * arch/mips/emma2rh/markeins/irq_markeins.c
3 * This file defines the irq handler for Mark-eins.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq_5477.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <linux/types.h>
28#include <linux/ptrace.h>
29
30#include <asm/debug.h>
31#include <asm/emma2rh/emma2rh.h>
32
33static int emma2rh_sw_irq_base = -1;
34static int emma2rh_gpio_irq_base = -1;
35
36void ll_emma2rh_sw_irq_enable(int reg);
37void ll_emma2rh_sw_irq_disable(int reg);
38void ll_emma2rh_gpio_irq_enable(int reg);
39void ll_emma2rh_gpio_irq_disable(int reg);
40
41static void emma2rh_sw_irq_enable(unsigned int irq)
42{
43 ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
44}
45
46static void emma2rh_sw_irq_disable(unsigned int irq)
47{
48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
49}
50
51static unsigned int emma2rh_sw_irq_startup(unsigned int irq)
52{
53 emma2rh_sw_irq_enable(irq);
54 return 0;
55}
56
57#define emma2rh_sw_irq_shutdown emma2rh_sw_irq_disable
58
59static void emma2rh_sw_irq_ack(unsigned int irq)
60{
61 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
62}
63
64static void emma2rh_sw_irq_end(unsigned int irq)
65{
66 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
67 ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
68}
69
70hw_irq_controller emma2rh_sw_irq_controller = {
71 .typename = "emma2rh_sw_irq",
72 .startup = emma2rh_sw_irq_startup,
73 .shutdown = emma2rh_sw_irq_shutdown,
74 .enable = emma2rh_sw_irq_enable,
75 .disable = emma2rh_sw_irq_disable,
76 .ack = emma2rh_sw_irq_ack,
77 .end = emma2rh_sw_irq_end,
78 .set_affinity = NULL,
79};
80
81void emma2rh_sw_irq_init(u32 irq_base)
82{
83 u32 i;
84
85 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_SW; i++) {
86 irq_desc[i].status = IRQ_DISABLED;
87 irq_desc[i].action = NULL;
88 irq_desc[i].depth = 2;
89 irq_desc[i].handler = &emma2rh_sw_irq_controller;
90 }
91
92 emma2rh_sw_irq_base = irq_base;
93}
94
95void ll_emma2rh_sw_irq_enable(int irq)
96{
97 u32 reg;
98
99 db_assert(irq >= 0);
100 db_assert(irq < NUM_EMMA2RH_IRQ_SW);
101
102 reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
103 reg |= 1 << irq;
104 emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg);
105}
106
107void ll_emma2rh_sw_irq_disable(int irq)
108{
109 u32 reg;
110
111 db_assert(irq >= 0);
112 db_assert(irq < 32);
113
114 reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
115 reg &= ~(1 << irq);
116 emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg);
117}
118
119static void emma2rh_gpio_irq_enable(unsigned int irq)
120{
121 ll_emma2rh_gpio_irq_enable(irq - emma2rh_gpio_irq_base);
122}
123
124static void emma2rh_gpio_irq_disable(unsigned int irq)
125{
126 ll_emma2rh_gpio_irq_disable(irq - emma2rh_gpio_irq_base);
127}
128
129static unsigned int emma2rh_gpio_irq_startup(unsigned int irq)
130{
131 emma2rh_gpio_irq_enable(irq);
132 return 0;
133}
134
135#define emma2rh_gpio_irq_shutdown emma2rh_gpio_irq_disable
136
137static void emma2rh_gpio_irq_ack(unsigned int irq)
138{
139 irq -= emma2rh_gpio_irq_base;
140 emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~(1 << irq));
141 ll_emma2rh_gpio_irq_disable(irq);
142}
143
144static void emma2rh_gpio_irq_end(unsigned int irq)
145{
146 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
147 ll_emma2rh_gpio_irq_enable(irq - emma2rh_gpio_irq_base);
148}
149
150hw_irq_controller emma2rh_gpio_irq_controller = {
151 .typename = "emma2rh_gpio_irq",
152 .startup = emma2rh_gpio_irq_startup,
153 .shutdown = emma2rh_gpio_irq_shutdown,
154 .enable = emma2rh_gpio_irq_enable,
155 .disable = emma2rh_gpio_irq_disable,
156 .ack = emma2rh_gpio_irq_ack,
157 .end = emma2rh_gpio_irq_end,
158 .set_affinity = NULL,
159};
160
161void emma2rh_gpio_irq_init(u32 irq_base)
162{
163 u32 i;
164
165 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_GPIO; i++) {
166 irq_desc[i].status = IRQ_DISABLED;
167 irq_desc[i].action = NULL;
168 irq_desc[i].depth = 2;
169 irq_desc[i].handler = &emma2rh_gpio_irq_controller;
170 }
171
172 emma2rh_gpio_irq_base = irq_base;
173}
174
175void ll_emma2rh_gpio_irq_enable(int irq)
176{
177 u32 reg;
178
179 db_assert(irq >= 0);
180 db_assert(irq < NUM_EMMA2RH_IRQ_GPIO);
181
182 reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
183 reg |= 1 << irq;
184 emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg);
185}
186
187void ll_emma2rh_gpio_irq_disable(int irq)
188{
189 u32 reg;
190
191 db_assert(irq >= 0);
192 db_assert(irq < NUM_EMMA2RH_IRQ_GPIO);
193
194 reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
195 reg &= ~(1 << irq);
196 emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg);
197}
diff --git a/arch/mips/emma2rh/markeins/led.c b/arch/mips/emma2rh/markeins/led.c
new file mode 100644
index 000000000000..b65254c1bfe9
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/led.c
@@ -0,0 +1,60 @@
1/*
2 * arch/mips/emma2rh/markeins/led.c
3 * This file defines the led display for Mark-eins.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/string.h>
24#include <asm/emma2rh/emma2rh.h>
25
26const unsigned long clear = 0x20202020;
27
28#define LED_BASE 0xb1400038
29
30void markeins_led_clear(void)
31{
32 emma2rh_out32(LED_BASE, clear);
33 emma2rh_out32(LED_BASE + 4, clear);
34}
35
36void markeins_led(const char *str)
37{
38 int i;
39 int len = strlen(str);
40
41 markeins_led_clear();
42 if (len > 8)
43 len = 8;
44
45 if (emma2rh_in32(0xb0000800) & (0x1 << 18))
46 for (i = 0; i < len; i++)
47 emma2rh_out8(LED_BASE + i, str[i]);
48 else
49 for (i = 0; i < len; i++)
50 emma2rh_out8(LED_BASE + (i & 4) + (3 - (i & 3)),
51 str[i]);
52}
53
54void markeins_led_hex(u32 val)
55{
56 char str[10];
57
58 sprintf(str, "%08x", val);
59 markeins_led(str);
60}
diff --git a/arch/mips/emma2rh/markeins/platform.c b/arch/mips/emma2rh/markeins/platform.c
new file mode 100644
index 000000000000..6c1eeae1a898
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/platform.c
@@ -0,0 +1,170 @@
1/*
2 * arch/mips/emma2rh/markeins/platofrm.c
3 * This file sets up platform devices for EMMA2RH Mark-eins.
4 *
5 * Copyright(C) MontaVista Software Inc, 2006
6 *
7 * Author: dmitry pervushin <dpervushin@ru.mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#include <linux/config.h>
24#include <linux/init.h>
25#include <linux/kernel.h>
26#include <linux/types.h>
27#include <linux/ioport.h>
28#include <linux/serial_8250.h>
29#include <linux/mtd/physmap.h>
30
31#include <asm/cpu.h>
32#include <asm/bootinfo.h>
33#include <asm/addrspace.h>
34#include <asm/time.h>
35#include <asm/bcache.h>
36#include <asm/irq.h>
37#include <asm/reboot.h>
38#include <asm/gdb-stub.h>
39#include <asm/traps.h>
40#include <asm/debug.h>
41
42#include <asm/emma2rh/emma2rh.h>
43
44
45#define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
46
47static struct resource i2c_emma_resources_0[] = {
48 { NULL, EMMA2RH_IRQ_PIIC0, EMMA2RH_IRQ_PIIC0, IORESOURCE_IRQ },
49 { NULL, KSEG1ADDR(EMMA2RH_PIIC0_BASE), KSEG1ADDR(EMMA2RH_PIIC0_BASE + 0x1000), 0 },
50};
51
52struct resource i2c_emma_resources_1[] = {
53 { NULL, EMMA2RH_IRQ_PIIC1, EMMA2RH_IRQ_PIIC1, IORESOURCE_IRQ },
54 { NULL, KSEG1ADDR(EMMA2RH_PIIC1_BASE), KSEG1ADDR(EMMA2RH_PIIC1_BASE + 0x1000), 0 },
55};
56
57struct resource i2c_emma_resources_2[] = {
58 { NULL, EMMA2RH_IRQ_PIIC2, EMMA2RH_IRQ_PIIC2, IORESOURCE_IRQ },
59 { NULL, KSEG1ADDR(EMMA2RH_PIIC2_BASE), KSEG1ADDR(EMMA2RH_PIIC2_BASE + 0x1000), 0 },
60};
61
62struct platform_device i2c_emma_devices[] = {
63 [0] = {
64 .name = I2C_EMMA2RH,
65 .id = 0,
66 .resource = i2c_emma_resources_0,
67 .num_resources = ARRAY_SIZE(i2c_emma_resources_0),
68 },
69 [1] = {
70 .name = I2C_EMMA2RH,
71 .id = 1,
72 .resource = i2c_emma_resources_1,
73 .num_resources = ARRAY_SIZE(i2c_emma_resources_1),
74 },
75 [2] = {
76 .name = I2C_EMMA2RH,
77 .id = 2,
78 .resource = i2c_emma_resources_2,
79 .num_resources = ARRAY_SIZE(i2c_emma_resources_2),
80 },
81};
82
83#define EMMA2RH_SERIAL_CLOCK 18544000
84#define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
85
86static struct plat_serial8250_port platform_serial_ports[] = {
87 [0] = {
88 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3),
89 .irq = EMMA2RH_IRQ_PFUR0,
90 .uartclk = EMMA2RH_SERIAL_CLOCK,
91 .regshift = 4,
92 .iotype = UPIO_MEM,
93 .flags = EMMA2RH_SERIAL_FLAGS,
94 },
95 [1] = {
96 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3),
97 .irq = EMMA2RH_IRQ_PFUR1,
98 .uartclk = EMMA2RH_SERIAL_CLOCK,
99 .regshift = 4,
100 .iotype = UPIO_MEM,
101 .flags = EMMA2RH_SERIAL_FLAGS,
102 },
103 [2] = {
104 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
105 .irq = EMMA2RH_IRQ_PFUR2,
106 .uartclk = EMMA2RH_SERIAL_CLOCK,
107 .regshift = 4,
108 .iotype = UPIO_MEM,
109 .flags = EMMA2RH_SERIAL_FLAGS,
110 },
111 [3] = {
112 .flags = 0,
113 },
114};
115
116static struct platform_device serial_emma = {
117 .name = "serial8250",
118 .dev = {
119 .platform_data = &platform_serial_ports,
120 },
121};
122
123static struct platform_device *devices[] = {
124 &i2c_emma_devices[0],
125 &i2c_emma_devices[1],
126 &i2c_emma_devices[2],
127 &serial_emma,
128};
129
130static struct mtd_partition markeins_parts[] = {
131 [0] = {
132 .name = "RootFS",
133 .offset = 0x00000000,
134 .size = 0x00c00000,
135 },
136 [1] = {
137 .name = "boot code area",
138 .offset = MTDPART_OFS_APPEND,
139 .size = 0x00100000,
140 },
141 [2] = {
142 .name = "kernel image",
143 .offset = MTDPART_OFS_APPEND,
144 .size = 0x00300000,
145 },
146 [3] = {
147 .name = "RootFS2",
148 .offset = MTDPART_OFS_APPEND,
149 .size = 0x00c00000,
150 },
151 [4] = {
152 .name = "boot code area2",
153 .offset = MTDPART_OFS_APPEND,
154 .size = 0x00100000,
155 },
156 [5] = {
157 .name = "kernel image2",
158 .offset = MTDPART_OFS_APPEND,
159 .size = MTDPART_SIZ_FULL,
160 },
161};
162
163static int __init platform_devices_setup(void)
164{
165 physmap_set_partitions(markeins_parts, ARRAY_SIZE(markeins_parts));
166 return platform_add_devices(devices, ARRAY_SIZE(devices));
167}
168
169arch_initcall(platform_devices_setup);
170
diff --git a/arch/mips/emma2rh/markeins/setup.c b/arch/mips/emma2rh/markeins/setup.c
new file mode 100644
index 000000000000..7d98fdbf8390
--- /dev/null
+++ b/arch/mips/emma2rh/markeins/setup.c
@@ -0,0 +1,182 @@
1/*
2 * arch/mips/emma2rh/markeins/setup.c
3 * This file is setup for EMMA2RH Mark-eins.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c.
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25#include <linux/config.h>
26#include <linux/init.h>
27#include <linux/kernel.h>
28#include <linux/types.h>
29#include <linux/initrd.h>
30#include <linux/irq.h>
31#include <linux/ide.h>
32#include <linux/ioport.h>
33#include <linux/param.h> /* for HZ */
34#include <linux/root_dev.h>
35#include <linux/serial.h>
36#include <linux/serial_core.h>
37
38#include <asm/cpu.h>
39#include <asm/bootinfo.h>
40#include <asm/addrspace.h>
41#include <asm/time.h>
42#include <asm/bcache.h>
43#include <asm/irq.h>
44#include <asm/reboot.h>
45#include <asm/gdb-stub.h>
46#include <asm/traps.h>
47#include <asm/debug.h>
48
49#include <asm/emma2rh/emma2rh.h>
50
51#define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */
52
53extern void markeins_led(const char *);
54
55static int bus_frequency = 0;
56
57static void markeins_machine_restart(char *command)
58{
59 static void (*back_to_prom) (void) = (void (*)(void))0xbfc00000;
60
61 printk("cannot EMMA2RH Mark-eins restart.\n");
62 markeins_led("restart.");
63 back_to_prom();
64}
65
66static void markeins_machine_halt(void)
67{
68 printk("EMMA2RH Mark-eins halted.\n");
69 markeins_led("halted.");
70 while (1) ;
71}
72
73static void markeins_machine_power_off(void)
74{
75 printk("EMMA2RH Mark-eins halted. Please turn off the power.\n");
76 markeins_led("poweroff.");
77 while (1) ;
78}
79
80static unsigned long clock[4] = { 166500000, 187312500, 199800000, 210600000 };
81
82static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
83{
84 u32 reg;
85
86 /* detect from boot strap */
87 reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0);
88 reg = (reg >> 4) & 0x3;
89 return clock[reg];
90}
91
92static void __init emma2rh_time_init(void)
93{
94 u32 reg;
95 if (bus_frequency == 0)
96 bus_frequency = detect_bus_frequency(0);
97
98 reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0);
99 if ((reg & 0x3) == 0)
100 reg = (reg >> 6) & 0x3;
101 else {
102 reg = emma2rh_in32(EMMA2RH_BHIF_MAIN_CTRL);
103 reg = (reg >> 4) & 0x3;
104 }
105 mips_hpt_frequency = (bus_frequency * (4 + reg)) / 4 / 2;
106}
107
108static void __init emma2rh_timer_setup(struct irqaction *irq)
109{
110 /* we are using the cpu counter for timer interrupts */
111 setup_irq(CPU_IRQ_BASE + 7, irq);
112}
113
114static void markeins_board_init(void);
115extern void markeins_irq_setup(void);
116
117static void inline __init markeins_sio_setup(void)
118{
119#ifdef CONFIG_KGDB_8250
120 struct uart_port emma_port;
121
122 memset(&emma_port, 0, sizeof(emma_port));
123
124 emma_port.flags =
125 UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
126 emma_port.iotype = UPIO_MEM;
127 emma_port.regshift = 4; /* I/O addresses are every 8 bytes */
128 emma_port.uartclk = 18544000; /* Clock rate of the chip */
129
130 emma_port.line = 0;
131 emma_port.mapbase = KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3);
132 emma_port.membase = (u8*)emma_port.mapbase;
133 early_serial_setup(&emma_port);
134
135 emma_port.line = 1;
136 emma_port.mapbase = KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3);
137 emma_port.membase = (u8*)emma_port.mapbase;
138 early_serial_setup(&emma_port);
139
140 emma_port.irq = EMMA2RH_IRQ_PFUR1;
141 kgdb8250_add_port(1, &emma_port);
142#endif
143}
144
145void __init plat_mem_setup(void)
146{
147 /* initialize board - we don't trust the loader */
148 markeins_board_init();
149
150 set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE));
151
152 board_time_init = emma2rh_time_init;
153 board_timer_setup = emma2rh_timer_setup;
154
155 _machine_restart = markeins_machine_restart;
156 _machine_halt = markeins_machine_halt;
157 pm_power_off = markeins_machine_power_off;
158
159 /* setup resource limits */
160 ioport_resource.start = EMMA2RH_PCI_IO_BASE;
161 ioport_resource.end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1;
162 iomem_resource.start = EMMA2RH_IO_BASE;
163 iomem_resource.end = EMMA2RH_ROM_BASE - 1;
164
165 /* Reboot on panic */
166 panic_timeout = 180;
167
168 markeins_sio_setup();
169}
170
171static void __init markeins_board_init(void)
172{
173 u32 val;
174
175 val = emma2rh_in32(EMMA2RH_PBRD_INT_EN); /* open serial interrupts. */
176 emma2rh_out32(EMMA2RH_PBRD_INT_EN, val | 0xaa);
177 val = emma2rh_in32(EMMA2RH_PBRD_CLKSEL); /* set serial clocks. */
178 emma2rh_out32(EMMA2RH_PBRD_CLKSEL, val | 0x5); /* 18MHz */
179 emma2rh_out32(EMMA2RH_PCI_CONTROL, 0);
180
181 markeins_led("MVL E2RH");
182}
diff --git a/arch/mips/galileo-boards/ev96100/setup.c b/arch/mips/galileo-boards/ev96100/setup.c
index 78dbb18edeb8..a04aea6123da 100644
--- a/arch/mips/galileo-boards/ev96100/setup.c
+++ b/arch/mips/galileo-boards/ev96100/setup.c
@@ -55,7 +55,7 @@ extern void mips_reboot_setup(void);
55 55
56unsigned char mac_0_1[12]; 56unsigned char mac_0_1[12];
57 57
58void __init plat_setup(void) 58void __init plat_mem_setup(void)
59{ 59{
60 unsigned int config = read_c0_config(); 60 unsigned int config = read_c0_config();
61 unsigned int status = read_c0_status(); 61 unsigned int status = read_c0_status();
diff --git a/arch/mips/gt64120/ev64120/setup.c b/arch/mips/gt64120/ev64120/setup.c
index 6d859d1e7a2d..4236da31ecc6 100644
--- a/arch/mips/gt64120/ev64120/setup.c
+++ b/arch/mips/gt64120/ev64120/setup.c
@@ -71,7 +71,7 @@ unsigned long __init prom_free_prom_memory(void)
71 */ 71 */
72extern void gt64120_time_init(void); 72extern void gt64120_time_init(void);
73 73
74void __init plat_setup(void) 74void __init plat_mem_setup(void)
75{ 75{
76 _machine_restart = galileo_machine_restart; 76 _machine_restart = galileo_machine_restart;
77 _machine_halt = galileo_machine_halt; 77 _machine_halt = galileo_machine_halt;
diff --git a/arch/mips/gt64120/momenco_ocelot/setup.c b/arch/mips/gt64120/momenco_ocelot/setup.c
index 20b65d3d2151..1193a22c4693 100644
--- a/arch/mips/gt64120/momenco_ocelot/setup.c
+++ b/arch/mips/gt64120/momenco_ocelot/setup.c
@@ -152,7 +152,7 @@ void PMON_v2_setup()
152 gt64120_base = 0xe0000000; 152 gt64120_base = 0xe0000000;
153} 153}
154 154
155void __init plat_setup(void) 155void __init plat_mem_setup(void)
156{ 156{
157 void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache); 157 void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache);
158 unsigned int tmpword; 158 unsigned int tmpword;
diff --git a/arch/mips/gt64120/wrppmc/Makefile b/arch/mips/gt64120/wrppmc/Makefile
new file mode 100644
index 000000000000..72606b9af12a
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/Makefile
@@ -0,0 +1,14 @@
1#
2# This file is subject to the terms and conditions of the GNU General Public
3# License. See the file "COPYING" in the main directory of this archive
4# for more details.
5#
6# Copyright 2006 Wind River System, Inc.
7# Author: Rongkai.Zhan <rongkai.zhan@windriver.com>
8#
9# Makefile for the Wind River MIPS 4KC PPMC Eval Board
10#
11
12obj-y += int-handler.o irq.o reset.o setup.o time.o pci.o
13
14EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/gt64120/wrppmc/int-handler.S b/arch/mips/gt64120/wrppmc/int-handler.S
new file mode 100644
index 000000000000..edee7b394175
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/int-handler.S
@@ -0,0 +1,59 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle
7 * Copyright (C) Wind River System Inc. Rongkai.Zhan <rongkai.zhan@windriver.com>
8 */
9#include <asm/asm.h>
10#include <asm/mipsregs.h>
11#include <asm/addrspace.h>
12#include <asm/regdef.h>
13#include <asm/stackframe.h>
14#include <asm/mach-wrppmc/mach-gt64120.h>
15
16 .align 5
17 .set noat
18NESTED(handle_IRQ, PT_SIZE, sp)
19 SAVE_ALL
20 CLI # Important: mark KERNEL mode !
21 .set at
22
23 mfc0 t0, CP0_CAUSE # get pending interrupts
24 mfc0 t1, CP0_STATUS # get enabled interrupts
25 and t0, t0, t1 # get allowed interrupts
26 andi t0, t0, 0xFF00
27 beqz t0, 1f
28 move a1, sp # Prepare 'struct pt_regs *regs' pointer
29
30 andi t1, t0, CAUSEF_IP7 # CPU Compare/Count internal timer
31 bnez t1, handle_cputimer_irq
32 andi t1, t0, CAUSEF_IP6 # UART 16550 port
33 bnez t1, handle_uart_irq
34 andi t1, t0, CAUSEF_IP3 # PCI INT_A
35 bnez t1, handle_pci_intA_irq
36
37 /* wrong alarm or masked ... */
381: j spurious_interrupt
39 nop
40END(handle_IRQ)
41
42 .align 5
43handle_cputimer_irq:
44 li a0, WRPPMC_MIPS_TIMER_IRQ
45 jal do_IRQ
46 j ret_from_irq
47
48 .align 5
49handle_uart_irq:
50 li a0, WRPPMC_UART16550_IRQ
51 jal do_IRQ
52 j ret_from_irq
53
54 .align 5
55handle_pci_intA_irq:
56 li a0, WRPPMC_PCI_INTA_IRQ
57 jal do_IRQ
58 j ret_from_irq
59
diff --git a/arch/mips/gt64120/wrppmc/irq.c b/arch/mips/gt64120/wrppmc/irq.c
new file mode 100644
index 000000000000..8605687e24ed
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/irq.c
@@ -0,0 +1,63 @@
1/*
2 * irq.c: GT64120 Interrupt Controller
3 *
4 * Copyright (C) 2006, Wind River System Inc.
5 * Author: Rongkai.Zhan, <rongkai.zhan@windriver.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12#include <linux/errno.h>
13#include <linux/init.h>
14#include <linux/kernel_stat.h>
15#include <linux/module.h>
16#include <linux/signal.h>
17#include <linux/sched.h>
18#include <linux/types.h>
19#include <linux/interrupt.h>
20#include <linux/ioport.h>
21#include <linux/timex.h>
22#include <linux/slab.h>
23#include <linux/random.h>
24#include <linux/bitops.h>
25#include <asm/bootinfo.h>
26#include <asm/io.h>
27#include <asm/bitops.h>
28#include <asm/mipsregs.h>
29#include <asm/system.h>
30#include <asm/irq_cpu.h>
31#include <asm/gt64120.h>
32
33extern asmlinkage void handle_IRQ(void);
34
35/**
36 * Initialize GT64120 Interrupt Controller
37 */
38void gt64120_init_pic(void)
39{
40 /* clear CPU Interrupt Cause Registers */
41 GT_WRITE(GT_INTRCAUSE_OFS, (0x1F << 21));
42 GT_WRITE(GT_HINTRCAUSE_OFS, 0x00);
43
44 /* Disable all interrupts from GT64120 bridge chip */
45 GT_WRITE(GT_INTRMASK_OFS, 0x00);
46 GT_WRITE(GT_HINTRMASK_OFS, 0x00);
47 GT_WRITE(GT_PCI0_ICMASK_OFS, 0x00);
48 GT_WRITE(GT_PCI0_HICMASK_OFS, 0x00);
49}
50
51void __init arch_init_irq(void)
52{
53 /* enable all CPU interrupt bits. */
54 set_c0_status(ST0_IM); /* IE bit is still 0 */
55
56 /* Install MIPS Interrupt Trap Vector */
57 set_except_vector(0, handle_IRQ);
58
59 /* IRQ 0 - 7 are for MIPS common irq_cpu controller */
60 mips_cpu_irq_init(0);
61
62 gt64120_init_pic();
63}
diff --git a/arch/mips/gt64120/wrppmc/pci.c b/arch/mips/gt64120/wrppmc/pci.c
new file mode 100644
index 000000000000..2fbe93467f78
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/pci.c
@@ -0,0 +1,53 @@
1/*
2 * pci.c: GT64120 PCI support.
3 *
4 * Copyright (C) 2006, Wind River System Inc. Rongkai.Zhan <rongkai.zhan@windriver.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/types.h>
12#include <linux/pci.h>
13#include <linux/kernel.h>
14#include <asm/gt64120.h>
15
16extern struct pci_ops gt64120_pci_ops;
17
18static struct resource pci0_io_resource = {
19 .name = "pci_0 io",
20 .start = GT_PCI_IO_BASE,
21 .end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1,
22 .flags = IORESOURCE_IO,
23};
24
25static struct resource pci0_mem_resource = {
26 .name = "pci_0 memory",
27 .start = GT_PCI_MEM_BASE,
28 .end = GT_PCI_MEM_BASE + GT_PCI_MEM_SIZE - 1,
29 .flags = IORESOURCE_MEM,
30};
31
32static struct pci_controller hose_0 = {
33 .pci_ops = &gt64120_pci_ops,
34 .io_resource = &pci0_io_resource,
35 .mem_resource = &pci0_mem_resource,
36};
37
38static int __init gt64120_pci_init(void)
39{
40 u32 tmp;
41
42 tmp = GT_READ(GT_PCI0_CMD_OFS); /* Huh??? -- Ralf */
43 tmp = GT_READ(GT_PCI0_BARE_OFS);
44
45 /* reset the whole PCI I/O space range */
46 ioport_resource.start = GT_PCI_IO_BASE;
47 ioport_resource.end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1;
48
49 register_pci_controller(&hose_0);
50 return 0;
51}
52
53arch_initcall(gt64120_pci_init);
diff --git a/arch/mips/gt64120/wrppmc/reset.c b/arch/mips/gt64120/wrppmc/reset.c
new file mode 100644
index 000000000000..b97039c6d3db
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/reset.c
@@ -0,0 +1,50 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1997 Ralf Baechle
7 */
8#include <linux/sched.h>
9#include <linux/mm.h>
10#include <asm/io.h>
11#include <asm/pgtable.h>
12#include <asm/processor.h>
13#include <asm/reboot.h>
14#include <asm/system.h>
15#include <asm/cacheflush.h>
16
17void wrppmc_machine_restart(char *command)
18{
19 /*
20 * Ouch, we're still alive ... This time we take the silver bullet ...
21 * ... and find that we leave the hardware in a state in which the
22 * kernel in the flush locks up somewhen during of after the PCI
23 * detection stuff.
24 */
25 local_irq_disable();
26 set_c0_status(ST0_BEV | ST0_ERL);
27 change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
28 flush_cache_all();
29 write_c0_wired(0);
30 __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
31}
32
33void wrppmc_machine_halt(void)
34{
35 local_irq_disable();
36
37 printk(KERN_NOTICE "You can safely turn off the power\n");
38 while (1) {
39 __asm__(
40 ".set\tmips3\n\t"
41 "wait\n\t"
42 ".set\tmips0"
43 );
44 }
45}
46
47void wrppmc_machine_power_off(void)
48{
49 wrppmc_machine_halt();
50}
diff --git a/arch/mips/gt64120/wrppmc/setup.c b/arch/mips/gt64120/wrppmc/setup.c
new file mode 100644
index 000000000000..20c591e49dae
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/setup.c
@@ -0,0 +1,173 @@
1/*
2 * setup.c: Setup pointers to hardware dependent routines.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
9 * Copyright (C) 2006, Wind River System Inc. Rongkai.zhan <rongkai.zhan@windriver.com>
10 */
11#include <linux/config.h>
12#include <linux/init.h>
13#include <linux/string.h>
14#include <linux/kernel.h>
15#include <linux/tty.h>
16#include <linux/serial.h>
17#include <linux/serial_core.h>
18#include <linux/pm.h>
19
20#include <asm/io.h>
21#include <asm/bootinfo.h>
22#include <asm/reboot.h>
23#include <asm/time.h>
24#include <asm/gt64120.h>
25
26unsigned long gt64120_base = KSEG1ADDR(0x14000000);
27
28#ifdef WRPPMC_EARLY_DEBUG
29
30static volatile unsigned char * wrppmc_led = \
31 (volatile unsigned char *)KSEG1ADDR(WRPPMC_LED_BASE);
32
33/*
34 * PPMC LED control register:
35 * -) bit[0] controls DS1 LED (1 - OFF, 0 - ON)
36 * -) bit[1] controls DS2 LED (1 - OFF, 0 - ON)
37 * -) bit[2] controls DS4 LED (1 - OFF, 0 - ON)
38 */
39void wrppmc_led_on(int mask)
40{
41 unsigned char value = *wrppmc_led;
42
43 value &= (0xF8 | mask);
44 *wrppmc_led = value;
45}
46
47/* If mask = 0, turn off all LEDs */
48void wrppmc_led_off(int mask)
49{
50 unsigned char value = *wrppmc_led;
51
52 value |= (0x7 & mask);
53 *wrppmc_led = value;
54}
55
56/*
57 * We assume that bootloader has initialized UART16550 correctly
58 */
59void __init wrppmc_early_putc(char ch)
60{
61 static volatile unsigned char *wrppmc_uart = \
62 (volatile unsigned char *)KSEG1ADDR(WRPPMC_UART16550_BASE);
63 unsigned char value;
64
65 /* Wait until Transmit-Holding-Register is empty */
66 while (1) {
67 value = *(wrppmc_uart + 5);
68 if (value & 0x20)
69 break;
70 }
71
72 *wrppmc_uart = ch;
73}
74
75void __init wrppmc_early_printk(const char *fmt, ...)
76{
77 static char pbuf[256] = {'\0', };
78 char *ch = pbuf;
79 va_list args;
80 unsigned int i;
81
82 memset(pbuf, 0, 256);
83 va_start(args, fmt);
84 i = vsprintf(pbuf, fmt, args);
85 va_end(args);
86
87 /* Print the string */
88 while (*ch != '\0') {
89 wrppmc_early_putc(*ch);
90 /* if print '\n', also print '\r' */
91 if (*ch++ == '\n')
92 wrppmc_early_putc('\r');
93 }
94}
95#endif /* WRPPMC_EARLY_DEBUG */
96
97unsigned long __init prom_free_prom_memory(void)
98{
99 return 0;
100}
101
102#ifdef CONFIG_SERIAL_8250
103static void wrppmc_setup_serial(void)
104{
105 struct uart_port up;
106
107 memset(&up, 0x00, sizeof(struct uart_port));
108
109 /*
110 * A note about mapbase/membase
111 * -) mapbase is the physical address of the IO port.
112 * -) membase is an 'ioremapped' cookie.
113 */
114 up.line = 0;
115 up.type = PORT_16550;
116 up.iotype = UPIO_MEM;
117 up.mapbase = WRPPMC_UART16550_BASE;
118 up.membase = ioremap(up.mapbase, 8);
119 up.irq = WRPPMC_UART16550_IRQ;
120 up.uartclk = WRPPMC_UART16550_CLOCK;
121 up.flags = UPF_SKIP_TEST/* | UPF_BOOT_AUTOCONF */;
122 up.regshift = 0;
123
124 early_serial_setup(&up);
125}
126#endif
127
128void __init plat_setup(void)
129{
130 extern void wrppmc_time_init(void);
131 extern void wrppmc_timer_setup(struct irqaction *);
132 extern void wrppmc_machine_restart(char *command);
133 extern void wrppmc_machine_halt(void);
134 extern void wrppmc_machine_power_off(void);
135
136 _machine_restart = wrppmc_machine_restart;
137 _machine_halt = wrppmc_machine_halt;
138 pm_power_off = wrppmc_machine_power_off;
139
140 /* Use MIPS Count/Compare Timer */
141 board_time_init = wrppmc_time_init;
142 board_timer_setup = wrppmc_timer_setup;
143
144 /* This makes the operations of 'in/out[bwl]' to the
145 * physical address ( < KSEG0) can work via KSEG1
146 */
147 set_io_port_base(KSEG1);
148
149#ifdef CONFIG_SERIAL_8250
150 wrppmc_setup_serial();
151#endif
152}
153
154const char *get_system_type(void)
155{
156 return "Wind River PPMC (GT64120)";
157}
158
159/*
160 * Initializes basic routines and structures pointers, memory size (as
161 * given by the bios and saves the command line.
162 */
163void __init prom_init(void)
164{
165 mips_machgroup = MACH_GROUP_GALILEO;
166 mips_machtype = MACH_EV64120A;
167
168 add_memory_region(WRPPMC_SDRAM_SCS0_BASE, WRPPMC_SDRAM_SCS0_SIZE, BOOT_MEM_RAM);
169 add_memory_region(WRPPMC_BOOTROM_BASE, WRPPMC_BOOTROM_SIZE, BOOT_MEM_ROM_DATA);
170
171 wrppmc_early_printk("prom_init: GT64120 SDRAM Bank 0: 0x%x - 0x%08lx\n",
172 WRPPMC_SDRAM_SCS0_BASE, (WRPPMC_SDRAM_SCS0_BASE + WRPPMC_SDRAM_SCS0_SIZE));
173}
diff --git a/arch/mips/gt64120/wrppmc/time.c b/arch/mips/gt64120/wrppmc/time.c
new file mode 100644
index 000000000000..175d22adb450
--- /dev/null
+++ b/arch/mips/gt64120/wrppmc/time.c
@@ -0,0 +1,57 @@
1/*
2 * time.c: MIPS CPU Count/Compare timer hookup
3 *
4 * Author: Mark.Zhan, <rongkai.zhan@windriver.com>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
11 * Copyright (C) 2006, Wind River System Inc.
12 */
13#include <linux/config.h>
14#include <linux/init.h>
15#include <linux/string.h>
16#include <linux/kernel.h>
17#include <linux/param.h> /* for HZ */
18#include <linux/irq.h>
19#include <linux/timex.h>
20#include <linux/interrupt.h>
21
22#include <asm/reboot.h>
23#include <asm/time.h>
24#include <asm/io.h>
25#include <asm/bootinfo.h>
26#include <asm/gt64120.h>
27
28#define WRPPMC_CPU_CLK_FREQ 40000000 /* 40MHZ */
29
30void __init wrppmc_timer_setup(struct irqaction *irq)
31{
32 /* Install ISR for timer interrupt */
33 setup_irq(WRPPMC_MIPS_TIMER_IRQ, irq);
34
35 /* to generate the first timer interrupt */
36 write_c0_compare(mips_hpt_frequency/HZ);
37 write_c0_count(0);
38}
39
40/*
41 * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect
42 *
43 * NOTE: We disable all GT64120 timers, and use MIPS processor internal
44 * timer as the source of kernel clock tick.
45 */
46void __init wrppmc_time_init(void)
47{
48 /* Disable GT64120 timers */
49 GT_WRITE(GT_TC_CONTROL_OFS, 0x00);
50 GT_WRITE(GT_TC0_OFS, 0x00);
51 GT_WRITE(GT_TC1_OFS, 0x00);
52 GT_WRITE(GT_TC2_OFS, 0x00);
53 GT_WRITE(GT_TC3_OFS, 0x00);
54
55 /* Use MIPS compare/count internal timer */
56 mips_hpt_frequency = WRPPMC_CPU_CLK_FREQ;
57}
diff --git a/arch/mips/ite-boards/generic/it8172_setup.c b/arch/mips/ite-boards/generic/it8172_setup.c
index fc73c8d69df7..da6ae0991199 100644
--- a/arch/mips/ite-boards/generic/it8172_setup.c
+++ b/arch/mips/ite-boards/generic/it8172_setup.c
@@ -72,11 +72,29 @@ struct {
72 struct resource flash; 72 struct resource flash;
73 struct resource boot; 73 struct resource boot;
74} it8172_resources = { 74} it8172_resources = {
75 { "RAM", 0, 0, IORESOURCE_MEM }, /* to be initted */ 75 {
76 { "PCI Mem", 0x10000000, 0x13FFFFFF, IORESOURCE_MEM }, 76 .start = 0, /* to be initted */
77 { "PCI I/O", 0x14000000, 0x17FFFFFF }, 77 .end = 0,
78 { "Flash", 0x08000000, 0x0CFFFFFF }, 78 .name = "RAM",
79 { "Boot ROM", 0x1FC00000, 0x1FFFFFFF } 79 .flags = IORESOURCE_MEM
80 }, {
81 .start = 0x10000000,
82 .end = 0x13FFFFFF,
83 .name = "PCI Mem",
84 .flags = IORESOURCE_MEM
85 }, {
86 .start = 0x14000000,
87 .end = 0x17FFFFFF
88 .name = "PCI I/O",
89 }, {
90 .start = 0x08000000,
91 .end = 0x0CFFFFFF
92 .name = "Flash",
93 }, {
94 .start = 0x1FC00000,
95 .end = 0x1FFFFFFF
96 .name = "Boot ROM",
97 }
80}; 98};
81#else 99#else
82struct { 100struct {
@@ -89,14 +107,44 @@ struct {
89 struct resource flash; 107 struct resource flash;
90 struct resource boot; 108 struct resource boot;
91} it8172_resources = { 109} it8172_resources = {
92 { "RAM", 0, 0, IORESOURCE_MEM }, /* to be initted */ 110 {
93 { "PCI Mem0", 0x0C000000, 0x0FFFFFFF, IORESOURCE_MEM }, 111 .start = 0, /* to be initted */
94 { "PCI Mem1", 0x10000000, 0x13FFFFFF, IORESOURCE_MEM }, 112 .end = 0,
95 { "PCI I/O", 0x14000000, 0x17FFFFFF }, 113 .name = "RAM",
96 { "PCI Mem2", 0x1A000000, 0x1BFFFFFF, IORESOURCE_MEM }, 114 .flags = IORESOURCE_MEM
97 { "PCI Mem3", 0x1C000000, 0x1FBFFFFF, IORESOURCE_MEM }, 115 }, {
98 { "Flash", 0x08000000, 0x0CFFFFFF }, 116 .start = 0x0C000000,
99 { "Boot ROM", 0x1FC00000, 0x1FFFFFFF } 117 .end = 0x0FFFFFFF,
118 .name = "PCI Mem0",
119 .flags = IORESOURCE_MEM
120 }, {
121 .start = 0x10000000,
122 .end = 0x13FFFFFF,
123 .name = "PCI Mem1",
124 .flags = IORESOURCE_MEM
125 }, {
126 .start = 0x14000000,
127 .end = 0x17FFFFFF
128 .name = "PCI I/O",
129 }, {
130 .start = 0x1A000000,
131 .end = 0x1BFFFFFF,
132 .name = "PCI Mem2",
133 .flags = IORESOURCE_MEM
134 }, {
135 .start = 0x1C000000,
136 .end = 0x1FBFFFFF,
137 .name = "PCI Mem3",
138 .flags = IORESOURCE_MEM
139 }, {
140 .start = 0x08000000,
141 .end = 0x0CFFFFFF
142 .name = "Flash",
143 }, {
144 .start = 0x1FC00000,
145 .end = 0x1FFFFFFF
146 .name = "Boot ROM",
147 }
100}; 148};
101#endif 149#endif
102 150
@@ -106,7 +154,7 @@ void __init it8172_init_ram_resource(unsigned long memsize)
106 it8172_resources.ram.end = memsize; 154 it8172_resources.ram.end = memsize;
107} 155}
108 156
109void __init plat_setup(void) 157void __init plat_mem_setup(void)
110{ 158{
111 unsigned short dsr; 159 unsigned short dsr;
112 char *argptr; 160 char *argptr;
diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c
index 4036dc434551..c8d0df7d0c36 100644
--- a/arch/mips/jazz/setup.c
+++ b/arch/mips/jazz/setup.c
@@ -52,7 +52,7 @@ static struct resource jazz_io_resources[] = {
52 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, 52 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
53}; 53};
54 54
55void __init plat_setup(void) 55void __init plat_mem_setup(void)
56{ 56{
57 int i; 57 int i;
58 58
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index 9359cc413494..308e6cdcd245 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -82,17 +82,54 @@ struct {
82 struct resource sio0; 82 struct resource sio0;
83 struct resource sio1; 83 struct resource sio1;
84} jmr3927_resources = { 84} jmr3927_resources = {
85 { "RAM0", 0, 0x01FFFFFF, IORESOURCE_MEM }, 85 {
86 { "RAM1", 0x02000000, 0x03FFFFFF, IORESOURCE_MEM }, 86 .start = 0,
87 { "PCIMEM", 0x08000000, 0x07FFFFFF, IORESOURCE_MEM }, 87 .end = 0x01FFFFFF,
88 { "IOB", 0x10000000, 0x13FFFFFF }, 88 .name = "RAM0",
89 { "IOC", 0x14000000, 0x14FFFFFF }, 89 .flags = IORESOURCE_MEM
90 { "PCIIO", 0x15000000, 0x15FFFFFF }, 90 }, {
91 { "JMY1394", 0x1D000000, 0x1D3FFFFF }, 91 .start = 0x02000000,
92 { "ROM1", 0x1E000000, 0x1E3FFFFF }, 92 .end = 0x03FFFFFF,
93 { "ROM0", 0x1FC00000, 0x1FFFFFFF }, 93 .name = "RAM1",
94 { "SIO0", 0xFFFEF300, 0xFFFEF3FF }, 94 .flags = IORESOURCE_MEM
95 { "SIO1", 0xFFFEF400, 0xFFFEF4FF }, 95 }, {
96 .start = 0x08000000,
97 .end = 0x07FFFFFF,
98 .name = "PCIMEM",
99 .flags = IORESOURCE_MEM
100 }, {
101 .start = 0x10000000,
102 .end = 0x13FFFFFF,
103 .name = "IOB"
104 }, {
105 .start = 0x14000000,
106 .end = 0x14FFFFFF,
107 .name = "IOC"
108 }, {
109 .start = 0x15000000,
110 .end = 0x15FFFFFF,
111 .name = "PCIIO"
112 }, {
113 .start = 0x1D000000,
114 .end = 0x1D3FFFFF,
115 .name = "JMY1394"
116 }, {
117 .start = 0x1E000000,
118 .end = 0x1E3FFFFF,
119 .name = "ROM1"
120 }, {
121 .start = 0x1FC00000,
122 .end = 0x1FFFFFFF,
123 .name = "ROM0"
124 }, {
125 .start = 0xFFFEF300,
126 .end = 0xFFFEF3FF,
127 .name = "SIO0"
128 }, {
129 .start = 0xFFFEF400,
130 .end = 0xFFFEF4FF,
131 .name = "SIO1"
132 },
96}; 133};
97 134
98/* don't enable - see errata */ 135/* don't enable - see errata */
@@ -201,7 +238,7 @@ static void jmr3927_board_init(void);
201extern struct resource pci_io_resource; 238extern struct resource pci_io_resource;
202extern struct resource pci_mem_resource; 239extern struct resource pci_mem_resource;
203 240
204void __init plat_setup(void) 241void __init plat_mem_setup(void)
205{ 242{
206 char *argptr; 243 char *argptr;
207 244
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 34e8a256765c..881c467c6982 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -13,6 +13,8 @@ binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \
13 13
14obj-$(CONFIG_MODULES) += mips_ksyms.o module.o 14obj-$(CONFIG_MODULES) += mips_ksyms.o module.o
15 15
16obj-$(CONFIG_APM) += apm.o
17
16obj-$(CONFIG_CPU_R3000) += r2300_fpu.o r2300_switch.o 18obj-$(CONFIG_CPU_R3000) += r2300_fpu.o r2300_switch.o
17obj-$(CONFIG_CPU_TX39XX) += r2300_fpu.o r2300_switch.o 19obj-$(CONFIG_CPU_TX39XX) += r2300_fpu.o r2300_switch.o
18obj-$(CONFIG_CPU_TX49XX) += r4k_fpu.o r4k_switch.o 20obj-$(CONFIG_CPU_TX49XX) += r4k_fpu.o r4k_switch.o
diff --git a/arch/mips/kernel/apm.c b/arch/mips/kernel/apm.c
new file mode 100644
index 000000000000..15f46b4471fd
--- /dev/null
+++ b/arch/mips/kernel/apm.c
@@ -0,0 +1,605 @@
1/*
2 * bios-less APM driver for MIPS Linux
3 * Jamey Hicks <jamey@crl.dec.com>
4 * adapted from the APM BIOS driver for Linux by Stephen Rothwell (sfr@linuxcare.com)
5 *
6 * APM 1.2 Reference:
7 * Intel Corporation, Microsoft Corporation. Advanced Power Management
8 * (APM) BIOS Interface Specification, Revision 1.2, February 1996.
9 *
10 * [This document is available from Microsoft at:
11 * http://www.microsoft.com/hwdev/busbios/amp_12.htm]
12 */
13#include <linux/config.h>
14#include <linux/module.h>
15#include <linux/poll.h>
16#include <linux/timer.h>
17#include <linux/slab.h>
18#include <linux/proc_fs.h>
19#include <linux/miscdevice.h>
20#include <linux/apm_bios.h>
21#include <linux/capability.h>
22#include <linux/sched.h>
23#include <linux/pm.h>
24#include <linux/device.h>
25#include <linux/kernel.h>
26#include <linux/list.h>
27#include <linux/init.h>
28#include <linux/completion.h>
29
30#include <asm/apm.h> /* apm_power_info */
31#include <asm/system.h>
32
33/*
34 * The apm_bios device is one of the misc char devices.
35 * This is its minor number.
36 */
37#define APM_MINOR_DEV 134
38
39/*
40 * See Documentation/Config.help for the configuration options.
41 *
42 * Various options can be changed at boot time as follows:
43 * (We allow underscores for compatibility with the modules code)
44 * apm=on/off enable/disable APM
45 */
46
47/*
48 * Maximum number of events stored
49 */
50#define APM_MAX_EVENTS 16
51
52struct apm_queue {
53 unsigned int event_head;
54 unsigned int event_tail;
55 apm_event_t events[APM_MAX_EVENTS];
56};
57
58/*
59 * The per-file APM data
60 */
61struct apm_user {
62 struct list_head list;
63
64 unsigned int suser: 1;
65 unsigned int writer: 1;
66 unsigned int reader: 1;
67
68 int suspend_result;
69 unsigned int suspend_state;
70#define SUSPEND_NONE 0 /* no suspend pending */
71#define SUSPEND_PENDING 1 /* suspend pending read */
72#define SUSPEND_READ 2 /* suspend read, pending ack */
73#define SUSPEND_ACKED 3 /* suspend acked */
74#define SUSPEND_DONE 4 /* suspend completed */
75
76 struct apm_queue queue;
77};
78
79/*
80 * Local variables
81 */
82static int suspends_pending;
83static int apm_disabled;
84static int mips_apm_active;
85
86static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
87static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
88
89/*
90 * This is a list of everyone who has opened /dev/apm_bios
91 */
92static DECLARE_RWSEM(user_list_lock);
93static LIST_HEAD(apm_user_list);
94
95/*
96 * kapmd info. kapmd provides us a process context to handle
97 * "APM" events within - specifically necessary if we're going
98 * to be suspending the system.
99 */
100static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait);
101static DECLARE_COMPLETION(kapmd_exit);
102static DEFINE_SPINLOCK(kapmd_queue_lock);
103static struct apm_queue kapmd_queue;
104
105
106static const char driver_version[] = "1.13"; /* no spaces */
107
108
109
110/*
111 * Compatibility cruft until the IPAQ people move over to the new
112 * interface.
113 */
114static void __apm_get_power_status(struct apm_power_info *info)
115{
116}
117
118/*
119 * This allows machines to provide their own "apm get power status" function.
120 */
121void (*apm_get_power_status)(struct apm_power_info *) = __apm_get_power_status;
122EXPORT_SYMBOL(apm_get_power_status);
123
124
125/*
126 * APM event queue management.
127 */
128static inline int queue_empty(struct apm_queue *q)
129{
130 return q->event_head == q->event_tail;
131}
132
133static inline apm_event_t queue_get_event(struct apm_queue *q)
134{
135 q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
136 return q->events[q->event_tail];
137}
138
139static void queue_add_event(struct apm_queue *q, apm_event_t event)
140{
141 q->event_head = (q->event_head + 1) % APM_MAX_EVENTS;
142 if (q->event_head == q->event_tail) {
143 static int notified;
144
145 if (notified++ == 0)
146 printk(KERN_ERR "apm: an event queue overflowed\n");
147 q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
148 }
149 q->events[q->event_head] = event;
150}
151
152static void queue_event_one_user(struct apm_user *as, apm_event_t event)
153{
154 if (as->suser && as->writer) {
155 switch (event) {
156 case APM_SYS_SUSPEND:
157 case APM_USER_SUSPEND:
158 /*
159 * If this user already has a suspend pending,
160 * don't queue another one.
161 */
162 if (as->suspend_state != SUSPEND_NONE)
163 return;
164
165 as->suspend_state = SUSPEND_PENDING;
166 suspends_pending++;
167 break;
168 }
169 }
170 queue_add_event(&as->queue, event);
171}
172
173static void queue_event(apm_event_t event, struct apm_user *sender)
174{
175 struct apm_user *as;
176
177 down_read(&user_list_lock);
178 list_for_each_entry(as, &apm_user_list, list) {
179 if (as != sender && as->reader)
180 queue_event_one_user(as, event);
181 }
182 up_read(&user_list_lock);
183 wake_up_interruptible(&apm_waitqueue);
184}
185
186static void apm_suspend(void)
187{
188 struct apm_user *as;
189 int err = pm_suspend(PM_SUSPEND_MEM);
190
191 /*
192 * Anyone on the APM queues will think we're still suspended.
193 * Send a message so everyone knows we're now awake again.
194 */
195 queue_event(APM_NORMAL_RESUME, NULL);
196
197 /*
198 * Finally, wake up anyone who is sleeping on the suspend.
199 */
200 down_read(&user_list_lock);
201 list_for_each_entry(as, &apm_user_list, list) {
202 as->suspend_result = err;
203 as->suspend_state = SUSPEND_DONE;
204 }
205 up_read(&user_list_lock);
206
207 wake_up(&apm_suspend_waitqueue);
208}
209
210static ssize_t apm_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
211{
212 struct apm_user *as = fp->private_data;
213 apm_event_t event;
214 int i = count, ret = 0;
215
216 if (count < sizeof(apm_event_t))
217 return -EINVAL;
218
219 if (queue_empty(&as->queue) && fp->f_flags & O_NONBLOCK)
220 return -EAGAIN;
221
222 wait_event_interruptible(apm_waitqueue, !queue_empty(&as->queue));
223
224 while ((i >= sizeof(event)) && !queue_empty(&as->queue)) {
225 event = queue_get_event(&as->queue);
226
227 ret = -EFAULT;
228 if (copy_to_user(buf, &event, sizeof(event)))
229 break;
230
231 if (event == APM_SYS_SUSPEND || event == APM_USER_SUSPEND)
232 as->suspend_state = SUSPEND_READ;
233
234 buf += sizeof(event);
235 i -= sizeof(event);
236 }
237
238 if (i < count)
239 ret = count - i;
240
241 return ret;
242}
243
244static unsigned int apm_poll(struct file *fp, poll_table * wait)
245{
246 struct apm_user *as = fp->private_data;
247
248 poll_wait(fp, &apm_waitqueue, wait);
249 return queue_empty(&as->queue) ? 0 : POLLIN | POLLRDNORM;
250}
251
252/*
253 * apm_ioctl - handle APM ioctl
254 *
255 * APM_IOC_SUSPEND
256 * This IOCTL is overloaded, and performs two functions. It is used to:
257 * - initiate a suspend
258 * - acknowledge a suspend read from /dev/apm_bios.
259 * Only when everyone who has opened /dev/apm_bios with write permission
260 * has acknowledge does the actual suspend happen.
261 */
262static int
263apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
264{
265 struct apm_user *as = filp->private_data;
266 unsigned long flags;
267 int err = -EINVAL;
268
269 if (!as->suser || !as->writer)
270 return -EPERM;
271
272 switch (cmd) {
273 case APM_IOC_SUSPEND:
274 as->suspend_result = -EINTR;
275
276 if (as->suspend_state == SUSPEND_READ) {
277 /*
278 * If we read a suspend command from /dev/apm_bios,
279 * then the corresponding APM_IOC_SUSPEND ioctl is
280 * interpreted as an acknowledge.
281 */
282 as->suspend_state = SUSPEND_ACKED;
283 suspends_pending--;
284 } else {
285 /*
286 * Otherwise it is a request to suspend the system.
287 * Queue an event for all readers, and expect an
288 * acknowledge from all writers who haven't already
289 * acknowledged.
290 */
291 queue_event(APM_USER_SUSPEND, as);
292 }
293
294 /*
295 * If there are no further acknowledges required, suspend
296 * the system.
297 */
298 if (suspends_pending == 0)
299 apm_suspend();
300
301 /*
302 * Wait for the suspend/resume to complete. If there are
303 * pending acknowledges, we wait here for them.
304 *
305 * Note that we need to ensure that the PM subsystem does
306 * not kick us out of the wait when it suspends the threads.
307 */
308 flags = current->flags;
309 current->flags |= PF_NOFREEZE;
310
311 /*
312 * Note: do not allow a thread which is acking the suspend
313 * to escape until the resume is complete.
314 */
315 if (as->suspend_state == SUSPEND_ACKED)
316 wait_event(apm_suspend_waitqueue,
317 as->suspend_state == SUSPEND_DONE);
318 else
319 wait_event_interruptible(apm_suspend_waitqueue,
320 as->suspend_state == SUSPEND_DONE);
321
322 current->flags = flags;
323 err = as->suspend_result;
324 as->suspend_state = SUSPEND_NONE;
325 break;
326 }
327
328 return err;
329}
330
331static int apm_release(struct inode * inode, struct file * filp)
332{
333 struct apm_user *as = filp->private_data;
334 filp->private_data = NULL;
335
336 down_write(&user_list_lock);
337 list_del(&as->list);
338 up_write(&user_list_lock);
339
340 /*
341 * We are now unhooked from the chain. As far as new
342 * events are concerned, we no longer exist. However, we
343 * need to balance suspends_pending, which means the
344 * possibility of sleeping.
345 */
346 if (as->suspend_state != SUSPEND_NONE) {
347 suspends_pending -= 1;
348 if (suspends_pending == 0)
349 apm_suspend();
350 }
351
352 kfree(as);
353 return 0;
354}
355
356static int apm_open(struct inode * inode, struct file * filp)
357{
358 struct apm_user *as;
359
360 as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL);
361 if (as) {
362 /*
363 * XXX - this is a tiny bit broken, when we consider BSD
364 * process accounting. If the device is opened by root, we
365 * instantly flag that we used superuser privs. Who knows,
366 * we might close the device immediately without doing a
367 * privileged operation -- cevans
368 */
369 as->suser = capable(CAP_SYS_ADMIN);
370 as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE;
371 as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ;
372
373 down_write(&user_list_lock);
374 list_add(&as->list, &apm_user_list);
375 up_write(&user_list_lock);
376
377 filp->private_data = as;
378 }
379
380 return as ? 0 : -ENOMEM;
381}
382
383static struct file_operations apm_bios_fops = {
384 .owner = THIS_MODULE,
385 .read = apm_read,
386 .poll = apm_poll,
387 .ioctl = apm_ioctl,
388 .open = apm_open,
389 .release = apm_release,
390};
391
392static struct miscdevice apm_device = {
393 .minor = APM_MINOR_DEV,
394 .name = "apm_bios",
395 .fops = &apm_bios_fops
396};
397
398
399#ifdef CONFIG_PROC_FS
400/*
401 * Arguments, with symbols from linux/apm_bios.h.
402 *
403 * 0) Linux driver version (this will change if format changes)
404 * 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2.
405 * 2) APM flags from APM Installation Check (0x00):
406 * bit 0: APM_16_BIT_SUPPORT
407 * bit 1: APM_32_BIT_SUPPORT
408 * bit 2: APM_IDLE_SLOWS_CLOCK
409 * bit 3: APM_BIOS_DISABLED
410 * bit 4: APM_BIOS_DISENGAGED
411 * 3) AC line status
412 * 0x00: Off-line
413 * 0x01: On-line
414 * 0x02: On backup power (BIOS >= 1.1 only)
415 * 0xff: Unknown
416 * 4) Battery status
417 * 0x00: High
418 * 0x01: Low
419 * 0x02: Critical
420 * 0x03: Charging
421 * 0x04: Selected battery not present (BIOS >= 1.2 only)
422 * 0xff: Unknown
423 * 5) Battery flag
424 * bit 0: High
425 * bit 1: Low
426 * bit 2: Critical
427 * bit 3: Charging
428 * bit 7: No system battery
429 * 0xff: Unknown
430 * 6) Remaining battery life (percentage of charge):
431 * 0-100: valid
432 * -1: Unknown
433 * 7) Remaining battery life (time units):
434 * Number of remaining minutes or seconds
435 * -1: Unknown
436 * 8) min = minutes; sec = seconds
437 */
438static int apm_get_info(char *buf, char **start, off_t fpos, int length)
439{
440 struct apm_power_info info;
441 char *units;
442 int ret;
443
444 info.ac_line_status = 0xff;
445 info.battery_status = 0xff;
446 info.battery_flag = 0xff;
447 info.battery_life = -1;
448 info.time = -1;
449 info.units = -1;
450
451 if (apm_get_power_status)
452 apm_get_power_status(&info);
453
454 switch (info.units) {
455 default: units = "?"; break;
456 case 0: units = "min"; break;
457 case 1: units = "sec"; break;
458 }
459
460 ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
461 driver_version, APM_32_BIT_SUPPORT,
462 info.ac_line_status, info.battery_status,
463 info.battery_flag, info.battery_life,
464 info.time, units);
465
466 return ret;
467}
468#endif
469
470static int kapmd(void *arg)
471{
472 daemonize("kapmd");
473 current->flags |= PF_NOFREEZE;
474
475 do {
476 apm_event_t event;
477
478 wait_event_interruptible(kapmd_wait,
479 !queue_empty(&kapmd_queue) || !mips_apm_active);
480
481 if (!mips_apm_active)
482 break;
483
484 spin_lock_irq(&kapmd_queue_lock);
485 event = 0;
486 if (!queue_empty(&kapmd_queue))
487 event = queue_get_event(&kapmd_queue);
488 spin_unlock_irq(&kapmd_queue_lock);
489
490 switch (event) {
491 case 0:
492 break;
493
494 case APM_LOW_BATTERY:
495 case APM_POWER_STATUS_CHANGE:
496 queue_event(event, NULL);
497 break;
498
499 case APM_USER_SUSPEND:
500 case APM_SYS_SUSPEND:
501 queue_event(event, NULL);
502 if (suspends_pending == 0)
503 apm_suspend();
504 break;
505
506 case APM_CRITICAL_SUSPEND:
507 apm_suspend();
508 break;
509 }
510 } while (1);
511
512 complete_and_exit(&kapmd_exit, 0);
513}
514
515static int __init apm_init(void)
516{
517 int ret;
518
519 if (apm_disabled) {
520 printk(KERN_NOTICE "apm: disabled on user request.\n");
521 return -ENODEV;
522 }
523
524 mips_apm_active = 1;
525
526 ret = kernel_thread(kapmd, NULL, CLONE_KERNEL);
527 if (ret < 0) {
528 mips_apm_active = 0;
529 return ret;
530 }
531
532#ifdef CONFIG_PROC_FS
533 create_proc_info_entry("apm", 0, NULL, apm_get_info);
534#endif
535
536 ret = misc_register(&apm_device);
537 if (ret != 0) {
538 remove_proc_entry("apm", NULL);
539
540 mips_apm_active = 0;
541 wake_up(&kapmd_wait);
542 wait_for_completion(&kapmd_exit);
543 }
544
545 return ret;
546}
547
548static void __exit apm_exit(void)
549{
550 misc_deregister(&apm_device);
551 remove_proc_entry("apm", NULL);
552
553 mips_apm_active = 0;
554 wake_up(&kapmd_wait);
555 wait_for_completion(&kapmd_exit);
556}
557
558module_init(apm_init);
559module_exit(apm_exit);
560
561MODULE_AUTHOR("Stephen Rothwell");
562MODULE_DESCRIPTION("Advanced Power Management");
563MODULE_LICENSE("GPL");
564
565#ifndef MODULE
566static int __init apm_setup(char *str)
567{
568 while ((str != NULL) && (*str != '\0')) {
569 if (strncmp(str, "off", 3) == 0)
570 apm_disabled = 1;
571 if (strncmp(str, "on", 2) == 0)
572 apm_disabled = 0;
573 str = strchr(str, ',');
574 if (str != NULL)
575 str += strspn(str, ", \t");
576 }
577 return 1;
578}
579
580__setup("apm=", apm_setup);
581#endif
582
583/**
584 * apm_queue_event - queue an APM event for kapmd
585 * @event: APM event
586 *
587 * Queue an APM event for kapmd to process and ultimately take the
588 * appropriate action. Only a subset of events are handled:
589 * %APM_LOW_BATTERY
590 * %APM_POWER_STATUS_CHANGE
591 * %APM_USER_SUSPEND
592 * %APM_SYS_SUSPEND
593 * %APM_CRITICAL_SUSPEND
594 */
595void apm_queue_event(apm_event_t event)
596{
597 unsigned long flags;
598
599 spin_lock_irqsave(&kapmd_queue_lock, flags);
600 queue_add_event(&kapmd_queue, event);
601 spin_unlock_irqrestore(&kapmd_queue_lock, flags);
602
603 wake_up_interruptible(&kapmd_wait);
604}
605EXPORT_SYMBOL(apm_queue_event);
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 0facfaf4e950..f1bb6a2dc5fc 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -141,72 +141,72 @@ void output_thread_defines(void)
141void output_thread_fpu_defines(void) 141void output_thread_fpu_defines(void)
142{ 142{
143 offset("#define THREAD_FPR0 ", 143 offset("#define THREAD_FPR0 ",
144 struct task_struct, thread.fpu.hard.fpr[0]); 144 struct task_struct, thread.fpu.fpr[0]);
145 offset("#define THREAD_FPR1 ", 145 offset("#define THREAD_FPR1 ",
146 struct task_struct, thread.fpu.hard.fpr[1]); 146 struct task_struct, thread.fpu.fpr[1]);
147 offset("#define THREAD_FPR2 ", 147 offset("#define THREAD_FPR2 ",
148 struct task_struct, thread.fpu.hard.fpr[2]); 148 struct task_struct, thread.fpu.fpr[2]);
149 offset("#define THREAD_FPR3 ", 149 offset("#define THREAD_FPR3 ",
150 struct task_struct, thread.fpu.hard.fpr[3]); 150 struct task_struct, thread.fpu.fpr[3]);
151 offset("#define THREAD_FPR4 ", 151 offset("#define THREAD_FPR4 ",
152 struct task_struct, thread.fpu.hard.fpr[4]); 152 struct task_struct, thread.fpu.fpr[4]);
153 offset("#define THREAD_FPR5 ", 153 offset("#define THREAD_FPR5 ",
154 struct task_struct, thread.fpu.hard.fpr[5]); 154 struct task_struct, thread.fpu.fpr[5]);
155 offset("#define THREAD_FPR6 ", 155 offset("#define THREAD_FPR6 ",
156 struct task_struct, thread.fpu.hard.fpr[6]); 156 struct task_struct, thread.fpu.fpr[6]);
157 offset("#define THREAD_FPR7 ", 157 offset("#define THREAD_FPR7 ",
158 struct task_struct, thread.fpu.hard.fpr[7]); 158 struct task_struct, thread.fpu.fpr[7]);
159 offset("#define THREAD_FPR8 ", 159 offset("#define THREAD_FPR8 ",
160 struct task_struct, thread.fpu.hard.fpr[8]); 160 struct task_struct, thread.fpu.fpr[8]);
161 offset("#define THREAD_FPR9 ", 161 offset("#define THREAD_FPR9 ",
162 struct task_struct, thread.fpu.hard.fpr[9]); 162 struct task_struct, thread.fpu.fpr[9]);
163 offset("#define THREAD_FPR10 ", 163 offset("#define THREAD_FPR10 ",
164 struct task_struct, thread.fpu.hard.fpr[10]); 164 struct task_struct, thread.fpu.fpr[10]);
165 offset("#define THREAD_FPR11 ", 165 offset("#define THREAD_FPR11 ",
166 struct task_struct, thread.fpu.hard.fpr[11]); 166 struct task_struct, thread.fpu.fpr[11]);
167 offset("#define THREAD_FPR12 ", 167 offset("#define THREAD_FPR12 ",
168 struct task_struct, thread.fpu.hard.fpr[12]); 168 struct task_struct, thread.fpu.fpr[12]);
169 offset("#define THREAD_FPR13 ", 169 offset("#define THREAD_FPR13 ",
170 struct task_struct, thread.fpu.hard.fpr[13]); 170 struct task_struct, thread.fpu.fpr[13]);
171 offset("#define THREAD_FPR14 ", 171 offset("#define THREAD_FPR14 ",
172 struct task_struct, thread.fpu.hard.fpr[14]); 172 struct task_struct, thread.fpu.fpr[14]);
173 offset("#define THREAD_FPR15 ", 173 offset("#define THREAD_FPR15 ",
174 struct task_struct, thread.fpu.hard.fpr[15]); 174 struct task_struct, thread.fpu.fpr[15]);
175 offset("#define THREAD_FPR16 ", 175 offset("#define THREAD_FPR16 ",
176 struct task_struct, thread.fpu.hard.fpr[16]); 176 struct task_struct, thread.fpu.fpr[16]);
177 offset("#define THREAD_FPR17 ", 177 offset("#define THREAD_FPR17 ",
178 struct task_struct, thread.fpu.hard.fpr[17]); 178 struct task_struct, thread.fpu.fpr[17]);
179 offset("#define THREAD_FPR18 ", 179 offset("#define THREAD_FPR18 ",
180 struct task_struct, thread.fpu.hard.fpr[18]); 180 struct task_struct, thread.fpu.fpr[18]);
181 offset("#define THREAD_FPR19 ", 181 offset("#define THREAD_FPR19 ",
182 struct task_struct, thread.fpu.hard.fpr[19]); 182 struct task_struct, thread.fpu.fpr[19]);
183 offset("#define THREAD_FPR20 ", 183 offset("#define THREAD_FPR20 ",
184 struct task_struct, thread.fpu.hard.fpr[20]); 184 struct task_struct, thread.fpu.fpr[20]);
185 offset("#define THREAD_FPR21 ", 185 offset("#define THREAD_FPR21 ",
186 struct task_struct, thread.fpu.hard.fpr[21]); 186 struct task_struct, thread.fpu.fpr[21]);
187 offset("#define THREAD_FPR22 ", 187 offset("#define THREAD_FPR22 ",
188 struct task_struct, thread.fpu.hard.fpr[22]); 188 struct task_struct, thread.fpu.fpr[22]);
189 offset("#define THREAD_FPR23 ", 189 offset("#define THREAD_FPR23 ",
190 struct task_struct, thread.fpu.hard.fpr[23]); 190 struct task_struct, thread.fpu.fpr[23]);
191 offset("#define THREAD_FPR24 ", 191 offset("#define THREAD_FPR24 ",
192 struct task_struct, thread.fpu.hard.fpr[24]); 192 struct task_struct, thread.fpu.fpr[24]);
193 offset("#define THREAD_FPR25 ", 193 offset("#define THREAD_FPR25 ",
194 struct task_struct, thread.fpu.hard.fpr[25]); 194 struct task_struct, thread.fpu.fpr[25]);
195 offset("#define THREAD_FPR26 ", 195 offset("#define THREAD_FPR26 ",
196 struct task_struct, thread.fpu.hard.fpr[26]); 196 struct task_struct, thread.fpu.fpr[26]);
197 offset("#define THREAD_FPR27 ", 197 offset("#define THREAD_FPR27 ",
198 struct task_struct, thread.fpu.hard.fpr[27]); 198 struct task_struct, thread.fpu.fpr[27]);
199 offset("#define THREAD_FPR28 ", 199 offset("#define THREAD_FPR28 ",
200 struct task_struct, thread.fpu.hard.fpr[28]); 200 struct task_struct, thread.fpu.fpr[28]);
201 offset("#define THREAD_FPR29 ", 201 offset("#define THREAD_FPR29 ",
202 struct task_struct, thread.fpu.hard.fpr[29]); 202 struct task_struct, thread.fpu.fpr[29]);
203 offset("#define THREAD_FPR30 ", 203 offset("#define THREAD_FPR30 ",
204 struct task_struct, thread.fpu.hard.fpr[30]); 204 struct task_struct, thread.fpu.fpr[30]);
205 offset("#define THREAD_FPR31 ", 205 offset("#define THREAD_FPR31 ",
206 struct task_struct, thread.fpu.hard.fpr[31]); 206 struct task_struct, thread.fpu.fpr[31]);
207 207
208 offset("#define THREAD_FCR31 ", 208 offset("#define THREAD_FCR31 ",
209 struct task_struct, thread.fpu.hard.fcr31); 209 struct task_struct, thread.fpu.fcr31);
210 linefeed; 210 linefeed;
211} 211}
212 212
diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c
index b6232d9033cb..76fd3f22c766 100644
--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -178,7 +178,7 @@ int __compute_return_epc(struct pt_regs *regs)
178 if (is_fpu_owner()) 178 if (is_fpu_owner())
179 asm volatile("cfc1\t%0,$31" : "=r" (fcr31)); 179 asm volatile("cfc1\t%0,$31" : "=r" (fcr31));
180 else 180 else
181 fcr31 = current->thread.fpu.hard.fcr31; 181 fcr31 = current->thread.fpu.fcr31;
182 preempt_enable(); 182 preempt_enable();
183 183
184 bit = (insn.i_format.rt >> 2); 184 bit = (insn.i_format.rt >> 2);
diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
index 2125ba5f1d9b..0cb8ed5662f3 100644
--- a/arch/mips/kernel/i8259.c
+++ b/arch/mips/kernel/i8259.c
@@ -302,11 +302,11 @@ static struct irqaction irq2 = {
302}; 302};
303 303
304static struct resource pic1_io_resource = { 304static struct resource pic1_io_resource = {
305 "pic1", 0x20, 0x3f, IORESOURCE_BUSY 305 .name = "pic1", .start = 0x20, .end = 0x3f, .flags = IORESOURCE_BUSY
306}; 306};
307 307
308static struct resource pic2_io_resource = { 308static struct resource pic2_io_resource = {
309 "pic2", 0xa0, 0xbf, IORESOURCE_BUSY 309 .name = "pic2", .start = 0xa0, .end = 0xbf, .flags = IORESOURCE_BUSY
310}; 310};
311 311
312/* 312/*
diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c
index 8150f071f80a..a9bf6cc3abd1 100644
--- a/arch/mips/kernel/irixsig.c
+++ b/arch/mips/kernel/irixsig.c
@@ -260,7 +260,7 @@ irix_sigreturn(struct pt_regs *regs)
260 260
261 for(i = 0; i < 32; i++) 261 for(i = 0; i < 32; i++)
262 error |= __get_user(fregs[i], &context->fpregs[i]); 262 error |= __get_user(fregs[i], &context->fpregs[i]);
263 error |= __get_user(current->thread.fpu.hard.fcr31, &context->fpcsr); 263 error |= __get_user(current->thread.fpu.fcr31, &context->fpcsr);
264 } 264 }
265 265
266 /* XXX do sigstack crapola here... XXX */ 266 /* XXX do sigstack crapola here... XXX */
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 9b4733c12395..1d44025188d8 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -120,11 +120,11 @@ int ptrace_getfpregs (struct task_struct *child, __u32 __user *data)
120 __put_user ((__u64) -1, i + (__u64 __user *) data); 120 __put_user ((__u64) -1, i + (__u64 __user *) data);
121 } 121 }
122 122
123 __put_user (child->thread.fpu.fcr31, data + 64);
124
123 if (cpu_has_fpu) { 125 if (cpu_has_fpu) {
124 unsigned int flags, tmp; 126 unsigned int flags, tmp;
125 127
126 __put_user (child->thread.fpu.hard.fcr31, data + 64);
127
128 preempt_disable(); 128 preempt_disable();
129 if (cpu_has_mipsmt) { 129 if (cpu_has_mipsmt) {
130 unsigned int vpflags = dvpe(); 130 unsigned int vpflags = dvpe();
@@ -142,7 +142,6 @@ int ptrace_getfpregs (struct task_struct *child, __u32 __user *data)
142 preempt_enable(); 142 preempt_enable();
143 __put_user (tmp, data + 65); 143 __put_user (tmp, data + 65);
144 } else { 144 } else {
145 __put_user (child->thread.fpu.soft.fcr31, data + 64);
146 __put_user ((__u32) 0, data + 65); 145 __put_user ((__u32) 0, data + 65);
147 } 146 }
148 147
@@ -162,10 +161,7 @@ int ptrace_setfpregs (struct task_struct *child, __u32 __user *data)
162 for (i = 0; i < 32; i++) 161 for (i = 0; i < 32; i++)
163 __get_user (fregs[i], i + (__u64 __user *) data); 162 __get_user (fregs[i], i + (__u64 __user *) data);
164 163
165 if (cpu_has_fpu) 164 __get_user (child->thread.fpu.fcr31, data + 64);
166 __get_user (child->thread.fpu.hard.fcr31, data + 64);
167 else
168 __get_user (child->thread.fpu.soft.fcr31, data + 64);
169 165
170 /* FIR may not be written. */ 166 /* FIR may not be written. */
171 167
@@ -241,10 +237,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
241 tmp = regs->lo; 237 tmp = regs->lo;
242 break; 238 break;
243 case FPC_CSR: 239 case FPC_CSR:
244 if (cpu_has_fpu) 240 tmp = child->thread.fpu.fcr31;
245 tmp = child->thread.fpu.hard.fcr31;
246 else
247 tmp = child->thread.fpu.soft.fcr31;
248 break; 241 break;
249 case FPC_EIR: { /* implementation / version register */ 242 case FPC_EIR: { /* implementation / version register */
250 unsigned int flags; 243 unsigned int flags;
@@ -336,9 +329,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
336 329
337 if (!tsk_used_math(child)) { 330 if (!tsk_used_math(child)) {
338 /* FP not yet used */ 331 /* FP not yet used */
339 memset(&child->thread.fpu.hard, ~0, 332 memset(&child->thread.fpu, ~0,
340 sizeof(child->thread.fpu.hard)); 333 sizeof(child->thread.fpu));
341 child->thread.fpu.hard.fcr31 = 0; 334 child->thread.fpu.fcr31 = 0;
342 } 335 }
343#ifdef CONFIG_32BIT 336#ifdef CONFIG_32BIT
344 /* 337 /*
@@ -369,10 +362,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
369 regs->lo = data; 362 regs->lo = data;
370 break; 363 break;
371 case FPC_CSR: 364 case FPC_CSR:
372 if (cpu_has_fpu) 365 child->thread.fpu.fcr31 = data;
373 child->thread.fpu.hard.fcr31 = data;
374 else
375 child->thread.fpu.soft.fcr31 = data;
376 break; 366 break;
377 case DSP_BASE ... DSP_BASE + 5: { 367 case DSP_BASE ... DSP_BASE + 5: {
378 dspreg_t *dregs; 368 dspreg_t *dregs;
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index 8704dc0496ea..f40ecd8be05f 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -166,10 +166,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
166 tmp = regs->lo; 166 tmp = regs->lo;
167 break; 167 break;
168 case FPC_CSR: 168 case FPC_CSR:
169 if (cpu_has_fpu) 169 tmp = child->thread.fpu.fcr31;
170 tmp = child->thread.fpu.hard.fcr31;
171 else
172 tmp = child->thread.fpu.soft.fcr31;
173 break; 170 break;
174 case FPC_EIR: { /* implementation / version register */ 171 case FPC_EIR: { /* implementation / version register */
175 unsigned int flags; 172 unsigned int flags;
@@ -288,9 +285,9 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
288 285
289 if (!tsk_used_math(child)) { 286 if (!tsk_used_math(child)) {
290 /* FP not yet used */ 287 /* FP not yet used */
291 memset(&child->thread.fpu.hard, ~0, 288 memset(&child->thread.fpu, ~0,
292 sizeof(child->thread.fpu.hard)); 289 sizeof(child->thread.fpu));
293 child->thread.fpu.hard.fcr31 = 0; 290 child->thread.fpu.fcr31 = 0;
294 } 291 }
295 /* 292 /*
296 * The odd registers are actually the high order bits 293 * The odd registers are actually the high order bits
@@ -318,10 +315,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
318 regs->lo = data; 315 regs->lo = data;
319 break; 316 break;
320 case FPC_CSR: 317 case FPC_CSR:
321 if (cpu_has_fpu) 318 child->thread.fpu.fcr31 = data;
322 child->thread.fpu.hard.fcr31 = data;
323 else
324 child->thread.fpu.soft.fcr31 = data;
325 break; 319 break;
326 case DSP_BASE ... DSP_BASE + 5: { 320 case DSP_BASE ... DSP_BASE + 5: {
327 dspreg_t *dregs; 321 dspreg_t *dregs;
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index 0b1b54acee9f..db94e556fc97 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -75,8 +75,8 @@
75 and t0, t0, t1 75 and t0, t0, t1
76 LONG_S t0, ST_OFF(t3) 76 LONG_S t0, ST_OFF(t3)
77 77
78 fpu_save_double a0 t1 t0 t2 # c0_status passed in t1 78 fpu_save_double a0 t0 t1 # c0_status passed in t0
79 # clobbers t0 and t2 79 # clobbers t1
801: 801:
81 81
82 /* 82 /*
@@ -129,9 +129,9 @@
129 */ 129 */
130LEAF(_save_fp) 130LEAF(_save_fp)
131#ifdef CONFIG_64BIT 131#ifdef CONFIG_64BIT
132 mfc0 t1, CP0_STATUS 132 mfc0 t0, CP0_STATUS
133#endif 133#endif
134 fpu_save_double a0 t1 t0 t2 # clobbers t1 134 fpu_save_double a0 t0 t1 # clobbers t1
135 jr ra 135 jr ra
136 END(_save_fp) 136 END(_save_fp)
137 137
@@ -139,7 +139,10 @@ LEAF(_save_fp)
139 * Restore a thread's fp context. 139 * Restore a thread's fp context.
140 */ 140 */
141LEAF(_restore_fp) 141LEAF(_restore_fp)
142 fpu_restore_double a0, t1 # clobbers t1 142#ifdef CONFIG_64BIT
143 mfc0 t0, CP0_STATUS
144#endif
145 fpu_restore_double a0 t0 t1 # clobbers t1
143 jr ra 146 jr ra
144 END(_restore_fp) 147 END(_restore_fp)
145 148
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 397a70e651b5..bfcec8d9bfe4 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -442,6 +442,48 @@ static inline void bootmem_init(void)
442#endif /* CONFIG_BLK_DEV_INITRD */ 442#endif /* CONFIG_BLK_DEV_INITRD */
443} 443}
444 444
445/*
446 * arch_mem_init - initialize memory managment subsystem
447 *
448 * o plat_mem_setup() detects the memory configuration and will record detected
449 * memory areas using add_memory_region.
450 * o parse_cmdline_early() parses the command line for mem= options which,
451 * iff detected, will override the results of the automatic detection.
452 *
453 * At this stage the memory configuration of the system is known to the
454 * kernel but generic memory managment system is still entirely uninitialized.
455 *
456 * o bootmem_init()
457 * o sparse_init()
458 * o paging_init()
459 *
460 * At this stage the bootmem allocator is ready to use.
461 *
462 * NOTE: historically plat_mem_setup did the entire platform initialization.
463 * This was rather impractical because it meant plat_mem_setup had to
464 * get away without any kind of memory allocator. To keep old code from
465 * breaking plat_setup was just renamed to plat_setup and a second platform
466 * initialization hook for anything else was introduced.
467 */
468
469extern void plat_mem_setup(void);
470
471static void __init arch_mem_init(char **cmdline_p)
472{
473 /* call board setup routine */
474 plat_mem_setup();
475
476 strlcpy(command_line, arcs_cmdline, sizeof(command_line));
477 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
478
479 *cmdline_p = command_line;
480
481 parse_cmdline_early();
482 bootmem_init();
483 sparse_init();
484 paging_init();
485}
486
445static inline void resource_init(void) 487static inline void resource_init(void)
446{ 488{
447 int i; 489 int i;
@@ -495,8 +537,6 @@ static inline void resource_init(void)
495#undef MAXMEM 537#undef MAXMEM
496#undef MAXMEM_PFN 538#undef MAXMEM_PFN
497 539
498extern void plat_setup(void);
499
500void __init setup_arch(char **cmdline_p) 540void __init setup_arch(char **cmdline_p)
501{ 541{
502 cpu_probe(); 542 cpu_probe();
@@ -511,18 +551,8 @@ void __init setup_arch(char **cmdline_p)
511#endif 551#endif
512#endif 552#endif
513 553
514 /* call board setup routine */ 554 arch_mem_init(cmdline_p);
515 plat_setup();
516 555
517 strlcpy(command_line, arcs_cmdline, sizeof(command_line));
518 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
519
520 *cmdline_p = command_line;
521
522 parse_cmdline_early();
523 bootmem_init();
524 sparse_init();
525 paging_init();
526 resource_init(); 556 resource_init();
527#ifdef CONFIG_SMP 557#ifdef CONFIG_SMP
528 plat_smp_setup(); 558 plat_smp_setup();
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index a7564b08eb4d..ad16eceb24dd 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -65,7 +65,7 @@ extern asmlinkage void handle_mcheck(void);
65extern asmlinkage void handle_reserved(void); 65extern asmlinkage void handle_reserved(void);
66 66
67extern int fpu_emulator_cop1Handler(struct pt_regs *xcp, 67extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
68 struct mips_fpu_soft_struct *ctx); 68 struct mips_fpu_struct *ctx);
69 69
70void (*board_be_init)(void); 70void (*board_be_init)(void);
71int (*board_be_handler)(struct pt_regs *regs, int is_fixup); 71int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
@@ -600,8 +600,7 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
600 preempt_enable(); 600 preempt_enable();
601 601
602 /* Run the emulator */ 602 /* Run the emulator */
603 sig = fpu_emulator_cop1Handler (regs, 603 sig = fpu_emulator_cop1Handler (regs, &current->thread.fpu);
604 &current->thread.fpu.soft);
605 604
606 preempt_disable(); 605 preempt_disable();
607 606
@@ -610,7 +609,7 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
610 * We can't allow the emulated instruction to leave any of 609 * We can't allow the emulated instruction to leave any of
611 * the cause bit set in $fcr31. 610 * the cause bit set in $fcr31.
612 */ 611 */
613 current->thread.fpu.soft.fcr31 &= ~FPU_CSR_ALL_X; 612 current->thread.fpu.fcr31 &= ~FPU_CSR_ALL_X;
614 613
615 /* Restore the hardware register state */ 614 /* Restore the hardware register state */
616 restore_fp(current); 615 restore_fp(current);
@@ -755,7 +754,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)
755 754
756 if (!cpu_has_fpu) { 755 if (!cpu_has_fpu) {
757 int sig = fpu_emulator_cop1Handler(regs, 756 int sig = fpu_emulator_cop1Handler(regs,
758 &current->thread.fpu.soft); 757 &current->thread.fpu);
759 if (sig) 758 if (sig)
760 force_sig(sig, current); 759 force_sig(sig, current);
761#ifdef CONFIG_MIPS_MT_FPAFF 760#ifdef CONFIG_MIPS_MT_FPAFF
diff --git a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
index bb70a8240e61..3f64277429e4 100644
--- a/arch/mips/lasat/setup.c
+++ b/arch/mips/lasat/setup.c
@@ -155,7 +155,7 @@ void __init serial_init(void)
155} 155}
156#endif 156#endif
157 157
158void __init plat_setup(void) 158void __init plat_mem_setup(void)
159{ 159{
160 int i; 160 int i;
161 lasat_misc = &lasat_misc_info[mips_machtype]; 161 lasat_misc = &lasat_misc_info[mips_machtype];
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index cf12caf80774..b225543f5302 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -7,4 +7,7 @@ lib-y += csum_partial_copy.o memcpy.o promlib.o strlen_user.o strncpy_user.o \
7 7
8obj-y += iomap.o 8obj-y += iomap.o
9 9
10# libgcc-style stuff needed in the kernel
11lib-y += ashldi3.o ashrdi3.o lshrdi3.o
12
10EXTRA_AFLAGS := $(CFLAGS) 13EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c
new file mode 100644
index 000000000000..beb80f316095
--- /dev/null
+++ b/arch/mips/lib/ashldi3.c
@@ -0,0 +1,29 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5long long __ashldi3(long long u, word_type b)
6{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 w.s.low = 0;
18 w.s.high = (unsigned int) uu.s.low << -bm;
19 } else {
20 const unsigned int carries = (unsigned int) uu.s.low >> bm;
21
22 w.s.low = (unsigned int) uu.s.low << b;
23 w.s.high = ((unsigned int) uu.s.high << b) | carries;
24 }
25
26 return w.ll;
27}
28
29EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c
new file mode 100644
index 000000000000..c884a912b660
--- /dev/null
+++ b/arch/mips/lib/ashrdi3.c
@@ -0,0 +1,31 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5long long __ashrdi3(long long u, word_type b)
6{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 /* w.s.high = 1..1 or 0..0 */
18 w.s.high =
19 uu.s.high >> 31;
20 w.s.low = uu.s.high >> -bm;
21 } else {
22 const unsigned int carries = (unsigned int) uu.s.high << bm;
23
24 w.s.high = uu.s.high >> b;
25 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
26 }
27
28 return w.ll;
29}
30
31EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/mips/lib/libgcc.h b/arch/mips/lib/libgcc.h
new file mode 100644
index 000000000000..3f19d1c5d942
--- /dev/null
+++ b/arch/mips/lib/libgcc.h
@@ -0,0 +1,26 @@
1#ifndef __ASM_LIBGCC_H
2#define __ASM_LIBGCC_H
3
4#include <asm/byteorder.h>
5
6typedef int word_type __attribute__ ((mode (__word__)));
7
8#ifdef __BIG_ENDIAN
9struct DWstruct {
10 int high, low;
11};
12#elif defined(__LITTLE_ENDIAN)
13struct DWstruct {
14 int low, high;
15};
16#else
17#error I feel sick.
18#endif
19
20typedef union
21{
22 struct DWstruct s;
23 long long ll;
24} DWunion;
25
26#endif /* __ASM_LIBGCC_H */
diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c
new file mode 100644
index 000000000000..dcf8d6810b7c
--- /dev/null
+++ b/arch/mips/lib/lshrdi3.c
@@ -0,0 +1,29 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5long long __lshrdi3(long long u, word_type b)
6{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 w.s.high = 0;
18 w.s.low = (unsigned int) uu.s.high >> -bm;
19 } else {
20 const unsigned int carries = (unsigned int) uu.s.high << bm;
21
22 w.s.high = (unsigned int) uu.s.high >> b;
23 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
24 }
25
26 return w.ll;
27}
28
29EXPORT_SYMBOL(__lshrdi3);
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index aa5818a0d884..3f0d5d26d506 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -60,15 +60,15 @@
60 60
61/* Function which emulates a floating point instruction. */ 61/* Function which emulates a floating point instruction. */
62 62
63static int fpu_emu(struct pt_regs *, struct mips_fpu_soft_struct *, 63static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
64 mips_instruction); 64 mips_instruction);
65 65
66#if __mips >= 4 && __mips != 32 66#if __mips >= 4 && __mips != 32
67static int fpux_emu(struct pt_regs *, 67static int fpux_emu(struct pt_regs *,
68 struct mips_fpu_soft_struct *, mips_instruction); 68 struct mips_fpu_struct *, mips_instruction);
69#endif 69#endif
70 70
71/* Further private data for which no space exists in mips_fpu_soft_struct */ 71/* Further private data for which no space exists in mips_fpu_struct */
72 72
73struct mips_fpu_emulator_stats fpuemustats; 73struct mips_fpu_emulator_stats fpuemustats;
74 74
@@ -203,7 +203,7 @@ static int isBranchInstr(mips_instruction * i)
203 * Two instructions if the instruction is in a branch delay slot. 203 * Two instructions if the instruction is in a branch delay slot.
204 */ 204 */
205 205
206static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx) 206static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
207{ 207{
208 mips_instruction ir; 208 mips_instruction ir;
209 void * emulpc, *contpc; 209 void * emulpc, *contpc;
@@ -595,7 +595,7 @@ DEF3OP(msub, dp, ieee754dp_mul, ieee754dp_sub,);
595DEF3OP(nmadd, dp, ieee754dp_mul, ieee754dp_add, ieee754dp_neg); 595DEF3OP(nmadd, dp, ieee754dp_mul, ieee754dp_add, ieee754dp_neg);
596DEF3OP(nmsub, dp, ieee754dp_mul, ieee754dp_sub, ieee754dp_neg); 596DEF3OP(nmsub, dp, ieee754dp_mul, ieee754dp_sub, ieee754dp_neg);
597 597
598static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx, 598static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
599 mips_instruction ir) 599 mips_instruction ir)
600{ 600{
601 unsigned rcsr = 0; /* resulting csr */ 601 unsigned rcsr = 0; /* resulting csr */
@@ -759,7 +759,7 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
759/* 759/*
760 * Emulate a single COP1 arithmetic instruction. 760 * Emulate a single COP1 arithmetic instruction.
761 */ 761 */
762static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx, 762static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
763 mips_instruction ir) 763 mips_instruction ir)
764{ 764{
765 int rfmt; /* resulting format */ 765 int rfmt; /* resulting format */
@@ -1233,8 +1233,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_soft_struct *ctx,
1233 return 0; 1233 return 0;
1234} 1234}
1235 1235
1236int fpu_emulator_cop1Handler(struct pt_regs *xcp, 1236int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
1237 struct mips_fpu_soft_struct *ctx)
1238{ 1237{
1239 unsigned long oldepc, prevepc; 1238 unsigned long oldepc, prevepc;
1240 mips_instruction insn; 1239 mips_instruction insn;
diff --git a/arch/mips/math-emu/ieee754.h b/arch/mips/math-emu/ieee754.h
index 171f177c0f88..dd917332792c 100644
--- a/arch/mips/math-emu/ieee754.h
+++ b/arch/mips/math-emu/ieee754.h
@@ -329,7 +329,7 @@ struct _ieee754_csr {
329 unsigned pad0:7; 329 unsigned pad0:7;
330#endif 330#endif
331}; 331};
332#define ieee754_csr (*(struct _ieee754_csr *)(&current->thread.fpu.soft.fcr31)) 332#define ieee754_csr (*(struct _ieee754_csr *)(&current->thread.fpu.fcr31))
333 333
334static inline unsigned ieee754_getrm(void) 334static inline unsigned ieee754_getrm(void)
335{ 335{
diff --git a/arch/mips/math-emu/kernel_linkage.c b/arch/mips/math-emu/kernel_linkage.c
index d187ab71c2ff..56ca0c6a7178 100644
--- a/arch/mips/math-emu/kernel_linkage.c
+++ b/arch/mips/math-emu/kernel_linkage.c
@@ -39,9 +39,9 @@ void fpu_emulator_init_fpu(void)
39 printk("Algorithmics/MIPS FPU Emulator v1.5\n"); 39 printk("Algorithmics/MIPS FPU Emulator v1.5\n");
40 } 40 }
41 41
42 current->thread.fpu.soft.fcr31 = 0; 42 current->thread.fpu.fcr31 = 0;
43 for (i = 0; i < 32; i++) { 43 for (i = 0; i < 32; i++) {
44 current->thread.fpu.soft.fpr[i] = SIGNALLING_NAN; 44 current->thread.fpu.fpr[i] = SIGNALLING_NAN;
45 } 45 }
46} 46}
47 47
@@ -59,10 +59,9 @@ int fpu_emulator_save_context(struct sigcontext *sc)
59 59
60 for (i = 0; i < 32; i++) { 60 for (i = 0; i < 32; i++) {
61 err |= 61 err |=
62 __put_user(current->thread.fpu.soft.fpr[i], 62 __put_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
63 &sc->sc_fpregs[i]);
64 } 63 }
65 err |= __put_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr); 64 err |= __put_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
66 65
67 return err; 66 return err;
68} 67}
@@ -74,10 +73,9 @@ int fpu_emulator_restore_context(struct sigcontext *sc)
74 73
75 for (i = 0; i < 32; i++) { 74 for (i = 0; i < 32; i++) {
76 err |= 75 err |=
77 __get_user(current->thread.fpu.soft.fpr[i], 76 __get_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
78 &sc->sc_fpregs[i]);
79 } 77 }
80 err |= __get_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr); 78 err |= __get_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
81 79
82 return err; 80 return err;
83} 81}
@@ -94,10 +92,9 @@ int fpu_emulator_save_context32(struct sigcontext32 *sc)
94 92
95 for (i = 0; i < 32; i+=2) { 93 for (i = 0; i < 32; i+=2) {
96 err |= 94 err |=
97 __put_user(current->thread.fpu.soft.fpr[i], 95 __put_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
98 &sc->sc_fpregs[i]);
99 } 96 }
100 err |= __put_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr); 97 err |= __put_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
101 98
102 return err; 99 return err;
103} 100}
@@ -109,10 +106,9 @@ int fpu_emulator_restore_context32(struct sigcontext32 *sc)
109 106
110 for (i = 0; i < 32; i+=2) { 107 for (i = 0; i < 32; i+=2) {
111 err |= 108 err |=
112 __get_user(current->thread.fpu.soft.fpr[i], 109 __get_user(current->thread.fpu.fpr[i], &sc->sc_fpregs[i]);
113 &sc->sc_fpregs[i]);
114 } 110 }
115 err |= __get_user(current->thread.fpu.soft.fcr31, &sc->sc_fpc_csr); 111 err |= __get_user(current->thread.fpu.fcr31, &sc->sc_fpc_csr);
116 112
117 return err; 113 return err;
118} 114}
diff --git a/arch/mips/mips-boards/atlas/atlas_setup.c b/arch/mips/mips-boards/atlas/atlas_setup.c
index c20d401ecf80..8cc9effcb832 100644
--- a/arch/mips/mips-boards/atlas/atlas_setup.c
+++ b/arch/mips/mips-boards/atlas/atlas_setup.c
@@ -50,7 +50,7 @@ const char *get_system_type(void)
50 return "MIPS Atlas"; 50 return "MIPS Atlas";
51} 51}
52 52
53void __init plat_setup(void) 53void __init plat_mem_setup(void)
54{ 54{
55 mips_pcibios_init(); 55 mips_pcibios_init();
56 56
diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c
index bc4d093685bb..fd492562584a 100644
--- a/arch/mips/mips-boards/generic/memory.c
+++ b/arch/mips/mips-boards/generic/memory.c
@@ -76,6 +76,15 @@ struct prom_pmemblock * __init prom_getmdesc(void)
76 memsize = simple_strtol(memsize_str, NULL, 0); 76 memsize = simple_strtol(memsize_str, NULL, 0);
77 } 77 }
78 } 78 }
79
80#ifdef CONFIG_CPU_BIG_ENDIAN
81 /*
82 * SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last
83 * word of physical memory
84 */
85 memsize -= PAGE_SIZE;
86#endif
87
79 memset(mdesc, 0, sizeof(mdesc)); 88 memset(mdesc, 0, sizeof(mdesc));
80 89
81 mdesc[0].type = yamon_dontuse; 90 mdesc[0].type = yamon_dontuse;
diff --git a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mips-boards/malta/malta_setup.c
index b8488aab6df1..0766e434b6bd 100644
--- a/arch/mips/mips-boards/malta/malta_setup.c
+++ b/arch/mips/mips-boards/malta/malta_setup.c
@@ -53,11 +53,11 @@ extern void kgdb_config(void);
53#endif 53#endif
54 54
55struct resource standard_io_resources[] = { 55struct resource standard_io_resources[] = {
56 { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, 56 { .name = "dma1", .start = 0x00, .end = 0x1f, .flags = IORESOURCE_BUSY },
57 { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, 57 { .name = "timer", .start = 0x40, .end = 0x5f, .flags = IORESOURCE_BUSY },
58 { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY }, 58 { .name = "keyboard", .start = 0x60, .end = 0x6f, .flags = IORESOURCE_BUSY },
59 { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, 59 { .name = "dma page reg", .start = 0x80, .end = 0x8f, .flags = IORESOURCE_BUSY },
60 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, 60 { .name = "dma2", .start = 0xc0, .end = 0xdf, .flags = IORESOURCE_BUSY },
61}; 61};
62 62
63#ifdef CONFIG_MTD 63#ifdef CONFIG_MTD
@@ -111,7 +111,7 @@ void __init fd_activate(void)
111} 111}
112#endif 112#endif
113 113
114void __init plat_setup(void) 114void __init plat_mem_setup(void)
115{ 115{
116 unsigned int i; 116 unsigned int i;
117 117
diff --git a/arch/mips/mips-boards/malta/malta_smp.c b/arch/mips/mips-boards/malta/malta_smp.c
index 6c6c8eeedbce..cf967170fe29 100644
--- a/arch/mips/mips-boards/malta/malta_smp.c
+++ b/arch/mips/mips-boards/malta/malta_smp.c
@@ -34,25 +34,6 @@ void core_send_ipi(int cpu, unsigned int action)
34} 34}
35 35
36/* 36/*
37 * Detect available CPUs/VPEs/TCs and populate phys_cpu_present_map
38 */
39
40void __init prom_build_cpu_map(void)
41{
42 int nextslot;
43
44 /*
45 * As of November, 2004, MIPSsim only simulates one core
46 * at a time. However, that core may be a MIPS MT core
47 * with multiple virtual processors and thread contexts.
48 */
49
50 if (read_c0_config3() & (1<<2)) {
51 nextslot = mipsmt_build_cpu_map(1);
52 }
53}
54
55/*
56 * Platform "CPU" startup hook 37 * Platform "CPU" startup hook
57 */ 38 */
58 39
diff --git a/arch/mips/mips-boards/sead/sead_setup.c b/arch/mips/mips-boards/sead/sead_setup.c
index 4266ce445174..6430f11f3a95 100644
--- a/arch/mips/mips-boards/sead/sead_setup.c
+++ b/arch/mips/mips-boards/sead/sead_setup.c
@@ -45,7 +45,7 @@ const char *get_system_type(void)
45 return "MIPS SEAD"; 45 return "MIPS SEAD";
46} 46}
47 47
48void __init plat_setup(void) 48void __init plat_mem_setup(void)
49{ 49{
50 ioport_resource.end = 0x7fffffff; 50 ioport_resource.end = 0x7fffffff;
51 51
diff --git a/arch/mips/mips-boards/sim/sim_setup.c b/arch/mips/mips-boards/sim/sim_setup.c
index a2fd62997ca3..15a5dac4ae19 100644
--- a/arch/mips/mips-boards/sim/sim_setup.c
+++ b/arch/mips/mips-boards/sim/sim_setup.c
@@ -50,7 +50,7 @@ const char *get_system_type(void)
50 return "MIPSsim"; 50 return "MIPSsim";
51} 51}
52 52
53void __init plat_setup(void) 53void __init plat_mem_setup(void)
54{ 54{
55 set_io_port_base(0xbfd00000); 55 set_io_port_base(0xbfd00000);
56 56
diff --git a/arch/mips/mips-boards/sim/sim_smp.c b/arch/mips/mips-boards/sim/sim_smp.c
index b7084e7c4bf9..004070956cca 100644
--- a/arch/mips/mips-boards/sim/sim_smp.c
+++ b/arch/mips/mips-boards/sim/sim_smp.c
@@ -51,27 +51,6 @@ void core_send_ipi(int cpu, unsigned int action)
51} 51}
52 52
53/* 53/*
54 * Detect available CPUs/VPEs/TCs and populate phys_cpu_present_map
55 */
56
57void __init prom_build_cpu_map(void)
58{
59#ifdef CONFIG_MIPS_MT_SMTC
60 int nextslot;
61
62 /*
63 * As of November, 2004, MIPSsim only simulates one core
64 * at a time. However, that core may be a MIPS MT core
65 * with multiple virtual processors and thread contexts.
66 */
67
68 if (read_c0_config3() & (1<<2)) {
69 nextslot = mipsmt_build_cpu_map(1);
70 }
71#endif /* CONFIG_MIPS_MT_SMTC */
72}
73
74/*
75 * Platform "CPU" startup hook 54 * Platform "CPU" startup hook
76 */ 55 */
77 56
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 9dca099ba16b..965cb4c4359d 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -413,7 +413,6 @@ out:
413 return ret; 413 return ret;
414} 414}
415 415
416extern void __init sanitize_tlb_entries(void);
417static void __init probe_tlb(unsigned long config) 416static void __init probe_tlb(unsigned long config)
418{ 417{
419 struct cpuinfo_mips *c = &current_cpu_data; 418 struct cpuinfo_mips *c = &current_cpu_data;
diff --git a/arch/mips/momentum/jaguar_atx/setup.c b/arch/mips/momentum/jaguar_atx/setup.c
index 1379c76845dc..df1485501ce6 100644
--- a/arch/mips/momentum/jaguar_atx/setup.c
+++ b/arch/mips/momentum/jaguar_atx/setup.c
@@ -359,7 +359,7 @@ static __init int __init ja_pci_init(void)
359 359
360arch_initcall(ja_pci_init); 360arch_initcall(ja_pci_init);
361 361
362void __init plat_setup(void) 362void __init plat_mem_setup(void)
363{ 363{
364 unsigned int tmpword; 364 unsigned int tmpword;
365 365
diff --git a/arch/mips/momentum/ocelot_3/setup.c b/arch/mips/momentum/ocelot_3/setup.c
index c69195234309..8c53490ba6f1 100644
--- a/arch/mips/momentum/ocelot_3/setup.c
+++ b/arch/mips/momentum/ocelot_3/setup.c
@@ -313,7 +313,7 @@ static __init int __init ja_pci_init(void)
313 313
314arch_initcall(ja_pci_init); 314arch_initcall(ja_pci_init);
315 315
316void __init plat_setup(void) 316void __init plat_mem_setup(void)
317{ 317{
318 unsigned int tmpword; 318 unsigned int tmpword;
319 319
diff --git a/arch/mips/momentum/ocelot_c/setup.c b/arch/mips/momentum/ocelot_c/setup.c
index a3e6f5575592..257e1d1b72dd 100644
--- a/arch/mips/momentum/ocelot_c/setup.c
+++ b/arch/mips/momentum/ocelot_c/setup.c
@@ -231,7 +231,7 @@ void momenco_time_init(void)
231 rtc_mips_set_time = m48t37y_set_time; 231 rtc_mips_set_time = m48t37y_set_time;
232} 232}
233 233
234void __init plat_setup(void) 234void __init plat_mem_setup(void)
235{ 235{
236 unsigned int tmpword; 236 unsigned int tmpword;
237 237
diff --git a/arch/mips/momentum/ocelot_g/setup.c b/arch/mips/momentum/ocelot_g/setup.c
index fed4e8eee116..72143ab1e900 100644
--- a/arch/mips/momentum/ocelot_g/setup.c
+++ b/arch/mips/momentum/ocelot_g/setup.c
@@ -162,7 +162,7 @@ static void __init setup_l3cache(unsigned long size)
162 printk("Done\n"); 162 printk("Done\n");
163} 163}
164 164
165void __init plat_setup(void) 165void __init plat_mem_setup(void)
166{ 166{
167 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache); 167 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache);
168 unsigned int tmpword; 168 unsigned int tmpword;
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index 16205b587338..465778c5d816 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -18,12 +18,12 @@ obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
18obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o 18obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o
19obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o 19obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o
20obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o 20obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o
21obj-$(CONFIG_MARKEINS) += ops-emma2rh.o pci-emma2rh.o fixup-emma2rh.o
21 22
22# 23#
23# These are still pretty much in the old state, watch, go blind. 24# These are still pretty much in the old state, watch, go blind.
24# 25#
25obj-$(CONFIG_DDB5074) += fixup-ddb5074.o pci-ddb5074.o ops-ddb5074.o 26obj-$(CONFIG_BASLER_EXCITE) = ops-titan.o pci-excite.o fixup-excite.o
26obj-$(CONFIG_DDB5476) += ops-ddb5476.o pci-ddb5476.o
27obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o 27obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o
28obj-$(CONFIG_LASAT) += pci-lasat.o 28obj-$(CONFIG_LASAT) += pci-lasat.o
29obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o 29obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o
@@ -43,7 +43,7 @@ obj-$(CONFIG_MOMENCO_OCELOT_C) += fixup-ocelot-c.o pci-ocelot-c.o
43obj-$(CONFIG_MOMENCO_OCELOT_G) += fixup-ocelot-g.o pci-ocelot-g.o 43obj-$(CONFIG_MOMENCO_OCELOT_G) += fixup-ocelot-g.o pci-ocelot-g.o
44obj-$(CONFIG_PMC_YOSEMITE) += fixup-yosemite.o ops-titan.o ops-titan-ht.o \ 44obj-$(CONFIG_PMC_YOSEMITE) += fixup-yosemite.o ops-titan.o ops-titan-ht.o \
45 pci-yosemite.o 45 pci-yosemite.o
46obj-$(CONFIG_SGI_IP27) += pci-ip27.o 46obj-$(CONFIG_SGI_IP27) += ops-bridge.o pci-ip27.o
47obj-$(CONFIG_SGI_IP32) += fixup-ip32.o ops-mace.o pci-ip32.o 47obj-$(CONFIG_SGI_IP32) += fixup-ip32.o ops-mace.o pci-ip32.o
48obj-$(CONFIG_SIBYTE_SB1250) += fixup-sb1250.o pci-sb1250.o 48obj-$(CONFIG_SIBYTE_SB1250) += fixup-sb1250.o pci-sb1250.o
49obj-$(CONFIG_SIBYTE_BCM112X) += fixup-sb1250.o pci-sb1250.o 49obj-$(CONFIG_SIBYTE_BCM112X) += fixup-sb1250.o pci-sb1250.o
@@ -57,3 +57,4 @@ obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o ops-tx4927.o
57obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-tx4938.o ops-tx4938.o 57obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-tx4938.o ops-tx4938.o
58obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o 58obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
59obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o 59obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o
60obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
diff --git a/arch/mips/pci/fixup-ddb5074.c b/arch/mips/pci/fixup-ddb5074.c
deleted file mode 100644
index 5a4a7c239c42..000000000000
--- a/arch/mips/pci/fixup-ddb5074.c
+++ /dev/null
@@ -1,21 +0,0 @@
1/*
2 * It's nice to have the LEDs on the GPIO pins available for debugging
3 */
4static void ddb5074_fixup(struct pci_dev *dev)
5{
6 extern struct pci_dev *pci_pmu;
7 u8 t8;
8
9 pci_pmu = dev; /* for LEDs D2 and D3 */
10 /* Program the lines for LEDs D2 and D3 to output */
11 pci_read_config_byte(dev, 0x7d, &t8);
12 t8 |= 0xc0;
13 pci_write_config_byte(dev, 0x7d, t8);
14 /* Turn LEDs D2 and D3 off */
15 pci_read_config_byte(dev, 0x7e, &t8);
16 t8 |= 0xc0;
17 pci_write_config_byte(dev, 0x7e, t8);
18}
19
20DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
21 ddb5074_fixup);
diff --git a/arch/mips/pci/fixup-emma2rh.c b/arch/mips/pci/fixup-emma2rh.c
new file mode 100644
index 000000000000..3a34cd0efd6b
--- /dev/null
+++ b/arch/mips/pci/fixup-emma2rh.c
@@ -0,0 +1,102 @@
1/*
2 * arch/mips/pci/fixup-emma2rh.c
3 * This file defines the PCI configration.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/config.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <linux/types.h>
30#include <linux/pci.h>
31
32#include <asm/bootinfo.h>
33#include <asm/debug.h>
34
35#include <asm/emma2rh/emma2rh.h>
36
37#define EMMA2RH_PCI_HOST_SLOT 0x09
38#define EMMA2RH_USB_SLOT 0x03
39#define PCI_DEVICE_ID_NEC_EMMA2RH 0x014b /* EMMA2RH PCI Host */
40
41/*
42 * we fix up irqs based on the slot number.
43 * The first entry is at AD:11.
44 * Fortunately this works because, although we have two pci buses,
45 * they all have different slot numbers (except for rockhopper slot 20
46 * which is handled below).
47 *
48 */
49
50#define MAX_SLOT_NUM 10
51static unsigned char irq_map[][5] __initdata = {
52 [3] = {0, MARKEINS_PCI_IRQ_INTB, MARKEINS_PCI_IRQ_INTC,
53 MARKEINS_PCI_IRQ_INTD, 0,},
54 [4] = {0, MARKEINS_PCI_IRQ_INTA, 0, 0, 0,},
55 [5] = {0, 0, 0, 0, 0,},
56 [6] = {0, MARKEINS_PCI_IRQ_INTC, MARKEINS_PCI_IRQ_INTD,
57 MARKEINS_PCI_IRQ_INTA, MARKEINS_PCI_IRQ_INTB,},
58};
59
60static void __devinit nec_usb_controller_fixup(struct pci_dev *dev)
61{
62 if (PCI_SLOT(dev->devfn) == EMMA2RH_USB_SLOT)
63 /* on board USB controller configuration */
64 pci_write_config_dword(dev, 0xe4, 1 << 5);
65}
66
67DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
68 nec_usb_controller_fixup);
69
70/*
71 * Prevent the PCI layer from seeing the resources allocated to this device
72 * if it is the host bridge by marking it as such. These resources are of
73 * no consequence to the PCI layer (they are handled elsewhere).
74 */
75static void __devinit emma2rh_pci_host_fixup(struct pci_dev *dev)
76{
77 int i;
78
79 if (PCI_SLOT(dev->devfn) == EMMA2RH_PCI_HOST_SLOT) {
80 dev->class &= 0xff;
81 dev->class |= PCI_CLASS_BRIDGE_HOST << 8;
82 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
83 dev->resource[i].start = 0;
84 dev->resource[i].end = 0;
85 dev->resource[i].flags = 0;
86 }
87 }
88}
89
90DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_EMMA2RH,
91 emma2rh_pci_host_fixup);
92
93int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
94{
95 return irq_map[slot][pin];
96}
97
98/* Do platform specific device initialization at pci_enable_device() time */
99int pcibios_plat_dev_init(struct pci_dev *dev)
100{
101 return 0;
102}
diff --git a/arch/mips/pci/fixup-excite.c b/arch/mips/pci/fixup-excite.c
new file mode 100644
index 000000000000..1da696d43f00
--- /dev/null
+++ b/arch/mips/pci/fixup-excite.c
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/pci.h>
22#include <excite.h>
23
24int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
25{
26 if (pin == 0)
27 return -1;
28
29 return USB_IRQ; /* USB controller is the only PCI device */
30}
31
32/* Do platform specific device initialization at pci_enable_device() time */
33int pcibios_plat_dev_init(struct pci_dev *dev)
34{
35 return 0;
36}
diff --git a/arch/mips/pci/fixup-wrppmc.c b/arch/mips/pci/fixup-wrppmc.c
new file mode 100644
index 000000000000..3357c1300bb1
--- /dev/null
+++ b/arch/mips/pci/fixup-wrppmc.c
@@ -0,0 +1,37 @@
1/*
2 * fixup-wrppmc.c: PPMC board specific PCI fixup
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2006, Wind River Inc. Rongkai.zhan (rongkai.zhan@windriver.com)
9 */
10#include <linux/init.h>
11#include <linux/pci.h>
12#include <asm/gt64120.h>
13
14/* PCI interrupt pins */
15#define PCI_INTA 1
16#define PCI_INTB 2
17#define PCI_INTC 3
18#define PCI_INTD 4
19
20#define PCI_SLOT_MAXNR 32 /* Each PCI bus has 32 physical slots */
21
22static char pci_irq_tab[PCI_SLOT_MAXNR][5] __initdata = {
23 /* 0 INTA INTB INTC INTD */
24 [0] = {0, 0, 0, 0, 0}, /* Slot 0: GT64120 PCI bridge */
25 [6] = {0, WRPPMC_PCI_INTA_IRQ, 0, 0, 0},
26};
27
28int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
29{
30 return pci_irq_tab[slot][pin];
31}
32
33/* Do platform specific device initialization at pci_enable_device() time */
34int pcibios_plat_dev_init(struct pci_dev *dev)
35{
36 return 0;
37}
diff --git a/arch/mips/pci/ops-bridge.c b/arch/mips/pci/ops-bridge.c
new file mode 100644
index 000000000000..1fa09929cd7a
--- /dev/null
+++ b/arch/mips/pci/ops-bridge.c
@@ -0,0 +1,306 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1999, 2000, 04, 06 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9#include <linux/pci.h>
10#include <asm/paccess.h>
11#include <asm/pci/bridge.h>
12#include <asm/sn/arch.h>
13#include <asm/sn/intr.h>
14#include <asm/sn/sn0/hub.h>
15
16/*
17 * The Bridge ASIC supports both type 0 and type 1 access. Type 1 is
18 * not really documented, so right now I can't write code which uses it.
19 * Therefore we use type 0 accesses for now even though they won't work
20 * correcly for PCI-to-PCI bridges.
21 *
22 * The function is complicated by the ultimate brokeness of the IOC3 chip
23 * which is used in SGI systems. The IOC3 can only handle 32-bit PCI
24 * accesses and does only decode parts of it's address space.
25 */
26
27static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
28 int where, int size, u32 * value)
29{
30 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
31 bridge_t *bridge = bc->base;
32 int slot = PCI_SLOT(devfn);
33 int fn = PCI_FUNC(devfn);
34 volatile void *addr;
35 u32 cf, shift, mask;
36 int res;
37
38 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
39 if (get_dbe(cf, (u32 *) addr))
40 return PCIBIOS_DEVICE_NOT_FOUND;
41
42 /*
43 * IOC3 is fucked fucked beyond believe ... Don't even give the
44 * generic PCI code a chance to look at it for real ...
45 */
46 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
47 goto oh_my_gawd;
48
49 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];
50
51 if (size == 1)
52 res = get_dbe(*value, (u8 *) addr);
53 else if (size == 2)
54 res = get_dbe(*value, (u16 *) addr);
55 else
56 res = get_dbe(*value, (u32 *) addr);
57
58 return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
59
60oh_my_gawd:
61
62 /*
63 * IOC3 is fucked fucked beyond believe ... Don't even give the
64 * generic PCI code a chance to look at the wrong register.
65 */
66 if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
67 *value = 0;
68 return PCIBIOS_SUCCESSFUL;
69 }
70
71 /*
72 * IOC3 is fucked fucked beyond believe ... Don't try to access
73 * anything but 32-bit words ...
74 */
75 addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
76
77 if (get_dbe(cf, (u32 *) addr))
78 return PCIBIOS_DEVICE_NOT_FOUND;
79
80 shift = ((where & 3) << 3);
81 mask = (0xffffffffU >> ((4 - size) << 3));
82 *value = (cf >> shift) & mask;
83
84 return PCIBIOS_SUCCESSFUL;
85}
86
87static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
88 int where, int size, u32 * value)
89{
90 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
91 bridge_t *bridge = bc->base;
92 int busno = bus->number;
93 int slot = PCI_SLOT(devfn);
94 int fn = PCI_FUNC(devfn);
95 volatile void *addr;
96 u32 cf, shift, mask;
97 int res;
98
99 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
100 addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
101 if (get_dbe(cf, (u32 *) addr))
102 return PCIBIOS_DEVICE_NOT_FOUND;
103
104 /*
105 * IOC3 is fucked fucked beyond believe ... Don't even give the
106 * generic PCI code a chance to look at it for real ...
107 */
108 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
109 goto oh_my_gawd;
110
111 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
112 addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
113
114 if (size == 1)
115 res = get_dbe(*value, (u8 *) addr);
116 else if (size == 2)
117 res = get_dbe(*value, (u16 *) addr);
118 else
119 res = get_dbe(*value, (u32 *) addr);
120
121 return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
122
123oh_my_gawd:
124
125 /*
126 * IOC3 is fucked fucked beyond believe ... Don't even give the
127 * generic PCI code a chance to look at the wrong register.
128 */
129 if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
130 *value = 0;
131 return PCIBIOS_SUCCESSFUL;
132 }
133
134 /*
135 * IOC3 is fucked fucked beyond believe ... Don't try to access
136 * anything but 32-bit words ...
137 */
138 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
139 addr = &bridge->b_type1_cfg.c[(fn << 8) | where];
140
141 if (get_dbe(cf, (u32 *) addr))
142 return PCIBIOS_DEVICE_NOT_FOUND;
143
144 shift = ((where & 3) << 3);
145 mask = (0xffffffffU >> ((4 - size) << 3));
146 *value = (cf >> shift) & mask;
147
148 return PCIBIOS_SUCCESSFUL;
149}
150
151static int pci_read_config(struct pci_bus *bus, unsigned int devfn,
152 int where, int size, u32 * value)
153{
154 if (bus->number > 0)
155 return pci_conf1_read_config(bus, devfn, where, size, value);
156
157 return pci_conf0_read_config(bus, devfn, where, size, value);
158}
159
160static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
161 int where, int size, u32 value)
162{
163 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
164 bridge_t *bridge = bc->base;
165 int slot = PCI_SLOT(devfn);
166 int fn = PCI_FUNC(devfn);
167 volatile void *addr;
168 u32 cf, shift, mask, smask;
169 int res;
170
171 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
172 if (get_dbe(cf, (u32 *) addr))
173 return PCIBIOS_DEVICE_NOT_FOUND;
174
175 /*
176 * IOC3 is fucked fucked beyond believe ... Don't even give the
177 * generic PCI code a chance to look at it for real ...
178 */
179 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
180 goto oh_my_gawd;
181
182 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];
183
184 if (size == 1) {
185 res = put_dbe(value, (u8 *) addr);
186 } else if (size == 2) {
187 res = put_dbe(value, (u16 *) addr);
188 } else {
189 res = put_dbe(value, (u32 *) addr);
190 }
191
192 if (res)
193 return PCIBIOS_DEVICE_NOT_FOUND;
194
195 return PCIBIOS_SUCCESSFUL;
196
197oh_my_gawd:
198
199 /*
200 * IOC3 is fucked fucked beyond believe ... Don't even give the
201 * generic PCI code a chance to touch the wrong register.
202 */
203 if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
204 return PCIBIOS_SUCCESSFUL;
205
206 /*
207 * IOC3 is fucked fucked beyond believe ... Don't try to access
208 * anything but 32-bit words ...
209 */
210 addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
211
212 if (get_dbe(cf, (u32 *) addr))
213 return PCIBIOS_DEVICE_NOT_FOUND;
214
215 shift = ((where & 3) << 3);
216 mask = (0xffffffffU >> ((4 - size) << 3));
217 smask = mask << shift;
218
219 cf = (cf & ~smask) | ((value & mask) << shift);
220 if (put_dbe(cf, (u32 *) addr))
221 return PCIBIOS_DEVICE_NOT_FOUND;
222
223 return PCIBIOS_SUCCESSFUL;
224}
225
226static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
227 int where, int size, u32 value)
228{
229 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
230 bridge_t *bridge = bc->base;
231 int slot = PCI_SLOT(devfn);
232 int fn = PCI_FUNC(devfn);
233 int busno = bus->number;
234 volatile void *addr;
235 u32 cf, shift, mask, smask;
236 int res;
237
238 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
239 addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
240 if (get_dbe(cf, (u32 *) addr))
241 return PCIBIOS_DEVICE_NOT_FOUND;
242
243 /*
244 * IOC3 is fucked fucked beyond believe ... Don't even give the
245 * generic PCI code a chance to look at it for real ...
246 */
247 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
248 goto oh_my_gawd;
249
250 addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
251
252 if (size == 1) {
253 res = put_dbe(value, (u8 *) addr);
254 } else if (size == 2) {
255 res = put_dbe(value, (u16 *) addr);
256 } else {
257 res = put_dbe(value, (u32 *) addr);
258 }
259
260 if (res)
261 return PCIBIOS_DEVICE_NOT_FOUND;
262
263 return PCIBIOS_SUCCESSFUL;
264
265oh_my_gawd:
266
267 /*
268 * IOC3 is fucked fucked beyond believe ... Don't even give the
269 * generic PCI code a chance to touch the wrong register.
270 */
271 if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
272 return PCIBIOS_SUCCESSFUL;
273
274 /*
275 * IOC3 is fucked fucked beyond believe ... Don't try to access
276 * anything but 32-bit words ...
277 */
278 addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
279
280 if (get_dbe(cf, (u32 *) addr))
281 return PCIBIOS_DEVICE_NOT_FOUND;
282
283 shift = ((where & 3) << 3);
284 mask = (0xffffffffU >> ((4 - size) << 3));
285 smask = mask << shift;
286
287 cf = (cf & ~smask) | ((value & mask) << shift);
288 if (put_dbe(cf, (u32 *) addr))
289 return PCIBIOS_DEVICE_NOT_FOUND;
290
291 return PCIBIOS_SUCCESSFUL;
292}
293
294static int pci_write_config(struct pci_bus *bus, unsigned int devfn,
295 int where, int size, u32 value)
296{
297 if (bus->number > 0)
298 return pci_conf1_write_config(bus, devfn, where, size, value);
299
300 return pci_conf0_write_config(bus, devfn, where, size, value);
301}
302
303struct pci_ops bridge_pci_ops = {
304 .read = pci_read_config,
305 .write = pci_write_config,
306};
diff --git a/arch/mips/pci/ops-ddb5074.c b/arch/mips/pci/ops-ddb5074.c
deleted file mode 100644
index 89f97bef4fc4..000000000000
--- a/arch/mips/pci/ops-ddb5074.c
+++ /dev/null
@@ -1,271 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/ddb5476/pci_ops.c
6 * Define the pci_ops for DB5477.
7 *
8 * Much of the code is derived from the original DDB5074 port by
9 * Geert Uytterhoeven <geert@sonycom.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17#include <linux/pci.h>
18#include <linux/kernel.h>
19#include <linux/types.h>
20
21#include <asm/addrspace.h>
22#include <asm/debug.h>
23
24#include <asm/ddb5xxx/ddb5xxx.h>
25
26/*
27 * config_swap structure records what set of pdar/pmr are used
28 * to access pci config space. It also provides a place hold the
29 * original values for future restoring.
30 */
31struct pci_config_swap {
32 u32 pdar;
33 u32 pmr;
34 u32 config_base;
35 u32 config_size;
36 u32 pdar_backup;
37 u32 pmr_backup;
38};
39
40/*
41 * On DDB5476, we have one set of swap registers
42 */
43struct pci_config_swap ext_pci_swap = {
44 DDB_PCIW0,
45 DDB_PCIINIT0,
46 DDB_PCI_CONFIG_BASE,
47 DDB_PCI_CONFIG_SIZE
48};
49
50static int pci_config_workaround = 1;
51
52/*
53 * access config space
54 */
55static inline u32 ddb_access_config_base(struct pci_config_swap *swap, u32 bus, /* 0 means top level bus */
56 u32 slot_num)
57{
58 u32 pci_addr = 0;
59 u32 pciinit_offset = 0;
60 u32 virt_addr = swap->config_base;
61 u32 option;
62
63 if (pci_config_workaround) {
64 if (slot_num == 5)
65 slot_num = 14;
66 } else {
67 if (slot_num == 5)
68 return DDB_BASE + DDB_PCI_BASE;
69 }
70
71 /* minimum pdar (window) size is 2MB */
72 db_assert(swap->config_size >= (2 << 20));
73
74 db_assert(slot_num < (1 << 5));
75 db_assert(bus < (1 << 8));
76
77 /* backup registers */
78 swap->pdar_backup = ddb_in32(swap->pdar);
79 swap->pmr_backup = ddb_in32(swap->pmr);
80
81 /* set the pdar (pci window) register */
82 ddb_set_pdar(swap->pdar, swap->config_base, swap->config_size, 32, /* 32 bit wide */
83 0, /* not on local memory bus */
84 0); /* not visible from PCI bus (N/A) */
85
86 /*
87 * calcuate the absolute pci config addr;
88 * according to the spec, we start scanning from adr:11 (0x800)
89 */
90 if (bus == 0) {
91 /* type 0 config */
92 pci_addr = 0x00040000 << slot_num;
93 } else {
94 /* type 1 config */
95 pci_addr = 0x00040000 << slot_num;
96 panic
97 ("ddb_access_config_base: we don't support type 1 config Yet");
98 }
99
100 /*
101 * if pci_addr is less than pci config window size, we set
102 * pciinit_offset to 0 and adjust the virt_address.
103 * Otherwise we will try to adjust pciinit_offset.
104 */
105 if (pci_addr < swap->config_size) {
106 virt_addr = KSEG1ADDR(swap->config_base + pci_addr);
107 pciinit_offset = 0;
108 } else {
109 db_assert((pci_addr & (swap->config_size - 1)) == 0);
110 virt_addr = KSEG1ADDR(swap->config_base);
111 pciinit_offset = pci_addr;
112 }
113
114 /* set the pmr register */
115 option = DDB_PCI_ACCESS_32;
116 if (bus != 0)
117 option |= DDB_PCI_CFGTYPE1;
118 ddb_set_pmr(swap->pmr, DDB_PCICMD_CFG, pciinit_offset, option);
119
120 return virt_addr;
121}
122
123static inline void ddb_close_config_base(struct pci_config_swap *swap)
124{
125 ddb_out32(swap->pdar, swap->pdar_backup);
126 ddb_out32(swap->pmr, swap->pmr_backup);
127}
128
129static int read_config_dword(struct pci_config_swap *swap,
130 struct pci_dev *dev, u32 where, u32 * val)
131{
132 u32 bus, slot_num, func_num;
133 u32 base;
134
135 db_assert((where & 3) == 0);
136 db_assert(where < (1 << 8));
137
138 /* check if the bus is top-level */
139 if (dev->bus->parent != NULL) {
140 bus = dev->bus->number;
141 db_assert(bus != 0);
142 } else {
143 bus = 0;
144 }
145
146 slot_num = PCI_SLOT(dev->devfn);
147 func_num = PCI_FUNC(dev->devfn);
148 base = ddb_access_config_base(swap, bus, slot_num);
149 *val = *(volatile u32 *) (base + (func_num << 8) + where);
150 ddb_close_config_base(swap);
151 return PCIBIOS_SUCCESSFUL;
152}
153
154static int read_config_word(struct pci_config_swap *swap,
155 struct pci_dev *dev, u32 where, u16 * val)
156{
157 int status;
158 u32 result;
159
160 db_assert((where & 1) == 0);
161
162 status = read_config_dword(swap, dev, where & ~3, &result);
163 if (where & 2)
164 result >>= 16;
165 *val = result & 0xffff;
166 return status;
167}
168
169static int read_config_byte(struct pci_config_swap *swap,
170 struct pci_dev *dev, u32 where, u8 * val)
171{
172 int status;
173 u32 result;
174
175 status = read_config_dword(swap, dev, where & ~3, &result);
176 if (where & 1)
177 result >>= 8;
178 if (where & 2)
179 result >>= 16;
180 *val = result & 0xff;
181 return status;
182}
183
184static int write_config_dword(struct pci_config_swap *swap,
185 struct pci_dev *dev, u32 where, u32 val)
186{
187 u32 bus, slot_num, func_num;
188 u32 base;
189
190 db_assert((where & 3) == 0);
191 db_assert(where < (1 << 8));
192
193 /* check if the bus is top-level */
194 if (dev->bus->parent != NULL) {
195 bus = dev->bus->number;
196 db_assert(bus != 0);
197 } else {
198 bus = 0;
199 }
200
201 slot_num = PCI_SLOT(dev->devfn);
202 func_num = PCI_FUNC(dev->devfn);
203 base = ddb_access_config_base(swap, bus, slot_num);
204 *(volatile u32 *) (base + (func_num << 8) + where) = val;
205 ddb_close_config_base(swap);
206 return PCIBIOS_SUCCESSFUL;
207}
208
209static int write_config_word(struct pci_config_swap *swap,
210 struct pci_dev *dev, u32 where, u16 val)
211{
212 int status, shift = 0;
213 u32 result;
214
215 db_assert((where & 1) == 0);
216
217 status = read_config_dword(swap, dev, where & ~3, &result);
218 if (status != PCIBIOS_SUCCESSFUL)
219 return status;
220
221 if (where & 2)
222 shift += 16;
223 result &= ~(0xffff << shift);
224 result |= val << shift;
225 return write_config_dword(swap, dev, where & ~3, result);
226}
227
228static int write_config_byte(struct pci_config_swap *swap,
229 struct pci_dev *dev, u32 where, u8 val)
230{
231 int status, shift = 0;
232 u32 result;
233
234 status = read_config_dword(swap, dev, where & ~3, &result);
235 if (status != PCIBIOS_SUCCESSFUL)
236 return status;
237
238 if (where & 2)
239 shift += 16;
240 if (where & 1)
241 shift += 8;
242 result &= ~(0xff << shift);
243 result |= val << shift;
244 return write_config_dword(swap, dev, where & ~3, result);
245}
246
247#define MAKE_PCI_OPS(prefix, rw, unitname, unittype, pciswap) \
248static int prefix##_##rw##_config_##unitname(struct pci_dev *dev, int where, unittype val) \
249{ \
250 return rw##_config_##unitname(pciswap, \
251 dev, \
252 where, \
253 val); \
254}
255
256MAKE_PCI_OPS(extpci, read, byte, u8 *, &ext_pci_swap)
257 MAKE_PCI_OPS(extpci, read, word, u16 *, &ext_pci_swap)
258 MAKE_PCI_OPS(extpci, read, dword, u32 *, &ext_pci_swap)
259
260 MAKE_PCI_OPS(extpci, write, byte, u8, &ext_pci_swap)
261 MAKE_PCI_OPS(extpci, write, word, u16, &ext_pci_swap)
262 MAKE_PCI_OPS(extpci, write, dword, u32, &ext_pci_swap)
263
264struct pci_ops ddb5476_ext_pci_ops = {
265 extpci_read_config_byte,
266 extpci_read_config_word,
267 extpci_read_config_dword,
268 extpci_write_config_byte,
269 extpci_write_config_word,
270 extpci_write_config_dword
271};
diff --git a/arch/mips/pci/ops-ddb5476.c b/arch/mips/pci/ops-ddb5476.c
deleted file mode 100644
index 12da58e75ec7..000000000000
--- a/arch/mips/pci/ops-ddb5476.c
+++ /dev/null
@@ -1,286 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/ddb5476/pci_ops.c
6 * Define the pci_ops for DB5477.
7 *
8 * Much of the code is derived from the original DDB5074 port by
9 * Geert Uytterhoeven <geert@sonycom.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17#include <linux/pci.h>
18#include <linux/kernel.h>
19#include <linux/types.h>
20
21#include <asm/addrspace.h>
22#include <asm/debug.h>
23
24#include <asm/ddb5xxx/ddb5xxx.h>
25
26/*
27 * config_swap structure records what set of pdar/pmr are used
28 * to access pci config space. It also provides a place hold the
29 * original values for future restoring.
30 */
31struct pci_config_swap {
32 u32 pdar;
33 u32 pmr;
34 u32 config_base;
35 u32 config_size;
36 u32 pdar_backup;
37 u32 pmr_backup;
38};
39
40/*
41 * On DDB5476, we have one set of swap registers
42 */
43struct pci_config_swap ext_pci_swap = {
44 DDB_PCIW0,
45 DDB_PCIINIT0,
46 DDB_PCI_CONFIG_BASE,
47 DDB_PCI_CONFIG_SIZE
48};
49
50static int pci_config_workaround = 1;
51
52/*
53 * access config space
54 */
55static inline u32 ddb_access_config_base(struct pci_config_swap *swap, u32 bus, /* 0 means top level bus */
56 u32 slot_num)
57{
58 u32 pci_addr = 0;
59 u32 pciinit_offset = 0;
60 u32 virt_addr = swap->config_base;
61 u32 option;
62
63 if (pci_config_workaround) {
64 /* [jsun] work around Vrc5476 controller itself, returnning
65 * slot 0 essentially makes vrc5476 invisible
66 */
67 if (slot_num == 12)
68 slot_num = 0;
69
70#if 0
71 /* BUG : skip P2P bridge for now */
72 if (slot_num == 5)
73 slot_num = 0;
74#endif
75
76 } else {
77 /* now we have to be hornest, returning the true
78 * PCI config headers for vrc5476
79 */
80 if (slot_num == 12) {
81 swap->pdar_backup = ddb_in32(swap->pdar);
82 swap->pmr_backup = ddb_in32(swap->pmr);
83 return DDB_BASE + DDB_PCI_BASE;
84 }
85 }
86
87 /* minimum pdar (window) size is 2MB */
88 db_assert(swap->config_size >= (2 << 20));
89
90 db_assert(slot_num < (1 << 5));
91 db_assert(bus < (1 << 8));
92
93 /* backup registers */
94 swap->pdar_backup = ddb_in32(swap->pdar);
95 swap->pmr_backup = ddb_in32(swap->pmr);
96
97 /* set the pdar (pci window) register */
98 ddb_set_pdar(swap->pdar, swap->config_base, swap->config_size, 32, /* 32 bit wide */
99 0, /* not on local memory bus */
100 0); /* not visible from PCI bus (N/A) */
101
102 /*
103 * calcuate the absolute pci config addr;
104 * according to the spec, we start scanning from adr:11 (0x800)
105 */
106 if (bus == 0) {
107 /* type 0 config */
108 pci_addr = 0x800 << slot_num;
109 } else {
110 /* type 1 config */
111 pci_addr = (bus << 16) | (slot_num << 11);
112 /* panic("ddb_access_config_base: we don't support type 1 config Yet"); */
113 }
114
115 /*
116 * if pci_addr is less than pci config window size, we set
117 * pciinit_offset to 0 and adjust the virt_address.
118 * Otherwise we will try to adjust pciinit_offset.
119 */
120 if (pci_addr < swap->config_size) {
121 virt_addr = KSEG1ADDR(swap->config_base + pci_addr);
122 pciinit_offset = 0;
123 } else {
124 db_assert((pci_addr & (swap->config_size - 1)) == 0);
125 virt_addr = KSEG1ADDR(swap->config_base);
126 pciinit_offset = pci_addr;
127 }
128
129 /* set the pmr register */
130 option = DDB_PCI_ACCESS_32;
131 if (bus != 0)
132 option |= DDB_PCI_CFGTYPE1;
133 ddb_set_pmr(swap->pmr, DDB_PCICMD_CFG, pciinit_offset, option);
134
135 return virt_addr;
136}
137
138static inline void ddb_close_config_base(struct pci_config_swap *swap)
139{
140 ddb_out32(swap->pdar, swap->pdar_backup);
141 ddb_out32(swap->pmr, swap->pmr_backup);
142}
143
144static int read_config_dword(struct pci_config_swap *swap,
145 struct pci_dev *dev, u32 where, u32 * val)
146{
147 u32 bus, slot_num, func_num;
148 u32 base;
149
150 db_assert((where & 3) == 0);
151 db_assert(where < (1 << 8));
152
153 /* check if the bus is top-level */
154 if (dev->bus->parent != NULL) {
155 bus = dev->bus->number;
156 db_assert(bus != 0);
157 } else {
158 bus = 0;
159 }
160
161 slot_num = PCI_SLOT(dev->devfn);
162 func_num = PCI_FUNC(dev->devfn);
163 base = ddb_access_config_base(swap, bus, slot_num);
164 *val = *(volatile u32 *) (base + (func_num << 8) + where);
165 ddb_close_config_base(swap);
166 return PCIBIOS_SUCCESSFUL;
167}
168
169static int read_config_word(struct pci_config_swap *swap,
170 struct pci_dev *dev, u32 where, u16 * val)
171{
172 int status;
173 u32 result;
174
175 db_assert((where & 1) == 0);
176
177 status = read_config_dword(swap, dev, where & ~3, &result);
178 if (where & 2)
179 result >>= 16;
180 *val = result & 0xffff;
181 return status;
182}
183
184static int read_config_byte(struct pci_config_swap *swap,
185 struct pci_dev *dev, u32 where, u8 * val)
186{
187 int status;
188 u32 result;
189
190 status = read_config_dword(swap, dev, where & ~3, &result);
191 if (where & 1)
192 result >>= 8;
193 if (where & 2)
194 result >>= 16;
195 *val = result & 0xff;
196 return status;
197}
198
199static int write_config_dword(struct pci_config_swap *swap,
200 struct pci_dev *dev, u32 where, u32 val)
201{
202 u32 bus, slot_num, func_num;
203 u32 base;
204
205 db_assert((where & 3) == 0);
206 db_assert(where < (1 << 8));
207
208 /* check if the bus is top-level */
209 if (dev->bus->parent != NULL) {
210 bus = dev->bus->number;
211 db_assert(bus != 0);
212 } else {
213 bus = 0;
214 }
215
216 slot_num = PCI_SLOT(dev->devfn);
217 func_num = PCI_FUNC(dev->devfn);
218 base = ddb_access_config_base(swap, bus, slot_num);
219 *(volatile u32 *) (base + (func_num << 8) + where) = val;
220 ddb_close_config_base(swap);
221 return PCIBIOS_SUCCESSFUL;
222}
223
224static int write_config_word(struct pci_config_swap *swap,
225 struct pci_dev *dev, u32 where, u16 val)
226{
227 int status, shift = 0;
228 u32 result;
229
230 db_assert((where & 1) == 0);
231
232 status = read_config_dword(swap, dev, where & ~3, &result);
233 if (status != PCIBIOS_SUCCESSFUL)
234 return status;
235
236 if (where & 2)
237 shift += 16;
238 result &= ~(0xffff << shift);
239 result |= val << shift;
240 return write_config_dword(swap, dev, where & ~3, result);
241}
242
243static int write_config_byte(struct pci_config_swap *swap,
244 struct pci_dev *dev, u32 where, u8 val)
245{
246 int status, shift = 0;
247 u32 result;
248
249 status = read_config_dword(swap, dev, where & ~3, &result);
250 if (status != PCIBIOS_SUCCESSFUL)
251 return status;
252
253 if (where & 2)
254 shift += 16;
255 if (where & 1)
256 shift += 8;
257 result &= ~(0xff << shift);
258 result |= val << shift;
259 return write_config_dword(swap, dev, where & ~3, result);
260}
261
262#define MAKE_PCI_OPS(prefix, rw, unitname, unittype, pciswap) \
263static int prefix##_##rw##_config_##unitname(struct pci_dev *dev, int where, unittype val) \
264{ \
265 return rw##_config_##unitname(pciswap, \
266 dev, \
267 where, \
268 val); \
269}
270
271MAKE_PCI_OPS(extpci, read, byte, u8 *, &ext_pci_swap)
272 MAKE_PCI_OPS(extpci, read, word, u16 *, &ext_pci_swap)
273 MAKE_PCI_OPS(extpci, read, dword, u32 *, &ext_pci_swap)
274
275 MAKE_PCI_OPS(extpci, write, byte, u8, &ext_pci_swap)
276 MAKE_PCI_OPS(extpci, write, word, u16, &ext_pci_swap)
277 MAKE_PCI_OPS(extpci, write, dword, u32, &ext_pci_swap)
278
279struct pci_ops ddb5476_ext_pci_ops = {
280 extpci_read_config_byte,
281 extpci_read_config_word,
282 extpci_read_config_dword,
283 extpci_write_config_byte,
284 extpci_write_config_word,
285 extpci_write_config_dword
286};
diff --git a/arch/mips/pci/ops-emma2rh.c b/arch/mips/pci/ops-emma2rh.c
new file mode 100644
index 000000000000..e21b11bf66bc
--- /dev/null
+++ b/arch/mips/pci/ops-emma2rh.c
@@ -0,0 +1,186 @@
1/*
2 * arch/mips/pci/ops-emma2rh.c
3 * This file defines the PCI operation for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/pci/ops-vr41xx.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/config.h>
27#include <linux/pci.h>
28#include <linux/kernel.h>
29#include <linux/types.h>
30
31#include <asm/addrspace.h>
32#include <asm/debug.h>
33
34#include <asm/emma2rh/emma2rh.h>
35
36#define RTABORT (0x1<<9)
37#define RMABORT (0x1<<10)
38#define EMMA2RH_PCI_SLOT_NUM 9 /* 0000:09.0 is final PCI device */
39
40/*
41 * access config space
42 */
43
44static int check_args(struct pci_bus *bus, u32 devfn, u32 * bus_num)
45{
46 /* check if the bus is top-level */
47 if (bus->parent != NULL) {
48 *bus_num = bus->number;
49 db_assert(bus_num != 0);
50 } else
51 *bus_num = 0;
52
53 if (*bus_num == 0) {
54 /* Type 0 */
55 if (PCI_SLOT(devfn) >= 10)
56 return PCIBIOS_DEVICE_NOT_FOUND;
57 } else {
58 /* Type 1 */
59 if ((*bus_num >= 64) || (PCI_SLOT(devfn) >= 16))
60 return PCIBIOS_DEVICE_NOT_FOUND;
61 }
62 return 0;
63}
64
65static inline int set_pci_configuration_address(unsigned char bus_num,
66 unsigned int devfn, int where)
67{
68 u32 config_win0;
69
70 emma2rh_out32(EMMA2RH_PCI_INT, ~RMABORT);
71 if (bus_num == 0)
72 /*
73 * Type 0 configuration
74 */
75 config_win0 = (1 << (22 + PCI_SLOT(devfn))) | (5 << 9);
76 else
77 /*
78 * Type 1 configuration
79 */
80 config_win0 = (bus_num << 26) | (PCI_SLOT(devfn) << 22) |
81 (1 << 15) | (5 << 9);
82
83 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, config_win0);
84
85 return 0;
86}
87
88static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
89 int size, uint32_t * val)
90{
91 u32 bus_num;
92 u32 base = KSEG1ADDR(EMMA2RH_PCI_CONFIG_BASE);
93 u32 backup_win0;
94 u32 data;
95
96 *val = 0xffffffffU;
97
98 if (check_args(bus, devfn, &bus_num) == PCIBIOS_DEVICE_NOT_FOUND)
99 return PCIBIOS_DEVICE_NOT_FOUND;
100
101 backup_win0 = emma2rh_in32(EMMA2RH_PCI_IWIN0_CTR);
102
103 if (set_pci_configuration_address(bus_num, devfn, where) < 0)
104 return PCIBIOS_DEVICE_NOT_FOUND;
105
106 data =
107 *(volatile u32 *)(base + (PCI_FUNC(devfn) << 8) +
108 (where & 0xfffffffc));
109
110 switch (size) {
111 case 1:
112 *val = (data >> ((where & 3) << 3)) & 0xffU;
113 break;
114 case 2:
115 *val = (data >> ((where & 2) << 3)) & 0xffffU;
116 break;
117 case 4:
118 *val = data;
119 break;
120 default:
121 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, backup_win0);
122 return PCIBIOS_FUNC_NOT_SUPPORTED;
123 }
124
125 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, backup_win0);
126
127 if (emma2rh_in32(EMMA2RH_PCI_INT) & RMABORT)
128 return PCIBIOS_DEVICE_NOT_FOUND;
129
130 return PCIBIOS_SUCCESSFUL;
131}
132
133static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
134 int size, u32 val)
135{
136 u32 bus_num;
137 u32 base = KSEG1ADDR(EMMA2RH_PCI_CONFIG_BASE);
138 u32 backup_win0;
139 u32 data;
140 int shift;
141
142 if (check_args(bus, devfn, &bus_num) == PCIBIOS_DEVICE_NOT_FOUND)
143 return PCIBIOS_DEVICE_NOT_FOUND;
144
145 backup_win0 = emma2rh_in32(EMMA2RH_PCI_IWIN0_CTR);
146
147 if (set_pci_configuration_address(bus_num, devfn, where) < 0)
148 return PCIBIOS_DEVICE_NOT_FOUND;
149
150 /* read modify write */
151 data =
152 *(volatile u32 *)(base + (PCI_FUNC(devfn) << 8) +
153 (where & 0xfffffffc));
154
155 switch (size) {
156 case 1:
157 shift = (where & 3) << 3;
158 data &= ~(0xffU << shift);
159 data |= ((val & 0xffU) << shift);
160 break;
161 case 2:
162 shift = (where & 2) << 3;
163 data &= ~(0xffffU << shift);
164 data |= ((val & 0xffffU) << shift);
165 break;
166 case 4:
167 data = val;
168 break;
169 default:
170 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, backup_win0);
171 return PCIBIOS_FUNC_NOT_SUPPORTED;
172 }
173 *(volatile u32 *)(base + (PCI_FUNC(devfn) << 8) +
174 (where & 0xfffffffc)) = data;
175
176 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, backup_win0);
177 if (emma2rh_in32(EMMA2RH_PCI_INT) & RMABORT)
178 return PCIBIOS_DEVICE_NOT_FOUND;
179
180 return PCIBIOS_SUCCESSFUL;
181}
182
183struct pci_ops emma2rh_pci_ops = {
184 .read = pci_config_read,
185 .write = pci_config_write,
186};
diff --git a/arch/mips/pci/ops-it8172.c b/arch/mips/pci/ops-it8172.c
index b7a8b9a6f9db..ba8328505a0a 100644
--- a/arch/mips/pci/ops-it8172.c
+++ b/arch/mips/pci/ops-it8172.c
@@ -50,30 +50,28 @@
50static struct resource pci_mem_resource_1; 50static struct resource pci_mem_resource_1;
51 51
52static struct resource pci_io_resource = { 52static struct resource pci_io_resource = {
53 "io pci IO space", 53 .start = 0x14018000,
54 0x14018000, 54 .end = 0x17FFFFFF,
55 0x17FFFFFF, 55 .name = "io pci IO space",
56 IORESOURCE_IO 56 .flags = IORESOURCE_IO
57}; 57};
58 58
59static struct resource pci_mem_resource_0 = { 59static struct resource pci_mem_resource_0 = {
60 "ext pci memory space 0/1", 60 .start = 0x10101000,
61 0x10101000, 61 .end = 0x13FFFFFF,
62 0x13FFFFFF, 62 .name = "ext pci memory space 0/1",
63 IORESOURCE_MEM, 63 .flags = IORESOURCE_MEM,
64 &pci_mem_resource_0, 64 .parent = &pci_mem_resource_0,
65 NULL, 65 .sibling = NULL,
66 &pci_mem_resource_1 66 .child = &pci_mem_resource_1
67}; 67};
68 68
69static struct resource pci_mem_resource_1 = { 69static struct resource pci_mem_resource_1 = {
70 "ext pci memory space 2/3", 70 .start = 0x1A000000,
71 0x1A000000, 71 .end = 0x1FBFFFFF,
72 0x1FBFFFFF, 72 .name = "ext pci memory space 2/3",
73 IORESOURCE_MEM, 73 .flags = IORESOURCE_MEM,
74 &pci_mem_resource_0, 74 .parent = &pci_mem_resource_0
75 NULL,
76 NULL
77}; 75};
78 76
79extern struct pci_ops it8172_pci_ops; 77extern struct pci_ops it8172_pci_ops;
diff --git a/arch/mips/pci/ops-sni.c b/arch/mips/pci/ops-sni.c
index 62bdd19c7f8e..2b0ccd6d9dcd 100644
--- a/arch/mips/pci/ops-sni.c
+++ b/arch/mips/pci/ops-sni.c
@@ -47,13 +47,13 @@ static int pcimt_read(struct pci_bus *bus, unsigned int devfn, int reg,
47 47
48 switch (size) { 48 switch (size) {
49 case 1: 49 case 1:
50 *val = *(volatile u8 *) (PCIMT_CONFIG_DATA + (reg & 3)); 50 *val = inb(PCIMT_CONFIG_DATA + (reg & 3));
51 break; 51 break;
52 case 2: 52 case 2:
53 *val = *(volatile u16 *) (PCIMT_CONFIG_DATA + (reg & 2)); 53 *val = inw(PCIMT_CONFIG_DATA + (reg & 2));
54 break; 54 break;
55 case 4: 55 case 4:
56 *val = *(volatile u32 *) PCIMT_CONFIG_DATA; 56 *val = inl(PCIMT_CONFIG_DATA);
57 break; 57 break;
58 } 58 }
59 59
@@ -70,13 +70,13 @@ static int pcimt_write(struct pci_bus *bus, unsigned int devfn, int reg,
70 70
71 switch (size) { 71 switch (size) {
72 case 1: 72 case 1:
73 *(volatile u8 *) (PCIMT_CONFIG_DATA + (reg & 3)) = val; 73 outb (val, PCIMT_CONFIG_DATA + (reg & 3));
74 break; 74 break;
75 case 2: 75 case 2:
76 *(volatile u16 *) (PCIMT_CONFIG_DATA + (reg & 2)) = val; 76 outw (val, PCIMT_CONFIG_DATA + (reg & 2));
77 break; 77 break;
78 case 4: 78 case 4:
79 *(volatile u32 *) PCIMT_CONFIG_DATA = val; 79 outl (val, PCIMT_CONFIG_DATA);
80 break; 80 break;
81 } 81 }
82 82
diff --git a/arch/mips/pci/ops-titan.c b/arch/mips/pci/ops-titan.c
index 233ec6f2054d..ebf8fc40e9b2 100644
--- a/arch/mips/pci/ops-titan.c
+++ b/arch/mips/pci/ops-titan.c
@@ -26,8 +26,19 @@
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28 28
29#include <asm/titan_dep.h> 29#include <asm/pci.h>
30#include <asm/io.h>
31#include <asm/rm9k-ocd.h>
30 32
33/*
34 * PCI specific defines
35 */
36#define TITAN_PCI_0_CONFIG_ADDRESS 0x780
37#define TITAN_PCI_0_CONFIG_DATA 0x784
38
39/*
40 * Titan PCI Config Read Byte
41 */
31static int titan_read_config(struct pci_bus *bus, unsigned int devfn, int reg, 42static int titan_read_config(struct pci_bus *bus, unsigned int devfn, int reg,
32 int size, u32 * val) 43 int size, u32 * val)
33{ 44{
@@ -43,8 +54,8 @@ static int titan_read_config(struct pci_bus *bus, unsigned int devfn, int reg,
43 54
44 55
45 /* start the configuration cycle */ 56 /* start the configuration cycle */
46 TITAN_WRITE(TITAN_PCI_0_CONFIG_ADDRESS, address); 57 ocd_writel(address, TITAN_PCI_0_CONFIG_ADDRESS);
47 tmp = TITAN_READ(TITAN_PCI_0_CONFIG_DATA) >> ((reg & 3) << 3); 58 tmp = ocd_readl(TITAN_PCI_0_CONFIG_DATA) >> ((reg & 3) << 3);
48 59
49 switch (size) { 60 switch (size) {
50 case 1: 61 case 1:
@@ -71,20 +82,20 @@ static int titan_write_config(struct pci_bus *bus, unsigned int devfn, int reg,
71 (reg & 0xfc) | 0x80000000; 82 (reg & 0xfc) | 0x80000000;
72 83
73 /* start the configuration cycle */ 84 /* start the configuration cycle */
74 TITAN_WRITE(TITAN_PCI_0_CONFIG_ADDRESS, address); 85 ocd_writel(address, TITAN_PCI_0_CONFIG_ADDRESS);
75 86
76 /* write the data */ 87 /* write the data */
77 switch (size) { 88 switch (size) {
78 case 1: 89 case 1:
79 TITAN_WRITE_8(TITAN_PCI_0_CONFIG_DATA + (~reg & 0x3), val); 90 ocd_writeb(val, TITAN_PCI_0_CONFIG_DATA + (~reg & 0x3));
80 break; 91 break;
81 92
82 case 2: 93 case 2:
83 TITAN_WRITE_16(TITAN_PCI_0_CONFIG_DATA + (~reg & 0x2), val); 94 ocd_writew(val, TITAN_PCI_0_CONFIG_DATA + (~reg & 0x2));
84 break; 95 break;
85 96
86 case 4: 97 case 4:
87 TITAN_WRITE(TITAN_PCI_0_CONFIG_DATA, val); 98 ocd_writel(val, TITAN_PCI_0_CONFIG_DATA);
88 break; 99 break;
89 } 100 }
90 101
diff --git a/arch/mips/pci/pci-ddb5074.c b/arch/mips/pci/pci-ddb5074.c
deleted file mode 100644
index 73f9ceeb2f55..000000000000
--- a/arch/mips/pci/pci-ddb5074.c
+++ /dev/null
@@ -1,79 +0,0 @@
1#include <linux/kernel.h>
2#include <linux/init.h>
3#include <linux/types.h>
4#include <linux/pci.h>
5
6#include <asm/debug.h>
7
8#include <asm/ddb5xxx/ddb5xxx.h>
9
10static struct resource extpci_io_resource = {
11 "pci IO space",
12 0x1000, /* leave some room for ISA bus */
13 DDB_PCI_IO_SIZE - 1,
14 IORESOURCE_IO
15};
16
17static struct resource extpci_mem_resource = {
18 "pci memory space",
19 DDB_PCI_MEM_BASE + 0x00100000, /* leave 1 MB for RTC */
20 DDB_PCI_MEM_BASE + DDB_PCI_MEM_SIZE - 1,
21 IORESOURCE_MEM
22};
23
24extern struct pci_ops ddb5476_ext_pci_ops;
25
26struct pci_controller ddb5476_controller = {
27 .pci_ops = &ddb5476_ext_pci_ops,
28 .io_resource = &extpci_io_resource,
29 .mem_resource = &extpci_mem_resource,
30};
31
32#define PCI_EXT_INTA 8
33#define PCI_EXT_INTB 9
34#define PCI_EXT_INTC 10
35#define PCI_EXT_INTD 11
36#define PCI_EXT_INTE 12
37
38#define MAX_SLOT_NUM 14
39
40static unsigned char irq_map[MAX_SLOT_NUM] = {
41 [ 0] = nile4_to_irq(PCI_EXT_INTE),
42 [ 1] = nile4_to_irq(PCI_EXT_INTA),
43 [ 2] = nile4_to_irq(PCI_EXT_INTA),
44 [ 3] = nile4_to_irq(PCI_EXT_INTB),
45 [ 4] = nile4_to_irq(PCI_EXT_INTC),
46 [ 5] = nile4_to_irq(NILE4_INT_UART),
47 [10] = nile4_to_irq(PCI_EXT_INTE),
48 [13] = nile4_to_irq(PCI_EXT_INTE),
49};
50
51int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
52{
53 return irq_map[slot];
54}
55
56/* Do platform specific device initialization at pci_enable_device() time */
57int pcibios_plat_dev_init(struct pci_dev *dev)
58{
59 return 0;
60}
61
62void __init ddb_pci_reset_bus(void)
63{
64 u32 temp;
65
66 /*
67 * I am not sure about the "official" procedure, the following
68 * steps work as far as I know:
69 * We first set PCI cold reset bit (bit 31) in PCICTRL-H.
70 * Then we clear the PCI warm reset bit (bit 30) to 0 in PCICTRL-H.
71 * The same is true for both PCI channels.
72 */
73 temp = ddb_in32(DDB_PCICTRL + 4);
74 temp |= 0x80000000;
75 ddb_out32(DDB_PCICTRL + 4, temp);
76 temp &= ~0xc0000000;
77 ddb_out32(DDB_PCICTRL + 4, temp);
78
79}
diff --git a/arch/mips/pci/pci-ddb5476.c b/arch/mips/pci/pci-ddb5476.c
deleted file mode 100644
index 90dd49509800..000000000000
--- a/arch/mips/pci/pci-ddb5476.c
+++ /dev/null
@@ -1,93 +0,0 @@
1#include <linux/kernel.h>
2#include <linux/init.h>
3#include <linux/types.h>
4#include <linux/pci.h>
5
6#include <asm/debug.h>
7
8#include <asm/ddb5xxx/ddb5xxx.h>
9
10static struct resource extpci_io_resource = {
11 "pci IO space",
12 0x1000, /* leave some room for ISA bus */
13 DDB_PCI_IO_SIZE - 1,
14 IORESOURCE_IO
15};
16
17static struct resource extpci_mem_resource = {
18 "pci memory space",
19 DDB_PCI_MEM_BASE + 0x00100000, /* leave 1 MB for RTC */
20 DDB_PCI_MEM_BASE + DDB_PCI_MEM_SIZE - 1,
21 IORESOURCE_MEM
22};
23
24extern struct pci_ops ddb5476_ext_pci_ops;
25
26struct pci_controller ddb5476_controller = {
27 .pci_ops = &ddb5476_ext_pci_ops,
28 .io_resource = &extpci_io_resource,
29 .mem_resource = &extpci_mem_resource
30};
31
32
33/*
34 * we fix up irqs based on the slot number.
35 * The first entry is at AD:11.
36 *
37 * This does not work for devices on sub-buses yet.
38 */
39
40/*
41 * temporary
42 */
43
44#define PCI_EXT_INTA 8
45#define PCI_EXT_INTB 9
46#define PCI_EXT_INTC 10
47#define PCI_EXT_INTD 11
48#define PCI_EXT_INTE 12
49
50/*
51 * based on ddb5477 manual page 11
52 */
53#define MAX_SLOT_NUM 21
54static unsigned char irq_map[MAX_SLOT_NUM] = {
55 [ 2] = 9, /* AD:13 USB */
56 [ 3] = 10, /* AD:14 PMU */
57 [ 5] = 0, /* AD:16 P2P bridge */
58 [ 6] = nile4_to_irq(PCI_EXT_INTB), /* AD:17 */
59 [ 7] = nile4_to_irq(PCI_EXT_INTC), /* AD:18 */
60 [ 8] = nile4_to_irq(PCI_EXT_INTD), /* AD:19 */
61 [ 9] = nile4_to_irq(PCI_EXT_INTA), /* AD:20 */
62 [13] = 14, /* AD:24 HD controller, M5229 */
63};
64
65int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
66{
67 return irq_map[slot];
68}
69
70/* Do platform specific device initialization at pci_enable_device() time */
71int pcibios_plat_dev_init(struct pci_dev *dev)
72{
73 return 0;
74}
75
76void __init ddb_pci_reset_bus(void)
77{
78 u32 temp;
79
80 /*
81 * I am not sure about the "official" procedure, the following
82 * steps work as far as I know:
83 * We first set PCI cold reset bit (bit 31) in PCICTRL-H.
84 * Then we clear the PCI warm reset bit (bit 30) to 0 in PCICTRL-H.
85 * The same is true for both PCI channels.
86 */
87 temp = ddb_in32(DDB_PCICTRL + 4);
88 temp |= 0x80000000;
89 ddb_out32(DDB_PCICTRL + 4, temp);
90 temp &= ~0xc0000000;
91 ddb_out32(DDB_PCICTRL + 4, temp);
92
93}
diff --git a/arch/mips/pci/pci-ddb5477.c b/arch/mips/pci/pci-ddb5477.c
index 826d653184e5..d071bc375b11 100644
--- a/arch/mips/pci/pci-ddb5477.c
+++ b/arch/mips/pci/pci-ddb5477.c
@@ -22,31 +22,31 @@
22#include <asm/ddb5xxx/ddb5xxx.h> 22#include <asm/ddb5xxx/ddb5xxx.h>
23 23
24static struct resource extpci_io_resource = { 24static struct resource extpci_io_resource = {
25 "ext pci IO space", 25 .start = DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + 0x4000,
26 DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + 0x4000, 26 .end = DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI0_IO_SIZE - 1,
27 DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI0_IO_SIZE - 1, 27 .name = "ext pci IO space",
28 IORESOURCE_IO 28 .flags = IORESOURCE_IO
29}; 29};
30 30
31static struct resource extpci_mem_resource = { 31static struct resource extpci_mem_resource = {
32 "ext pci memory space", 32 .start = DDB_PCI0_MEM_BASE + 0x100000,
33 DDB_PCI0_MEM_BASE + 0x100000, 33 .end = DDB_PCI0_MEM_BASE + DDB_PCI0_MEM_SIZE - 1,
34 DDB_PCI0_MEM_BASE + DDB_PCI0_MEM_SIZE - 1, 34 .name = "ext pci memory space",
35 IORESOURCE_MEM 35 .flags = IORESOURCE_MEM
36}; 36};
37 37
38static struct resource iopci_io_resource = { 38static struct resource iopci_io_resource = {
39 "io pci IO space", 39 .start = DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE,
40 DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE, 40 .end = DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI1_IO_SIZE - 1,
41 DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI1_IO_SIZE - 1, 41 .name = "io pci IO space",
42 IORESOURCE_IO 42 .flags = IORESOURCE_IO
43}; 43};
44 44
45static struct resource iopci_mem_resource = { 45static struct resource iopci_mem_resource = {
46 "ext pci memory space", 46 .start = DDB_PCI1_MEM_BASE,
47 DDB_PCI1_MEM_BASE, 47 .end = DDB_PCI1_MEM_BASE + DDB_PCI1_MEM_SIZE - 1,
48 DDB_PCI1_MEM_BASE + DDB_PCI1_MEM_SIZE - 1, 48 .name = "ext pci memory space",
49 IORESOURCE_MEM 49 .flags = IORESOURCE_MEM
50}; 50};
51 51
52extern struct pci_ops ddb5477_ext_pci_ops; 52extern struct pci_ops ddb5477_ext_pci_ops;
diff --git a/arch/mips/pci/pci-emma2rh.c b/arch/mips/pci/pci-emma2rh.c
new file mode 100644
index 000000000000..0f8b230057d3
--- /dev/null
+++ b/arch/mips/pci/pci-emma2rh.c
@@ -0,0 +1,90 @@
1/*
2 * arch/mips/pci/pci-emma2rh.c
3 * This file defines the PCI configration.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006
6 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
8 *
9 * Copyright 2001 MontaVista Software Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/config.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <linux/types.h>
30#include <linux/pci.h>
31
32#include <asm/bootinfo.h>
33#include <asm/debug.h>
34
35#include <asm/emma2rh/emma2rh.h>
36
37static struct resource pci_io_resource = {
38 .name = "pci IO space",
39 .start = EMMA2RH_PCI_IO_BASE,
40 .end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1,
41 .flags = IORESOURCE_IO,
42};
43
44static struct resource pci_mem_resource = {
45 .name = "pci memory space",
46 .start = EMMA2RH_PCI_MEM_BASE,
47 .end = EMMA2RH_PCI_MEM_BASE + EMMA2RH_PCI_MEM_SIZE - 1,
48 .flags = IORESOURCE_MEM,
49};
50
51extern struct pci_ops emma2rh_pci_ops;
52
53static struct pci_controller emma2rh_pci_controller = {
54 .pci_ops = &emma2rh_pci_ops,
55 .mem_resource = &pci_mem_resource,
56 .io_resource = &pci_io_resource,
57 .mem_offset = -0x04000000,
58 .io_offset = 0,
59};
60
61static void __init emma2rh_pci_init(void)
62{
63 /* setup PCI interface */
64 emma2rh_out32(EMMA2RH_PCI_ARBIT_CTR, 0x70f);
65
66 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, 0x80000a18);
67 emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE + PCI_COMMAND,
68 PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_CAP_LIST |
69 PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
70 emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE + PCI_BASE_ADDRESS_0, 0x10000000);
71 emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE + PCI_BASE_ADDRESS_1, 0x00000000);
72
73 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, 0x12000000 | 0x218);
74 emma2rh_out32(EMMA2RH_PCI_IWIN1_CTR, 0x18000000 | 0x600);
75 emma2rh_out32(EMMA2RH_PCI_INIT_ESWP, 0x00000200);
76
77 emma2rh_out32(EMMA2RH_PCI_TWIN_CTR, 0x00009200);
78 emma2rh_out32(EMMA2RH_PCI_TWIN_BADR, 0x00000000);
79 emma2rh_out32(EMMA2RH_PCI_TWIN0_DADR, 0x00000000);
80 emma2rh_out32(EMMA2RH_PCI_TWIN1_DADR, 0x00000000);
81}
82
83static int __init emma2rh_pci_setup(void)
84{
85 emma2rh_pci_init();
86 register_pci_controller(&emma2rh_pci_controller);
87 return 0;
88}
89
90arch_initcall(emma2rh_pci_setup);
diff --git a/arch/mips/pci/pci-excite.c b/arch/mips/pci/pci-excite.c
new file mode 100644
index 000000000000..3c86c77cb74f
--- /dev/null
+++ b/arch/mips/pci/pci-excite.c
@@ -0,0 +1,149 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 * Based on the PMC-Sierra Yosemite board support by Ralf Baechle.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/pci.h>
24#include <linux/bitops.h>
25#include <asm/rm9k-ocd.h>
26#include <excite.h>
27
28
29extern struct pci_ops titan_pci_ops;
30
31
32static struct resource
33 mem_resource = {
34 .name = "PCI memory",
35 .start = EXCITE_PHYS_PCI_MEM,
36 .end = EXCITE_PHYS_PCI_MEM + EXCITE_SIZE_PCI_MEM - 1,
37 .flags = IORESOURCE_MEM
38 },
39 io_resource = {
40 .name = "PCI I/O",
41 .start = EXCITE_PHYS_PCI_IO,
42 .end = EXCITE_PHYS_PCI_IO + EXCITE_SIZE_PCI_IO - 1,
43 .flags = IORESOURCE_IO
44 };
45
46
47static struct pci_controller bx_controller = {
48 .pci_ops = &titan_pci_ops,
49 .mem_resource = &mem_resource,
50 .mem_offset = 0x00000000UL,
51 .io_resource = &io_resource,
52 .io_offset = 0x00000000UL
53};
54
55
56static char
57 iopage_failed[] __initdata = "Cannot allocate PCI I/O page",
58 modebits_no_pci[] __initdata = "PCI is not configured in mode bits";
59
60#define RM9000x2_OCD_HTSC 0x0604
61#define RM9000x2_OCD_HTBHL 0x060c
62#define RM9000x2_OCD_PCIHRST 0x078c
63
64#define RM9K_OCD_MODEBIT1 0x00d4 /* (MODEBIT1) Mode Bit 1 */
65#define RM9K_OCD_CPHDCR 0x00f4 /* CPU-PCI/HT Data Control. */
66
67#define PCISC_FB2B 0x00000200
68#define PCISC_MWICG 0x00000010
69#define PCISC_EMC 0x00000004
70#define PCISC_ERMA 0x00000002
71
72
73
74static int __init basler_excite_pci_setup(void)
75{
76 const unsigned int fullbars = memsize / (256 << 20);
77 unsigned int i;
78
79 /* Check modebits to see if PCI is really enabled. */
80 if (!((ocd_readl(RM9K_OCD_MODEBIT1) >> (47-32)) & 0x1))
81 panic(modebits_no_pci);
82
83 if (NULL == request_mem_region(EXCITE_PHYS_PCI_IO, EXCITE_SIZE_PCI_IO,
84 "Memory-mapped PCI I/O page"))
85 panic(iopage_failed);
86
87 /* Enable PCI 0 as master for config cycles */
88 ocd_writel(PCISC_EMC | PCISC_ERMA, RM9000x2_OCD_HTSC);
89
90
91 /* Set up latency timer */
92 ocd_writel(0x8008, RM9000x2_OCD_HTBHL);
93
94 /* Setup host IO and Memory space */
95 ocd_writel((EXCITE_PHYS_PCI_IO >> 4) | 1, LKB7);
96 ocd_writel(((EXCITE_SIZE_PCI_IO >> 4) & 0x7fffff00) - 0x100, LKM7);
97 ocd_writel((EXCITE_PHYS_PCI_MEM >> 4) | 1, LKB8);
98 ocd_writel(((EXCITE_SIZE_PCI_MEM >> 4) & 0x7fffff00) - 0x100, LKM8);
99
100 /* Set up PCI BARs to map all installed memory */
101 for (i = 0; i < 6; i++) {
102 const unsigned int bar = 0x610 + i * 4;
103
104 if (i < fullbars) {
105 ocd_writel(0x10000000 * i, bar);
106 ocd_writel(0x01000000 * i, bar + 0x140);
107 ocd_writel(0x0ffff029, bar + 0x100);
108 continue;
109 }
110
111 if (i == fullbars) {
112 int o;
113 u32 mask;
114
115 const unsigned long rem = memsize - i * 0x10000000;
116 if (!rem) {
117 ocd_writel(0x00000000, bar + 0x100);
118 continue;
119 }
120
121 o = ffs(rem) - 1;
122 if (rem & ~(0x1 << o))
123 o++;
124 mask = ((0x1 << o) & 0x0ffff000) - 0x1000;
125 ocd_writel(0x10000000 * i, bar);
126 ocd_writel(0x01000000 * i, bar + 0x140);
127 ocd_writel(0x00000029 | mask, bar + 0x100);
128 continue;
129 }
130
131 ocd_writel(0x00000000, bar + 0x100);
132 }
133
134 /* Finally, enable the PCI interupt */
135#if USB_IRQ > 7
136 set_c0_intcontrol(1 << USB_IRQ);
137#else
138 set_c0_status(1 << (USB_IRQ + 8));
139#endif
140
141 ioport_resource.start = EXCITE_PHYS_PCI_IO;
142 ioport_resource.end = EXCITE_PHYS_PCI_IO + EXCITE_SIZE_PCI_IO - 1;
143 set_io_port_base((unsigned long) ioremap_nocache(EXCITE_PHYS_PCI_IO, EXCITE_SIZE_PCI_IO));
144 register_pci_controller(&bx_controller);
145 return 0;
146}
147
148
149arch_initcall(basler_excite_pci_setup);
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
index 6002d2a6a262..80eb9af9ecdf 100644
--- a/arch/mips/pci/pci-ip27.c
+++ b/arch/mips/pci/pci-ip27.c
@@ -40,297 +40,7 @@ static struct bridge_controller bridges[MAX_PCI_BUSSES];
40struct bridge_controller *irq_to_bridge[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS]; 40struct bridge_controller *irq_to_bridge[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS];
41int irq_to_slot[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS]; 41int irq_to_slot[MAX_PCI_BUSSES * MAX_DEVICES_PER_PCIBUS];
42 42
43/* 43extern struct pci_ops bridge_pci_ops;
44 * The Bridge ASIC supports both type 0 and type 1 access. Type 1 is
45 * not really documented, so right now I can't write code which uses it.
46 * Therefore we use type 0 accesses for now even though they won't work
47 * correcly for PCI-to-PCI bridges.
48 *
49 * The function is complicated by the ultimate brokeness of the IOC3 chip
50 * which is used in SGI systems. The IOC3 can only handle 32-bit PCI
51 * accesses and does only decode parts of it's address space.
52 */
53
54static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
55 int where, int size, u32 * value)
56{
57 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
58 bridge_t *bridge = bc->base;
59 int slot = PCI_SLOT(devfn);
60 int fn = PCI_FUNC(devfn);
61 volatile void *addr;
62 u32 cf, shift, mask;
63 int res;
64
65 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
66 if (get_dbe(cf, (u32 *) addr))
67 return PCIBIOS_DEVICE_NOT_FOUND;
68
69 /*
70 * IOC3 is fucked fucked beyond believe ... Don't even give the
71 * generic PCI code a chance to look at it for real ...
72 */
73 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
74 goto oh_my_gawd;
75
76 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];
77
78 if (size == 1)
79 res = get_dbe(*value, (u8 *) addr);
80 else if (size == 2)
81 res = get_dbe(*value, (u16 *) addr);
82 else
83 res = get_dbe(*value, (u32 *) addr);
84
85 return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
86
87oh_my_gawd:
88
89 /*
90 * IOC3 is fucked fucked beyond believe ... Don't even give the
91 * generic PCI code a chance to look at the wrong register.
92 */
93 if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
94 *value = 0;
95 return PCIBIOS_SUCCESSFUL;
96 }
97
98 /*
99 * IOC3 is fucked fucked beyond believe ... Don't try to access
100 * anything but 32-bit words ...
101 */
102 addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
103
104 if (get_dbe(cf, (u32 *) addr))
105 return PCIBIOS_DEVICE_NOT_FOUND;
106
107 shift = ((where & 3) << 3);
108 mask = (0xffffffffU >> ((4 - size) << 3));
109 *value = (cf >> shift) & mask;
110
111 return PCIBIOS_SUCCESSFUL;
112}
113
114static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
115 int where, int size, u32 * value)
116{
117 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
118 bridge_t *bridge = bc->base;
119 int busno = bus->number;
120 int slot = PCI_SLOT(devfn);
121 int fn = PCI_FUNC(devfn);
122 volatile void *addr;
123 u32 cf, shift, mask;
124 int res;
125
126 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
127 addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
128 if (get_dbe(cf, (u32 *) addr))
129 return PCIBIOS_DEVICE_NOT_FOUND;
130
131 /*
132 * IOC3 is fucked fucked beyond believe ... Don't even give the
133 * generic PCI code a chance to look at it for real ...
134 */
135 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
136 goto oh_my_gawd;
137
138 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
139 addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
140
141 if (size == 1)
142 res = get_dbe(*value, (u8 *) addr);
143 else if (size == 2)
144 res = get_dbe(*value, (u16 *) addr);
145 else
146 res = get_dbe(*value, (u32 *) addr);
147
148 return res ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
149
150oh_my_gawd:
151
152 /*
153 * IOC3 is fucked fucked beyond believe ... Don't even give the
154 * generic PCI code a chance to look at the wrong register.
155 */
156 if ((where >= 0x14 && where < 0x40) || (where >= 0x48)) {
157 *value = 0;
158 return PCIBIOS_SUCCESSFUL;
159 }
160
161 /*
162 * IOC3 is fucked fucked beyond believe ... Don't try to access
163 * anything but 32-bit words ...
164 */
165 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
166 addr = &bridge->b_type1_cfg.c[(fn << 8) | where];
167
168 if (get_dbe(cf, (u32 *) addr))
169 return PCIBIOS_DEVICE_NOT_FOUND;
170
171 shift = ((where & 3) << 3);
172 mask = (0xffffffffU >> ((4 - size) << 3));
173 *value = (cf >> shift) & mask;
174
175 return PCIBIOS_SUCCESSFUL;
176}
177
178static int pci_read_config(struct pci_bus *bus, unsigned int devfn,
179 int where, int size, u32 * value)
180{
181 if (bus->number > 0)
182 return pci_conf1_read_config(bus, devfn, where, size, value);
183
184 return pci_conf0_read_config(bus, devfn, where, size, value);
185}
186
187static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
188 int where, int size, u32 value)
189{
190 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
191 bridge_t *bridge = bc->base;
192 int slot = PCI_SLOT(devfn);
193 int fn = PCI_FUNC(devfn);
194 volatile void *addr;
195 u32 cf, shift, mask, smask;
196 int res;
197
198 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
199 if (get_dbe(cf, (u32 *) addr))
200 return PCIBIOS_DEVICE_NOT_FOUND;
201
202 /*
203 * IOC3 is fucked fucked beyond believe ... Don't even give the
204 * generic PCI code a chance to look at it for real ...
205 */
206 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
207 goto oh_my_gawd;
208
209 addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[where ^ (4 - size)];
210
211 if (size == 1) {
212 res = put_dbe(value, (u8 *) addr);
213 } else if (size == 2) {
214 res = put_dbe(value, (u16 *) addr);
215 } else {
216 res = put_dbe(value, (u32 *) addr);
217 }
218
219 if (res)
220 return PCIBIOS_DEVICE_NOT_FOUND;
221
222 return PCIBIOS_SUCCESSFUL;
223
224oh_my_gawd:
225
226 /*
227 * IOC3 is fucked fucked beyond believe ... Don't even give the
228 * generic PCI code a chance to touch the wrong register.
229 */
230 if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
231 return PCIBIOS_SUCCESSFUL;
232
233 /*
234 * IOC3 is fucked fucked beyond believe ... Don't try to access
235 * anything but 32-bit words ...
236 */
237 addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
238
239 if (get_dbe(cf, (u32 *) addr))
240 return PCIBIOS_DEVICE_NOT_FOUND;
241
242 shift = ((where & 3) << 3);
243 mask = (0xffffffffU >> ((4 - size) << 3));
244 smask = mask << shift;
245
246 cf = (cf & ~smask) | ((value & mask) << shift);
247 if (put_dbe(cf, (u32 *) addr))
248 return PCIBIOS_DEVICE_NOT_FOUND;
249
250 return PCIBIOS_SUCCESSFUL;
251}
252
253static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
254 int where, int size, u32 value)
255{
256 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
257 bridge_t *bridge = bc->base;
258 int slot = PCI_SLOT(devfn);
259 int fn = PCI_FUNC(devfn);
260 int busno = bus->number;
261 volatile void *addr;
262 u32 cf, shift, mask, smask;
263 int res;
264
265 bridge->b_pci_cfg = (busno << 16) | (slot << 11);
266 addr = &bridge->b_type1_cfg.c[(fn << 8) | PCI_VENDOR_ID];
267 if (get_dbe(cf, (u32 *) addr))
268 return PCIBIOS_DEVICE_NOT_FOUND;
269
270 /*
271 * IOC3 is fucked fucked beyond believe ... Don't even give the
272 * generic PCI code a chance to look at it for real ...
273 */
274 if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16)))
275 goto oh_my_gawd;
276
277 addr = &bridge->b_type1_cfg.c[(fn << 8) | (where ^ (4 - size))];
278
279 if (size == 1) {
280 res = put_dbe(value, (u8 *) addr);
281 } else if (size == 2) {
282 res = put_dbe(value, (u16 *) addr);
283 } else {
284 res = put_dbe(value, (u32 *) addr);
285 }
286
287 if (res)
288 return PCIBIOS_DEVICE_NOT_FOUND;
289
290 return PCIBIOS_SUCCESSFUL;
291
292oh_my_gawd:
293
294 /*
295 * IOC3 is fucked fucked beyond believe ... Don't even give the
296 * generic PCI code a chance to touch the wrong register.
297 */
298 if ((where >= 0x14 && where < 0x40) || (where >= 0x48))
299 return PCIBIOS_SUCCESSFUL;
300
301 /*
302 * IOC3 is fucked fucked beyond believe ... Don't try to access
303 * anything but 32-bit words ...
304 */
305 addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
306
307 if (get_dbe(cf, (u32 *) addr))
308 return PCIBIOS_DEVICE_NOT_FOUND;
309
310 shift = ((where & 3) << 3);
311 mask = (0xffffffffU >> ((4 - size) << 3));
312 smask = mask << shift;
313
314 cf = (cf & ~smask) | ((value & mask) << shift);
315 if (put_dbe(cf, (u32 *) addr))
316 return PCIBIOS_DEVICE_NOT_FOUND;
317
318 return PCIBIOS_SUCCESSFUL;
319}
320
321static int pci_write_config(struct pci_bus *bus, unsigned int devfn,
322 int where, int size, u32 value)
323{
324 if (bus->number > 0)
325 return pci_conf1_write_config(bus, devfn, where, size, value);
326
327 return pci_conf0_write_config(bus, devfn, where, size, value);
328}
329
330static struct pci_ops bridge_pci_ops = {
331 .read = pci_read_config,
332 .write = pci_write_config,
333};
334 44
335int __init bridge_probe(nasid_t nasid, int widget_id, int masterwid) 45int __init bridge_probe(nasid_t nasid, int widget_id, int masterwid)
336{ 46{
@@ -370,8 +80,7 @@ int __init bridge_probe(nasid_t nasid, int widget_id, int masterwid)
370 bc->widget_id = widget_id; 80 bc->widget_id = widget_id;
371 bc->nasid = nasid; 81 bc->nasid = nasid;
372 82
373 bc->baddr = (u64)masterwid << 60; 83 bc->baddr = (u64)masterwid << 60 | PCI64_ATTR_BAR;
374 bc->baddr |= (1UL << 56); /* Barrier set */
375 84
376 /* 85 /*
377 * point to this bridge 86 * point to this bridge
diff --git a/arch/mips/pci/pci-jmr3927.c b/arch/mips/pci/pci-jmr3927.c
index f02ef6e36b02..cb84f4e8ccae 100644
--- a/arch/mips/pci/pci-jmr3927.c
+++ b/arch/mips/pci/pci-jmr3927.c
@@ -35,17 +35,17 @@
35#include <asm/debug.h> 35#include <asm/debug.h>
36 36
37struct resource pci_io_resource = { 37struct resource pci_io_resource = {
38 "IO MEM", 38 .name = "IO MEM",
39 0x1000, /* reserve regacy I/O space */ 39 .start = 0x1000, /* reserve regacy I/O space */
40 0x1000 + JMR3927_PCIIO_SIZE - 1, 40 .end = 0x1000 + JMR3927_PCIIO_SIZE - 1,
41 IORESOURCE_IO 41 .flags = IORESOURCE_IO
42}; 42};
43 43
44struct resource pci_mem_resource = { 44struct resource pci_mem_resource = {
45 "PCI MEM", 45 .name = "PCI MEM",
46 JMR3927_PCIMEM, 46 .start = JMR3927_PCIMEM,
47 JMR3927_PCIMEM + JMR3927_PCIMEM_SIZE - 1, 47 .end = JMR3927_PCIMEM + JMR3927_PCIMEM_SIZE - 1,
48 IORESOURCE_MEM 48 .flags = IORESOURCE_MEM
49}; 49};
50 50
51extern struct pci_ops jmr3927_pci_ops; 51extern struct pci_ops jmr3927_pci_ops;
diff --git a/arch/mips/pci/pci-ocelot.c b/arch/mips/pci/pci-ocelot.c
index 3da8a4ee6baa..2b9495dce6ba 100644
--- a/arch/mips/pci/pci-ocelot.c
+++ b/arch/mips/pci/pci-ocelot.c
@@ -71,13 +71,13 @@ static inline void pci0WriteConfigReg(unsigned int offset, unsigned int data)
71} 71}
72 72
73static struct resource ocelot_mem_resource = { 73static struct resource ocelot_mem_resource = {
74 iomem_resource.start = GT_PCI_MEM_BASE; 74 start = GT_PCI_MEM_BASE;
75 iomem_resource.end = GT_PCI_MEM_BASE + GT_PCI_MEM_BASE - 1; 75 end = GT_PCI_MEM_BASE + GT_PCI_MEM_BASE - 1;
76}; 76};
77 77
78static struct resource ocelot_io_resource = { 78static struct resource ocelot_io_resource = {
79 ioport_resource.start = GT_PCI_IO_BASE; 79 start = GT_PCI_IO_BASE;
80 ioport_resource.end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1; 80 end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1;
81}; 81};
82 82
83static struct pci_controller ocelot_pci_controller = { 83static struct pci_controller ocelot_pci_controller = {
diff --git a/arch/mips/pci/pci-yosemite.c b/arch/mips/pci/pci-yosemite.c
index dac9ed4b0ccf..0357946f30e6 100644
--- a/arch/mips/pci/pci-yosemite.c
+++ b/arch/mips/pci/pci-yosemite.c
@@ -14,7 +14,10 @@
14extern struct pci_ops titan_pci_ops; 14extern struct pci_ops titan_pci_ops;
15 15
16static struct resource py_mem_resource = { 16static struct resource py_mem_resource = {
17 "Titan PCI MEM", 0xe0000000UL, 0xe3ffffffUL, IORESOURCE_MEM 17 .start = 0xe0000000UL,
18 .end = 0xe3ffffffUL,
19 .name = "Titan PCI MEM",
20 .flags = IORESOURCE_MEM
18}; 21};
19 22
20/* 23/*
@@ -26,7 +29,10 @@ static struct resource py_mem_resource = {
26#define TITAN_IO_BASE 0xe8000000UL 29#define TITAN_IO_BASE 0xe8000000UL
27 30
28static struct resource py_io_resource = { 31static struct resource py_io_resource = {
29 "Titan IO MEM", 0x00001000UL, TITAN_IO_SIZE - 1, IORESOURCE_IO, 32 .start = 0x00001000UL,
33 .end = TITAN_IO_SIZE - 1,
34 .name = "Titan IO MEM",
35 .flags = IORESOURCE_IO,
30}; 36};
31 37
32static struct pci_controller py_controller = { 38static struct pci_controller py_controller = {
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 21402ffd7c98..4dfce154d4af 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -76,11 +76,6 @@ pcibios_align_resource(void *data, struct resource *res,
76 res->start = start; 76 res->start = start;
77} 77}
78 78
79struct pci_controller * __init alloc_pci_controller(void)
80{
81 return alloc_bootmem(sizeof(struct pci_controller));
82}
83
84void __init register_pci_controller(struct pci_controller *hose) 79void __init register_pci_controller(struct pci_controller *hose)
85{ 80{
86 *hose_tail = hose; 81 *hose_tail = hose;
diff --git a/arch/mips/philips/pnx8550/common/pci.c b/arch/mips/philips/pnx8550/common/pci.c
index baa6905f649f..eee4f3dfc410 100644
--- a/arch/mips/philips/pnx8550/common/pci.c
+++ b/arch/mips/philips/pnx8550/common/pci.c
@@ -27,17 +27,17 @@
27#include <nand.h> 27#include <nand.h>
28 28
29static struct resource pci_io_resource = { 29static struct resource pci_io_resource = {
30 "pci IO space", 30 .start = PNX8550_PCIIO + 0x1000, /* reserve regacy I/O space */
31 (u32)(PNX8550_PCIIO + 0x1000), /* reserve regacy I/O space */ 31 .end = PNX8550_PCIIO + PNX8550_PCIIO_SIZE,
32 (u32)(PNX8550_PCIIO + PNX8550_PCIIO_SIZE), 32 .name = "pci IO space",
33 IORESOURCE_IO 33 .flags = IORESOURCE_IO
34}; 34};
35 35
36static struct resource pci_mem_resource = { 36static struct resource pci_mem_resource = {
37 "pci memory space", 37 .start = PNX8550_PCIMEM,
38 (u32)(PNX8550_PCIMEM), 38 .end = PNX8550_PCIMEM + PNX8550_PCIMEM_SIZE - 1,
39 (u32)(PNX8550_PCIMEM + PNX8550_PCIMEM_SIZE - 1), 39 .name = "pci memory space",
40 IORESOURCE_MEM 40 .flags = IORESOURCE_MEM
41}; 41};
42 42
43extern struct pci_ops pnx8550_pci_ops; 43extern struct pci_ops pnx8550_pci_ops;
diff --git a/arch/mips/philips/pnx8550/common/setup.c b/arch/mips/philips/pnx8550/common/setup.c
index 0d8a77619391..0e791f4f6ea3 100644
--- a/arch/mips/philips/pnx8550/common/setup.c
+++ b/arch/mips/philips/pnx8550/common/setup.c
@@ -58,10 +58,27 @@ extern void prom_printf(char *fmt, ...);
58extern char *prom_getcmdline(void); 58extern char *prom_getcmdline(void);
59 59
60struct resource standard_io_resources[] = { 60struct resource standard_io_resources[] = {
61 {"dma1", 0x00, 0x1f, IORESOURCE_BUSY}, 61 {
62 {"timer", 0x40, 0x5f, IORESOURCE_BUSY}, 62 .start = .0x00,
63 {"dma page reg", 0x80, 0x8f, IORESOURCE_BUSY}, 63 .end = 0x1f,
64 {"dma2", 0xc0, 0xdf, IORESOURCE_BUSY}, 64 .name = "dma1",
65 .flags = IORESOURCE_BUSY
66 }, {
67 .start = 0x40,
68 .end = 0x5f,
69 .name = "timer",
70 .flags = IORESOURCE_BUSY
71 }, {
72 .start = 0x80,
73 .end = 0x8f,
74 .name = "dma page reg",
75 .flags = IORESOURCE_BUSY
76 }, {
77 .start = 0xc0,
78 .end = 0xdf,
79 .name = "dma2",
80 .flags = IORESOURCE_BUSY
81 },
65}; 82};
66 83
67#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource)) 84#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
@@ -82,7 +99,7 @@ unsigned long get_system_mem_size(void)
82 99
83int pnx8550_console_port = -1; 100int pnx8550_console_port = -1;
84 101
85void __init plat_setup(void) 102void __init plat_mem_setup(void)
86{ 103{
87 int i; 104 int i;
88 char* argptr; 105 char* argptr;
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c
index 3f724d661bdb..aa0d6ff3c6ec 100644
--- a/arch/mips/pmc-sierra/yosemite/setup.c
+++ b/arch/mips/pmc-sierra/yosemite/setup.c
@@ -218,7 +218,7 @@ static void __init py_late_time_init(void)
218 py_rtc_setup(); 218 py_rtc_setup();
219} 219}
220 220
221void __init plat_setup(void) 221void __init plat_mem_setup(void)
222{ 222{
223 board_time_init = yosemite_time_init; 223 board_time_init = yosemite_time_init;
224 late_time_init = py_late_time_init; 224 late_time_init = py_late_time_init;
diff --git a/arch/mips/qemu/Makefile b/arch/mips/qemu/Makefile
index 730f459f3e99..078cd3029c9f 100644
--- a/arch/mips/qemu/Makefile
+++ b/arch/mips/qemu/Makefile
@@ -2,6 +2,6 @@
2# Makefile for Qemu specific kernel interface routines under Linux. 2# Makefile for Qemu specific kernel interface routines under Linux.
3# 3#
4 4
5obj-y = q-firmware.o q-irq.o q-mem.o q-setup.o 5obj-y = q-firmware.o q-irq.o q-mem.o q-setup.o q-reset.o
6 6
7obj-$(CONFIG_SMP) += q-smp.o 7obj-$(CONFIG_SMP) += q-smp.o
diff --git a/arch/mips/qemu/q-reset.c b/arch/mips/qemu/q-reset.c
new file mode 100644
index 000000000000..c04ebcfc7843
--- /dev/null
+++ b/arch/mips/qemu/q-reset.c
@@ -0,0 +1,34 @@
1#include <linux/config.h>
2
3#include <asm/io.h>
4#include <asm/reboot.h>
5#include <asm/cacheflush.h>
6#include <asm/qemu.h>
7
8static void qemu_machine_restart(char *command)
9{
10 volatile unsigned int *reg = (unsigned int *)QEMU_RESTART_REG;
11
12 set_c0_status(ST0_BEV | ST0_ERL);
13 change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
14 flush_cache_all();
15 write_c0_wired(0);
16 *reg = 42;
17 while (1)
18 cpu_wait();
19}
20
21static void qemu_machine_halt(void)
22{
23 volatile unsigned int *reg = (unsigned int *)QEMU_HALT_REG;
24
25 *reg = 42;
26 while (1)
27 cpu_wait();
28}
29
30void qemu_reboot_setup(void)
31{
32 _machine_restart = qemu_machine_restart;
33 _machine_halt = qemu_machine_halt;
34}
diff --git a/arch/mips/qemu/q-setup.c b/arch/mips/qemu/q-setup.c
index 022eb1af6db1..e100d6072e31 100644
--- a/arch/mips/qemu/q-setup.c
+++ b/arch/mips/qemu/q-setup.c
@@ -2,6 +2,8 @@
2#include <asm/io.h> 2#include <asm/io.h>
3#include <asm/time.h> 3#include <asm/time.h>
4 4
5extern void qemu_reboot_setup(void);
6
5#define QEMU_PORT_BASE 0xb4000000 7#define QEMU_PORT_BASE 0xb4000000
6 8
7const char *get_system_type(void) 9const char *get_system_type(void)
@@ -18,8 +20,10 @@ static void __init qemu_timer_setup(struct irqaction *irq)
18 setup_irq(0, irq); 20 setup_irq(0, irq);
19} 21}
20 22
21void __init plat_setup(void) 23void __init plat_mem_setup(void)
22{ 24{
23 set_io_port_base(QEMU_PORT_BASE); 25 set_io_port_base(QEMU_PORT_BASE);
24 board_timer_setup = qemu_timer_setup; 26 board_timer_setup = qemu_timer_setup;
27
28 qemu_reboot_setup();
25} 29}
diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
index 7018e1833e85..d7138906eb10 100644
--- a/arch/mips/sgi-ip22/ip22-setup.c
+++ b/arch/mips/sgi-ip22/ip22-setup.c
@@ -53,7 +53,7 @@ EXPORT_SYMBOL(ip22_do_break);
53extern void ip22_be_init(void) __init; 53extern void ip22_be_init(void) __init;
54extern void ip22_time_init(void) __init; 54extern void ip22_time_init(void) __init;
55 55
56void __init plat_setup(void) 56void __init plat_mem_setup(void)
57{ 57{
58 char *ctype; 58 char *ctype;
59 char *cserial; 59 char *cserial;
diff --git a/arch/mips/sgi-ip27/Kconfig b/arch/mips/sgi-ip27/Kconfig
index 7b0bc4437243..f14ef38646d0 100644
--- a/arch/mips/sgi-ip27/Kconfig
+++ b/arch/mips/sgi-ip27/Kconfig
@@ -4,31 +4,29 @@
4# This options adds support for userspace processes upto 16TB size. 4# This options adds support for userspace processes upto 16TB size.
5# Normally the limit is just .5TB. 5# Normally the limit is just .5TB.
6 6
7config SGI_SN0_N_MODE 7choice
8 bool "IP27 N-Mode" 8 prompt "Node addressing mode"
9 depends on SGI_IP27 9 depends on SGI_IP27
10 help 10 default SGI_SN_M_MODE
11 The nodes of Origin 200, Origin 2000 and Onyx 2 systems can be
12 configured in either N-Modes which allows for more nodes or M-Mode
13 which allows for more memory. Your system is most probably
14 running in M-Mode, so you should say N here.
15 11
16config ARCH_DISCONTIGMEM_ENABLE 12config SGI_SN_M_MODE
17 bool 13 bool "IP27 M-Mode"
18 default y if SGI_IP27
19 help 14 help
20 Say Y to upport efficient handling of discontiguous physical memory, 15 The nodes of Origin, Onyx, Fuel and Tezro systems can be configured
21 for architectures which are either NUMA (Non-Uniform Memory Access) 16 in either N-Modes which allows for more nodes or M-Mode which allows
22 or have huge holes in the physical address space for other reasons. 17 for more memory. Your hardware is almost certainly running in
23 See <file:Documentation/vm/numa> for more. 18 M-Mode, so choose M-mode here.
24 19
25config NUMA 20config SGI_SN_N_MODE
26 bool "NUMA Support" 21 bool "IP27 N-Mode"
27 depends on SGI_IP27 22 depends on EXPERIMENTAL
28 help 23 help
29 Say Y to compile the kernel to support NUMA (Non-Uniform Memory 24 The nodes of Origin, Onyx, Fuel and Tezro systems can be configured
30 Access). This option is for configuring high-end multiprocessor 25 in either N-Modes which allows for more nodes or M-Mode which allows
31 server machines. If in doubt, say N. 26 for more memory. Your hardware is almost certainly running in
27 M-Mode, so choose M-mode here.
28
29endchoice
32 30
33config MAPPED_KERNEL 31config MAPPED_KERNEL
34 bool "Mapped kernel support" 32 bool "Mapped kernel support"
diff --git a/arch/mips/sgi-ip27/ip27-init.c b/arch/mips/sgi-ip27/ip27-init.c
index 8651a0e75404..a6b490e99709 100644
--- a/arch/mips/sgi-ip27/ip27-init.c
+++ b/arch/mips/sgi-ip27/ip27-init.c
@@ -196,7 +196,7 @@ extern void ip27_setup_console(void);
196extern void ip27_time_init(void); 196extern void ip27_time_init(void);
197extern void ip27_reboot_setup(void); 197extern void ip27_reboot_setup(void);
198 198
199void __init plat_setup(void) 199void __init plat_mem_setup(void)
200{ 200{
201 hubreg_t p, e, n_mode; 201 hubreg_t p, e, n_mode;
202 nasid_t nid; 202 nasid_t nid;
@@ -228,7 +228,7 @@ void __init plat_setup(void)
228 */ 228 */
229 n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK; 229 n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
230 printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M'); 230 printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M');
231#ifdef CONFIG_SGI_SN0_N_MODE 231#ifdef CONFIG_SGI_SN_N_MODE
232 if (!n_mode) 232 if (!n_mode)
233 panic("Kernel compiled for M mode."); 233 panic("Kernel compiled for M mode.");
234#else 234#else
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 2e643d2f51cb..0b61a39ce2bb 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -360,7 +360,7 @@ static struct hw_interrupt_type bridge_irq_type = {
360 360
361static unsigned long irq_map[NR_IRQS / BITS_PER_LONG]; 361static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];
362 362
363static int allocate_irqno(void) 363int allocate_irqno(void)
364{ 364{
365 int irq; 365 int irq;
366 366
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 36b662e27b6e..1fb860c7ac6d 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -89,11 +89,13 @@ static int set_rtc_mmss(unsigned long nowtime)
89} 89}
90#endif 90#endif
91 91
92static unsigned int rt_timer_irq;
93
92void ip27_rt_timer_interrupt(struct pt_regs *regs) 94void ip27_rt_timer_interrupt(struct pt_regs *regs)
93{ 95{
94 int cpu = smp_processor_id(); 96 int cpu = smp_processor_id();
95 int cpuA = cputoslice(cpu) == 0; 97 int cpuA = cputoslice(cpu) == 0;
96 int irq = 9; /* XXX Assign number */ 98 unsigned int irq = rt_timer_irq;
97 99
98 irq_enter(); 100 irq_enter();
99 write_seqlock(&xtime_lock); 101 write_seqlock(&xtime_lock);
@@ -179,13 +181,68 @@ static __init unsigned long get_m48t35_time(void)
179 return mktime(year, month, date, hour, min, sec); 181 return mktime(year, month, date, hour, min, sec);
180} 182}
181 183
184static void startup_rt_irq(unsigned int irq)
185{
186}
187
188static void shutdown_rt_irq(unsigned int irq)
189{
190}
191
192static void enable_rt_irq(unsigned int irq)
193{
194}
195
196static void disable_rt_irq(unsigned int irq)
197{
198}
199
200static void mask_and_ack_rt(unsigned int irq)
201{
202}
203
204static void end_rt_irq(unsigned int irq)
205{
206}
207
208static struct hw_interrupt_type rt_irq_type = {
209 .typename = "SN HUB RT timer",
210 .startup = startup_rt_irq,
211 .shutdown = shutdown_rt_irq,
212 .enable = enable_rt_irq,
213 .disable = disable_rt_irq,
214 .ack = mask_and_ack_rt,
215 .end = end_rt_irq,
216};
217
218static struct irqaction rt_irqaction = {
219 .handler = ip27_rt_timer_interrupt,
220 .flags = SA_INTERRUPT,
221 .mask = CPU_MASK_NONE,
222 .name = "timer"
223};
224
225extern int allocate_irqno(void);
226
182static void ip27_timer_setup(struct irqaction *irq) 227static void ip27_timer_setup(struct irqaction *irq)
183{ 228{
229 int irqno = allocate_irqno();
230
231 if (irqno < 0)
232 panic("Can't allocate interrupt number for timer interrupt");
233
234 irq_desc[irqno].status = IRQ_DISABLED;
235 irq_desc[irqno].action = NULL;
236 irq_desc[irqno].depth = 1;
237 irq_desc[irqno].handler = &rt_irq_type;
238
184 /* over-write the handler, we use our own way */ 239 /* over-write the handler, we use our own way */
185 irq->handler = no_action; 240 irq->handler = no_action;
186 241
187 /* setup irqaction */ 242 /* setup irqaction */
188// setup_irq(IP27_TIMER_IRQ, irq); /* XXX Can't do this yet. */ 243 irq_desc[irqno].status |= IRQ_PER_CPU;
244
245 rt_timer_irq = irqno;
189} 246}
190 247
191void __init ip27_time_init(void) 248void __init ip27_time_init(void)
diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
index a2dd8ae1ea8f..acbdad06fac1 100644
--- a/arch/mips/sgi-ip32/ip32-setup.c
+++ b/arch/mips/sgi-ip32/ip32-setup.c
@@ -87,7 +87,7 @@ void __init ip32_timer_setup(struct irqaction *irq)
87 setup_irq(IP32_R4K_TIMER_IRQ, irq); 87 setup_irq(IP32_R4K_TIMER_IRQ, irq);
88} 88}
89 89
90void __init plat_setup(void) 90void __init plat_mem_setup(void)
91{ 91{
92 board_be_init = ip32_be_init; 92 board_be_init = ip32_be_init;
93 93
diff --git a/arch/mips/sibyte/bcm1480/time.c b/arch/mips/sibyte/bcm1480/time.c
index e545752695a1..efaf83efd2e4 100644
--- a/arch/mips/sibyte/bcm1480/time.c
+++ b/arch/mips/sibyte/bcm1480/time.c
@@ -110,17 +110,18 @@ void bcm1480_timer_interrupt(struct pt_regs *regs)
110 __raw_writeq(M_SCD_TIMER_ENABLE|M_SCD_TIMER_MODE_CONTINUOUS, 110 __raw_writeq(M_SCD_TIMER_ENABLE|M_SCD_TIMER_MODE_CONTINUOUS,
111 IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); 111 IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)));
112 112
113 /*
114 * CPU 0 handles the global timer interrupt job
115 */
116 if (cpu == 0) { 113 if (cpu == 0) {
114 /*
115 * CPU 0 handles the global timer interrupt job
116 */
117 ll_timer_interrupt(irq, regs); 117 ll_timer_interrupt(irq, regs);
118 } 118 }
119 119 else {
120 /* 120 /*
121 * every CPU should do profiling and process accouting 121 * other CPUs should just do profiling and process accounting
122 */ 122 */
123 ll_local_timer_interrupt(irq, regs); 123 ll_local_timer_interrupt(irq, regs);
124 }
124} 125}
125 126
126/* 127/*
diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
index 0f6e54db4888..f853c32f60a0 100644
--- a/arch/mips/sibyte/sb1250/irq.c
+++ b/arch/mips/sibyte/sb1250/irq.c
@@ -435,13 +435,17 @@ static inline int dclz(unsigned long long x)
435 return lz; 435 return lz;
436} 436}
437 437
438extern void sb1250_timer_interrupt(struct pt_regs *regs);
439extern void sb1250_mailbox_interrupt(struct pt_regs *regs);
440extern void sb1250_kgdb_interrupt(struct pt_regs *regs);
441
438asmlinkage void plat_irq_dispatch(struct pt_regs *regs) 442asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
439{ 443{
440 unsigned int pending; 444 unsigned int pending;
441 445
442#ifdef CONFIG_SIBYTE_SB1250_PROF 446#ifdef CONFIG_SIBYTE_SB1250_PROF
443 /* Set compare to count to silence count/compare timer interrupts */ 447 /* Set compare to count to silence count/compare timer interrupts */
444 write_c0_count(read_c0_count()); 448 write_c0_compare(read_c0_count());
445#endif 449#endif
446 450
447 /* 451 /*
@@ -482,7 +486,7 @@ asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
482 * Default...we've hit an IP[2] interrupt, which means we've 486 * Default...we've hit an IP[2] interrupt, which means we've
483 * got to check the 1250 interrupt registers to figure out what 487 * got to check the 1250 interrupt registers to figure out what
484 * to do. Need to detect which CPU we're on, now that 488 * to do. Need to detect which CPU we're on, now that
485 ~ smp_affinity is supported. 489 * smp_affinity is supported.
486 */ 490 */
487 mask = __raw_readq(IOADDR(A_IMR_REGISTER(smp_processor_id(), 491 mask = __raw_readq(IOADDR(A_IMR_REGISTER(smp_processor_id(),
488 R_IMR_INTERRUPT_STATUS_BASE))); 492 R_IMR_INTERRUPT_STATUS_BASE)));
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index 4b5f74ff3edd..f9e694988cdf 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -72,8 +72,10 @@ const char *get_system_type(void)
72 72
73void __init swarm_time_init(void) 73void __init swarm_time_init(void)
74{ 74{
75#if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
75 /* Setup HPT */ 76 /* Setup HPT */
76 sb1250_hpt_setup(); 77 sb1250_hpt_setup();
78#endif
77} 79}
78 80
79void __init swarm_timer_setup(struct irqaction *irq) 81void __init swarm_timer_setup(struct irqaction *irq)
@@ -103,7 +105,7 @@ int swarm_be_handler(struct pt_regs *regs, int is_fixup)
103 return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL); 105 return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
104} 106}
105 107
106void __init plat_setup(void) 108void __init plat_mem_setup(void)
107{ 109{
108#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) 110#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
109 bcm1480_setup(); 111 bcm1480_setup();
diff --git a/arch/mips/sni/Makefile b/arch/mips/sni/Makefile
index 9c7eaa5fb210..a5eb0adb87c7 100644
--- a/arch/mips/sni/Makefile
+++ b/arch/mips/sni/Makefile
@@ -3,5 +3,6 @@
3# 3#
4 4
5obj-y += irq.o pcimt_scache.o reset.o setup.o 5obj-y += irq.o pcimt_scache.o reset.o setup.o
6obj-$(CONFIG_CPU_BIG_ENDIAN) += sniprom.o
6 7
7EXTRA_AFLAGS := $(CFLAGS) 8EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
index 01ba6c581e3d..a050bb6ae704 100644
--- a/arch/mips/sni/setup.c
+++ b/arch/mips/sni/setup.c
@@ -21,8 +21,11 @@
21#include <linux/fb.h> 21#include <linux/fb.h>
22#include <linux/tty.h> 22#include <linux/tty.h>
23 23
24#ifdef CONFIG_ARC
24#include <asm/arc/types.h> 25#include <asm/arc/types.h>
25#include <asm/sgialib.h> 26#include <asm/sgialib.h>
27#endif
28
26#include <asm/bcache.h> 29#include <asm/bcache.h>
27#include <asm/bootinfo.h> 30#include <asm/bootinfo.h>
28#include <asm/io.h> 31#include <asm/io.h>
@@ -72,8 +75,7 @@ static inline void sni_pcimt_detect(void)
72 75
73static void __init sni_display_setup(void) 76static void __init sni_display_setup(void)
74{ 77{
75#ifdef CONFIG_VT 78#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_ARC)
76#if defined(CONFIG_VGA_CONSOLE)
77 struct screen_info *si = &screen_info; 79 struct screen_info *si = &screen_info;
78 DISPLAY_STATUS *di; 80 DISPLAY_STATUS *di;
79 81
@@ -88,24 +90,54 @@ static void __init sni_display_setup(void)
88 si->orig_video_points = 16; 90 si->orig_video_points = 16;
89 } 91 }
90#endif 92#endif
91#endif
92} 93}
93 94
94static struct resource sni_io_resource = { 95static struct resource sni_io_resource = {
95 "PCIMT IO MEM", 0x00001000UL, 0x03bfffffUL, IORESOURCE_IO, 96 .start = 0x00001000UL,
97 .end = 0x03bfffffUL,
98 .name = "PCIMT IO MEM",
99 .flags = IORESOURCE_IO,
96}; 100};
97 101
98static struct resource pcimt_io_resources[] = { 102static struct resource pcimt_io_resources[] = {
99 { "dma1", 0x00, 0x1f, IORESOURCE_BUSY }, 103 {
100 { "timer", 0x40, 0x5f, IORESOURCE_BUSY }, 104 .start = 0x00,
101 { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY }, 105 .end = 0x1f,
102 { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY }, 106 .name = "dma1",
103 { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY }, 107 .flags = IORESOURCE_BUSY
104 { "PCI config data", 0xcfc, 0xcff, IORESOURCE_BUSY } 108 }, {
109 .start = 0x40,
110 .end = 0x5f,
111 .name = "timer",
112 .flags = IORESOURCE_BUSY
113 }, {
114 .start = 0x60,
115 .end = 0x6f,
116 .name = "keyboard",
117 .flags = IORESOURCE_BUSY
118 }, {
119 .start = 0x80,
120 .end = 0x8f,
121 .name = "dma page reg",
122 .flags = IORESOURCE_BUSY
123 }, {
124 .start = 0xc0,
125 .end = 0xdf,
126 .name = "dma2",
127 .flags = IORESOURCE_BUSY
128 }, {
129 .start = 0xcfc,
130 .end = 0xcff,
131 .name = "PCI config data",
132 .flags = IORESOURCE_BUSY
133 }
105}; 134};
106 135
107static struct resource sni_mem_resource = { 136static struct resource sni_mem_resource = {
108 "PCIMT PCI MEM", 0x10000000UL, 0xffffffffUL, IORESOURCE_MEM 137 .start = 0x10000000UL,
138 .end = 0xffffffffUL,
139 .name = "PCIMT PCI MEM",
140 .flags = IORESOURCE_MEM
109}; 141};
110 142
111/* 143/*
@@ -122,19 +154,72 @@ static struct resource sni_mem_resource = {
122 * 0xa0000000 - 0xffffffff (1.5GB) PCI/EISA Bus Memory 154 * 0xa0000000 - 0xffffffff (1.5GB) PCI/EISA Bus Memory
123 */ 155 */
124static struct resource pcimt_mem_resources[] = { 156static struct resource pcimt_mem_resources[] = {
125 { "Video RAM area", 0x100a0000, 0x100bffff, IORESOURCE_BUSY }, 157 {
126 { "ISA Reserved", 0x100c0000, 0x100fffff, IORESOURCE_BUSY }, 158 .start = 0x100a0000,
127 { "PCI IO", 0x14000000, 0x17bfffff, IORESOURCE_BUSY }, 159 .end = 0x100bffff,
128 { "Cache Replacement Area", 0x17c00000, 0x17ffffff, IORESOURCE_BUSY}, 160 .name = "Video RAM area",
129 { "PCI INT Acknowledge", 0x1a000000, 0x1a000003, IORESOURCE_BUSY }, 161 .flags = IORESOURCE_BUSY
130 { "Boot PROM", 0x1fc00000, 0x1fc7ffff, IORESOURCE_BUSY}, 162 }, {
131 { "Diag PROM", 0x1fc80000, 0x1fcfffff, IORESOURCE_BUSY}, 163 .start = 0x100c0000,
132 { "X-Bus", 0x1fd00000, 0x1fdfffff, IORESOURCE_BUSY}, 164 .end = 0x100fffff,
133 { "BIOS map", 0x1fe00000, 0x1fefffff, IORESOURCE_BUSY}, 165 .name = "ISA Reserved",
134 { "NVRAM / EEPROM", 0x1ff00000, 0x1ff7ffff, IORESOURCE_BUSY}, 166 .flags = IORESOURCE_BUSY
135 { "ASIC PCI", 0x1fff0000, 0x1fffefff, IORESOURCE_BUSY}, 167 }, {
136 { "MP Agent", 0x1ffff000, 0x1fffffff, IORESOURCE_BUSY}, 168 .start = 0x14000000,
137 { "Main Memory", 0x20000000, 0x9fffffff, IORESOURCE_BUSY} 169 .end = 0x17bfffff,
170 .name = "PCI IO",
171 .flags = IORESOURCE_BUSY
172 }, {
173 .start = 0x17c00000,
174 .end = 0x17ffffff,
175 .name = "Cache Replacement Area",
176 .flags = IORESOURCE_BUSY
177 }, {
178 .start = 0x1a000000,
179 .end = 0x1a000003,
180 .name = "PCI INT Acknowledge",
181 .flags = IORESOURCE_BUSY
182 }, {
183 .start = 0x1fc00000,
184 .end = 0x1fc7ffff,
185 .name = "Boot PROM",
186 .flags = IORESOURCE_BUSY
187 }, {
188 .start = 0x1fc80000,
189 .end = 0x1fcfffff,
190 .name = "Diag PROM",
191 .flags = IORESOURCE_BUSY
192 }, {
193 .start = 0x1fd00000,
194 .end = 0x1fdfffff,
195 .name = "X-Bus",
196 .flags = IORESOURCE_BUSY
197 }, {
198 .start = 0x1fe00000,
199 .end = 0x1fefffff,
200 .name = "BIOS map",
201 .flags = IORESOURCE_BUSY
202 }, {
203 .start = 0x1ff00000,
204 .end = 0x1ff7ffff,
205 .name = "NVRAM / EEPROM",
206 .flags = IORESOURCE_BUSY
207 }, {
208 .start = 0x1fff0000,
209 .end = 0x1fffefff,
210 .name = "ASIC PCI",
211 .flags = IORESOURCE_BUSY
212 }, {
213 .start = 0x1ffff000,
214 .end = 0x1fffffff,
215 .name = "MP Agent",
216 .flags = IORESOURCE_BUSY
217 }, {
218 .start = 0x20000000,
219 .end = 0x9fffffff,
220 .name = "Main Memory",
221 .flags = IORESOURCE_BUSY
222 }
138}; 223};
139 224
140static void __init sni_resource_init(void) 225static void __init sni_resource_init(void)
@@ -168,7 +253,7 @@ static inline void sni_pcimt_time_init(void)
168 rtc_mips_set_time = mc146818_set_rtc_mmss; 253 rtc_mips_set_time = mc146818_set_rtc_mmss;
169} 254}
170 255
171void __init plat_setup(void) 256void __init plat_mem_setup(void)
172{ 257{
173 sni_pcimt_detect(); 258 sni_pcimt_detect();
174 sni_pcimt_sc_init(); 259 sni_pcimt_sc_init();
diff --git a/arch/mips/sni/sniprom.c b/arch/mips/sni/sniprom.c
new file mode 100644
index 000000000000..d1d0f1f493b4
--- /dev/null
+++ b/arch/mips/sni/sniprom.c
@@ -0,0 +1,158 @@
1/*
2 * Big Endian PROM code for SNI RM machines
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2005-2006 Florian Lohoff (flo@rfc822.org)
9 * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/string.h>
15
16#include <asm/addrspace.h>
17#include <asm/sni.h>
18#include <asm/mipsprom.h>
19#include <asm/bootinfo.h>
20
21/* special SNI prom calls */
22/*
23 * This does not exist in all proms - SINIX compares
24 * the prom env variable "version" against "2.0008"
25 * or greater. If lesser it tries to probe interesting
26 * registers
27 */
28#define PROM_GET_MEMCONF 58
29
30#define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
31#define PROM_ENTRY(x) (PROM_VEC + (x))
32
33
34#undef DEBUG
35#ifdef DEBUG
36#define DBG_PRINTF(x...) prom_printf(x)
37#else
38#define DBG_PRINTF(x...)
39#endif
40
41static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR);
42static char *(*__prom_getenv)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV);
43static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF);
44
45char *prom_getenv (char *s)
46{
47 return __prom_getenv(s);
48}
49
50void prom_printf(char *fmt, ...)
51{
52 va_list args;
53 char ppbuf[1024];
54 char *bptr;
55
56 va_start(args, fmt);
57 vsprintf(ppbuf, fmt, args);
58
59 bptr = ppbuf;
60
61 while (*bptr != 0) {
62 if (*bptr == '\n')
63 __prom_putchar('\r');
64
65 __prom_putchar(*bptr++);
66 }
67 va_end(args);
68}
69
70unsigned long prom_free_prom_memory(void)
71{
72 return 0;
73}
74
75/*
76 * /proc/cpuinfo system type
77 *
78 */
79static const char *systype = "Unknown";
80const char *get_system_type(void)
81{
82 return systype;
83}
84
85#define SNI_IDPROM_BASE 0xbff00000
86#define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE+0x28) /* Memsize in 16MB quantities */
87#define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE+0x29) /* Board Type */
88#define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE+0x30) /* CPU Type */
89
90#define SNI_IDPROM_SIZE 0x1000
91
92#ifdef DEBUG
93static void sni_idprom_dump(void)
94{
95 int i;
96
97 prom_printf("SNI IDProm dump (first 128byte):\n");
98 for(i=0;i<128;i++) {
99 if (i%16 == 0)
100 prom_printf("%04x ", i);
101
102 prom_printf("%02x ", *(unsigned char *) (SNI_IDPROM_BASE+i));
103
104 if (i%16 == 15)
105 prom_printf("\n");
106 }
107}
108#endif
109
110static void sni_mem_init(void )
111{
112 int i, memsize;
113 struct membank {
114 u32 size;
115 u32 base;
116 u32 size2;
117 u32 pad1;
118 u32 pad2;
119 } memconf[8];
120
121 /* MemSIZE from prom in 16MByte chunks */
122 memsize=*((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
123
124 DBG_PRINTF("IDProm memsize: %lu MByte\n", memsize);
125
126 /* get memory bank layout from prom */
127 __prom_get_memconf(&memconf);
128
129 DBG_PRINTF("prom_get_mem_conf memory configuration:\n");
130 for(i=0;i<8 && memconf[i].size;i++) {
131 prom_printf("Bank%d: %08x @ %08x\n", i,
132 memconf[i].size, memconf[i].base);
133 add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM);
134 }
135}
136
137void __init prom_init(void)
138{
139 int argc = fw_arg0;
140 char **argv = (void *)fw_arg1;
141 unsigned int sni_brd_type = *(unsigned char *) SNI_IDPROM_BRDTYPE;
142 int i;
143
144 DBG_PRINTF("Found SNI brdtype %02x\n", sni_brd_type);
145
146#ifdef DEBUG
147 sni_idprom_dump();
148#endif
149 sni_mem_init();
150
151 /* copy prom cmdline parameters to kernel cmdline */
152 for (i = 1; i < argc; i++) {
153 strcat(arcs_cmdline, argv[i]);
154 if (i < (argc - 1))
155 strcat(arcs_cmdline, " ");
156 }
157}
158
diff --git a/arch/mips/tx4927/common/tx4927_setup.c b/arch/mips/tx4927/common/tx4927_setup.c
index 77c3b66fb959..81a5acfe8c42 100644
--- a/arch/mips/tx4927/common/tx4927_setup.c
+++ b/arch/mips/tx4927/common/tx4927_setup.c
@@ -64,7 +64,7 @@ static void tx4927_write_buffer_flush(void)
64} 64}
65 65
66 66
67void __init plat_setup(void) 67void __init plat_mem_setup(void)
68{ 68{
69 board_time_init = tx4927_time_init; 69 board_time_init = tx4927_time_init;
70 board_timer_setup = tx4927_timer_setup; 70 board_timer_setup = tx4927_timer_setup;
diff --git a/arch/mips/tx4938/common/setup.c b/arch/mips/tx4938/common/setup.c
index fc992953bf95..ef59a5cffc69 100644
--- a/arch/mips/tx4938/common/setup.c
+++ b/arch/mips/tx4938/common/setup.c
@@ -61,7 +61,7 @@ tx4938_write_buffer_flush(void)
61} 61}
62 62
63void __init 63void __init
64plat_setup(void) 64plat_mem_setup(void)
65{ 65{
66 board_time_init = tx4938_time_init; 66 board_time_init = tx4938_time_init;
67 board_timer_setup = tx4938_timer_setup; 67 board_timer_setup = tx4938_timer_setup;
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
index 9166cd4557eb..96e833cd4c14 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
@@ -664,7 +664,10 @@ static struct resource rbtx4938_fpga_resource;
664 664
665static char pcode_str[8]; 665static char pcode_str[8];
666static struct resource tx4938_reg_resource = { 666static struct resource tx4938_reg_resource = {
667 pcode_str, TX4938_REG_BASE, TX4938_REG_BASE+TX4938_REG_SIZE, IORESOURCE_MEM 667 .start = TX4938_REG_BASE,
668 .end = TX4938_REG_BASE + TX4938_REG_SIZE,
669 .name = pcode_str,
670 .flags = IORESOURCE_MEM
668}; 671};
669 672
670void __init tx4938_board_setup(void) 673void __init tx4938_board_setup(void)
diff --git a/arch/mips/vr41xx/Kconfig b/arch/mips/vr41xx/Kconfig
index 055a2cdfc841..6046ef23b2bf 100644
--- a/arch/mips/vr41xx/Kconfig
+++ b/arch/mips/vr41xx/Kconfig
@@ -4,7 +4,6 @@ config CASIO_E55
4 select DMA_NONCOHERENT 4 select DMA_NONCOHERENT
5 select IRQ_CPU 5 select IRQ_CPU
6 select ISA 6 select ISA
7 select SYS_HAS_CPU_VR41XX
8 select SYS_SUPPORTS_32BIT_KERNEL 7 select SYS_SUPPORTS_32BIT_KERNEL
9 select SYS_SUPPORTS_LITTLE_ENDIAN 8 select SYS_SUPPORTS_LITTLE_ENDIAN
10 9
@@ -14,18 +13,15 @@ config IBM_WORKPAD
14 select DMA_NONCOHERENT 13 select DMA_NONCOHERENT
15 select IRQ_CPU 14 select IRQ_CPU
16 select ISA 15 select ISA
17 select SYS_HAS_CPU_VR41XX
18 select SYS_SUPPORTS_32BIT_KERNEL 16 select SYS_SUPPORTS_32BIT_KERNEL
19 select SYS_SUPPORTS_LITTLE_ENDIAN 17 select SYS_SUPPORTS_LITTLE_ENDIAN
20 18
21config NEC_CMBVR4133 19config NEC_CMBVR4133
22 bool "Support for NEC CMB-VR4133" 20 bool "Support for NEC CMB-VR4133"
23 depends on MACH_VR41XX 21 depends on MACH_VR41XX
24 select CPU_VR41XX
25 select DMA_NONCOHERENT 22 select DMA_NONCOHERENT
26 select IRQ_CPU 23 select IRQ_CPU
27 select HW_HAS_PCI 24 select HW_HAS_PCI
28 select SYS_HAS_CPU_VR41XX
29 select SYS_SUPPORTS_32BIT_KERNEL 25 select SYS_SUPPORTS_32BIT_KERNEL
30 select SYS_SUPPORTS_LITTLE_ENDIAN 26 select SYS_SUPPORTS_LITTLE_ENDIAN
31 27
@@ -41,7 +37,6 @@ config TANBAC_TB022X
41 select DMA_NONCOHERENT 37 select DMA_NONCOHERENT
42 select HW_HAS_PCI 38 select HW_HAS_PCI
43 select IRQ_CPU 39 select IRQ_CPU
44 select SYS_HAS_CPU_VR41XX
45 select SYS_SUPPORTS_32BIT_KERNEL 40 select SYS_SUPPORTS_32BIT_KERNEL
46 select SYS_SUPPORTS_LITTLE_ENDIAN 41 select SYS_SUPPORTS_LITTLE_ENDIAN
47 help 42 help
@@ -74,7 +69,6 @@ config VICTOR_MPC30X
74 select DMA_NONCOHERENT 69 select DMA_NONCOHERENT
75 select HW_HAS_PCI 70 select HW_HAS_PCI
76 select IRQ_CPU 71 select IRQ_CPU
77 select SYS_HAS_CPU_VR41XX
78 select SYS_SUPPORTS_32BIT_KERNEL 72 select SYS_SUPPORTS_32BIT_KERNEL
79 select SYS_SUPPORTS_LITTLE_ENDIAN 73 select SYS_SUPPORTS_LITTLE_ENDIAN
80 74
@@ -84,7 +78,6 @@ config ZAO_CAPCELLA
84 select DMA_NONCOHERENT 78 select DMA_NONCOHERENT
85 select HW_HAS_PCI 79 select HW_HAS_PCI
86 select IRQ_CPU 80 select IRQ_CPU
87 select SYS_HAS_CPU_VR41XX
88 select SYS_SUPPORTS_32BIT_KERNEL 81 select SYS_SUPPORTS_32BIT_KERNEL
89 select SYS_SUPPORTS_LITTLE_ENDIAN 82 select SYS_SUPPORTS_LITTLE_ENDIAN
90 83
diff --git a/arch/mips/vr41xx/common/init.c b/arch/mips/vr41xx/common/init.c
index 707bd0933eed..915bfa5c0719 100644
--- a/arch/mips/vr41xx/common/init.c
+++ b/arch/mips/vr41xx/common/init.c
@@ -58,7 +58,7 @@ static void __init timer_init(void)
58 board_timer_setup = setup_timer_irq; 58 board_timer_setup = setup_timer_irq;
59} 59}
60 60
61void __init plat_setup(void) 61void __init plat_mem_setup(void)
62{ 62{
63 vr41xx_calculate_clock_frequency(); 63 vr41xx_calculate_clock_frequency();
64 64
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 41e9ab40cd54..f70bd090dacd 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -822,6 +822,7 @@ static void __init prom_send_capabilities(void)
822 /* try calling the ibm,client-architecture-support method */ 822 /* try calling the ibm,client-architecture-support method */
823 if (call_prom_ret("call-method", 3, 2, &ret, 823 if (call_prom_ret("call-method", 3, 2, &ret,
824 ADDR("ibm,client-architecture-support"), 824 ADDR("ibm,client-architecture-support"),
825 root,
825 ADDR(ibm_architecture_vec)) == 0) { 826 ADDR(ibm_architecture_vec)) == 0) {
826 /* the call exists... */ 827 /* the call exists... */
827 if (ret) 828 if (ret)
@@ -1622,6 +1623,15 @@ static int __init prom_find_machine_type(void)
1622 if (strstr(p, RELOC("Power Macintosh")) || 1623 if (strstr(p, RELOC("Power Macintosh")) ||
1623 strstr(p, RELOC("MacRISC"))) 1624 strstr(p, RELOC("MacRISC")))
1624 return PLATFORM_POWERMAC; 1625 return PLATFORM_POWERMAC;
1626#ifdef CONFIG_PPC64
1627 /* We must make sure we don't detect the IBM Cell
1628 * blades as pSeries due to some firmware issues,
1629 * so we do it here.
1630 */
1631 if (strstr(p, RELOC("IBM,CBEA")) ||
1632 strstr(p, RELOC("IBM,CPBW-1.0")))
1633 return PLATFORM_GENERIC;
1634#endif /* CONFIG_PPC64 */
1625 i += sl + 1; 1635 i += sl + 1;
1626 } 1636 }
1627 } 1637 }
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 01e3c08cb550..8fdeca2d4597 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -803,10 +803,13 @@ static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int
803 if (__get_user(cmcp, &ucp->uc_regs)) 803 if (__get_user(cmcp, &ucp->uc_regs))
804 return -EFAULT; 804 return -EFAULT;
805 mcp = (struct mcontext __user *)(u64)cmcp; 805 mcp = (struct mcontext __user *)(u64)cmcp;
806 /* no need to check access_ok(mcp), since mcp < 4GB */
806 } 807 }
807#else 808#else
808 if (__get_user(mcp, &ucp->uc_regs)) 809 if (__get_user(mcp, &ucp->uc_regs))
809 return -EFAULT; 810 return -EFAULT;
811 if (!access_ok(VERIFY_READ, mcp, sizeof(*mcp)))
812 return -EFAULT;
810#endif 813#endif
811 restore_sigmask(&set); 814 restore_sigmask(&set);
812 if (restore_user_regs(regs, mcp, sig)) 815 if (restore_user_regs(regs, mcp, sig))
@@ -908,13 +911,14 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
908{ 911{
909 struct sig_dbg_op op; 912 struct sig_dbg_op op;
910 int i; 913 int i;
914 unsigned char tmp;
911 unsigned long new_msr = regs->msr; 915 unsigned long new_msr = regs->msr;
912#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) 916#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
913 unsigned long new_dbcr0 = current->thread.dbcr0; 917 unsigned long new_dbcr0 = current->thread.dbcr0;
914#endif 918#endif
915 919
916 for (i=0; i<ndbg; i++) { 920 for (i=0; i<ndbg; i++) {
917 if (__copy_from_user(&op, dbg, sizeof(op))) 921 if (copy_from_user(&op, dbg + i, sizeof(op)))
918 return -EFAULT; 922 return -EFAULT;
919 switch (op.dbg_type) { 923 switch (op.dbg_type) {
920 case SIG_DBG_SINGLE_STEPPING: 924 case SIG_DBG_SINGLE_STEPPING:
@@ -959,6 +963,11 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
959 current->thread.dbcr0 = new_dbcr0; 963 current->thread.dbcr0 = new_dbcr0;
960#endif 964#endif
961 965
966 if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx))
967 || __get_user(tmp, (u8 __user *) ctx)
968 || __get_user(tmp, (u8 __user *) (ctx + 1) - 1))
969 return -EFAULT;
970
962 /* 971 /*
963 * If we get a fault copying the context into the kernel's 972 * If we get a fault copying the context into the kernel's
964 * image of the user's registers, we can't just return -EFAULT 973 * image of the user's registers, we can't just return -EFAULT
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 27f65b95184d..c2db642f4cdd 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -182,6 +182,8 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig,
182 err |= __get_user(msr, &sc->gp_regs[PT_MSR]); 182 err |= __get_user(msr, &sc->gp_regs[PT_MSR]);
183 if (err) 183 if (err)
184 return err; 184 return err;
185 if (v_regs && !access_ok(VERIFY_READ, v_regs, 34 * sizeof(vector128)))
186 return -EFAULT;
185 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */ 187 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */
186 if (v_regs != 0 && (msr & MSR_VEC) != 0) 188 if (v_regs != 0 && (msr & MSR_VEC) != 0)
187 err |= __copy_from_user(current->thread.vr, v_regs, 189 err |= __copy_from_user(current->thread.vr, v_regs,
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 33654d1b1b43..994856e55b7c 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -52,7 +52,7 @@ static inline void __tlbie(unsigned long va, unsigned int psize)
52 default: 52 default:
53 penc = mmu_psize_defs[psize].penc; 53 penc = mmu_psize_defs[psize].penc;
54 va &= ~((1ul << mmu_psize_defs[psize].shift) - 1); 54 va &= ~((1ul << mmu_psize_defs[psize].shift) - 1);
55 va |= (0x7f >> (8 - penc)) << 12; 55 va |= penc << 12;
56 asm volatile("tlbie %0,1" : : "r" (va) : "memory"); 56 asm volatile("tlbie %0,1" : : "r" (va) : "memory");
57 break; 57 break;
58 } 58 }
@@ -74,7 +74,7 @@ static inline void __tlbiel(unsigned long va, unsigned int psize)
74 default: 74 default:
75 penc = mmu_psize_defs[psize].penc; 75 penc = mmu_psize_defs[psize].penc;
76 va &= ~((1ul << mmu_psize_defs[psize].shift) - 1); 76 va &= ~((1ul << mmu_psize_defs[psize].shift) - 1);
77 va |= (0x7f >> (8 - penc)) << 12; 77 va |= penc << 12;
78 asm volatile(".long 0x7c000224 | (%0 << 11) | (1 << 21)" 78 asm volatile(".long 0x7c000224 | (%0 << 11) | (1 << 21)"
79 : : "r"(va) : "memory"); 79 : : "r"(va) : "memory");
80 break; 80 break;
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 6574b22b3cf3..fd3e5609e3e0 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -125,14 +125,13 @@ static void __init cell_init_early(void)
125 125
126static int __init cell_probe(void) 126static int __init cell_probe(void)
127{ 127{
128 /* XXX This is temporary, the Cell maintainer will come up with
129 * more appropriate detection logic
130 */
131 unsigned long root = of_get_flat_dt_root(); 128 unsigned long root = of_get_flat_dt_root();
132 if (!of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
133 return 0;
134 129
135 return 1; 130 if (of_flat_dt_is_compatible(root, "IBM,CBEA") ||
131 of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
132 return 1;
133
134 return 0;
136} 135}
137 136
138/* 137/*
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 5f79f01c44f2..3ba87835757e 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -389,6 +389,7 @@ static int __init pSeries_probe_hypertas(unsigned long node,
389 389
390static int __init pSeries_probe(void) 390static int __init pSeries_probe(void)
391{ 391{
392 unsigned long root = of_get_flat_dt_root();
392 char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(), 393 char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(),
393 "device_type", NULL); 394 "device_type", NULL);
394 if (dtype == NULL) 395 if (dtype == NULL)
@@ -396,6 +397,13 @@ static int __init pSeries_probe(void)
396 if (strcmp(dtype, "chrp")) 397 if (strcmp(dtype, "chrp"))
397 return 0; 398 return 0;
398 399
400 /* Cell blades firmware claims to be chrp while it's not. Until this
401 * is fixed, we need to avoid those here.
402 */
403 if (of_flat_dt_is_compatible(root, "IBM,CPBW-1.0") ||
404 of_flat_dt_is_compatible(root, "IBM,CBEA"))
405 return 0;
406
399 DBG("pSeries detected, looking for LPAR capability...\n"); 407 DBG("pSeries detected, looking for LPAR capability...\n");
400 408
401 /* Now try to figure out if we are running on LPAR */ 409 /* Now try to figure out if we are running on LPAR */
diff --git a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
index a93f5da6855d..40b42c88e6a7 100644
--- a/arch/sparc/kernel/smp.c
+++ b/arch/sparc/kernel/smp.c
@@ -69,6 +69,17 @@ void __init smp_store_cpu_info(int id)
69 "clock-frequency", 0); 69 "clock-frequency", 0);
70 cpu_data(id).prom_node = cpu_node; 70 cpu_data(id).prom_node = cpu_node;
71 cpu_data(id).mid = cpu_get_hwmid(cpu_node); 71 cpu_data(id).mid = cpu_get_hwmid(cpu_node);
72
73 /* this is required to tune the scheduler correctly */
74 /* is it possible to have CPUs with different cache sizes? */
75 if (id == boot_cpu_id) {
76 int cache_line,cache_nlines;
77 cache_line = 0x20;
78 cache_line = prom_getintdefault(cpu_node, "ecache-line-size", cache_line);
79 cache_nlines = 0x8000;
80 cache_nlines = prom_getintdefault(cpu_node, "ecache-nlines", cache_nlines);
81 max_cache_size = cache_line * cache_nlines;
82 }
72 if (cpu_data(id).mid < 0) 83 if (cpu_data(id).mid < 0)
73 panic("No MID found for CPU%d at node 0x%08d", id, cpu_node); 84 panic("No MID found for CPU%d at node 0x%08d", id, cpu_node);
74} 85}
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 2b7a1f316a93..0c0895202970 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -599,18 +599,128 @@ struct pci_iommu_ops pci_sun4v_iommu_ops = {
599 599
600/* SUN4V PCI configuration space accessors. */ 600/* SUN4V PCI configuration space accessors. */
601 601
602static inline int pci_sun4v_out_of_range(struct pci_pbm_info *pbm, unsigned int bus, unsigned int device, unsigned int func) 602struct pdev_entry {
603 struct pdev_entry *next;
604 u32 devhandle;
605 unsigned int bus;
606 unsigned int device;
607 unsigned int func;
608};
609
610#define PDEV_HTAB_SIZE 16
611#define PDEV_HTAB_MASK (PDEV_HTAB_SIZE - 1)
612static struct pdev_entry *pdev_htab[PDEV_HTAB_SIZE];
613
614static inline unsigned int pdev_hashfn(u32 devhandle, unsigned int bus, unsigned int device, unsigned int func)
603{ 615{
604 if (bus == pbm->pci_first_busno) { 616 unsigned int val;
605 if (device == 0 && func == 0) 617
606 return 0; 618 val = (devhandle ^ (devhandle >> 4));
607 return 1; 619 val ^= bus;
620 val ^= device;
621 val ^= func;
622
623 return val & PDEV_HTAB_MASK;
624}
625
626static int pdev_htab_add(u32 devhandle, unsigned int bus, unsigned int device, unsigned int func)
627{
628 struct pdev_entry *p = kmalloc(sizeof(*p), GFP_KERNEL);
629 struct pdev_entry **slot;
630
631 if (!p)
632 return -ENOMEM;
633
634 slot = &pdev_htab[pdev_hashfn(devhandle, bus, device, func)];
635 p->next = *slot;
636 *slot = p;
637
638 p->devhandle = devhandle;
639 p->bus = bus;
640 p->device = device;
641 p->func = func;
642
643 return 0;
644}
645
646/* Recursively descend into the OBP device tree, rooted at toplevel_node,
647 * looking for a PCI device matching bus and devfn.
648 */
649static int obp_find(struct linux_prom_pci_registers *pregs, int toplevel_node, unsigned int bus, unsigned int devfn)
650{
651 toplevel_node = prom_getchild(toplevel_node);
652
653 while (toplevel_node != 0) {
654 int ret = obp_find(pregs, toplevel_node, bus, devfn);
655
656 if (ret != 0)
657 return ret;
658
659 ret = prom_getproperty(toplevel_node, "reg", (char *) pregs,
660 sizeof(*pregs) * PROMREG_MAX);
661 if (ret == 0 || ret == -1)
662 goto next_sibling;
663
664 if (((pregs[0].phys_hi >> 16) & 0xff) == bus &&
665 ((pregs[0].phys_hi >> 8) & 0xff) == devfn)
666 break;
667
668 next_sibling:
669 toplevel_node = prom_getsibling(toplevel_node);
670 }
671
672 return toplevel_node;
673}
674
675static int pdev_htab_populate(struct pci_pbm_info *pbm)
676{
677 struct linux_prom_pci_registers pr[PROMREG_MAX];
678 u32 devhandle = pbm->devhandle;
679 unsigned int bus;
680
681 for (bus = pbm->pci_first_busno; bus <= pbm->pci_last_busno; bus++) {
682 unsigned int devfn;
683
684 for (devfn = 0; devfn < 256; devfn++) {
685 unsigned int device = PCI_SLOT(devfn);
686 unsigned int func = PCI_FUNC(devfn);
687
688 if (obp_find(pr, pbm->prom_node, bus, devfn)) {
689 int err = pdev_htab_add(devhandle, bus,
690 device, func);
691 if (err)
692 return err;
693 }
694 }
695 }
696
697 return 0;
698}
699
700static struct pdev_entry *pdev_find(u32 devhandle, unsigned int bus, unsigned int device, unsigned int func)
701{
702 struct pdev_entry *p;
703
704 p = pdev_htab[pdev_hashfn(devhandle, bus, device, func)];
705 while (p) {
706 if (p->devhandle == devhandle &&
707 p->bus == bus &&
708 p->device == device &&
709 p->func == func)
710 break;
711
712 p = p->next;
608 } 713 }
609 714
715 return p;
716}
717
718static inline int pci_sun4v_out_of_range(struct pci_pbm_info *pbm, unsigned int bus, unsigned int device, unsigned int func)
719{
610 if (bus < pbm->pci_first_busno || 720 if (bus < pbm->pci_first_busno ||
611 bus > pbm->pci_last_busno) 721 bus > pbm->pci_last_busno)
612 return 1; 722 return 1;
613 return 0; 723 return pdev_find(pbm->devhandle, bus, device, func) == NULL;
614} 724}
615 725
616static int pci_sun4v_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, 726static int pci_sun4v_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
@@ -1063,6 +1173,8 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, int prom_node, u32
1063 1173
1064 pci_sun4v_get_bus_range(pbm); 1174 pci_sun4v_get_bus_range(pbm);
1065 pci_sun4v_iommu_init(pbm); 1175 pci_sun4v_iommu_init(pbm);
1176
1177 pdev_htab_populate(pbm);
1066} 1178}
1067 1179
1068void sun4v_pci_init(int node, char *model_name) 1180void sun4v_pci_init(int node, char *model_name)
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 4e8cd79156e0..f03d52d0b88d 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -1287,6 +1287,40 @@ int setup_profiling_timer(unsigned int multiplier)
1287 return 0; 1287 return 0;
1288} 1288}
1289 1289
1290static void __init smp_tune_scheduling(void)
1291{
1292 int instance, node;
1293 unsigned int def, smallest = ~0U;
1294
1295 def = ((tlb_type == hypervisor) ?
1296 (3 * 1024 * 1024) :
1297 (4 * 1024 * 1024));
1298
1299 instance = 0;
1300 while (!cpu_find_by_instance(instance, &node, NULL)) {
1301 unsigned int val;
1302
1303 val = prom_getintdefault(node, "ecache-size", def);
1304 if (val < smallest)
1305 smallest = val;
1306
1307 instance++;
1308 }
1309
1310 /* Any value less than 256K is nonsense. */
1311 if (smallest < (256U * 1024U))
1312 smallest = 256 * 1024;
1313
1314 max_cache_size = smallest;
1315
1316 if (smallest < 1U * 1024U * 1024U)
1317 printk(KERN_INFO "Using max_cache_size of %uKB\n",
1318 smallest / 1024U);
1319 else
1320 printk(KERN_INFO "Using max_cache_size of %uMB\n",
1321 smallest / 1024U / 1024U);
1322}
1323
1290/* Constrain the number of cpus to max_cpus. */ 1324/* Constrain the number of cpus to max_cpus. */
1291void __init smp_prepare_cpus(unsigned int max_cpus) 1325void __init smp_prepare_cpus(unsigned int max_cpus)
1292{ 1326{
@@ -1322,6 +1356,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
1322 } 1356 }
1323 1357
1324 smp_store_cpu_info(boot_cpu_id); 1358 smp_store_cpu_info(boot_cpu_id);
1359 smp_tune_scheduling();
1325} 1360}
1326 1361
1327/* Set this up early so that things like the scheduler can init 1362/* Set this up early so that things like the scheduler can init
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index 62d8a99271ea..38e569f786dd 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -297,7 +297,6 @@ EXPORT_SYMBOL(svr4_getcontext);
297EXPORT_SYMBOL(svr4_setcontext); 297EXPORT_SYMBOL(svr4_setcontext);
298EXPORT_SYMBOL(compat_sys_ioctl); 298EXPORT_SYMBOL(compat_sys_ioctl);
299EXPORT_SYMBOL(sparc32_open); 299EXPORT_SYMBOL(sparc32_open);
300EXPORT_SYMBOL(sys_close);
301#endif 300#endif
302 301
303/* Special internal versions of library functions. */ 302/* Special internal versions of library functions. */
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 2793a5d82380..563db528e031 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -1797,7 +1797,9 @@ static const char *sun4v_err_type_to_str(u32 type)
1797 }; 1797 };
1798} 1798}
1799 1799
1800static void sun4v_log_error(struct sun4v_error_entry *ent, int cpu, const char *pfx, atomic_t *ocnt) 1800extern void __show_regs(struct pt_regs * regs);
1801
1802static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent, int cpu, const char *pfx, atomic_t *ocnt)
1801{ 1803{
1802 int cnt; 1804 int cnt;
1803 1805
@@ -1830,6 +1832,8 @@ static void sun4v_log_error(struct sun4v_error_entry *ent, int cpu, const char *
1830 pfx, 1832 pfx,
1831 ent->err_raddr, ent->err_size, ent->err_cpu); 1833 ent->err_raddr, ent->err_size, ent->err_cpu);
1832 1834
1835 __show_regs(regs);
1836
1833 if ((cnt = atomic_read(ocnt)) != 0) { 1837 if ((cnt = atomic_read(ocnt)) != 0) {
1834 atomic_set(ocnt, 0); 1838 atomic_set(ocnt, 0);
1835 wmb(); 1839 wmb();
@@ -1862,7 +1866,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
1862 1866
1863 put_cpu(); 1867 put_cpu();
1864 1868
1865 sun4v_log_error(&local_copy, cpu, 1869 sun4v_log_error(regs, &local_copy, cpu,
1866 KERN_ERR "RESUMABLE ERROR", 1870 KERN_ERR "RESUMABLE ERROR",
1867 &sun4v_resum_oflow_cnt); 1871 &sun4v_resum_oflow_cnt);
1868} 1872}
@@ -1910,7 +1914,7 @@ void sun4v_nonresum_error(struct pt_regs *regs, unsigned long offset)
1910 } 1914 }
1911#endif 1915#endif
1912 1916
1913 sun4v_log_error(&local_copy, cpu, 1917 sun4v_log_error(regs, &local_copy, cpu,
1914 KERN_EMERG "NON-RESUMABLE ERROR", 1918 KERN_EMERG "NON-RESUMABLE ERROR",
1915 &sun4v_nonresum_oflow_cnt); 1919 &sun4v_nonresum_oflow_cnt);
1916 1920
@@ -2200,7 +2204,6 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
2200void die_if_kernel(char *str, struct pt_regs *regs) 2204void die_if_kernel(char *str, struct pt_regs *regs)
2201{ 2205{
2202 static int die_counter; 2206 static int die_counter;
2203 extern void __show_regs(struct pt_regs * regs);
2204 extern void smp_report_regs(void); 2207 extern void smp_report_regs(void);
2205 int count = 0; 2208 int count = 0;
2206 2209
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index a46d030e092a..052b17487625 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1323,17 +1323,12 @@ cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
1323 struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_mask); 1323 struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_mask);
1324 1324
1325 if (cic) { 1325 if (cic) {
1326 RB_CLEAR(&cic->rb_node); 1326 memset(cic, 0, sizeof(*cic));
1327 cic->key = NULL; 1327 RB_CLEAR_COLOR(&cic->rb_node);
1328 cic->cfqq[ASYNC] = NULL;
1329 cic->cfqq[SYNC] = NULL;
1330 cic->last_end_request = jiffies; 1328 cic->last_end_request = jiffies;
1331 cic->ttime_total = 0; 1329 INIT_LIST_HEAD(&cic->queue_list);
1332 cic->ttime_samples = 0;
1333 cic->ttime_mean = 0;
1334 cic->dtor = cfq_free_io_context; 1330 cic->dtor = cfq_free_io_context;
1335 cic->exit = cfq_exit_io_context; 1331 cic->exit = cfq_exit_io_context;
1336 INIT_LIST_HEAD(&cic->queue_list);
1337 atomic_inc(&ioc_count); 1332 atomic_inc(&ioc_count);
1338 } 1333 }
1339 1334
diff --git a/drivers/Kconfig b/drivers/Kconfig
index aeb5ab2391e4..8b11cebe65df 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -72,4 +72,6 @@ source "drivers/edac/Kconfig"
72 72
73source "drivers/rtc/Kconfig" 73source "drivers/rtc/Kconfig"
74 74
75source "drivers/dma/Kconfig"
76
75endmenu 77endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 447d8e68887a..3c5170310bd0 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_SGI_SN) += sn/
74obj-y += firmware/ 74obj-y += firmware/
75obj-$(CONFIG_CRYPTO) += crypto/ 75obj-$(CONFIG_CRYPTO) += crypto/
76obj-$(CONFIG_SUPERH) += sh/ 76obj-$(CONFIG_SUPERH) += sh/
77obj-$(CONFIG_DMA_ENGINE) += dma/
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 07bc6dfe662b..8920e8c6e246 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -812,6 +812,9 @@ static int irqrouter_resume(struct sys_device *dev)
812 812
813 ACPI_FUNCTION_TRACE("irqrouter_resume"); 813 ACPI_FUNCTION_TRACE("irqrouter_resume");
814 814
815 /* Make sure SCI is enabled again (Apple firmware bug?) */
816 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK);
817
815 acpi_in_resume = 1; 818 acpi_in_resume = 1;
816 list_for_each(node, &acpi_link.entries) { 819 list_for_each(node, &acpi_link.entries) {
817 link = list_entry(node, struct acpi_pci_link, node); 820 link = list_entry(node, struct acpi_pci_link, node);
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index abbdb37a7f5f..f36db22ce1ae 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -577,6 +577,8 @@ acpi_processor_register_performance(struct acpi_processor_performance
577 return_VALUE(-EBUSY); 577 return_VALUE(-EBUSY);
578 } 578 }
579 579
580 WARN_ON(!performance);
581
580 pr->performance = performance; 582 pr->performance = performance;
581 583
582 if (acpi_processor_get_performance_info(pr)) { 584 if (acpi_processor_get_performance_info(pr)) {
@@ -609,7 +611,8 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
609 return_VOID; 611 return_VOID;
610 } 612 }
611 613
612 kfree(pr->performance->states); 614 if (pr->performance)
615 kfree(pr->performance->states);
613 pr->performance = NULL; 616 pr->performance = NULL;
614 617
615 acpi_cpufreq_remove_file(pr); 618 acpi_cpufreq_remove_file(pr);
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index fdff774b8ab9..c1434ed11880 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -116,8 +116,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
116 skb = skb_share_check(skb, GFP_ATOMIC); 116 skb = skb_share_check(skb, GFP_ATOMIC);
117 if (skb == NULL) 117 if (skb == NULL)
118 return 0; 118 return 0;
119 if (skb_is_nonlinear(skb)) 119 if (skb_linearize(skb))
120 if (skb_linearize(skb, GFP_ATOMIC) < 0)
121 goto exit; 120 goto exit;
122 if (!is_aoe_netif(ifp)) 121 if (!is_aoe_netif(ifp))
123 goto exit; 122 goto exit;
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index a59876a0bfa1..3170eaa25087 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1009,9 +1009,9 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
1009 if (fp->f_mode & FMODE_WRITE) { 1009 if (fp->f_mode & FMODE_WRITE) {
1010 ret = -EROFS; 1010 ret = -EROFS;
1011 if (cdrom_open_write(cdi)) 1011 if (cdrom_open_write(cdi))
1012 goto err; 1012 goto err_release;
1013 if (!CDROM_CAN(CDC_RAM)) 1013 if (!CDROM_CAN(CDC_RAM))
1014 goto err; 1014 goto err_release;
1015 ret = 0; 1015 ret = 0;
1016 cdi->media_written = 0; 1016 cdi->media_written = 0;
1017 } 1017 }
@@ -1026,6 +1026,8 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
1026 not be mounting, but opening with O_NONBLOCK */ 1026 not be mounting, but opening with O_NONBLOCK */
1027 check_disk_change(ip->i_bdev); 1027 check_disk_change(ip->i_bdev);
1028 return 0; 1028 return 0;
1029err_release:
1030 cdi->ops->release(cdi);
1029err: 1031err:
1030 cdi->use_count--; 1032 cdi->use_count--;
1031 return ret; 1033 return ret;
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index f5b01c6d498e..fb919bfb2824 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -41,9 +41,9 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o
41obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o 41obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
42obj-$(CONFIG_SX) += sx.o generic_serial.o 42obj-$(CONFIG_SX) += sx.o generic_serial.o
43obj-$(CONFIG_RIO) += rio/ generic_serial.o 43obj-$(CONFIG_RIO) += rio/ generic_serial.o
44obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
45obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o 44obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
46obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o 45obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
46obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
47obj-$(CONFIG_RAW_DRIVER) += raw.o 47obj-$(CONFIG_RAW_DRIVER) += raw.o
48obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 48obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
49obj-$(CONFIG_MMTIMER) += mmtimer.o 49obj-$(CONFIG_MMTIMER) += mmtimer.o
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index 2b5838e64751..b4e00a343da9 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -46,12 +46,6 @@ struct vm_operations_struct alpha_core_agp_vm_ops = {
46}; 46};
47 47
48 48
49static int alpha_core_agp_nop(void)
50{
51 /* just return success */
52 return 0;
53}
54
55static int alpha_core_agp_fetch_size(void) 49static int alpha_core_agp_fetch_size(void)
56{ 50{
57 return alpha_core_agp_sizes[0].size; 51 return alpha_core_agp_sizes[0].size;
@@ -120,6 +114,11 @@ static int alpha_core_agp_remove_memory(struct agp_memory *mem, off_t pg_start,
120 return status; 114 return status;
121} 115}
122 116
117static int alpha_core_agp_create_free_gatt_table(struct agp_bridge_data *a)
118{
119 return 0;
120}
121
123struct agp_bridge_driver alpha_core_agp_driver = { 122struct agp_bridge_driver alpha_core_agp_driver = {
124 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
125 .aperture_sizes = alpha_core_agp_sizes, 124 .aperture_sizes = alpha_core_agp_sizes,
@@ -135,8 +134,8 @@ struct agp_bridge_driver alpha_core_agp_driver = {
135 .tlb_flush = alpha_core_agp_tlbflush, 134 .tlb_flush = alpha_core_agp_tlbflush,
136 .mask_memory = agp_generic_mask_memory, 135 .mask_memory = agp_generic_mask_memory,
137 .cache_flush = global_cache_flush, 136 .cache_flush = global_cache_flush,
138 .create_gatt_table = alpha_core_agp_nop, 137 .create_gatt_table = alpha_core_agp_create_free_gatt_table,
139 .free_gatt_table = alpha_core_agp_nop, 138 .free_gatt_table = alpha_core_agp_create_free_gatt_table,
140 .insert_memory = alpha_core_agp_insert_memory, 139 .insert_memory = alpha_core_agp_insert_memory,
141 .remove_memory = alpha_core_agp_remove_memory, 140 .remove_memory = alpha_core_agp_remove_memory,
142 .alloc_by_type = agp_generic_alloc_by_type, 141 .alloc_by_type = agp_generic_alloc_by_type,
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 4e1891e2c035..a92ab53a1370 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -809,12 +809,10 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
809 case U32_APER_SIZE: 809 case U32_APER_SIZE:
810 bridge->current_size = A_IDX32(bridge); 810 bridge->current_size = A_IDX32(bridge);
811 break; 811 break;
812 /* This case will never really happen. */ 812 /* These cases will never really happen. */
813 case FIXED_APER_SIZE: 813 case FIXED_APER_SIZE:
814 case LVL2_APER_SIZE: 814 case LVL2_APER_SIZE:
815 default: 815 default:
816 bridge->current_size =
817 bridge->current_size;
818 break; 816 break;
819 } 817 }
820 temp = bridge->current_size; 818 temp = bridge->current_size;
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index bddcae54b16d..61ac3809f997 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -736,7 +736,7 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
736static int intel_i915_fetch_size(void) 736static int intel_i915_fetch_size(void)
737{ 737{
738 struct aper_size_info_fixed *values; 738 struct aper_size_info_fixed *values;
739 u32 temp, offset = 0; 739 u32 temp, offset;
740 740
741#define I915_256MB_ADDRESS_MASK (1<<27) 741#define I915_256MB_ADDRESS_MASK (1<<27)
742 742
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 9846defbddb4..1de1b12043bf 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -329,7 +329,7 @@ static int agp_uninorth_suspend(struct pci_dev *pdev)
329 /* turn off AGP on the bridge */ 329 /* turn off AGP on the bridge */
330 agp = pci_find_capability(pdev, PCI_CAP_ID_AGP); 330 agp = pci_find_capability(pdev, PCI_CAP_ID_AGP);
331 pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd); 331 pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd);
332 bridge->dev_private_data = (void *)cmd; 332 bridge->dev_private_data = (void *)(long)cmd;
333 if (cmd & PCI_AGP_COMMAND_AGP) { 333 if (cmd & PCI_AGP_COMMAND_AGP) {
334 printk("uninorth-agp: disabling AGP on bridge %s\n", 334 printk("uninorth-agp: disabling AGP on bridge %s\n",
335 pci_name(pdev)); 335 pci_name(pdev));
@@ -351,7 +351,7 @@ static int agp_uninorth_resume(struct pci_dev *pdev)
351 if (bridge == NULL) 351 if (bridge == NULL)
352 return -ENODEV; 352 return -ENODEV;
353 353
354 command = (u32)bridge->dev_private_data; 354 command = (long)bridge->dev_private_data;
355 bridge->dev_private_data = NULL; 355 bridge->dev_private_data = NULL;
356 if (!(command & PCI_AGP_COMMAND_AGP)) 356 if (!(command & PCI_AGP_COMMAND_AGP))
357 return 0; 357 return 0;
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index ede365d05387..b9371d5bf790 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1384,8 +1384,10 @@ do_it_again:
1384 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, 1384 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,
1385 * we won't get any more characters. 1385 * we won't get any more characters.
1386 */ 1386 */
1387 if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) 1387 if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) {
1388 n_tty_set_room(tty);
1388 check_unthrottle(tty); 1389 check_unthrottle(tty);
1390 }
1389 1391
1390 if (b - buf >= minimum) 1392 if (b - buf >= minimum)
1391 break; 1393 break;
diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c
index 9f2f00d82917..05f8ce2cfb4a 100644
--- a/drivers/connector/cn_queue.c
+++ b/drivers/connector/cn_queue.c
@@ -127,7 +127,7 @@ void cn_queue_del_callback(struct cn_queue_dev *dev, struct cb_id *id)
127 127
128 if (found) { 128 if (found) {
129 cn_queue_free_callback(cbq); 129 cn_queue_free_callback(cbq);
130 atomic_dec_and_test(&dev->refcnt); 130 atomic_dec(&dev->refcnt);
131 } 131 }
132} 132}
133 133
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 29b2fa5534ae..44d1eca83a72 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -257,7 +257,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
257 if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { 257 if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) {
258 if ((policy) && (policy->cpu == freqs->cpu) && 258 if ((policy) && (policy->cpu == freqs->cpu) &&
259 (policy->cur) && (policy->cur != freqs->old)) { 259 (policy->cur) && (policy->cur != freqs->old)) {
260 dprintk(KERN_WARNING "Warning: CPU frequency is" 260 dprintk("Warning: CPU frequency is"
261 " %u, cpufreq assumed %u kHz.\n", 261 " %u, cpufreq assumed %u kHz.\n",
262 freqs->old, policy->cur); 262 freqs->old, policy->cur);
263 freqs->old = policy->cur; 263 freqs->old = policy->cur;
@@ -874,7 +874,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne
874{ 874{
875 struct cpufreq_freqs freqs; 875 struct cpufreq_freqs freqs;
876 876
877 dprintk(KERN_WARNING "Warning: CPU frequency out of sync: cpufreq and timing " 877 dprintk("Warning: CPU frequency out of sync: cpufreq and timing "
878 "core thinks of %u, is %u kHz.\n", old_freq, new_freq); 878 "core thinks of %u, is %u kHz.\n", old_freq, new_freq);
879 879
880 freqs.cpu = cpu; 880 freqs.cpu = cpu;
@@ -1006,7 +1006,7 @@ static int cpufreq_suspend(struct sys_device * sysdev, pm_message_t pmsg)
1006 struct cpufreq_freqs freqs; 1006 struct cpufreq_freqs freqs;
1007 1007
1008 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) 1008 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
1009 dprintk(KERN_DEBUG "Warning: CPU frequency is %u, " 1009 dprintk("Warning: CPU frequency is %u, "
1010 "cpufreq assumed %u kHz.\n", 1010 "cpufreq assumed %u kHz.\n",
1011 cur_freq, cpu_policy->cur); 1011 cur_freq, cpu_policy->cur);
1012 1012
@@ -1087,7 +1087,7 @@ static int cpufreq_resume(struct sys_device * sysdev)
1087 struct cpufreq_freqs freqs; 1087 struct cpufreq_freqs freqs;
1088 1088
1089 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) 1089 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
1090 dprintk(KERN_WARNING "Warning: CPU frequency" 1090 dprintk("Warning: CPU frequency"
1091 "is %u, cpufreq assumed %u kHz.\n", 1091 "is %u, cpufreq assumed %u kHz.\n",
1092 cur_freq, cpu_policy->cur); 1092 cur_freq, cpu_policy->cur);
1093 1093
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 9694b6ed3268..c576c0b3f452 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -74,7 +74,7 @@ static ssize_t
74show_total_trans(struct cpufreq_policy *policy, char *buf) 74show_total_trans(struct cpufreq_policy *policy, char *buf)
75{ 75{
76 struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; 76 struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu];
77 if(!stat) 77 if (!stat)
78 return 0; 78 return 0;
79 return sprintf(buf, "%d\n", 79 return sprintf(buf, "%d\n",
80 cpufreq_stats_table[stat->cpu]->total_trans); 80 cpufreq_stats_table[stat->cpu]->total_trans);
@@ -86,7 +86,7 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf)
86 ssize_t len = 0; 86 ssize_t len = 0;
87 int i; 87 int i;
88 struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; 88 struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu];
89 if(!stat) 89 if (!stat)
90 return 0; 90 return 0;
91 cpufreq_stats_update(stat->cpu); 91 cpufreq_stats_update(stat->cpu);
92 for (i = 0; i < stat->state_num; i++) { 92 for (i = 0; i < stat->state_num; i++) {
@@ -104,7 +104,7 @@ show_trans_table(struct cpufreq_policy *policy, char *buf)
104 int i, j; 104 int i, j;
105 105
106 struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu]; 106 struct cpufreq_stats *stat = cpufreq_stats_table[policy->cpu];
107 if(!stat) 107 if (!stat)
108 return 0; 108 return 0;
109 cpufreq_stats_update(stat->cpu); 109 cpufreq_stats_update(stat->cpu);
110 len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); 110 len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n");
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index a4818ce88919..551f4ccf87fd 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -20,7 +20,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
20{ 20{
21 unsigned int min_freq = ~0; 21 unsigned int min_freq = ~0;
22 unsigned int max_freq = 0; 22 unsigned int max_freq = 0;
23 unsigned int i = 0; 23 unsigned int i;
24 24
25 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { 25 for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
26 unsigned int freq = table[i].frequency; 26 unsigned int freq = table[i].frequency;
@@ -51,7 +51,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
51 struct cpufreq_frequency_table *table) 51 struct cpufreq_frequency_table *table)
52{ 52{
53 unsigned int next_larger = ~0; 53 unsigned int next_larger = ~0;
54 unsigned int i = 0; 54 unsigned int i;
55 unsigned int count = 0; 55 unsigned int count = 0;
56 56
57 dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu); 57 dprintk("request for verification of policy (%u - %u kHz) for cpu %u\n", policy->min, policy->max, policy->cpu);
@@ -91,20 +91,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
91 unsigned int relation, 91 unsigned int relation,
92 unsigned int *index) 92 unsigned int *index)
93{ 93{
94 struct cpufreq_frequency_table optimal = { .index = ~0, }; 94 struct cpufreq_frequency_table optimal = {
95 struct cpufreq_frequency_table suboptimal = { .index = ~0, }; 95 .index = ~0,
96 .frequency = 0,
97 };
98 struct cpufreq_frequency_table suboptimal = {
99 .index = ~0,
100 .frequency = 0,
101 };
96 unsigned int i; 102 unsigned int i;
97 103
98 dprintk("request for target %u kHz (relation: %u) for cpu %u\n", target_freq, relation, policy->cpu); 104 dprintk("request for target %u kHz (relation: %u) for cpu %u\n", target_freq, relation, policy->cpu);
99 105
100 switch (relation) { 106 switch (relation) {
101 case CPUFREQ_RELATION_H: 107 case CPUFREQ_RELATION_H:
102 optimal.frequency = 0;
103 suboptimal.frequency = ~0; 108 suboptimal.frequency = ~0;
104 break; 109 break;
105 case CPUFREQ_RELATION_L: 110 case CPUFREQ_RELATION_L:
106 optimal.frequency = ~0; 111 optimal.frequency = ~0;
107 suboptimal.frequency = 0;
108 break; 112 break;
109 } 113 }
110 114
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
new file mode 100644
index 000000000000..30d021d1a07c
--- /dev/null
+++ b/drivers/dma/Kconfig
@@ -0,0 +1,34 @@
1#
2# DMA engine configuration
3#
4
5menu "DMA Engine support"
6
7config DMA_ENGINE
8 bool "Support for DMA engines"
9 ---help---
10 DMA engines offload copy operations from the CPU to dedicated
11 hardware, allowing the copies to happen asynchronously.
12
13comment "DMA Clients"
14
15config NET_DMA
16 bool "Network: TCP receive copy offload"
17 depends on DMA_ENGINE && NET
18 default y
19 ---help---
20 This enables the use of DMA engines in the network stack to
21 offload receive copy-to-user operations, freeing CPU cycles.
22 Since this is the main user of the DMA engine, it should be enabled;
23 say Y here.
24
25comment "DMA Devices"
26
27config INTEL_IOATDMA
28 tristate "Intel I/OAT DMA support"
29 depends on DMA_ENGINE && PCI
30 default m
31 ---help---
32 Enable support for the Intel(R) I/OAT DMA engine.
33
34endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
new file mode 100644
index 000000000000..bdcfdbdb1aec
--- /dev/null
+++ b/drivers/dma/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
2obj-$(CONFIG_NET_DMA) += iovlock.o
3obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
new file mode 100644
index 000000000000..5829143558e1
--- /dev/null
+++ b/drivers/dma/dmaengine.c
@@ -0,0 +1,408 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21
22/*
23 * This code implements the DMA subsystem. It provides a HW-neutral interface
24 * for other kernel code to use asynchronous memory copy capabilities,
25 * if present, and allows different HW DMA drivers to register as providing
26 * this capability.
27 *
28 * Due to the fact we are accelerating what is already a relatively fast
29 * operation, the code goes to great lengths to avoid additional overhead,
30 * such as locking.
31 *
32 * LOCKING:
33 *
34 * The subsystem keeps two global lists, dma_device_list and dma_client_list.
35 * Both of these are protected by a mutex, dma_list_mutex.
36 *
37 * Each device has a channels list, which runs unlocked but is never modified
38 * once the device is registered, it's just setup by the driver.
39 *
40 * Each client has a channels list, it's only modified under the client->lock
41 * and in an RCU callback, so it's safe to read under rcu_read_lock().
42 *
43 * Each device has a kref, which is initialized to 1 when the device is
44 * registered. A kref_put is done for each class_device registered. When the
45 * class_device is released, the coresponding kref_put is done in the release
46 * method. Every time one of the device's channels is allocated to a client,
47 * a kref_get occurs. When the channel is freed, the coresponding kref_put
48 * happens. The device's release function does a completion, so
49 * unregister_device does a remove event, class_device_unregister, a kref_put
50 * for the first reference, then waits on the completion for all other
51 * references to finish.
52 *
53 * Each channel has an open-coded implementation of Rusty Russell's "bigref,"
54 * with a kref and a per_cpu local_t. A single reference is set when on an
55 * ADDED event, and removed with a REMOVE event. Net DMA client takes an
56 * extra reference per outstanding transaction. The relase function does a
57 * kref_put on the device. -ChrisL
58 */
59
60#include <linux/init.h>
61#include <linux/module.h>
62#include <linux/device.h>
63#include <linux/dmaengine.h>
64#include <linux/hardirq.h>
65#include <linux/spinlock.h>
66#include <linux/percpu.h>
67#include <linux/rcupdate.h>
68#include <linux/mutex.h>
69
70static DEFINE_MUTEX(dma_list_mutex);
71static LIST_HEAD(dma_device_list);
72static LIST_HEAD(dma_client_list);
73
74/* --- sysfs implementation --- */
75
76static ssize_t show_memcpy_count(struct class_device *cd, char *buf)
77{
78 struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
79 unsigned long count = 0;
80 int i;
81
82 for_each_possible_cpu(i)
83 count += per_cpu_ptr(chan->local, i)->memcpy_count;
84
85 return sprintf(buf, "%lu\n", count);
86}
87
88static ssize_t show_bytes_transferred(struct class_device *cd, char *buf)
89{
90 struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
91 unsigned long count = 0;
92 int i;
93
94 for_each_possible_cpu(i)
95 count += per_cpu_ptr(chan->local, i)->bytes_transferred;
96
97 return sprintf(buf, "%lu\n", count);
98}
99
100static ssize_t show_in_use(struct class_device *cd, char *buf)
101{
102 struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
103
104 return sprintf(buf, "%d\n", (chan->client ? 1 : 0));
105}
106
107static struct class_device_attribute dma_class_attrs[] = {
108 __ATTR(memcpy_count, S_IRUGO, show_memcpy_count, NULL),
109 __ATTR(bytes_transferred, S_IRUGO, show_bytes_transferred, NULL),
110 __ATTR(in_use, S_IRUGO, show_in_use, NULL),
111 __ATTR_NULL
112};
113
114static void dma_async_device_cleanup(struct kref *kref);
115
116static void dma_class_dev_release(struct class_device *cd)
117{
118 struct dma_chan *chan = container_of(cd, struct dma_chan, class_dev);
119 kref_put(&chan->device->refcount, dma_async_device_cleanup);
120}
121
122static struct class dma_devclass = {
123 .name = "dma",
124 .class_dev_attrs = dma_class_attrs,
125 .release = dma_class_dev_release,
126};
127
128/* --- client and device registration --- */
129
130/**
131 * dma_client_chan_alloc - try to allocate a channel to a client
132 * @client: &dma_client
133 *
134 * Called with dma_list_mutex held.
135 */
136static struct dma_chan *dma_client_chan_alloc(struct dma_client *client)
137{
138 struct dma_device *device;
139 struct dma_chan *chan;
140 unsigned long flags;
141 int desc; /* allocated descriptor count */
142
143 /* Find a channel, any DMA engine will do */
144 list_for_each_entry(device, &dma_device_list, global_node) {
145 list_for_each_entry(chan, &device->channels, device_node) {
146 if (chan->client)
147 continue;
148
149 desc = chan->device->device_alloc_chan_resources(chan);
150 if (desc >= 0) {
151 kref_get(&device->refcount);
152 kref_init(&chan->refcount);
153 chan->slow_ref = 0;
154 INIT_RCU_HEAD(&chan->rcu);
155 chan->client = client;
156 spin_lock_irqsave(&client->lock, flags);
157 list_add_tail_rcu(&chan->client_node,
158 &client->channels);
159 spin_unlock_irqrestore(&client->lock, flags);
160 return chan;
161 }
162 }
163 }
164
165 return NULL;
166}
167
168/**
169 * dma_client_chan_free - release a DMA channel
170 * @chan: &dma_chan
171 */
172void dma_chan_cleanup(struct kref *kref)
173{
174 struct dma_chan *chan = container_of(kref, struct dma_chan, refcount);
175 chan->device->device_free_chan_resources(chan);
176 chan->client = NULL;
177 kref_put(&chan->device->refcount, dma_async_device_cleanup);
178}
179
180static void dma_chan_free_rcu(struct rcu_head *rcu)
181{
182 struct dma_chan *chan = container_of(rcu, struct dma_chan, rcu);
183 int bias = 0x7FFFFFFF;
184 int i;
185 for_each_possible_cpu(i)
186 bias -= local_read(&per_cpu_ptr(chan->local, i)->refcount);
187 atomic_sub(bias, &chan->refcount.refcount);
188 kref_put(&chan->refcount, dma_chan_cleanup);
189}
190
191static void dma_client_chan_free(struct dma_chan *chan)
192{
193 atomic_add(0x7FFFFFFF, &chan->refcount.refcount);
194 chan->slow_ref = 1;
195 call_rcu(&chan->rcu, dma_chan_free_rcu);
196}
197
198/**
199 * dma_chans_rebalance - reallocate channels to clients
200 *
201 * When the number of DMA channel in the system changes,
202 * channels need to be rebalanced among clients
203 */
204static void dma_chans_rebalance(void)
205{
206 struct dma_client *client;
207 struct dma_chan *chan;
208 unsigned long flags;
209
210 mutex_lock(&dma_list_mutex);
211
212 list_for_each_entry(client, &dma_client_list, global_node) {
213 while (client->chans_desired > client->chan_count) {
214 chan = dma_client_chan_alloc(client);
215 if (!chan)
216 break;
217 client->chan_count++;
218 client->event_callback(client,
219 chan,
220 DMA_RESOURCE_ADDED);
221 }
222 while (client->chans_desired < client->chan_count) {
223 spin_lock_irqsave(&client->lock, flags);
224 chan = list_entry(client->channels.next,
225 struct dma_chan,
226 client_node);
227 list_del_rcu(&chan->client_node);
228 spin_unlock_irqrestore(&client->lock, flags);
229 client->chan_count--;
230 client->event_callback(client,
231 chan,
232 DMA_RESOURCE_REMOVED);
233 dma_client_chan_free(chan);
234 }
235 }
236
237 mutex_unlock(&dma_list_mutex);
238}
239
240/**
241 * dma_async_client_register - allocate and register a &dma_client
242 * @event_callback: callback for notification of channel addition/removal
243 */
244struct dma_client *dma_async_client_register(dma_event_callback event_callback)
245{
246 struct dma_client *client;
247
248 client = kzalloc(sizeof(*client), GFP_KERNEL);
249 if (!client)
250 return NULL;
251
252 INIT_LIST_HEAD(&client->channels);
253 spin_lock_init(&client->lock);
254 client->chans_desired = 0;
255 client->chan_count = 0;
256 client->event_callback = event_callback;
257
258 mutex_lock(&dma_list_mutex);
259 list_add_tail(&client->global_node, &dma_client_list);
260 mutex_unlock(&dma_list_mutex);
261
262 return client;
263}
264
265/**
266 * dma_async_client_unregister - unregister a client and free the &dma_client
267 * @client:
268 *
269 * Force frees any allocated DMA channels, frees the &dma_client memory
270 */
271void dma_async_client_unregister(struct dma_client *client)
272{
273 struct dma_chan *chan;
274
275 if (!client)
276 return;
277
278 rcu_read_lock();
279 list_for_each_entry_rcu(chan, &client->channels, client_node)
280 dma_client_chan_free(chan);
281 rcu_read_unlock();
282
283 mutex_lock(&dma_list_mutex);
284 list_del(&client->global_node);
285 mutex_unlock(&dma_list_mutex);
286
287 kfree(client);
288 dma_chans_rebalance();
289}
290
291/**
292 * dma_async_client_chan_request - request DMA channels
293 * @client: &dma_client
294 * @number: count of DMA channels requested
295 *
296 * Clients call dma_async_client_chan_request() to specify how many
297 * DMA channels they need, 0 to free all currently allocated.
298 * The resulting allocations/frees are indicated to the client via the
299 * event callback.
300 */
301void dma_async_client_chan_request(struct dma_client *client,
302 unsigned int number)
303{
304 client->chans_desired = number;
305 dma_chans_rebalance();
306}
307
308/**
309 * dma_async_device_register -
310 * @device: &dma_device
311 */
312int dma_async_device_register(struct dma_device *device)
313{
314 static int id;
315 int chancnt = 0;
316 struct dma_chan* chan;
317
318 if (!device)
319 return -ENODEV;
320
321 init_completion(&device->done);
322 kref_init(&device->refcount);
323 device->dev_id = id++;
324
325 /* represent channels in sysfs. Probably want devs too */
326 list_for_each_entry(chan, &device->channels, device_node) {
327 chan->local = alloc_percpu(typeof(*chan->local));
328 if (chan->local == NULL)
329 continue;
330
331 chan->chan_id = chancnt++;
332 chan->class_dev.class = &dma_devclass;
333 chan->class_dev.dev = NULL;
334 snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d",
335 device->dev_id, chan->chan_id);
336
337 kref_get(&device->refcount);
338 class_device_register(&chan->class_dev);
339 }
340
341 mutex_lock(&dma_list_mutex);
342 list_add_tail(&device->global_node, &dma_device_list);
343 mutex_unlock(&dma_list_mutex);
344
345 dma_chans_rebalance();
346
347 return 0;
348}
349
350/**
351 * dma_async_device_unregister -
352 * @device: &dma_device
353 */
354static void dma_async_device_cleanup(struct kref *kref)
355{
356 struct dma_device *device;
357
358 device = container_of(kref, struct dma_device, refcount);
359 complete(&device->done);
360}
361
362void dma_async_device_unregister(struct dma_device* device)
363{
364 struct dma_chan *chan;
365 unsigned long flags;
366
367 mutex_lock(&dma_list_mutex);
368 list_del(&device->global_node);
369 mutex_unlock(&dma_list_mutex);
370
371 list_for_each_entry(chan, &device->channels, device_node) {
372 if (chan->client) {
373 spin_lock_irqsave(&chan->client->lock, flags);
374 list_del(&chan->client_node);
375 chan->client->chan_count--;
376 spin_unlock_irqrestore(&chan->client->lock, flags);
377 chan->client->event_callback(chan->client,
378 chan,
379 DMA_RESOURCE_REMOVED);
380 dma_client_chan_free(chan);
381 }
382 class_device_unregister(&chan->class_dev);
383 }
384 dma_chans_rebalance();
385
386 kref_put(&device->refcount, dma_async_device_cleanup);
387 wait_for_completion(&device->done);
388}
389
390static int __init dma_bus_init(void)
391{
392 mutex_init(&dma_list_mutex);
393 return class_register(&dma_devclass);
394}
395
396subsys_initcall(dma_bus_init);
397
398EXPORT_SYMBOL(dma_async_client_register);
399EXPORT_SYMBOL(dma_async_client_unregister);
400EXPORT_SYMBOL(dma_async_client_chan_request);
401EXPORT_SYMBOL(dma_async_memcpy_buf_to_buf);
402EXPORT_SYMBOL(dma_async_memcpy_buf_to_pg);
403EXPORT_SYMBOL(dma_async_memcpy_pg_to_pg);
404EXPORT_SYMBOL(dma_async_memcpy_complete);
405EXPORT_SYMBOL(dma_async_memcpy_issue_pending);
406EXPORT_SYMBOL(dma_async_device_register);
407EXPORT_SYMBOL(dma_async_device_unregister);
408EXPORT_SYMBOL(dma_chan_cleanup);
diff --git a/drivers/dma/ioatdma.c b/drivers/dma/ioatdma.c
new file mode 100644
index 000000000000..0fdf7fbd6495
--- /dev/null
+++ b/drivers/dma/ioatdma.c
@@ -0,0 +1,840 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21
22/*
23 * This driver supports an Intel I/OAT DMA engine, which does asynchronous
24 * copy operations.
25 */
26
27#include <linux/init.h>
28#include <linux/module.h>
29#include <linux/pci.h>
30#include <linux/interrupt.h>
31#include <linux/dmaengine.h>
32#include <linux/delay.h>
33#include <linux/dma-mapping.h>
34#include "ioatdma.h"
35#include "ioatdma_io.h"
36#include "ioatdma_registers.h"
37#include "ioatdma_hw.h"
38
39#define to_ioat_chan(chan) container_of(chan, struct ioat_dma_chan, common)
40#define to_ioat_device(dev) container_of(dev, struct ioat_device, common)
41#define to_ioat_desc(lh) container_of(lh, struct ioat_desc_sw, node)
42
43/* internal functions */
44static int __devinit ioat_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
45static void __devexit ioat_remove(struct pci_dev *pdev);
46
47static int enumerate_dma_channels(struct ioat_device *device)
48{
49 u8 xfercap_scale;
50 u32 xfercap;
51 int i;
52 struct ioat_dma_chan *ioat_chan;
53
54 device->common.chancnt = ioatdma_read8(device, IOAT_CHANCNT_OFFSET);
55 xfercap_scale = ioatdma_read8(device, IOAT_XFERCAP_OFFSET);
56 xfercap = (xfercap_scale == 0 ? -1 : (1UL << xfercap_scale));
57
58 for (i = 0; i < device->common.chancnt; i++) {
59 ioat_chan = kzalloc(sizeof(*ioat_chan), GFP_KERNEL);
60 if (!ioat_chan) {
61 device->common.chancnt = i;
62 break;
63 }
64
65 ioat_chan->device = device;
66 ioat_chan->reg_base = device->reg_base + (0x80 * (i + 1));
67 ioat_chan->xfercap = xfercap;
68 spin_lock_init(&ioat_chan->cleanup_lock);
69 spin_lock_init(&ioat_chan->desc_lock);
70 INIT_LIST_HEAD(&ioat_chan->free_desc);
71 INIT_LIST_HEAD(&ioat_chan->used_desc);
72 /* This should be made common somewhere in dmaengine.c */
73 ioat_chan->common.device = &device->common;
74 ioat_chan->common.client = NULL;
75 list_add_tail(&ioat_chan->common.device_node,
76 &device->common.channels);
77 }
78 return device->common.chancnt;
79}
80
81static struct ioat_desc_sw *ioat_dma_alloc_descriptor(
82 struct ioat_dma_chan *ioat_chan,
83 int flags)
84{
85 struct ioat_dma_descriptor *desc;
86 struct ioat_desc_sw *desc_sw;
87 struct ioat_device *ioat_device;
88 dma_addr_t phys;
89
90 ioat_device = to_ioat_device(ioat_chan->common.device);
91 desc = pci_pool_alloc(ioat_device->dma_pool, flags, &phys);
92 if (unlikely(!desc))
93 return NULL;
94
95 desc_sw = kzalloc(sizeof(*desc_sw), flags);
96 if (unlikely(!desc_sw)) {
97 pci_pool_free(ioat_device->dma_pool, desc, phys);
98 return NULL;
99 }
100
101 memset(desc, 0, sizeof(*desc));
102 desc_sw->hw = desc;
103 desc_sw->phys = phys;
104
105 return desc_sw;
106}
107
108#define INITIAL_IOAT_DESC_COUNT 128
109
110static void ioat_start_null_desc(struct ioat_dma_chan *ioat_chan);
111
112/* returns the actual number of allocated descriptors */
113static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
114{
115 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
116 struct ioat_desc_sw *desc = NULL;
117 u16 chanctrl;
118 u32 chanerr;
119 int i;
120 LIST_HEAD(tmp_list);
121
122 /*
123 * In-use bit automatically set by reading chanctrl
124 * If 0, we got it, if 1, someone else did
125 */
126 chanctrl = ioatdma_chan_read16(ioat_chan, IOAT_CHANCTRL_OFFSET);
127 if (chanctrl & IOAT_CHANCTRL_CHANNEL_IN_USE)
128 return -EBUSY;
129
130 /* Setup register to interrupt and write completion status on error */
131 chanctrl = IOAT_CHANCTRL_CHANNEL_IN_USE |
132 IOAT_CHANCTRL_ERR_INT_EN |
133 IOAT_CHANCTRL_ANY_ERR_ABORT_EN |
134 IOAT_CHANCTRL_ERR_COMPLETION_EN;
135 ioatdma_chan_write16(ioat_chan, IOAT_CHANCTRL_OFFSET, chanctrl);
136
137 chanerr = ioatdma_chan_read32(ioat_chan, IOAT_CHANERR_OFFSET);
138 if (chanerr) {
139 printk("IOAT: CHANERR = %x, clearing\n", chanerr);
140 ioatdma_chan_write32(ioat_chan, IOAT_CHANERR_OFFSET, chanerr);
141 }
142
143 /* Allocate descriptors */
144 for (i = 0; i < INITIAL_IOAT_DESC_COUNT; i++) {
145 desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_KERNEL);
146 if (!desc) {
147 printk(KERN_ERR "IOAT: Only %d initial descriptors\n", i);
148 break;
149 }
150 list_add_tail(&desc->node, &tmp_list);
151 }
152 spin_lock_bh(&ioat_chan->desc_lock);
153 list_splice(&tmp_list, &ioat_chan->free_desc);
154 spin_unlock_bh(&ioat_chan->desc_lock);
155
156 /* allocate a completion writeback area */
157 /* doing 2 32bit writes to mmio since 1 64b write doesn't work */
158 ioat_chan->completion_virt =
159 pci_pool_alloc(ioat_chan->device->completion_pool,
160 GFP_KERNEL,
161 &ioat_chan->completion_addr);
162 memset(ioat_chan->completion_virt, 0,
163 sizeof(*ioat_chan->completion_virt));
164 ioatdma_chan_write32(ioat_chan, IOAT_CHANCMP_OFFSET_LOW,
165 ((u64) ioat_chan->completion_addr) & 0x00000000FFFFFFFF);
166 ioatdma_chan_write32(ioat_chan, IOAT_CHANCMP_OFFSET_HIGH,
167 ((u64) ioat_chan->completion_addr) >> 32);
168
169 ioat_start_null_desc(ioat_chan);
170 return i;
171}
172
173static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan);
174
175static void ioat_dma_free_chan_resources(struct dma_chan *chan)
176{
177 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
178 struct ioat_device *ioat_device = to_ioat_device(chan->device);
179 struct ioat_desc_sw *desc, *_desc;
180 u16 chanctrl;
181 int in_use_descs = 0;
182
183 ioat_dma_memcpy_cleanup(ioat_chan);
184
185 ioatdma_chan_write8(ioat_chan, IOAT_CHANCMD_OFFSET, IOAT_CHANCMD_RESET);
186
187 spin_lock_bh(&ioat_chan->desc_lock);
188 list_for_each_entry_safe(desc, _desc, &ioat_chan->used_desc, node) {
189 in_use_descs++;
190 list_del(&desc->node);
191 pci_pool_free(ioat_device->dma_pool, desc->hw, desc->phys);
192 kfree(desc);
193 }
194 list_for_each_entry_safe(desc, _desc, &ioat_chan->free_desc, node) {
195 list_del(&desc->node);
196 pci_pool_free(ioat_device->dma_pool, desc->hw, desc->phys);
197 kfree(desc);
198 }
199 spin_unlock_bh(&ioat_chan->desc_lock);
200
201 pci_pool_free(ioat_device->completion_pool,
202 ioat_chan->completion_virt,
203 ioat_chan->completion_addr);
204
205 /* one is ok since we left it on there on purpose */
206 if (in_use_descs > 1)
207 printk(KERN_ERR "IOAT: Freeing %d in use descriptors!\n",
208 in_use_descs - 1);
209
210 ioat_chan->last_completion = ioat_chan->completion_addr = 0;
211
212 /* Tell hw the chan is free */
213 chanctrl = ioatdma_chan_read16(ioat_chan, IOAT_CHANCTRL_OFFSET);
214 chanctrl &= ~IOAT_CHANCTRL_CHANNEL_IN_USE;
215 ioatdma_chan_write16(ioat_chan, IOAT_CHANCTRL_OFFSET, chanctrl);
216}
217
218/**
219 * do_ioat_dma_memcpy - actual function that initiates a IOAT DMA transaction
220 * @chan: IOAT DMA channel handle
221 * @dest: DMA destination address
222 * @src: DMA source address
223 * @len: transaction length in bytes
224 */
225
226static dma_cookie_t do_ioat_dma_memcpy(struct ioat_dma_chan *ioat_chan,
227 dma_addr_t dest,
228 dma_addr_t src,
229 size_t len)
230{
231 struct ioat_desc_sw *first;
232 struct ioat_desc_sw *prev;
233 struct ioat_desc_sw *new;
234 dma_cookie_t cookie;
235 LIST_HEAD(new_chain);
236 u32 copy;
237 size_t orig_len;
238 dma_addr_t orig_src, orig_dst;
239 unsigned int desc_count = 0;
240 unsigned int append = 0;
241
242 if (!ioat_chan || !dest || !src)
243 return -EFAULT;
244
245 if (!len)
246 return ioat_chan->common.cookie;
247
248 orig_len = len;
249 orig_src = src;
250 orig_dst = dest;
251
252 first = NULL;
253 prev = NULL;
254
255 spin_lock_bh(&ioat_chan->desc_lock);
256
257 while (len) {
258 if (!list_empty(&ioat_chan->free_desc)) {
259 new = to_ioat_desc(ioat_chan->free_desc.next);
260 list_del(&new->node);
261 } else {
262 /* try to get another desc */
263 new = ioat_dma_alloc_descriptor(ioat_chan, GFP_ATOMIC);
264 /* will this ever happen? */
265 /* TODO add upper limit on these */
266 BUG_ON(!new);
267 }
268
269 copy = min((u32) len, ioat_chan->xfercap);
270
271 new->hw->size = copy;
272 new->hw->ctl = 0;
273 new->hw->src_addr = src;
274 new->hw->dst_addr = dest;
275 new->cookie = 0;
276
277 /* chain together the physical address list for the HW */
278 if (!first)
279 first = new;
280 else
281 prev->hw->next = (u64) new->phys;
282
283 prev = new;
284
285 len -= copy;
286 dest += copy;
287 src += copy;
288
289 list_add_tail(&new->node, &new_chain);
290 desc_count++;
291 }
292 new->hw->ctl = IOAT_DMA_DESCRIPTOR_CTL_CP_STS;
293 new->hw->next = 0;
294
295 /* cookie incr and addition to used_list must be atomic */
296
297 cookie = ioat_chan->common.cookie;
298 cookie++;
299 if (cookie < 0)
300 cookie = 1;
301 ioat_chan->common.cookie = new->cookie = cookie;
302
303 pci_unmap_addr_set(new, src, orig_src);
304 pci_unmap_addr_set(new, dst, orig_dst);
305 pci_unmap_len_set(new, src_len, orig_len);
306 pci_unmap_len_set(new, dst_len, orig_len);
307
308 /* write address into NextDescriptor field of last desc in chain */
309 to_ioat_desc(ioat_chan->used_desc.prev)->hw->next = first->phys;
310 list_splice_init(&new_chain, ioat_chan->used_desc.prev);
311
312 ioat_chan->pending += desc_count;
313 if (ioat_chan->pending >= 20) {
314 append = 1;
315 ioat_chan->pending = 0;
316 }
317
318 spin_unlock_bh(&ioat_chan->desc_lock);
319
320 if (append)
321 ioatdma_chan_write8(ioat_chan,
322 IOAT_CHANCMD_OFFSET,
323 IOAT_CHANCMD_APPEND);
324 return cookie;
325}
326
327/**
328 * ioat_dma_memcpy_buf_to_buf - wrapper that takes src & dest bufs
329 * @chan: IOAT DMA channel handle
330 * @dest: DMA destination address
331 * @src: DMA source address
332 * @len: transaction length in bytes
333 */
334
335static dma_cookie_t ioat_dma_memcpy_buf_to_buf(struct dma_chan *chan,
336 void *dest,
337 void *src,
338 size_t len)
339{
340 dma_addr_t dest_addr;
341 dma_addr_t src_addr;
342 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
343
344 dest_addr = pci_map_single(ioat_chan->device->pdev,
345 dest, len, PCI_DMA_FROMDEVICE);
346 src_addr = pci_map_single(ioat_chan->device->pdev,
347 src, len, PCI_DMA_TODEVICE);
348
349 return do_ioat_dma_memcpy(ioat_chan, dest_addr, src_addr, len);
350}
351
352/**
353 * ioat_dma_memcpy_buf_to_pg - wrapper, copying from a buf to a page
354 * @chan: IOAT DMA channel handle
355 * @page: pointer to the page to copy to
356 * @offset: offset into that page
357 * @src: DMA source address
358 * @len: transaction length in bytes
359 */
360
361static dma_cookie_t ioat_dma_memcpy_buf_to_pg(struct dma_chan *chan,
362 struct page *page,
363 unsigned int offset,
364 void *src,
365 size_t len)
366{
367 dma_addr_t dest_addr;
368 dma_addr_t src_addr;
369 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
370
371 dest_addr = pci_map_page(ioat_chan->device->pdev,
372 page, offset, len, PCI_DMA_FROMDEVICE);
373 src_addr = pci_map_single(ioat_chan->device->pdev,
374 src, len, PCI_DMA_TODEVICE);
375
376 return do_ioat_dma_memcpy(ioat_chan, dest_addr, src_addr, len);
377}
378
379/**
380 * ioat_dma_memcpy_pg_to_pg - wrapper, copying between two pages
381 * @chan: IOAT DMA channel handle
382 * @dest_pg: pointer to the page to copy to
383 * @dest_off: offset into that page
384 * @src_pg: pointer to the page to copy from
385 * @src_off: offset into that page
386 * @len: transaction length in bytes. This is guaranteed to not make a copy
387 * across a page boundary.
388 */
389
390static dma_cookie_t ioat_dma_memcpy_pg_to_pg(struct dma_chan *chan,
391 struct page *dest_pg,
392 unsigned int dest_off,
393 struct page *src_pg,
394 unsigned int src_off,
395 size_t len)
396{
397 dma_addr_t dest_addr;
398 dma_addr_t src_addr;
399 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
400
401 dest_addr = pci_map_page(ioat_chan->device->pdev,
402 dest_pg, dest_off, len, PCI_DMA_FROMDEVICE);
403 src_addr = pci_map_page(ioat_chan->device->pdev,
404 src_pg, src_off, len, PCI_DMA_TODEVICE);
405
406 return do_ioat_dma_memcpy(ioat_chan, dest_addr, src_addr, len);
407}
408
409/**
410 * ioat_dma_memcpy_issue_pending - push potentially unrecognoized appended descriptors to hw
411 * @chan: DMA channel handle
412 */
413
414static void ioat_dma_memcpy_issue_pending(struct dma_chan *chan)
415{
416 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
417
418 if (ioat_chan->pending != 0) {
419 ioat_chan->pending = 0;
420 ioatdma_chan_write8(ioat_chan,
421 IOAT_CHANCMD_OFFSET,
422 IOAT_CHANCMD_APPEND);
423 }
424}
425
426static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *chan)
427{
428 unsigned long phys_complete;
429 struct ioat_desc_sw *desc, *_desc;
430 dma_cookie_t cookie = 0;
431
432 prefetch(chan->completion_virt);
433
434 if (!spin_trylock(&chan->cleanup_lock))
435 return;
436
437 /* The completion writeback can happen at any time,
438 so reads by the driver need to be atomic operations
439 The descriptor physical addresses are limited to 32-bits
440 when the CPU can only do a 32-bit mov */
441
442#if (BITS_PER_LONG == 64)
443 phys_complete =
444 chan->completion_virt->full & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_ADDR;
445#else
446 phys_complete = chan->completion_virt->low & IOAT_LOW_COMPLETION_MASK;
447#endif
448
449 if ((chan->completion_virt->full & IOAT_CHANSTS_DMA_TRANSFER_STATUS) ==
450 IOAT_CHANSTS_DMA_TRANSFER_STATUS_HALTED) {
451 printk("IOAT: Channel halted, chanerr = %x\n",
452 ioatdma_chan_read32(chan, IOAT_CHANERR_OFFSET));
453
454 /* TODO do something to salvage the situation */
455 }
456
457 if (phys_complete == chan->last_completion) {
458 spin_unlock(&chan->cleanup_lock);
459 return;
460 }
461
462 spin_lock_bh(&chan->desc_lock);
463 list_for_each_entry_safe(desc, _desc, &chan->used_desc, node) {
464
465 /*
466 * Incoming DMA requests may use multiple descriptors, due to
467 * exceeding xfercap, perhaps. If so, only the last one will
468 * have a cookie, and require unmapping.
469 */
470 if (desc->cookie) {
471 cookie = desc->cookie;
472
473 /* yes we are unmapping both _page and _single alloc'd
474 regions with unmap_page. Is this *really* that bad?
475 */
476 pci_unmap_page(chan->device->pdev,
477 pci_unmap_addr(desc, dst),
478 pci_unmap_len(desc, dst_len),
479 PCI_DMA_FROMDEVICE);
480 pci_unmap_page(chan->device->pdev,
481 pci_unmap_addr(desc, src),
482 pci_unmap_len(desc, src_len),
483 PCI_DMA_TODEVICE);
484 }
485
486 if (desc->phys != phys_complete) {
487 /* a completed entry, but not the last, so cleanup */
488 list_del(&desc->node);
489 list_add_tail(&desc->node, &chan->free_desc);
490 } else {
491 /* last used desc. Do not remove, so we can append from
492 it, but don't look at it next time, either */
493 desc->cookie = 0;
494
495 /* TODO check status bits? */
496 break;
497 }
498 }
499
500 spin_unlock_bh(&chan->desc_lock);
501
502 chan->last_completion = phys_complete;
503 if (cookie != 0)
504 chan->completed_cookie = cookie;
505
506 spin_unlock(&chan->cleanup_lock);
507}
508
509/**
510 * ioat_dma_is_complete - poll the status of a IOAT DMA transaction
511 * @chan: IOAT DMA channel handle
512 * @cookie: DMA transaction identifier
513 */
514
515static enum dma_status ioat_dma_is_complete(struct dma_chan *chan,
516 dma_cookie_t cookie,
517 dma_cookie_t *done,
518 dma_cookie_t *used)
519{
520 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
521 dma_cookie_t last_used;
522 dma_cookie_t last_complete;
523 enum dma_status ret;
524
525 last_used = chan->cookie;
526 last_complete = ioat_chan->completed_cookie;
527
528 if (done)
529 *done= last_complete;
530 if (used)
531 *used = last_used;
532
533 ret = dma_async_is_complete(cookie, last_complete, last_used);
534 if (ret == DMA_SUCCESS)
535 return ret;
536
537 ioat_dma_memcpy_cleanup(ioat_chan);
538
539 last_used = chan->cookie;
540 last_complete = ioat_chan->completed_cookie;
541
542 if (done)
543 *done= last_complete;
544 if (used)
545 *used = last_used;
546
547 return dma_async_is_complete(cookie, last_complete, last_used);
548}
549
550/* PCI API */
551
552static struct pci_device_id ioat_pci_tbl[] = {
553 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT) },
554 { 0, }
555};
556
557static struct pci_driver ioat_pci_drv = {
558 .name = "ioatdma",
559 .id_table = ioat_pci_tbl,
560 .probe = ioat_probe,
561 .remove = __devexit_p(ioat_remove),
562};
563
564static irqreturn_t ioat_do_interrupt(int irq, void *data, struct pt_regs *regs)
565{
566 struct ioat_device *instance = data;
567 unsigned long attnstatus;
568 u8 intrctrl;
569
570 intrctrl = ioatdma_read8(instance, IOAT_INTRCTRL_OFFSET);
571
572 if (!(intrctrl & IOAT_INTRCTRL_MASTER_INT_EN))
573 return IRQ_NONE;
574
575 if (!(intrctrl & IOAT_INTRCTRL_INT_STATUS)) {
576 ioatdma_write8(instance, IOAT_INTRCTRL_OFFSET, intrctrl);
577 return IRQ_NONE;
578 }
579
580 attnstatus = ioatdma_read32(instance, IOAT_ATTNSTATUS_OFFSET);
581
582 printk(KERN_ERR "ioatdma error: interrupt! status %lx\n", attnstatus);
583
584 ioatdma_write8(instance, IOAT_INTRCTRL_OFFSET, intrctrl);
585 return IRQ_HANDLED;
586}
587
588static void ioat_start_null_desc(struct ioat_dma_chan *ioat_chan)
589{
590 struct ioat_desc_sw *desc;
591
592 spin_lock_bh(&ioat_chan->desc_lock);
593
594 if (!list_empty(&ioat_chan->free_desc)) {
595 desc = to_ioat_desc(ioat_chan->free_desc.next);
596 list_del(&desc->node);
597 } else {
598 /* try to get another desc */
599 spin_unlock_bh(&ioat_chan->desc_lock);
600 desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_KERNEL);
601 spin_lock_bh(&ioat_chan->desc_lock);
602 /* will this ever happen? */
603 BUG_ON(!desc);
604 }
605
606 desc->hw->ctl = IOAT_DMA_DESCRIPTOR_NUL;
607 desc->hw->next = 0;
608
609 list_add_tail(&desc->node, &ioat_chan->used_desc);
610 spin_unlock_bh(&ioat_chan->desc_lock);
611
612#if (BITS_PER_LONG == 64)
613 ioatdma_chan_write64(ioat_chan, IOAT_CHAINADDR_OFFSET, desc->phys);
614#else
615 ioatdma_chan_write32(ioat_chan,
616 IOAT_CHAINADDR_OFFSET_LOW,
617 (u32) desc->phys);
618 ioatdma_chan_write32(ioat_chan, IOAT_CHAINADDR_OFFSET_HIGH, 0);
619#endif
620 ioatdma_chan_write8(ioat_chan, IOAT_CHANCMD_OFFSET, IOAT_CHANCMD_START);
621}
622
623/*
624 * Perform a IOAT transaction to verify the HW works.
625 */
626#define IOAT_TEST_SIZE 2000
627
628static int ioat_self_test(struct ioat_device *device)
629{
630 int i;
631 u8 *src;
632 u8 *dest;
633 struct dma_chan *dma_chan;
634 dma_cookie_t cookie;
635 int err = 0;
636
637 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL);
638 if (!src)
639 return -ENOMEM;
640 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL);
641 if (!dest) {
642 kfree(src);
643 return -ENOMEM;
644 }
645
646 /* Fill in src buffer */
647 for (i = 0; i < IOAT_TEST_SIZE; i++)
648 src[i] = (u8)i;
649
650 /* Start copy, using first DMA channel */
651 dma_chan = container_of(device->common.channels.next,
652 struct dma_chan,
653 device_node);
654 if (ioat_dma_alloc_chan_resources(dma_chan) < 1) {
655 err = -ENODEV;
656 goto out;
657 }
658
659 cookie = ioat_dma_memcpy_buf_to_buf(dma_chan, dest, src, IOAT_TEST_SIZE);
660 ioat_dma_memcpy_issue_pending(dma_chan);
661 msleep(1);
662
663 if (ioat_dma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) {
664 printk(KERN_ERR "ioatdma: Self-test copy timed out, disabling\n");
665 err = -ENODEV;
666 goto free_resources;
667 }
668 if (memcmp(src, dest, IOAT_TEST_SIZE)) {
669 printk(KERN_ERR "ioatdma: Self-test copy failed compare, disabling\n");
670 err = -ENODEV;
671 goto free_resources;
672 }
673
674free_resources:
675 ioat_dma_free_chan_resources(dma_chan);
676out:
677 kfree(src);
678 kfree(dest);
679 return err;
680}
681
682static int __devinit ioat_probe(struct pci_dev *pdev,
683 const struct pci_device_id *ent)
684{
685 int err;
686 unsigned long mmio_start, mmio_len;
687 void *reg_base;
688 struct ioat_device *device;
689
690 err = pci_enable_device(pdev);
691 if (err)
692 goto err_enable_device;
693
694 err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
695 if (err)
696 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
697 if (err)
698 goto err_set_dma_mask;
699
700 err = pci_request_regions(pdev, ioat_pci_drv.name);
701 if (err)
702 goto err_request_regions;
703
704 mmio_start = pci_resource_start(pdev, 0);
705 mmio_len = pci_resource_len(pdev, 0);
706
707 reg_base = ioremap(mmio_start, mmio_len);
708 if (!reg_base) {
709 err = -ENOMEM;
710 goto err_ioremap;
711 }
712
713 device = kzalloc(sizeof(*device), GFP_KERNEL);
714 if (!device) {
715 err = -ENOMEM;
716 goto err_kzalloc;
717 }
718
719 /* DMA coherent memory pool for DMA descriptor allocations */
720 device->dma_pool = pci_pool_create("dma_desc_pool", pdev,
721 sizeof(struct ioat_dma_descriptor), 64, 0);
722 if (!device->dma_pool) {
723 err = -ENOMEM;
724 goto err_dma_pool;
725 }
726
727 device->completion_pool = pci_pool_create("completion_pool", pdev, sizeof(u64), SMP_CACHE_BYTES, SMP_CACHE_BYTES);
728 if (!device->completion_pool) {
729 err = -ENOMEM;
730 goto err_completion_pool;
731 }
732
733 device->pdev = pdev;
734 pci_set_drvdata(pdev, device);
735#ifdef CONFIG_PCI_MSI
736 if (pci_enable_msi(pdev) == 0) {
737 device->msi = 1;
738 } else {
739 device->msi = 0;
740 }
741#endif
742 err = request_irq(pdev->irq, &ioat_do_interrupt, SA_SHIRQ, "ioat",
743 device);
744 if (err)
745 goto err_irq;
746
747 device->reg_base = reg_base;
748
749 ioatdma_write8(device, IOAT_INTRCTRL_OFFSET, IOAT_INTRCTRL_MASTER_INT_EN);
750 pci_set_master(pdev);
751
752 INIT_LIST_HEAD(&device->common.channels);
753 enumerate_dma_channels(device);
754
755 device->common.device_alloc_chan_resources = ioat_dma_alloc_chan_resources;
756 device->common.device_free_chan_resources = ioat_dma_free_chan_resources;
757 device->common.device_memcpy_buf_to_buf = ioat_dma_memcpy_buf_to_buf;
758 device->common.device_memcpy_buf_to_pg = ioat_dma_memcpy_buf_to_pg;
759 device->common.device_memcpy_pg_to_pg = ioat_dma_memcpy_pg_to_pg;
760 device->common.device_memcpy_complete = ioat_dma_is_complete;
761 device->common.device_memcpy_issue_pending = ioat_dma_memcpy_issue_pending;
762 printk(KERN_INFO "Intel(R) I/OAT DMA Engine found, %d channels\n",
763 device->common.chancnt);
764
765 err = ioat_self_test(device);
766 if (err)
767 goto err_self_test;
768
769 dma_async_device_register(&device->common);
770
771 return 0;
772
773err_self_test:
774err_irq:
775 pci_pool_destroy(device->completion_pool);
776err_completion_pool:
777 pci_pool_destroy(device->dma_pool);
778err_dma_pool:
779 kfree(device);
780err_kzalloc:
781 iounmap(reg_base);
782err_ioremap:
783 pci_release_regions(pdev);
784err_request_regions:
785err_set_dma_mask:
786 pci_disable_device(pdev);
787err_enable_device:
788 return err;
789}
790
791static void __devexit ioat_remove(struct pci_dev *pdev)
792{
793 struct ioat_device *device;
794 struct dma_chan *chan, *_chan;
795 struct ioat_dma_chan *ioat_chan;
796
797 device = pci_get_drvdata(pdev);
798 dma_async_device_unregister(&device->common);
799
800 free_irq(device->pdev->irq, device);
801#ifdef CONFIG_PCI_MSI
802 if (device->msi)
803 pci_disable_msi(device->pdev);
804#endif
805 pci_pool_destroy(device->dma_pool);
806 pci_pool_destroy(device->completion_pool);
807 iounmap(device->reg_base);
808 pci_release_regions(pdev);
809 pci_disable_device(pdev);
810 list_for_each_entry_safe(chan, _chan, &device->common.channels, device_node) {
811 ioat_chan = to_ioat_chan(chan);
812 list_del(&chan->device_node);
813 kfree(ioat_chan);
814 }
815 kfree(device);
816}
817
818/* MODULE API */
819MODULE_VERSION("1.7");
820MODULE_LICENSE("GPL");
821MODULE_AUTHOR("Intel Corporation");
822
823static int __init ioat_init_module(void)
824{
825 /* it's currently unsafe to unload this module */
826 /* if forced, worst case is that rmmod hangs */
827 if (THIS_MODULE != NULL)
828 THIS_MODULE->unsafe = 1;
829
830 return pci_module_init(&ioat_pci_drv);
831}
832
833module_init(ioat_init_module);
834
835static void __exit ioat_exit_module(void)
836{
837 pci_unregister_driver(&ioat_pci_drv);
838}
839
840module_exit(ioat_exit_module);
diff --git a/drivers/dma/ioatdma.h b/drivers/dma/ioatdma.h
new file mode 100644
index 000000000000..a5d3b3644160
--- /dev/null
+++ b/drivers/dma/ioatdma.h
@@ -0,0 +1,125 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21#ifndef IOATDMA_H
22#define IOATDMA_H
23
24#include <linux/dmaengine.h>
25#include "ioatdma_hw.h"
26#include <linux/init.h>
27#include <linux/dmapool.h>
28#include <linux/cache.h>
29#include <linux/pci_ids.h>
30
31#define IOAT_LOW_COMPLETION_MASK 0xffffffc0
32
33extern struct list_head dma_device_list;
34extern struct list_head dma_client_list;
35
36/**
37 * struct ioat_device - internal representation of a IOAT device
38 * @pdev: PCI-Express device
39 * @reg_base: MMIO register space base address
40 * @dma_pool: for allocating DMA descriptors
41 * @common: embedded struct dma_device
42 * @msi: Message Signaled Interrupt number
43 */
44
45struct ioat_device {
46 struct pci_dev *pdev;
47 void *reg_base;
48 struct pci_pool *dma_pool;
49 struct pci_pool *completion_pool;
50
51 struct dma_device common;
52 u8 msi;
53};
54
55/**
56 * struct ioat_dma_chan - internal representation of a DMA channel
57 * @device:
58 * @reg_base:
59 * @sw_in_use:
60 * @completion:
61 * @completion_low:
62 * @completion_high:
63 * @completed_cookie: last cookie seen completed on cleanup
64 * @cookie: value of last cookie given to client
65 * @last_completion:
66 * @xfercap:
67 * @desc_lock:
68 * @free_desc:
69 * @used_desc:
70 * @resource:
71 * @device_node:
72 */
73
74struct ioat_dma_chan {
75
76 void *reg_base;
77
78 dma_cookie_t completed_cookie;
79 unsigned long last_completion;
80
81 u32 xfercap; /* XFERCAP register value expanded out */
82
83 spinlock_t cleanup_lock;
84 spinlock_t desc_lock;
85 struct list_head free_desc;
86 struct list_head used_desc;
87
88 int pending;
89
90 struct ioat_device *device;
91 struct dma_chan common;
92
93 dma_addr_t completion_addr;
94 union {
95 u64 full; /* HW completion writeback */
96 struct {
97 u32 low;
98 u32 high;
99 };
100 } *completion_virt;
101};
102
103/* wrapper around hardware descriptor format + additional software fields */
104
105/**
106 * struct ioat_desc_sw - wrapper around hardware descriptor
107 * @hw: hardware DMA descriptor
108 * @node:
109 * @cookie:
110 * @phys:
111 */
112
113struct ioat_desc_sw {
114 struct ioat_dma_descriptor *hw;
115 struct list_head node;
116 dma_cookie_t cookie;
117 dma_addr_t phys;
118 DECLARE_PCI_UNMAP_ADDR(src)
119 DECLARE_PCI_UNMAP_LEN(src_len)
120 DECLARE_PCI_UNMAP_ADDR(dst)
121 DECLARE_PCI_UNMAP_LEN(dst_len)
122};
123
124#endif /* IOATDMA_H */
125
diff --git a/drivers/dma/ioatdma_hw.h b/drivers/dma/ioatdma_hw.h
new file mode 100644
index 000000000000..4d7a12880be3
--- /dev/null
+++ b/drivers/dma/ioatdma_hw.h
@@ -0,0 +1,52 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21#ifndef _IOAT_HW_H_
22#define _IOAT_HW_H_
23
24/* PCI Configuration Space Values */
25#define IOAT_PCI_VID 0x8086
26#define IOAT_PCI_DID 0x1A38
27#define IOAT_PCI_RID 0x00
28#define IOAT_PCI_SVID 0x8086
29#define IOAT_PCI_SID 0x8086
30#define IOAT_VER 0x12 /* Version 1.2 */
31
32struct ioat_dma_descriptor {
33 uint32_t size;
34 uint32_t ctl;
35 uint64_t src_addr;
36 uint64_t dst_addr;
37 uint64_t next;
38 uint64_t rsv1;
39 uint64_t rsv2;
40 uint64_t user1;
41 uint64_t user2;
42};
43
44#define IOAT_DMA_DESCRIPTOR_CTL_INT_GN 0x00000001
45#define IOAT_DMA_DESCRIPTOR_CTL_SRC_SN 0x00000002
46#define IOAT_DMA_DESCRIPTOR_CTL_DST_SN 0x00000004
47#define IOAT_DMA_DESCRIPTOR_CTL_CP_STS 0x00000008
48#define IOAT_DMA_DESCRIPTOR_CTL_FRAME 0x00000010
49#define IOAT_DMA_DESCRIPTOR_NUL 0x00000020
50#define IOAT_DMA_DESCRIPTOR_OPCODE 0xFF000000
51
52#endif
diff --git a/drivers/dma/ioatdma_io.h b/drivers/dma/ioatdma_io.h
new file mode 100644
index 000000000000..c0b4bf66c920
--- /dev/null
+++ b/drivers/dma/ioatdma_io.h
@@ -0,0 +1,118 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21#ifndef IOATDMA_IO_H
22#define IOATDMA_IO_H
23
24#include <asm/io.h>
25
26/*
27 * device and per-channel MMIO register read and write functions
28 * this is a lot of anoying inline functions, but it's typesafe
29 */
30
31static inline u8 ioatdma_read8(struct ioat_device *device,
32 unsigned int offset)
33{
34 return readb(device->reg_base + offset);
35}
36
37static inline u16 ioatdma_read16(struct ioat_device *device,
38 unsigned int offset)
39{
40 return readw(device->reg_base + offset);
41}
42
43static inline u32 ioatdma_read32(struct ioat_device *device,
44 unsigned int offset)
45{
46 return readl(device->reg_base + offset);
47}
48
49static inline void ioatdma_write8(struct ioat_device *device,
50 unsigned int offset, u8 value)
51{
52 writeb(value, device->reg_base + offset);
53}
54
55static inline void ioatdma_write16(struct ioat_device *device,
56 unsigned int offset, u16 value)
57{
58 writew(value, device->reg_base + offset);
59}
60
61static inline void ioatdma_write32(struct ioat_device *device,
62 unsigned int offset, u32 value)
63{
64 writel(value, device->reg_base + offset);
65}
66
67static inline u8 ioatdma_chan_read8(struct ioat_dma_chan *chan,
68 unsigned int offset)
69{
70 return readb(chan->reg_base + offset);
71}
72
73static inline u16 ioatdma_chan_read16(struct ioat_dma_chan *chan,
74 unsigned int offset)
75{
76 return readw(chan->reg_base + offset);
77}
78
79static inline u32 ioatdma_chan_read32(struct ioat_dma_chan *chan,
80 unsigned int offset)
81{
82 return readl(chan->reg_base + offset);
83}
84
85static inline void ioatdma_chan_write8(struct ioat_dma_chan *chan,
86 unsigned int offset, u8 value)
87{
88 writeb(value, chan->reg_base + offset);
89}
90
91static inline void ioatdma_chan_write16(struct ioat_dma_chan *chan,
92 unsigned int offset, u16 value)
93{
94 writew(value, chan->reg_base + offset);
95}
96
97static inline void ioatdma_chan_write32(struct ioat_dma_chan *chan,
98 unsigned int offset, u32 value)
99{
100 writel(value, chan->reg_base + offset);
101}
102
103#if (BITS_PER_LONG == 64)
104static inline u64 ioatdma_chan_read64(struct ioat_dma_chan *chan,
105 unsigned int offset)
106{
107 return readq(chan->reg_base + offset);
108}
109
110static inline void ioatdma_chan_write64(struct ioat_dma_chan *chan,
111 unsigned int offset, u64 value)
112{
113 writeq(value, chan->reg_base + offset);
114}
115#endif
116
117#endif /* IOATDMA_IO_H */
118
diff --git a/drivers/dma/ioatdma_registers.h b/drivers/dma/ioatdma_registers.h
new file mode 100644
index 000000000000..41a21ab2b000
--- /dev/null
+++ b/drivers/dma/ioatdma_registers.h
@@ -0,0 +1,126 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21#ifndef _IOAT_REGISTERS_H_
22#define _IOAT_REGISTERS_H_
23
24
25/* MMIO Device Registers */
26#define IOAT_CHANCNT_OFFSET 0x00 /* 8-bit */
27
28#define IOAT_XFERCAP_OFFSET 0x01 /* 8-bit */
29#define IOAT_XFERCAP_4KB 12
30#define IOAT_XFERCAP_8KB 13
31#define IOAT_XFERCAP_16KB 14
32#define IOAT_XFERCAP_32KB 15
33#define IOAT_XFERCAP_32GB 0
34
35#define IOAT_GENCTRL_OFFSET 0x02 /* 8-bit */
36#define IOAT_GENCTRL_DEBUG_EN 0x01
37
38#define IOAT_INTRCTRL_OFFSET 0x03 /* 8-bit */
39#define IOAT_INTRCTRL_MASTER_INT_EN 0x01 /* Master Interrupt Enable */
40#define IOAT_INTRCTRL_INT_STATUS 0x02 /* ATTNSTATUS -or- Channel Int */
41#define IOAT_INTRCTRL_INT 0x04 /* INT_STATUS -and- MASTER_INT_EN */
42
43#define IOAT_ATTNSTATUS_OFFSET 0x04 /* Each bit is a channel */
44
45#define IOAT_VER_OFFSET 0x08 /* 8-bit */
46#define IOAT_VER_MAJOR_MASK 0xF0
47#define IOAT_VER_MINOR_MASK 0x0F
48#define GET_IOAT_VER_MAJOR(x) ((x) & IOAT_VER_MAJOR_MASK)
49#define GET_IOAT_VER_MINOR(x) ((x) & IOAT_VER_MINOR_MASK)
50
51#define IOAT_PERPORTOFFSET_OFFSET 0x0A /* 16-bit */
52
53#define IOAT_INTRDELAY_OFFSET 0x0C /* 16-bit */
54#define IOAT_INTRDELAY_INT_DELAY_MASK 0x3FFF /* Interrupt Delay Time */
55#define IOAT_INTRDELAY_COALESE_SUPPORT 0x8000 /* Interrupt Coalesing Supported */
56
57#define IOAT_DEVICE_STATUS_OFFSET 0x0E /* 16-bit */
58#define IOAT_DEVICE_STATUS_DEGRADED_MODE 0x0001
59
60
61#define IOAT_CHANNEL_MMIO_SIZE 0x80 /* Each Channel MMIO space is this size */
62
63/* DMA Channel Registers */
64#define IOAT_CHANCTRL_OFFSET 0x00 /* 16-bit Channel Control Register */
65#define IOAT_CHANCTRL_CHANNEL_PRIORITY_MASK 0xF000
66#define IOAT_CHANCTRL_CHANNEL_IN_USE 0x0100
67#define IOAT_CHANCTRL_DESCRIPTOR_ADDR_SNOOP_CONTROL 0x0020
68#define IOAT_CHANCTRL_ERR_INT_EN 0x0010
69#define IOAT_CHANCTRL_ANY_ERR_ABORT_EN 0x0008
70#define IOAT_CHANCTRL_ERR_COMPLETION_EN 0x0004
71#define IOAT_CHANCTRL_INT_DISABLE 0x0001
72
73#define IOAT_DMA_COMP_OFFSET 0x02 /* 16-bit DMA channel compatability */
74#define IOAT_DMA_COMP_V1 0x0001 /* Compatability with DMA version 1 */
75
76#define IOAT_CHANSTS_OFFSET 0x04 /* 64-bit Channel Status Register */
77#define IOAT_CHANSTS_OFFSET_LOW 0x04
78#define IOAT_CHANSTS_OFFSET_HIGH 0x08
79#define IOAT_CHANSTS_COMPLETED_DESCRIPTOR_ADDR 0xFFFFFFFFFFFFFFC0
80#define IOAT_CHANSTS_SOFT_ERR 0x0000000000000010
81#define IOAT_CHANSTS_DMA_TRANSFER_STATUS 0x0000000000000007
82#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_ACTIVE 0x0
83#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_DONE 0x1
84#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_SUSPENDED 0x2
85#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_HALTED 0x3
86
87#define IOAT_CHAINADDR_OFFSET 0x0C /* 64-bit Descriptor Chain Address Register */
88#define IOAT_CHAINADDR_OFFSET_LOW 0x0C
89#define IOAT_CHAINADDR_OFFSET_HIGH 0x10
90
91#define IOAT_CHANCMD_OFFSET 0x14 /* 8-bit DMA Channel Command Register */
92#define IOAT_CHANCMD_RESET 0x20
93#define IOAT_CHANCMD_RESUME 0x10
94#define IOAT_CHANCMD_ABORT 0x08
95#define IOAT_CHANCMD_SUSPEND 0x04
96#define IOAT_CHANCMD_APPEND 0x02
97#define IOAT_CHANCMD_START 0x01
98
99#define IOAT_CHANCMP_OFFSET 0x18 /* 64-bit Channel Completion Address Register */
100#define IOAT_CHANCMP_OFFSET_LOW 0x18
101#define IOAT_CHANCMP_OFFSET_HIGH 0x1C
102
103#define IOAT_CDAR_OFFSET 0x20 /* 64-bit Current Descriptor Address Register */
104#define IOAT_CDAR_OFFSET_LOW 0x20
105#define IOAT_CDAR_OFFSET_HIGH 0x24
106
107#define IOAT_CHANERR_OFFSET 0x28 /* 32-bit Channel Error Register */
108#define IOAT_CHANERR_DMA_TRANSFER_SRC_ADDR_ERR 0x0001
109#define IOAT_CHANERR_DMA_TRANSFER_DEST_ADDR_ERR 0x0002
110#define IOAT_CHANERR_NEXT_DESCRIPTOR_ADDR_ERR 0x0004
111#define IOAT_CHANERR_NEXT_DESCRIPTOR_ALIGNMENT_ERR 0x0008
112#define IOAT_CHANERR_CHAIN_ADDR_VALUE_ERR 0x0010
113#define IOAT_CHANERR_CHANCMD_ERR 0x0020
114#define IOAT_CHANERR_CHIPSET_UNCORRECTABLE_DATA_INTEGRITY_ERR 0x0040
115#define IOAT_CHANERR_DMA_UNCORRECTABLE_DATA_INTEGRITY_ERR 0x0080
116#define IOAT_CHANERR_READ_DATA_ERR 0x0100
117#define IOAT_CHANERR_WRITE_DATA_ERR 0x0200
118#define IOAT_CHANERR_DESCRIPTOR_CONTROL_ERR 0x0400
119#define IOAT_CHANERR_DESCRIPTOR_LENGTH_ERR 0x0800
120#define IOAT_CHANERR_COMPLETION_ADDR_ERR 0x1000
121#define IOAT_CHANERR_INT_CONFIGURATION_ERR 0x2000
122#define IOAT_CHANERR_SOFT_ERR 0x4000
123
124#define IOAT_CHANERR_MASK_OFFSET 0x2C /* 32-bit Channel Error Register */
125
126#endif /* _IOAT_REGISTERS_H_ */
diff --git a/drivers/dma/iovlock.c b/drivers/dma/iovlock.c
new file mode 100644
index 000000000000..5ed327e453a2
--- /dev/null
+++ b/drivers/dma/iovlock.c
@@ -0,0 +1,301 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 * Portions based on net/core/datagram.c and copyrighted by their authors.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59
17 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * The full GNU General Public License is included in this distribution in the
20 * file called COPYING.
21 */
22
23/*
24 * This code allows the net stack to make use of a DMA engine for
25 * skb to iovec copies.
26 */
27
28#include <linux/dmaengine.h>
29#include <linux/pagemap.h>
30#include <net/tcp.h> /* for memcpy_toiovec */
31#include <asm/io.h>
32#include <asm/uaccess.h>
33
34int num_pages_spanned(struct iovec *iov)
35{
36 return
37 ((PAGE_ALIGN((unsigned long)iov->iov_base + iov->iov_len) -
38 ((unsigned long)iov->iov_base & PAGE_MASK)) >> PAGE_SHIFT);
39}
40
41/*
42 * Pin down all the iovec pages needed for len bytes.
43 * Return a struct dma_pinned_list to keep track of pages pinned down.
44 *
45 * We are allocating a single chunk of memory, and then carving it up into
46 * 3 sections, the latter 2 whose size depends on the number of iovecs and the
47 * total number of pages, respectively.
48 */
49struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len)
50{
51 struct dma_pinned_list *local_list;
52 struct page **pages;
53 int i;
54 int ret;
55 int nr_iovecs = 0;
56 int iovec_len_used = 0;
57 int iovec_pages_used = 0;
58 long err;
59
60 /* don't pin down non-user-based iovecs */
61 if (segment_eq(get_fs(), KERNEL_DS))
62 return NULL;
63
64 /* determine how many iovecs/pages there are, up front */
65 do {
66 iovec_len_used += iov[nr_iovecs].iov_len;
67 iovec_pages_used += num_pages_spanned(&iov[nr_iovecs]);
68 nr_iovecs++;
69 } while (iovec_len_used < len);
70
71 /* single kmalloc for pinned list, page_list[], and the page arrays */
72 local_list = kmalloc(sizeof(*local_list)
73 + (nr_iovecs * sizeof (struct dma_page_list))
74 + (iovec_pages_used * sizeof (struct page*)), GFP_KERNEL);
75 if (!local_list) {
76 err = -ENOMEM;
77 goto out;
78 }
79
80 /* list of pages starts right after the page list array */
81 pages = (struct page **) &local_list->page_list[nr_iovecs];
82
83 for (i = 0; i < nr_iovecs; i++) {
84 struct dma_page_list *page_list = &local_list->page_list[i];
85
86 len -= iov[i].iov_len;
87
88 if (!access_ok(VERIFY_WRITE, iov[i].iov_base, iov[i].iov_len)) {
89 err = -EFAULT;
90 goto unpin;
91 }
92
93 page_list->nr_pages = num_pages_spanned(&iov[i]);
94 page_list->base_address = iov[i].iov_base;
95
96 page_list->pages = pages;
97 pages += page_list->nr_pages;
98
99 /* pin pages down */
100 down_read(&current->mm->mmap_sem);
101 ret = get_user_pages(
102 current,
103 current->mm,
104 (unsigned long) iov[i].iov_base,
105 page_list->nr_pages,
106 1, /* write */
107 0, /* force */
108 page_list->pages,
109 NULL);
110 up_read(&current->mm->mmap_sem);
111
112 if (ret != page_list->nr_pages) {
113 err = -ENOMEM;
114 goto unpin;
115 }
116
117 local_list->nr_iovecs = i + 1;
118 }
119
120 return local_list;
121
122unpin:
123 dma_unpin_iovec_pages(local_list);
124out:
125 return ERR_PTR(err);
126}
127
128void dma_unpin_iovec_pages(struct dma_pinned_list *pinned_list)
129{
130 int i, j;
131
132 if (!pinned_list)
133 return;
134
135 for (i = 0; i < pinned_list->nr_iovecs; i++) {
136 struct dma_page_list *page_list = &pinned_list->page_list[i];
137 for (j = 0; j < page_list->nr_pages; j++) {
138 set_page_dirty_lock(page_list->pages[j]);
139 page_cache_release(page_list->pages[j]);
140 }
141 }
142
143 kfree(pinned_list);
144}
145
146static dma_cookie_t dma_memcpy_to_kernel_iovec(struct dma_chan *chan, struct
147 iovec *iov, unsigned char *kdata, size_t len)
148{
149 dma_cookie_t dma_cookie = 0;
150
151 while (len > 0) {
152 if (iov->iov_len) {
153 int copy = min_t(unsigned int, iov->iov_len, len);
154 dma_cookie = dma_async_memcpy_buf_to_buf(
155 chan,
156 iov->iov_base,
157 kdata,
158 copy);
159 kdata += copy;
160 len -= copy;
161 iov->iov_len -= copy;
162 iov->iov_base += copy;
163 }
164 iov++;
165 }
166
167 return dma_cookie;
168}
169
170/*
171 * We have already pinned down the pages we will be using in the iovecs.
172 * Each entry in iov array has corresponding entry in pinned_list->page_list.
173 * Using array indexing to keep iov[] and page_list[] in sync.
174 * Initial elements in iov array's iov->iov_len will be 0 if already copied into
175 * by another call.
176 * iov array length remaining guaranteed to be bigger than len.
177 */
178dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
179 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len)
180{
181 int iov_byte_offset;
182 int copy;
183 dma_cookie_t dma_cookie = 0;
184 int iovec_idx;
185 int page_idx;
186
187 if (!chan)
188 return memcpy_toiovec(iov, kdata, len);
189
190 /* -> kernel copies (e.g. smbfs) */
191 if (!pinned_list)
192 return dma_memcpy_to_kernel_iovec(chan, iov, kdata, len);
193
194 iovec_idx = 0;
195 while (iovec_idx < pinned_list->nr_iovecs) {
196 struct dma_page_list *page_list;
197
198 /* skip already used-up iovecs */
199 while (!iov[iovec_idx].iov_len)
200 iovec_idx++;
201
202 page_list = &pinned_list->page_list[iovec_idx];
203
204 iov_byte_offset = ((unsigned long)iov[iovec_idx].iov_base & ~PAGE_MASK);
205 page_idx = (((unsigned long)iov[iovec_idx].iov_base & PAGE_MASK)
206 - ((unsigned long)page_list->base_address & PAGE_MASK)) >> PAGE_SHIFT;
207
208 /* break up copies to not cross page boundary */
209 while (iov[iovec_idx].iov_len) {
210 copy = min_t(int, PAGE_SIZE - iov_byte_offset, len);
211 copy = min_t(int, copy, iov[iovec_idx].iov_len);
212
213 dma_cookie = dma_async_memcpy_buf_to_pg(chan,
214 page_list->pages[page_idx],
215 iov_byte_offset,
216 kdata,
217 copy);
218
219 len -= copy;
220 iov[iovec_idx].iov_len -= copy;
221 iov[iovec_idx].iov_base += copy;
222
223 if (!len)
224 return dma_cookie;
225
226 kdata += copy;
227 iov_byte_offset = 0;
228 page_idx++;
229 }
230 iovec_idx++;
231 }
232
233 /* really bad if we ever run out of iovecs */
234 BUG();
235 return -EFAULT;
236}
237
238dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
239 struct dma_pinned_list *pinned_list, struct page *page,
240 unsigned int offset, size_t len)
241{
242 int iov_byte_offset;
243 int copy;
244 dma_cookie_t dma_cookie = 0;
245 int iovec_idx;
246 int page_idx;
247 int err;
248
249 /* this needs as-yet-unimplemented buf-to-buff, so punt. */
250 /* TODO: use dma for this */
251 if (!chan || !pinned_list) {
252 u8 *vaddr = kmap(page);
253 err = memcpy_toiovec(iov, vaddr + offset, len);
254 kunmap(page);
255 return err;
256 }
257
258 iovec_idx = 0;
259 while (iovec_idx < pinned_list->nr_iovecs) {
260 struct dma_page_list *page_list;
261
262 /* skip already used-up iovecs */
263 while (!iov[iovec_idx].iov_len)
264 iovec_idx++;
265
266 page_list = &pinned_list->page_list[iovec_idx];
267
268 iov_byte_offset = ((unsigned long)iov[iovec_idx].iov_base & ~PAGE_MASK);
269 page_idx = (((unsigned long)iov[iovec_idx].iov_base & PAGE_MASK)
270 - ((unsigned long)page_list->base_address & PAGE_MASK)) >> PAGE_SHIFT;
271
272 /* break up copies to not cross page boundary */
273 while (iov[iovec_idx].iov_len) {
274 copy = min_t(int, PAGE_SIZE - iov_byte_offset, len);
275 copy = min_t(int, copy, iov[iovec_idx].iov_len);
276
277 dma_cookie = dma_async_memcpy_pg_to_pg(chan,
278 page_list->pages[page_idx],
279 iov_byte_offset,
280 page,
281 offset,
282 copy);
283
284 len -= copy;
285 iov[iovec_idx].iov_len -= copy;
286 iov[iovec_idx].iov_base += copy;
287
288 if (!len)
289 return dma_cookie;
290
291 offset += copy;
292 iov_byte_offset = 0;
293 page_idx++;
294 }
295 iovec_idx++;
296 }
297
298 /* really bad if we ever run out of iovecs */
299 BUG();
300 return -EFAULT;
301}
diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
index afc612b8577d..ba2d6505e9a4 100644
--- a/drivers/infiniband/Kconfig
+++ b/drivers/infiniband/Kconfig
@@ -29,6 +29,11 @@ config INFINIBAND_USER_ACCESS
29 libibverbs, libibcm and a hardware driver library from 29 libibverbs, libibcm and a hardware driver library from
30 <http://www.openib.org>. 30 <http://www.openib.org>.
31 31
32config INFINIBAND_ADDR_TRANS
33 bool
34 depends on INFINIBAND && INET
35 default y
36
32source "drivers/infiniband/hw/mthca/Kconfig" 37source "drivers/infiniband/hw/mthca/Kconfig"
33source "drivers/infiniband/hw/ipath/Kconfig" 38source "drivers/infiniband/hw/ipath/Kconfig"
34 39
diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
index ec3353f24b27..68e73ec2d1f8 100644
--- a/drivers/infiniband/core/Makefile
+++ b/drivers/infiniband/core/Makefile
@@ -1,5 +1,7 @@
1infiniband-$(CONFIG_INFINIBAND_ADDR_TRANS) := ib_addr.o rdma_cm.o
2
1obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \ 3obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \
2 ib_cm.o 4 ib_cm.o $(infiniband-y)
3obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o 5obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o
4obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o 6obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o
5 7
@@ -12,8 +14,13 @@ ib_sa-y := sa_query.o
12 14
13ib_cm-y := cm.o 15ib_cm-y := cm.o
14 16
17rdma_cm-y := cma.o
18
19ib_addr-y := addr.o
20
15ib_umad-y := user_mad.o 21ib_umad-y := user_mad.o
16 22
17ib_ucm-y := ucm.o 23ib_ucm-y := ucm.o
18 24
19ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_mem.o 25ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_mem.o \
26 uverbs_marshall.o
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
new file mode 100644
index 000000000000..d294bbc42f09
--- /dev/null
+++ b/drivers/infiniband/core/addr.c
@@ -0,0 +1,367 @@
1/*
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005 Intel Corporation. All rights reserved.
6 *
7 * This Software is licensed under one of the following licenses:
8 *
9 * 1) under the terms of the "Common Public License 1.0" a copy of which is
10 * available from the Open Source Initiative, see
11 * http://www.opensource.org/licenses/cpl.php.
12 *
13 * 2) under the terms of the "The BSD License" a copy of which is
14 * available from the Open Source Initiative, see
15 * http://www.opensource.org/licenses/bsd-license.php.
16 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
18 * copy of which is available from the Open Source Initiative, see
19 * http://www.opensource.org/licenses/gpl-license.php.
20 *
21 * Licensee has the right to choose one of the above licenses.
22 *
23 * Redistributions of source code must retain the above copyright
24 * notice and one of the license notices.
25 *
26 * Redistributions in binary form must reproduce both the above copyright
27 * notice, one of the license notices in the documentation
28 * and/or other materials provided with the distribution.
29 */
30
31#include <linux/mutex.h>
32#include <linux/inetdevice.h>
33#include <linux/workqueue.h>
34#include <linux/if_arp.h>
35#include <net/arp.h>
36#include <net/neighbour.h>
37#include <net/route.h>
38#include <rdma/ib_addr.h>
39
40MODULE_AUTHOR("Sean Hefty");
41MODULE_DESCRIPTION("IB Address Translation");
42MODULE_LICENSE("Dual BSD/GPL");
43
44struct addr_req {
45 struct list_head list;
46 struct sockaddr src_addr;
47 struct sockaddr dst_addr;
48 struct rdma_dev_addr *addr;
49 void *context;
50 void (*callback)(int status, struct sockaddr *src_addr,
51 struct rdma_dev_addr *addr, void *context);
52 unsigned long timeout;
53 int status;
54};
55
56static void process_req(void *data);
57
58static DEFINE_MUTEX(lock);
59static LIST_HEAD(req_list);
60static DECLARE_WORK(work, process_req, NULL);
61static struct workqueue_struct *addr_wq;
62
63static int copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
64 unsigned char *dst_dev_addr)
65{
66 switch (dev->type) {
67 case ARPHRD_INFINIBAND:
68 dev_addr->dev_type = IB_NODE_CA;
69 break;
70 default:
71 return -EADDRNOTAVAIL;
72 }
73
74 memcpy(dev_addr->src_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
75 memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
76 if (dst_dev_addr)
77 memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
78 return 0;
79}
80
81int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
82{
83 struct net_device *dev;
84 u32 ip = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
85 int ret;
86
87 dev = ip_dev_find(ip);
88 if (!dev)
89 return -EADDRNOTAVAIL;
90
91 ret = copy_addr(dev_addr, dev, NULL);
92 dev_put(dev);
93 return ret;
94}
95EXPORT_SYMBOL(rdma_translate_ip);
96
97static void set_timeout(unsigned long time)
98{
99 unsigned long delay;
100
101 cancel_delayed_work(&work);
102
103 delay = time - jiffies;
104 if ((long)delay <= 0)
105 delay = 1;
106
107 queue_delayed_work(addr_wq, &work, delay);
108}
109
110static void queue_req(struct addr_req *req)
111{
112 struct addr_req *temp_req;
113
114 mutex_lock(&lock);
115 list_for_each_entry_reverse(temp_req, &req_list, list) {
116 if (time_after(req->timeout, temp_req->timeout))
117 break;
118 }
119
120 list_add(&req->list, &temp_req->list);
121
122 if (req_list.next == &req->list)
123 set_timeout(req->timeout);
124 mutex_unlock(&lock);
125}
126
127static void addr_send_arp(struct sockaddr_in *dst_in)
128{
129 struct rtable *rt;
130 struct flowi fl;
131 u32 dst_ip = dst_in->sin_addr.s_addr;
132
133 memset(&fl, 0, sizeof fl);
134 fl.nl_u.ip4_u.daddr = dst_ip;
135 if (ip_route_output_key(&rt, &fl))
136 return;
137
138 arp_send(ARPOP_REQUEST, ETH_P_ARP, rt->rt_gateway, rt->idev->dev,
139 rt->rt_src, NULL, rt->idev->dev->dev_addr, NULL);
140 ip_rt_put(rt);
141}
142
143static int addr_resolve_remote(struct sockaddr_in *src_in,
144 struct sockaddr_in *dst_in,
145 struct rdma_dev_addr *addr)
146{
147 u32 src_ip = src_in->sin_addr.s_addr;
148 u32 dst_ip = dst_in->sin_addr.s_addr;
149 struct flowi fl;
150 struct rtable *rt;
151 struct neighbour *neigh;
152 int ret;
153
154 memset(&fl, 0, sizeof fl);
155 fl.nl_u.ip4_u.daddr = dst_ip;
156 fl.nl_u.ip4_u.saddr = src_ip;
157 ret = ip_route_output_key(&rt, &fl);
158 if (ret)
159 goto out;
160
161 /* If the device does ARP internally, return 'done' */
162 if (rt->idev->dev->flags & IFF_NOARP) {
163 copy_addr(addr, rt->idev->dev, NULL);
164 goto put;
165 }
166
167 neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->idev->dev);
168 if (!neigh) {
169 ret = -ENODATA;
170 goto put;
171 }
172
173 if (!(neigh->nud_state & NUD_VALID)) {
174 ret = -ENODATA;
175 goto release;
176 }
177
178 if (!src_ip) {
179 src_in->sin_family = dst_in->sin_family;
180 src_in->sin_addr.s_addr = rt->rt_src;
181 }
182
183 ret = copy_addr(addr, neigh->dev, neigh->ha);
184release:
185 neigh_release(neigh);
186put:
187 ip_rt_put(rt);
188out:
189 return ret;
190}
191
192static void process_req(void *data)
193{
194 struct addr_req *req, *temp_req;
195 struct sockaddr_in *src_in, *dst_in;
196 struct list_head done_list;
197
198 INIT_LIST_HEAD(&done_list);
199
200 mutex_lock(&lock);
201 list_for_each_entry_safe(req, temp_req, &req_list, list) {
202 if (req->status) {
203 src_in = (struct sockaddr_in *) &req->src_addr;
204 dst_in = (struct sockaddr_in *) &req->dst_addr;
205 req->status = addr_resolve_remote(src_in, dst_in,
206 req->addr);
207 }
208 if (req->status && time_after(jiffies, req->timeout))
209 req->status = -ETIMEDOUT;
210 else if (req->status == -ENODATA)
211 continue;
212
213 list_del(&req->list);
214 list_add_tail(&req->list, &done_list);
215 }
216
217 if (!list_empty(&req_list)) {
218 req = list_entry(req_list.next, struct addr_req, list);
219 set_timeout(req->timeout);
220 }
221 mutex_unlock(&lock);
222
223 list_for_each_entry_safe(req, temp_req, &done_list, list) {
224 list_del(&req->list);
225 req->callback(req->status, &req->src_addr, req->addr,
226 req->context);
227 kfree(req);
228 }
229}
230
231static int addr_resolve_local(struct sockaddr_in *src_in,
232 struct sockaddr_in *dst_in,
233 struct rdma_dev_addr *addr)
234{
235 struct net_device *dev;
236 u32 src_ip = src_in->sin_addr.s_addr;
237 u32 dst_ip = dst_in->sin_addr.s_addr;
238 int ret;
239
240 dev = ip_dev_find(dst_ip);
241 if (!dev)
242 return -EADDRNOTAVAIL;
243
244 if (ZERONET(src_ip)) {
245 src_in->sin_family = dst_in->sin_family;
246 src_in->sin_addr.s_addr = dst_ip;
247 ret = copy_addr(addr, dev, dev->dev_addr);
248 } else if (LOOPBACK(src_ip)) {
249 ret = rdma_translate_ip((struct sockaddr *)dst_in, addr);
250 if (!ret)
251 memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
252 } else {
253 ret = rdma_translate_ip((struct sockaddr *)src_in, addr);
254 if (!ret)
255 memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
256 }
257
258 dev_put(dev);
259 return ret;
260}
261
262int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
263 struct rdma_dev_addr *addr, int timeout_ms,
264 void (*callback)(int status, struct sockaddr *src_addr,
265 struct rdma_dev_addr *addr, void *context),
266 void *context)
267{
268 struct sockaddr_in *src_in, *dst_in;
269 struct addr_req *req;
270 int ret = 0;
271
272 req = kmalloc(sizeof *req, GFP_KERNEL);
273 if (!req)
274 return -ENOMEM;
275 memset(req, 0, sizeof *req);
276
277 if (src_addr)
278 memcpy(&req->src_addr, src_addr, ip_addr_size(src_addr));
279 memcpy(&req->dst_addr, dst_addr, ip_addr_size(dst_addr));
280 req->addr = addr;
281 req->callback = callback;
282 req->context = context;
283
284 src_in = (struct sockaddr_in *) &req->src_addr;
285 dst_in = (struct sockaddr_in *) &req->dst_addr;
286
287 req->status = addr_resolve_local(src_in, dst_in, addr);
288 if (req->status == -EADDRNOTAVAIL)
289 req->status = addr_resolve_remote(src_in, dst_in, addr);
290
291 switch (req->status) {
292 case 0:
293 req->timeout = jiffies;
294 queue_req(req);
295 break;
296 case -ENODATA:
297 req->timeout = msecs_to_jiffies(timeout_ms) + jiffies;
298 queue_req(req);
299 addr_send_arp(dst_in);
300 break;
301 default:
302 ret = req->status;
303 kfree(req);
304 break;
305 }
306 return ret;
307}
308EXPORT_SYMBOL(rdma_resolve_ip);
309
310void rdma_addr_cancel(struct rdma_dev_addr *addr)
311{
312 struct addr_req *req, *temp_req;
313
314 mutex_lock(&lock);
315 list_for_each_entry_safe(req, temp_req, &req_list, list) {
316 if (req->addr == addr) {
317 req->status = -ECANCELED;
318 req->timeout = jiffies;
319 list_del(&req->list);
320 list_add(&req->list, &req_list);
321 set_timeout(req->timeout);
322 break;
323 }
324 }
325 mutex_unlock(&lock);
326}
327EXPORT_SYMBOL(rdma_addr_cancel);
328
329static int addr_arp_recv(struct sk_buff *skb, struct net_device *dev,
330 struct packet_type *pkt, struct net_device *orig_dev)
331{
332 struct arphdr *arp_hdr;
333
334 arp_hdr = (struct arphdr *) skb->nh.raw;
335
336 if (arp_hdr->ar_op == htons(ARPOP_REQUEST) ||
337 arp_hdr->ar_op == htons(ARPOP_REPLY))
338 set_timeout(jiffies);
339
340 kfree_skb(skb);
341 return 0;
342}
343
344static struct packet_type addr_arp = {
345 .type = __constant_htons(ETH_P_ARP),
346 .func = addr_arp_recv,
347 .af_packet_priv = (void*) 1,
348};
349
350static int addr_init(void)
351{
352 addr_wq = create_singlethread_workqueue("ib_addr_wq");
353 if (!addr_wq)
354 return -ENOMEM;
355
356 dev_add_pack(&addr_arp);
357 return 0;
358}
359
360static void addr_cleanup(void)
361{
362 dev_remove_pack(&addr_arp);
363 destroy_workqueue(addr_wq);
364}
365
366module_init(addr_init);
367module_exit(addr_cleanup);
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 50364c0b090c..e05ca2cdc73f 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -191,6 +191,24 @@ int ib_find_cached_pkey(struct ib_device *device,
191} 191}
192EXPORT_SYMBOL(ib_find_cached_pkey); 192EXPORT_SYMBOL(ib_find_cached_pkey);
193 193
194int ib_get_cached_lmc(struct ib_device *device,
195 u8 port_num,
196 u8 *lmc)
197{
198 unsigned long flags;
199 int ret = 0;
200
201 if (port_num < start_port(device) || port_num > end_port(device))
202 return -EINVAL;
203
204 read_lock_irqsave(&device->cache.lock, flags);
205 *lmc = device->cache.lmc_cache[port_num - start_port(device)];
206 read_unlock_irqrestore(&device->cache.lock, flags);
207
208 return ret;
209}
210EXPORT_SYMBOL(ib_get_cached_lmc);
211
194static void ib_cache_update(struct ib_device *device, 212static void ib_cache_update(struct ib_device *device,
195 u8 port) 213 u8 port)
196{ 214{
@@ -251,6 +269,8 @@ static void ib_cache_update(struct ib_device *device,
251 device->cache.pkey_cache[port - start_port(device)] = pkey_cache; 269 device->cache.pkey_cache[port - start_port(device)] = pkey_cache;
252 device->cache.gid_cache [port - start_port(device)] = gid_cache; 270 device->cache.gid_cache [port - start_port(device)] = gid_cache;
253 271
272 device->cache.lmc_cache[port - start_port(device)] = tprops->lmc;
273
254 write_unlock_irq(&device->cache.lock); 274 write_unlock_irq(&device->cache.lock);
255 275
256 kfree(old_pkey_cache); 276 kfree(old_pkey_cache);
@@ -305,7 +325,13 @@ static void ib_cache_setup_one(struct ib_device *device)
305 kmalloc(sizeof *device->cache.gid_cache * 325 kmalloc(sizeof *device->cache.gid_cache *
306 (end_port(device) - start_port(device) + 1), GFP_KERNEL); 326 (end_port(device) - start_port(device) + 1), GFP_KERNEL);
307 327
308 if (!device->cache.pkey_cache || !device->cache.gid_cache) { 328 device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache *
329 (end_port(device) -
330 start_port(device) + 1),
331 GFP_KERNEL);
332
333 if (!device->cache.pkey_cache || !device->cache.gid_cache ||
334 !device->cache.lmc_cache) {
309 printk(KERN_WARNING "Couldn't allocate cache " 335 printk(KERN_WARNING "Couldn't allocate cache "
310 "for %s\n", device->name); 336 "for %s\n", device->name);
311 goto err; 337 goto err;
@@ -333,6 +359,7 @@ err_cache:
333err: 359err:
334 kfree(device->cache.pkey_cache); 360 kfree(device->cache.pkey_cache);
335 kfree(device->cache.gid_cache); 361 kfree(device->cache.gid_cache);
362 kfree(device->cache.lmc_cache);
336} 363}
337 364
338static void ib_cache_cleanup_one(struct ib_device *device) 365static void ib_cache_cleanup_one(struct ib_device *device)
@@ -349,6 +376,7 @@ static void ib_cache_cleanup_one(struct ib_device *device)
349 376
350 kfree(device->cache.pkey_cache); 377 kfree(device->cache.pkey_cache);
351 kfree(device->cache.gid_cache); 378 kfree(device->cache.gid_cache);
379 kfree(device->cache.lmc_cache);
352} 380}
353 381
354static struct ib_client cache_client = { 382static struct ib_client cache_client = {
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 86fee43502cd..450adfe0a4f1 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -32,7 +32,7 @@
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 * 34 *
35 * $Id: cm.c 2821 2005-07-08 17:07:28Z sean.hefty $ 35 * $Id: cm.c 4311 2005-12-05 18:42:01Z sean.hefty $
36 */ 36 */
37 37
38#include <linux/completion.h> 38#include <linux/completion.h>
@@ -132,6 +132,7 @@ struct cm_id_private {
132 /* todo: use alternate port on send failure */ 132 /* todo: use alternate port on send failure */
133 struct cm_av av; 133 struct cm_av av;
134 struct cm_av alt_av; 134 struct cm_av alt_av;
135 struct ib_cm_compare_data *compare_data;
135 136
136 void *private_data; 137 void *private_data;
137 __be64 tid; 138 __be64 tid;
@@ -253,23 +254,13 @@ static void cm_set_private_data(struct cm_id_private *cm_id_priv,
253 cm_id_priv->private_data_len = private_data_len; 254 cm_id_priv->private_data_len = private_data_len;
254} 255}
255 256
256static void cm_set_ah_attr(struct ib_ah_attr *ah_attr, u8 port_num, 257static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
257 u16 dlid, u8 sl, u16 src_path_bits) 258 struct ib_grh *grh, struct cm_av *av)
258{
259 memset(ah_attr, 0, sizeof ah_attr);
260 ah_attr->dlid = dlid;
261 ah_attr->sl = sl;
262 ah_attr->src_path_bits = src_path_bits;
263 ah_attr->port_num = port_num;
264}
265
266static void cm_init_av_for_response(struct cm_port *port,
267 struct ib_wc *wc, struct cm_av *av)
268{ 259{
269 av->port = port; 260 av->port = port;
270 av->pkey_index = wc->pkey_index; 261 av->pkey_index = wc->pkey_index;
271 cm_set_ah_attr(&av->ah_attr, port->port_num, wc->slid, 262 ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc,
272 wc->sl, wc->dlid_path_bits); 263 grh, &av->ah_attr);
273} 264}
274 265
275static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av) 266static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
@@ -299,9 +290,8 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
299 return ret; 290 return ret;
300 291
301 av->port = port; 292 av->port = port;
302 cm_set_ah_attr(&av->ah_attr, av->port->port_num, 293 ib_init_ah_from_path(cm_dev->device, port->port_num, path,
303 be16_to_cpu(path->dlid), path->sl, 294 &av->ah_attr);
304 be16_to_cpu(path->slid) & 0x7F);
305 av->packet_life_time = path->packet_life_time; 295 av->packet_life_time = path->packet_life_time;
306 return 0; 296 return 0;
307} 297}
@@ -357,6 +347,41 @@ static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id)
357 return cm_id_priv; 347 return cm_id_priv;
358} 348}
359 349
350static void cm_mask_copy(u8 *dst, u8 *src, u8 *mask)
351{
352 int i;
353
354 for (i = 0; i < IB_CM_COMPARE_SIZE / sizeof(unsigned long); i++)
355 ((unsigned long *) dst)[i] = ((unsigned long *) src)[i] &
356 ((unsigned long *) mask)[i];
357}
358
359static int cm_compare_data(struct ib_cm_compare_data *src_data,
360 struct ib_cm_compare_data *dst_data)
361{
362 u8 src[IB_CM_COMPARE_SIZE];
363 u8 dst[IB_CM_COMPARE_SIZE];
364
365 if (!src_data || !dst_data)
366 return 0;
367
368 cm_mask_copy(src, src_data->data, dst_data->mask);
369 cm_mask_copy(dst, dst_data->data, src_data->mask);
370 return memcmp(src, dst, IB_CM_COMPARE_SIZE);
371}
372
373static int cm_compare_private_data(u8 *private_data,
374 struct ib_cm_compare_data *dst_data)
375{
376 u8 src[IB_CM_COMPARE_SIZE];
377
378 if (!dst_data)
379 return 0;
380
381 cm_mask_copy(src, private_data, dst_data->mask);
382 return memcmp(src, dst_data->data, IB_CM_COMPARE_SIZE);
383}
384
360static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv) 385static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
361{ 386{
362 struct rb_node **link = &cm.listen_service_table.rb_node; 387 struct rb_node **link = &cm.listen_service_table.rb_node;
@@ -364,14 +389,18 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
364 struct cm_id_private *cur_cm_id_priv; 389 struct cm_id_private *cur_cm_id_priv;
365 __be64 service_id = cm_id_priv->id.service_id; 390 __be64 service_id = cm_id_priv->id.service_id;
366 __be64 service_mask = cm_id_priv->id.service_mask; 391 __be64 service_mask = cm_id_priv->id.service_mask;
392 int data_cmp;
367 393
368 while (*link) { 394 while (*link) {
369 parent = *link; 395 parent = *link;
370 cur_cm_id_priv = rb_entry(parent, struct cm_id_private, 396 cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
371 service_node); 397 service_node);
398 data_cmp = cm_compare_data(cm_id_priv->compare_data,
399 cur_cm_id_priv->compare_data);
372 if ((cur_cm_id_priv->id.service_mask & service_id) == 400 if ((cur_cm_id_priv->id.service_mask & service_id) ==
373 (service_mask & cur_cm_id_priv->id.service_id) && 401 (service_mask & cur_cm_id_priv->id.service_id) &&
374 (cm_id_priv->id.device == cur_cm_id_priv->id.device)) 402 (cm_id_priv->id.device == cur_cm_id_priv->id.device) &&
403 !data_cmp)
375 return cur_cm_id_priv; 404 return cur_cm_id_priv;
376 405
377 if (cm_id_priv->id.device < cur_cm_id_priv->id.device) 406 if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
@@ -380,6 +409,10 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
380 link = &(*link)->rb_right; 409 link = &(*link)->rb_right;
381 else if (service_id < cur_cm_id_priv->id.service_id) 410 else if (service_id < cur_cm_id_priv->id.service_id)
382 link = &(*link)->rb_left; 411 link = &(*link)->rb_left;
412 else if (service_id > cur_cm_id_priv->id.service_id)
413 link = &(*link)->rb_right;
414 else if (data_cmp < 0)
415 link = &(*link)->rb_left;
383 else 416 else
384 link = &(*link)->rb_right; 417 link = &(*link)->rb_right;
385 } 418 }
@@ -389,16 +422,20 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
389} 422}
390 423
391static struct cm_id_private * cm_find_listen(struct ib_device *device, 424static struct cm_id_private * cm_find_listen(struct ib_device *device,
392 __be64 service_id) 425 __be64 service_id,
426 u8 *private_data)
393{ 427{
394 struct rb_node *node = cm.listen_service_table.rb_node; 428 struct rb_node *node = cm.listen_service_table.rb_node;
395 struct cm_id_private *cm_id_priv; 429 struct cm_id_private *cm_id_priv;
430 int data_cmp;
396 431
397 while (node) { 432 while (node) {
398 cm_id_priv = rb_entry(node, struct cm_id_private, service_node); 433 cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
434 data_cmp = cm_compare_private_data(private_data,
435 cm_id_priv->compare_data);
399 if ((cm_id_priv->id.service_mask & service_id) == 436 if ((cm_id_priv->id.service_mask & service_id) ==
400 cm_id_priv->id.service_id && 437 cm_id_priv->id.service_id &&
401 (cm_id_priv->id.device == device)) 438 (cm_id_priv->id.device == device) && !data_cmp)
402 return cm_id_priv; 439 return cm_id_priv;
403 440
404 if (device < cm_id_priv->id.device) 441 if (device < cm_id_priv->id.device)
@@ -407,6 +444,10 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device,
407 node = node->rb_right; 444 node = node->rb_right;
408 else if (service_id < cm_id_priv->id.service_id) 445 else if (service_id < cm_id_priv->id.service_id)
409 node = node->rb_left; 446 node = node->rb_left;
447 else if (service_id > cm_id_priv->id.service_id)
448 node = node->rb_right;
449 else if (data_cmp < 0)
450 node = node->rb_left;
410 else 451 else
411 node = node->rb_right; 452 node = node->rb_right;
412 } 453 }
@@ -730,15 +771,14 @@ retest:
730 wait_for_completion(&cm_id_priv->comp); 771 wait_for_completion(&cm_id_priv->comp);
731 while ((work = cm_dequeue_work(cm_id_priv)) != NULL) 772 while ((work = cm_dequeue_work(cm_id_priv)) != NULL)
732 cm_free_work(work); 773 cm_free_work(work);
733 if (cm_id_priv->private_data && cm_id_priv->private_data_len) 774 kfree(cm_id_priv->compare_data);
734 kfree(cm_id_priv->private_data); 775 kfree(cm_id_priv->private_data);
735 kfree(cm_id_priv); 776 kfree(cm_id_priv);
736} 777}
737EXPORT_SYMBOL(ib_destroy_cm_id); 778EXPORT_SYMBOL(ib_destroy_cm_id);
738 779
739int ib_cm_listen(struct ib_cm_id *cm_id, 780int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
740 __be64 service_id, 781 struct ib_cm_compare_data *compare_data)
741 __be64 service_mask)
742{ 782{
743 struct cm_id_private *cm_id_priv, *cur_cm_id_priv; 783 struct cm_id_private *cm_id_priv, *cur_cm_id_priv;
744 unsigned long flags; 784 unsigned long flags;
@@ -752,7 +792,19 @@ int ib_cm_listen(struct ib_cm_id *cm_id,
752 return -EINVAL; 792 return -EINVAL;
753 793
754 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 794 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
755 BUG_ON(cm_id->state != IB_CM_IDLE); 795 if (cm_id->state != IB_CM_IDLE)
796 return -EINVAL;
797
798 if (compare_data) {
799 cm_id_priv->compare_data = kzalloc(sizeof *compare_data,
800 GFP_KERNEL);
801 if (!cm_id_priv->compare_data)
802 return -ENOMEM;
803 cm_mask_copy(cm_id_priv->compare_data->data,
804 compare_data->data, compare_data->mask);
805 memcpy(cm_id_priv->compare_data->mask, compare_data->mask,
806 IB_CM_COMPARE_SIZE);
807 }
756 808
757 cm_id->state = IB_CM_LISTEN; 809 cm_id->state = IB_CM_LISTEN;
758 810
@@ -769,6 +821,8 @@ int ib_cm_listen(struct ib_cm_id *cm_id,
769 821
770 if (cur_cm_id_priv) { 822 if (cur_cm_id_priv) {
771 cm_id->state = IB_CM_IDLE; 823 cm_id->state = IB_CM_IDLE;
824 kfree(cm_id_priv->compare_data);
825 cm_id_priv->compare_data = NULL;
772 ret = -EBUSY; 826 ret = -EBUSY;
773 } 827 }
774 return ret; 828 return ret;
@@ -1241,7 +1295,8 @@ static struct cm_id_private * cm_match_req(struct cm_work *work,
1241 1295
1242 /* Find matching listen request. */ 1296 /* Find matching listen request. */
1243 listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device, 1297 listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device,
1244 req_msg->service_id); 1298 req_msg->service_id,
1299 req_msg->private_data);
1245 if (!listen_cm_id_priv) { 1300 if (!listen_cm_id_priv) {
1246 spin_unlock_irqrestore(&cm.lock, flags); 1301 spin_unlock_irqrestore(&cm.lock, flags);
1247 cm_issue_rej(work->port, work->mad_recv_wc, 1302 cm_issue_rej(work->port, work->mad_recv_wc,
@@ -1276,6 +1331,7 @@ static int cm_req_handler(struct cm_work *work)
1276 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 1331 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
1277 cm_id_priv->id.remote_id = req_msg->local_comm_id; 1332 cm_id_priv->id.remote_id = req_msg->local_comm_id;
1278 cm_init_av_for_response(work->port, work->mad_recv_wc->wc, 1333 cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
1334 work->mad_recv_wc->recv_buf.grh,
1279 &cm_id_priv->av); 1335 &cm_id_priv->av);
1280 cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv-> 1336 cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv->
1281 id.local_id); 1337 id.local_id);
@@ -2549,7 +2605,7 @@ static void cm_format_sidr_req(struct cm_sidr_req_msg *sidr_req_msg,
2549 cm_format_mad_hdr(&sidr_req_msg->hdr, CM_SIDR_REQ_ATTR_ID, 2605 cm_format_mad_hdr(&sidr_req_msg->hdr, CM_SIDR_REQ_ATTR_ID,
2550 cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR)); 2606 cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR));
2551 sidr_req_msg->request_id = cm_id_priv->id.local_id; 2607 sidr_req_msg->request_id = cm_id_priv->id.local_id;
2552 sidr_req_msg->pkey = cpu_to_be16(param->pkey); 2608 sidr_req_msg->pkey = cpu_to_be16(param->path->pkey);
2553 sidr_req_msg->service_id = param->service_id; 2609 sidr_req_msg->service_id = param->service_id;
2554 2610
2555 if (param->private_data && param->private_data_len) 2611 if (param->private_data && param->private_data_len)
@@ -2641,6 +2697,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
2641 cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid); 2697 cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid);
2642 cm_id_priv->av.dgid.global.interface_id = 0; 2698 cm_id_priv->av.dgid.global.interface_id = 0;
2643 cm_init_av_for_response(work->port, work->mad_recv_wc->wc, 2699 cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
2700 work->mad_recv_wc->recv_buf.grh,
2644 &cm_id_priv->av); 2701 &cm_id_priv->av);
2645 cm_id_priv->id.remote_id = sidr_req_msg->request_id; 2702 cm_id_priv->id.remote_id = sidr_req_msg->request_id;
2646 cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD; 2703 cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD;
@@ -2654,7 +2711,8 @@ static int cm_sidr_req_handler(struct cm_work *work)
2654 goto out; /* Duplicate message. */ 2711 goto out; /* Duplicate message. */
2655 } 2712 }
2656 cur_cm_id_priv = cm_find_listen(cm_id->device, 2713 cur_cm_id_priv = cm_find_listen(cm_id->device,
2657 sidr_req_msg->service_id); 2714 sidr_req_msg->service_id,
2715 sidr_req_msg->private_data);
2658 if (!cur_cm_id_priv) { 2716 if (!cur_cm_id_priv) {
2659 rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); 2717 rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
2660 spin_unlock_irqrestore(&cm.lock, flags); 2718 spin_unlock_irqrestore(&cm.lock, flags);
@@ -3291,7 +3349,6 @@ error:
3291 3349
3292static void __exit ib_cm_cleanup(void) 3350static void __exit ib_cm_cleanup(void)
3293{ 3351{
3294 flush_workqueue(cm.wq);
3295 destroy_workqueue(cm.wq); 3352 destroy_workqueue(cm.wq);
3296 ib_unregister_client(&cm_client); 3353 ib_unregister_client(&cm_client);
3297 idr_destroy(&cm.local_id_table); 3354 idr_destroy(&cm.local_id_table);
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
new file mode 100644
index 000000000000..a76834edf608
--- /dev/null
+++ b/drivers/infiniband/core/cma.c
@@ -0,0 +1,1927 @@
1/*
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
6 *
7 * This Software is licensed under one of the following licenses:
8 *
9 * 1) under the terms of the "Common Public License 1.0" a copy of which is
10 * available from the Open Source Initiative, see
11 * http://www.opensource.org/licenses/cpl.php.
12 *
13 * 2) under the terms of the "The BSD License" a copy of which is
14 * available from the Open Source Initiative, see
15 * http://www.opensource.org/licenses/bsd-license.php.
16 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
18 * copy of which is available from the Open Source Initiative, see
19 * http://www.opensource.org/licenses/gpl-license.php.
20 *
21 * Licensee has the right to choose one of the above licenses.
22 *
23 * Redistributions of source code must retain the above copyright
24 * notice and one of the license notices.
25 *
26 * Redistributions in binary form must reproduce both the above copyright
27 * notice, one of the license notices in the documentation
28 * and/or other materials provided with the distribution.
29 *
30 */
31
32#include <linux/completion.h>
33#include <linux/in.h>
34#include <linux/in6.h>
35#include <linux/mutex.h>
36#include <linux/random.h>
37#include <linux/idr.h>
38
39#include <net/tcp.h>
40
41#include <rdma/rdma_cm.h>
42#include <rdma/rdma_cm_ib.h>
43#include <rdma/ib_cache.h>
44#include <rdma/ib_cm.h>
45#include <rdma/ib_sa.h>
46
47MODULE_AUTHOR("Sean Hefty");
48MODULE_DESCRIPTION("Generic RDMA CM Agent");
49MODULE_LICENSE("Dual BSD/GPL");
50
51#define CMA_CM_RESPONSE_TIMEOUT 20
52#define CMA_MAX_CM_RETRIES 3
53
54static void cma_add_one(struct ib_device *device);
55static void cma_remove_one(struct ib_device *device);
56
57static struct ib_client cma_client = {
58 .name = "cma",
59 .add = cma_add_one,
60 .remove = cma_remove_one
61};
62
63static LIST_HEAD(dev_list);
64static LIST_HEAD(listen_any_list);
65static DEFINE_MUTEX(lock);
66static struct workqueue_struct *cma_wq;
67static DEFINE_IDR(sdp_ps);
68static DEFINE_IDR(tcp_ps);
69
70struct cma_device {
71 struct list_head list;
72 struct ib_device *device;
73 __be64 node_guid;
74 struct completion comp;
75 atomic_t refcount;
76 struct list_head id_list;
77};
78
79enum cma_state {
80 CMA_IDLE,
81 CMA_ADDR_QUERY,
82 CMA_ADDR_RESOLVED,
83 CMA_ROUTE_QUERY,
84 CMA_ROUTE_RESOLVED,
85 CMA_CONNECT,
86 CMA_DISCONNECT,
87 CMA_ADDR_BOUND,
88 CMA_LISTEN,
89 CMA_DEVICE_REMOVAL,
90 CMA_DESTROYING
91};
92
93struct rdma_bind_list {
94 struct idr *ps;
95 struct hlist_head owners;
96 unsigned short port;
97};
98
99/*
100 * Device removal can occur at anytime, so we need extra handling to
101 * serialize notifying the user of device removal with other callbacks.
102 * We do this by disabling removal notification while a callback is in process,
103 * and reporting it after the callback completes.
104 */
105struct rdma_id_private {
106 struct rdma_cm_id id;
107
108 struct rdma_bind_list *bind_list;
109 struct hlist_node node;
110 struct list_head list;
111 struct list_head listen_list;
112 struct cma_device *cma_dev;
113
114 enum cma_state state;
115 spinlock_t lock;
116 struct completion comp;
117 atomic_t refcount;
118 wait_queue_head_t wait_remove;
119 atomic_t dev_remove;
120
121 int backlog;
122 int timeout_ms;
123 struct ib_sa_query *query;
124 int query_id;
125 union {
126 struct ib_cm_id *ib;
127 } cm_id;
128
129 u32 seq_num;
130 u32 qp_num;
131 enum ib_qp_type qp_type;
132 u8 srq;
133};
134
135struct cma_work {
136 struct work_struct work;
137 struct rdma_id_private *id;
138 enum cma_state old_state;
139 enum cma_state new_state;
140 struct rdma_cm_event event;
141};
142
143union cma_ip_addr {
144 struct in6_addr ip6;
145 struct {
146 __u32 pad[3];
147 __u32 addr;
148 } ip4;
149};
150
151struct cma_hdr {
152 u8 cma_version;
153 u8 ip_version; /* IP version: 7:4 */
154 __u16 port;
155 union cma_ip_addr src_addr;
156 union cma_ip_addr dst_addr;
157};
158
159struct sdp_hh {
160 u8 bsdh[16];
161 u8 sdp_version; /* Major version: 7:4 */
162 u8 ip_version; /* IP version: 7:4 */
163 u8 sdp_specific1[10];
164 __u16 port;
165 __u16 sdp_specific2;
166 union cma_ip_addr src_addr;
167 union cma_ip_addr dst_addr;
168};
169
170struct sdp_hah {
171 u8 bsdh[16];
172 u8 sdp_version;
173};
174
175#define CMA_VERSION 0x00
176#define SDP_MAJ_VERSION 0x2
177
178static int cma_comp(struct rdma_id_private *id_priv, enum cma_state comp)
179{
180 unsigned long flags;
181 int ret;
182
183 spin_lock_irqsave(&id_priv->lock, flags);
184 ret = (id_priv->state == comp);
185 spin_unlock_irqrestore(&id_priv->lock, flags);
186 return ret;
187}
188
189static int cma_comp_exch(struct rdma_id_private *id_priv,
190 enum cma_state comp, enum cma_state exch)
191{
192 unsigned long flags;
193 int ret;
194
195 spin_lock_irqsave(&id_priv->lock, flags);
196 if ((ret = (id_priv->state == comp)))
197 id_priv->state = exch;
198 spin_unlock_irqrestore(&id_priv->lock, flags);
199 return ret;
200}
201
202static enum cma_state cma_exch(struct rdma_id_private *id_priv,
203 enum cma_state exch)
204{
205 unsigned long flags;
206 enum cma_state old;
207
208 spin_lock_irqsave(&id_priv->lock, flags);
209 old = id_priv->state;
210 id_priv->state = exch;
211 spin_unlock_irqrestore(&id_priv->lock, flags);
212 return old;
213}
214
215static inline u8 cma_get_ip_ver(struct cma_hdr *hdr)
216{
217 return hdr->ip_version >> 4;
218}
219
220static inline void cma_set_ip_ver(struct cma_hdr *hdr, u8 ip_ver)
221{
222 hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF);
223}
224
225static inline u8 sdp_get_majv(u8 sdp_version)
226{
227 return sdp_version >> 4;
228}
229
230static inline u8 sdp_get_ip_ver(struct sdp_hh *hh)
231{
232 return hh->ip_version >> 4;
233}
234
235static inline void sdp_set_ip_ver(struct sdp_hh *hh, u8 ip_ver)
236{
237 hh->ip_version = (ip_ver << 4) | (hh->ip_version & 0xF);
238}
239
240static void cma_attach_to_dev(struct rdma_id_private *id_priv,
241 struct cma_device *cma_dev)
242{
243 atomic_inc(&cma_dev->refcount);
244 id_priv->cma_dev = cma_dev;
245 id_priv->id.device = cma_dev->device;
246 list_add_tail(&id_priv->list, &cma_dev->id_list);
247}
248
249static inline void cma_deref_dev(struct cma_device *cma_dev)
250{
251 if (atomic_dec_and_test(&cma_dev->refcount))
252 complete(&cma_dev->comp);
253}
254
255static void cma_detach_from_dev(struct rdma_id_private *id_priv)
256{
257 list_del(&id_priv->list);
258 cma_deref_dev(id_priv->cma_dev);
259 id_priv->cma_dev = NULL;
260}
261
262static int cma_acquire_ib_dev(struct rdma_id_private *id_priv)
263{
264 struct cma_device *cma_dev;
265 union ib_gid *gid;
266 int ret = -ENODEV;
267
268 gid = ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr);
269
270 mutex_lock(&lock);
271 list_for_each_entry(cma_dev, &dev_list, list) {
272 ret = ib_find_cached_gid(cma_dev->device, gid,
273 &id_priv->id.port_num, NULL);
274 if (!ret) {
275 cma_attach_to_dev(id_priv, cma_dev);
276 break;
277 }
278 }
279 mutex_unlock(&lock);
280 return ret;
281}
282
283static int cma_acquire_dev(struct rdma_id_private *id_priv)
284{
285 switch (id_priv->id.route.addr.dev_addr.dev_type) {
286 case IB_NODE_CA:
287 return cma_acquire_ib_dev(id_priv);
288 default:
289 return -ENODEV;
290 }
291}
292
293static void cma_deref_id(struct rdma_id_private *id_priv)
294{
295 if (atomic_dec_and_test(&id_priv->refcount))
296 complete(&id_priv->comp);
297}
298
299static void cma_release_remove(struct rdma_id_private *id_priv)
300{
301 if (atomic_dec_and_test(&id_priv->dev_remove))
302 wake_up(&id_priv->wait_remove);
303}
304
305struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
306 void *context, enum rdma_port_space ps)
307{
308 struct rdma_id_private *id_priv;
309
310 id_priv = kzalloc(sizeof *id_priv, GFP_KERNEL);
311 if (!id_priv)
312 return ERR_PTR(-ENOMEM);
313
314 id_priv->state = CMA_IDLE;
315 id_priv->id.context = context;
316 id_priv->id.event_handler = event_handler;
317 id_priv->id.ps = ps;
318 spin_lock_init(&id_priv->lock);
319 init_completion(&id_priv->comp);
320 atomic_set(&id_priv->refcount, 1);
321 init_waitqueue_head(&id_priv->wait_remove);
322 atomic_set(&id_priv->dev_remove, 0);
323 INIT_LIST_HEAD(&id_priv->listen_list);
324 get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
325
326 return &id_priv->id;
327}
328EXPORT_SYMBOL(rdma_create_id);
329
330static int cma_init_ib_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
331{
332 struct ib_qp_attr qp_attr;
333 struct rdma_dev_addr *dev_addr;
334 int ret;
335
336 dev_addr = &id_priv->id.route.addr.dev_addr;
337 ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num,
338 ib_addr_get_pkey(dev_addr),
339 &qp_attr.pkey_index);
340 if (ret)
341 return ret;
342
343 qp_attr.qp_state = IB_QPS_INIT;
344 qp_attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE;
345 qp_attr.port_num = id_priv->id.port_num;
346 return ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS |
347 IB_QP_PKEY_INDEX | IB_QP_PORT);
348}
349
350int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
351 struct ib_qp_init_attr *qp_init_attr)
352{
353 struct rdma_id_private *id_priv;
354 struct ib_qp *qp;
355 int ret;
356
357 id_priv = container_of(id, struct rdma_id_private, id);
358 if (id->device != pd->device)
359 return -EINVAL;
360
361 qp = ib_create_qp(pd, qp_init_attr);
362 if (IS_ERR(qp))
363 return PTR_ERR(qp);
364
365 switch (id->device->node_type) {
366 case IB_NODE_CA:
367 ret = cma_init_ib_qp(id_priv, qp);
368 break;
369 default:
370 ret = -ENOSYS;
371 break;
372 }
373
374 if (ret)
375 goto err;
376
377 id->qp = qp;
378 id_priv->qp_num = qp->qp_num;
379 id_priv->qp_type = qp->qp_type;
380 id_priv->srq = (qp->srq != NULL);
381 return 0;
382err:
383 ib_destroy_qp(qp);
384 return ret;
385}
386EXPORT_SYMBOL(rdma_create_qp);
387
388void rdma_destroy_qp(struct rdma_cm_id *id)
389{
390 ib_destroy_qp(id->qp);
391}
392EXPORT_SYMBOL(rdma_destroy_qp);
393
394static int cma_modify_qp_rtr(struct rdma_cm_id *id)
395{
396 struct ib_qp_attr qp_attr;
397 int qp_attr_mask, ret;
398
399 if (!id->qp)
400 return 0;
401
402 /* Need to update QP attributes from default values. */
403 qp_attr.qp_state = IB_QPS_INIT;
404 ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
405 if (ret)
406 return ret;
407
408 ret = ib_modify_qp(id->qp, &qp_attr, qp_attr_mask);
409 if (ret)
410 return ret;
411
412 qp_attr.qp_state = IB_QPS_RTR;
413 ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
414 if (ret)
415 return ret;
416
417 return ib_modify_qp(id->qp, &qp_attr, qp_attr_mask);
418}
419
420static int cma_modify_qp_rts(struct rdma_cm_id *id)
421{
422 struct ib_qp_attr qp_attr;
423 int qp_attr_mask, ret;
424
425 if (!id->qp)
426 return 0;
427
428 qp_attr.qp_state = IB_QPS_RTS;
429 ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
430 if (ret)
431 return ret;
432
433 return ib_modify_qp(id->qp, &qp_attr, qp_attr_mask);
434}
435
436static int cma_modify_qp_err(struct rdma_cm_id *id)
437{
438 struct ib_qp_attr qp_attr;
439
440 if (!id->qp)
441 return 0;
442
443 qp_attr.qp_state = IB_QPS_ERR;
444 return ib_modify_qp(id->qp, &qp_attr, IB_QP_STATE);
445}
446
447int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
448 int *qp_attr_mask)
449{
450 struct rdma_id_private *id_priv;
451 int ret;
452
453 id_priv = container_of(id, struct rdma_id_private, id);
454 switch (id_priv->id.device->node_type) {
455 case IB_NODE_CA:
456 ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, qp_attr,
457 qp_attr_mask);
458 if (qp_attr->qp_state == IB_QPS_RTR)
459 qp_attr->rq_psn = id_priv->seq_num;
460 break;
461 default:
462 ret = -ENOSYS;
463 break;
464 }
465
466 return ret;
467}
468EXPORT_SYMBOL(rdma_init_qp_attr);
469
470static inline int cma_zero_addr(struct sockaddr *addr)
471{
472 struct in6_addr *ip6;
473
474 if (addr->sa_family == AF_INET)
475 return ZERONET(((struct sockaddr_in *) addr)->sin_addr.s_addr);
476 else {
477 ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
478 return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |
479 ip6->s6_addr32[3] | ip6->s6_addr32[4]) == 0;
480 }
481}
482
483static inline int cma_loopback_addr(struct sockaddr *addr)
484{
485 return LOOPBACK(((struct sockaddr_in *) addr)->sin_addr.s_addr);
486}
487
488static inline int cma_any_addr(struct sockaddr *addr)
489{
490 return cma_zero_addr(addr) || cma_loopback_addr(addr);
491}
492
493static inline int cma_any_port(struct sockaddr *addr)
494{
495 return !((struct sockaddr_in *) addr)->sin_port;
496}
497
498static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
499 u8 *ip_ver, __u16 *port,
500 union cma_ip_addr **src, union cma_ip_addr **dst)
501{
502 switch (ps) {
503 case RDMA_PS_SDP:
504 if (sdp_get_majv(((struct sdp_hh *) hdr)->sdp_version) !=
505 SDP_MAJ_VERSION)
506 return -EINVAL;
507
508 *ip_ver = sdp_get_ip_ver(hdr);
509 *port = ((struct sdp_hh *) hdr)->port;
510 *src = &((struct sdp_hh *) hdr)->src_addr;
511 *dst = &((struct sdp_hh *) hdr)->dst_addr;
512 break;
513 default:
514 if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION)
515 return -EINVAL;
516
517 *ip_ver = cma_get_ip_ver(hdr);
518 *port = ((struct cma_hdr *) hdr)->port;
519 *src = &((struct cma_hdr *) hdr)->src_addr;
520 *dst = &((struct cma_hdr *) hdr)->dst_addr;
521 break;
522 }
523
524 if (*ip_ver != 4 && *ip_ver != 6)
525 return -EINVAL;
526 return 0;
527}
528
529static void cma_save_net_info(struct rdma_addr *addr,
530 struct rdma_addr *listen_addr,
531 u8 ip_ver, __u16 port,
532 union cma_ip_addr *src, union cma_ip_addr *dst)
533{
534 struct sockaddr_in *listen4, *ip4;
535 struct sockaddr_in6 *listen6, *ip6;
536
537 switch (ip_ver) {
538 case 4:
539 listen4 = (struct sockaddr_in *) &listen_addr->src_addr;
540 ip4 = (struct sockaddr_in *) &addr->src_addr;
541 ip4->sin_family = listen4->sin_family;
542 ip4->sin_addr.s_addr = dst->ip4.addr;
543 ip4->sin_port = listen4->sin_port;
544
545 ip4 = (struct sockaddr_in *) &addr->dst_addr;
546 ip4->sin_family = listen4->sin_family;
547 ip4->sin_addr.s_addr = src->ip4.addr;
548 ip4->sin_port = port;
549 break;
550 case 6:
551 listen6 = (struct sockaddr_in6 *) &listen_addr->src_addr;
552 ip6 = (struct sockaddr_in6 *) &addr->src_addr;
553 ip6->sin6_family = listen6->sin6_family;
554 ip6->sin6_addr = dst->ip6;
555 ip6->sin6_port = listen6->sin6_port;
556
557 ip6 = (struct sockaddr_in6 *) &addr->dst_addr;
558 ip6->sin6_family = listen6->sin6_family;
559 ip6->sin6_addr = src->ip6;
560 ip6->sin6_port = port;
561 break;
562 default:
563 break;
564 }
565}
566
567static inline int cma_user_data_offset(enum rdma_port_space ps)
568{
569 switch (ps) {
570 case RDMA_PS_SDP:
571 return 0;
572 default:
573 return sizeof(struct cma_hdr);
574 }
575}
576
577static int cma_notify_user(struct rdma_id_private *id_priv,
578 enum rdma_cm_event_type type, int status,
579 void *data, u8 data_len)
580{
581 struct rdma_cm_event event;
582
583 event.event = type;
584 event.status = status;
585 event.private_data = data;
586 event.private_data_len = data_len;
587
588 return id_priv->id.event_handler(&id_priv->id, &event);
589}
590
591static void cma_cancel_route(struct rdma_id_private *id_priv)
592{
593 switch (id_priv->id.device->node_type) {
594 case IB_NODE_CA:
595 if (id_priv->query)
596 ib_sa_cancel_query(id_priv->query_id, id_priv->query);
597 break;
598 default:
599 break;
600 }
601}
602
603static inline int cma_internal_listen(struct rdma_id_private *id_priv)
604{
605 return (id_priv->state == CMA_LISTEN) && id_priv->cma_dev &&
606 cma_any_addr(&id_priv->id.route.addr.src_addr);
607}
608
609static void cma_destroy_listen(struct rdma_id_private *id_priv)
610{
611 cma_exch(id_priv, CMA_DESTROYING);
612
613 if (id_priv->cma_dev) {
614 switch (id_priv->id.device->node_type) {
615 case IB_NODE_CA:
616 if (id_priv->cm_id.ib && !IS_ERR(id_priv->cm_id.ib))
617 ib_destroy_cm_id(id_priv->cm_id.ib);
618 break;
619 default:
620 break;
621 }
622 cma_detach_from_dev(id_priv);
623 }
624 list_del(&id_priv->listen_list);
625
626 cma_deref_id(id_priv);
627 wait_for_completion(&id_priv->comp);
628
629 kfree(id_priv);
630}
631
632static void cma_cancel_listens(struct rdma_id_private *id_priv)
633{
634 struct rdma_id_private *dev_id_priv;
635
636 mutex_lock(&lock);
637 list_del(&id_priv->list);
638
639 while (!list_empty(&id_priv->listen_list)) {
640 dev_id_priv = list_entry(id_priv->listen_list.next,
641 struct rdma_id_private, listen_list);
642 cma_destroy_listen(dev_id_priv);
643 }
644 mutex_unlock(&lock);
645}
646
647static void cma_cancel_operation(struct rdma_id_private *id_priv,
648 enum cma_state state)
649{
650 switch (state) {
651 case CMA_ADDR_QUERY:
652 rdma_addr_cancel(&id_priv->id.route.addr.dev_addr);
653 break;
654 case CMA_ROUTE_QUERY:
655 cma_cancel_route(id_priv);
656 break;
657 case CMA_LISTEN:
658 if (cma_any_addr(&id_priv->id.route.addr.src_addr) &&
659 !id_priv->cma_dev)
660 cma_cancel_listens(id_priv);
661 break;
662 default:
663 break;
664 }
665}
666
667static void cma_release_port(struct rdma_id_private *id_priv)
668{
669 struct rdma_bind_list *bind_list = id_priv->bind_list;
670
671 if (!bind_list)
672 return;
673
674 mutex_lock(&lock);
675 hlist_del(&id_priv->node);
676 if (hlist_empty(&bind_list->owners)) {
677 idr_remove(bind_list->ps, bind_list->port);
678 kfree(bind_list);
679 }
680 mutex_unlock(&lock);
681}
682
683void rdma_destroy_id(struct rdma_cm_id *id)
684{
685 struct rdma_id_private *id_priv;
686 enum cma_state state;
687
688 id_priv = container_of(id, struct rdma_id_private, id);
689 state = cma_exch(id_priv, CMA_DESTROYING);
690 cma_cancel_operation(id_priv, state);
691
692 if (id_priv->cma_dev) {
693 switch (id->device->node_type) {
694 case IB_NODE_CA:
695 if (id_priv->cm_id.ib && !IS_ERR(id_priv->cm_id.ib))
696 ib_destroy_cm_id(id_priv->cm_id.ib);
697 break;
698 default:
699 break;
700 }
701 mutex_lock(&lock);
702 cma_detach_from_dev(id_priv);
703 mutex_unlock(&lock);
704 }
705
706 cma_release_port(id_priv);
707 cma_deref_id(id_priv);
708 wait_for_completion(&id_priv->comp);
709
710 kfree(id_priv->id.route.path_rec);
711 kfree(id_priv);
712}
713EXPORT_SYMBOL(rdma_destroy_id);
714
715static int cma_rep_recv(struct rdma_id_private *id_priv)
716{
717 int ret;
718
719 ret = cma_modify_qp_rtr(&id_priv->id);
720 if (ret)
721 goto reject;
722
723 ret = cma_modify_qp_rts(&id_priv->id);
724 if (ret)
725 goto reject;
726
727 ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0);
728 if (ret)
729 goto reject;
730
731 return 0;
732reject:
733 cma_modify_qp_err(&id_priv->id);
734 ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
735 NULL, 0, NULL, 0);
736 return ret;
737}
738
739static int cma_verify_rep(struct rdma_id_private *id_priv, void *data)
740{
741 if (id_priv->id.ps == RDMA_PS_SDP &&
742 sdp_get_majv(((struct sdp_hah *) data)->sdp_version) !=
743 SDP_MAJ_VERSION)
744 return -EINVAL;
745
746 return 0;
747}
748
749static int cma_rtu_recv(struct rdma_id_private *id_priv)
750{
751 int ret;
752
753 ret = cma_modify_qp_rts(&id_priv->id);
754 if (ret)
755 goto reject;
756
757 return 0;
758reject:
759 cma_modify_qp_err(&id_priv->id);
760 ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
761 NULL, 0, NULL, 0);
762 return ret;
763}
764
765static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
766{
767 struct rdma_id_private *id_priv = cm_id->context;
768 enum rdma_cm_event_type event;
769 u8 private_data_len = 0;
770 int ret = 0, status = 0;
771
772 atomic_inc(&id_priv->dev_remove);
773 if (!cma_comp(id_priv, CMA_CONNECT))
774 goto out;
775
776 switch (ib_event->event) {
777 case IB_CM_REQ_ERROR:
778 case IB_CM_REP_ERROR:
779 event = RDMA_CM_EVENT_UNREACHABLE;
780 status = -ETIMEDOUT;
781 break;
782 case IB_CM_REP_RECEIVED:
783 status = cma_verify_rep(id_priv, ib_event->private_data);
784 if (status)
785 event = RDMA_CM_EVENT_CONNECT_ERROR;
786 else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) {
787 status = cma_rep_recv(id_priv);
788 event = status ? RDMA_CM_EVENT_CONNECT_ERROR :
789 RDMA_CM_EVENT_ESTABLISHED;
790 } else
791 event = RDMA_CM_EVENT_CONNECT_RESPONSE;
792 private_data_len = IB_CM_REP_PRIVATE_DATA_SIZE;
793 break;
794 case IB_CM_RTU_RECEIVED:
795 status = cma_rtu_recv(id_priv);
796 event = status ? RDMA_CM_EVENT_CONNECT_ERROR :
797 RDMA_CM_EVENT_ESTABLISHED;
798 break;
799 case IB_CM_DREQ_ERROR:
800 status = -ETIMEDOUT; /* fall through */
801 case IB_CM_DREQ_RECEIVED:
802 case IB_CM_DREP_RECEIVED:
803 if (!cma_comp_exch(id_priv, CMA_CONNECT, CMA_DISCONNECT))
804 goto out;
805 event = RDMA_CM_EVENT_DISCONNECTED;
806 break;
807 case IB_CM_TIMEWAIT_EXIT:
808 case IB_CM_MRA_RECEIVED:
809 /* ignore event */
810 goto out;
811 case IB_CM_REJ_RECEIVED:
812 cma_modify_qp_err(&id_priv->id);
813 status = ib_event->param.rej_rcvd.reason;
814 event = RDMA_CM_EVENT_REJECTED;
815 break;
816 default:
817 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d",
818 ib_event->event);
819 goto out;
820 }
821
822 ret = cma_notify_user(id_priv, event, status, ib_event->private_data,
823 private_data_len);
824 if (ret) {
825 /* Destroy the CM ID by returning a non-zero value. */
826 id_priv->cm_id.ib = NULL;
827 cma_exch(id_priv, CMA_DESTROYING);
828 cma_release_remove(id_priv);
829 rdma_destroy_id(&id_priv->id);
830 return ret;
831 }
832out:
833 cma_release_remove(id_priv);
834 return ret;
835}
836
837static struct rdma_id_private *cma_new_id(struct rdma_cm_id *listen_id,
838 struct ib_cm_event *ib_event)
839{
840 struct rdma_id_private *id_priv;
841 struct rdma_cm_id *id;
842 struct rdma_route *rt;
843 union cma_ip_addr *src, *dst;
844 __u16 port;
845 u8 ip_ver;
846
847 id = rdma_create_id(listen_id->event_handler, listen_id->context,
848 listen_id->ps);
849 if (IS_ERR(id))
850 return NULL;
851
852 rt = &id->route;
853 rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
854 rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths, GFP_KERNEL);
855 if (!rt->path_rec)
856 goto err;
857
858 if (cma_get_net_info(ib_event->private_data, listen_id->ps,
859 &ip_ver, &port, &src, &dst))
860 goto err;
861
862 cma_save_net_info(&id->route.addr, &listen_id->route.addr,
863 ip_ver, port, src, dst);
864 rt->path_rec[0] = *ib_event->param.req_rcvd.primary_path;
865 if (rt->num_paths == 2)
866 rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
867
868 ib_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
869 ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
870 ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
871 rt->addr.dev_addr.dev_type = IB_NODE_CA;
872
873 id_priv = container_of(id, struct rdma_id_private, id);
874 id_priv->state = CMA_CONNECT;
875 return id_priv;
876err:
877 rdma_destroy_id(id);
878 return NULL;
879}
880
881static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
882{
883 struct rdma_id_private *listen_id, *conn_id;
884 int offset, ret;
885
886 listen_id = cm_id->context;
887 atomic_inc(&listen_id->dev_remove);
888 if (!cma_comp(listen_id, CMA_LISTEN)) {
889 ret = -ECONNABORTED;
890 goto out;
891 }
892
893 conn_id = cma_new_id(&listen_id->id, ib_event);
894 if (!conn_id) {
895 ret = -ENOMEM;
896 goto out;
897 }
898
899 atomic_inc(&conn_id->dev_remove);
900 ret = cma_acquire_ib_dev(conn_id);
901 if (ret) {
902 ret = -ENODEV;
903 cma_release_remove(conn_id);
904 rdma_destroy_id(&conn_id->id);
905 goto out;
906 }
907
908 conn_id->cm_id.ib = cm_id;
909 cm_id->context = conn_id;
910 cm_id->cm_handler = cma_ib_handler;
911
912 offset = cma_user_data_offset(listen_id->id.ps);
913 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0,
914 ib_event->private_data + offset,
915 IB_CM_REQ_PRIVATE_DATA_SIZE - offset);
916 if (ret) {
917 /* Destroy the CM ID by returning a non-zero value. */
918 conn_id->cm_id.ib = NULL;
919 cma_exch(conn_id, CMA_DESTROYING);
920 cma_release_remove(conn_id);
921 rdma_destroy_id(&conn_id->id);
922 }
923out:
924 cma_release_remove(listen_id);
925 return ret;
926}
927
928static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr)
929{
930 return cpu_to_be64(((u64)ps << 16) +
931 be16_to_cpu(((struct sockaddr_in *) addr)->sin_port));
932}
933
934static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
935 struct ib_cm_compare_data *compare)
936{
937 struct cma_hdr *cma_data, *cma_mask;
938 struct sdp_hh *sdp_data, *sdp_mask;
939 __u32 ip4_addr;
940 struct in6_addr ip6_addr;
941
942 memset(compare, 0, sizeof *compare);
943 cma_data = (void *) compare->data;
944 cma_mask = (void *) compare->mask;
945 sdp_data = (void *) compare->data;
946 sdp_mask = (void *) compare->mask;
947
948 switch (addr->sa_family) {
949 case AF_INET:
950 ip4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
951 if (ps == RDMA_PS_SDP) {
952 sdp_set_ip_ver(sdp_data, 4);
953 sdp_set_ip_ver(sdp_mask, 0xF);
954 sdp_data->dst_addr.ip4.addr = ip4_addr;
955 sdp_mask->dst_addr.ip4.addr = ~0;
956 } else {
957 cma_set_ip_ver(cma_data, 4);
958 cma_set_ip_ver(cma_mask, 0xF);
959 cma_data->dst_addr.ip4.addr = ip4_addr;
960 cma_mask->dst_addr.ip4.addr = ~0;
961 }
962 break;
963 case AF_INET6:
964 ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr;
965 if (ps == RDMA_PS_SDP) {
966 sdp_set_ip_ver(sdp_data, 6);
967 sdp_set_ip_ver(sdp_mask, 0xF);
968 sdp_data->dst_addr.ip6 = ip6_addr;
969 memset(&sdp_mask->dst_addr.ip6, 0xFF,
970 sizeof sdp_mask->dst_addr.ip6);
971 } else {
972 cma_set_ip_ver(cma_data, 6);
973 cma_set_ip_ver(cma_mask, 0xF);
974 cma_data->dst_addr.ip6 = ip6_addr;
975 memset(&cma_mask->dst_addr.ip6, 0xFF,
976 sizeof cma_mask->dst_addr.ip6);
977 }
978 break;
979 default:
980 break;
981 }
982}
983
984static int cma_ib_listen(struct rdma_id_private *id_priv)
985{
986 struct ib_cm_compare_data compare_data;
987 struct sockaddr *addr;
988 __be64 svc_id;
989 int ret;
990
991 id_priv->cm_id.ib = ib_create_cm_id(id_priv->id.device, cma_req_handler,
992 id_priv);
993 if (IS_ERR(id_priv->cm_id.ib))
994 return PTR_ERR(id_priv->cm_id.ib);
995
996 addr = &id_priv->id.route.addr.src_addr;
997 svc_id = cma_get_service_id(id_priv->id.ps, addr);
998 if (cma_any_addr(addr))
999 ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL);
1000 else {
1001 cma_set_compare_data(id_priv->id.ps, addr, &compare_data);
1002 ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, &compare_data);
1003 }
1004
1005 if (ret) {
1006 ib_destroy_cm_id(id_priv->cm_id.ib);
1007 id_priv->cm_id.ib = NULL;
1008 }
1009
1010 return ret;
1011}
1012
1013static int cma_listen_handler(struct rdma_cm_id *id,
1014 struct rdma_cm_event *event)
1015{
1016 struct rdma_id_private *id_priv = id->context;
1017
1018 id->context = id_priv->id.context;
1019 id->event_handler = id_priv->id.event_handler;
1020 return id_priv->id.event_handler(id, event);
1021}
1022
1023static void cma_listen_on_dev(struct rdma_id_private *id_priv,
1024 struct cma_device *cma_dev)
1025{
1026 struct rdma_id_private *dev_id_priv;
1027 struct rdma_cm_id *id;
1028 int ret;
1029
1030 id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps);
1031 if (IS_ERR(id))
1032 return;
1033
1034 dev_id_priv = container_of(id, struct rdma_id_private, id);
1035
1036 dev_id_priv->state = CMA_ADDR_BOUND;
1037 memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr,
1038 ip_addr_size(&id_priv->id.route.addr.src_addr));
1039
1040 cma_attach_to_dev(dev_id_priv, cma_dev);
1041 list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
1042
1043 ret = rdma_listen(id, id_priv->backlog);
1044 if (ret)
1045 goto err;
1046
1047 return;
1048err:
1049 cma_destroy_listen(dev_id_priv);
1050}
1051
1052static void cma_listen_on_all(struct rdma_id_private *id_priv)
1053{
1054 struct cma_device *cma_dev;
1055
1056 mutex_lock(&lock);
1057 list_add_tail(&id_priv->list, &listen_any_list);
1058 list_for_each_entry(cma_dev, &dev_list, list)
1059 cma_listen_on_dev(id_priv, cma_dev);
1060 mutex_unlock(&lock);
1061}
1062
1063static int cma_bind_any(struct rdma_cm_id *id, sa_family_t af)
1064{
1065 struct sockaddr_in addr_in;
1066
1067 memset(&addr_in, 0, sizeof addr_in);
1068 addr_in.sin_family = af;
1069 return rdma_bind_addr(id, (struct sockaddr *) &addr_in);
1070}
1071
1072int rdma_listen(struct rdma_cm_id *id, int backlog)
1073{
1074 struct rdma_id_private *id_priv;
1075 int ret;
1076
1077 id_priv = container_of(id, struct rdma_id_private, id);
1078 if (id_priv->state == CMA_IDLE) {
1079 ret = cma_bind_any(id, AF_INET);
1080 if (ret)
1081 return ret;
1082 }
1083
1084 if (!cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_LISTEN))
1085 return -EINVAL;
1086
1087 id_priv->backlog = backlog;
1088 if (id->device) {
1089 switch (id->device->node_type) {
1090 case IB_NODE_CA:
1091 ret = cma_ib_listen(id_priv);
1092 if (ret)
1093 goto err;
1094 break;
1095 default:
1096 ret = -ENOSYS;
1097 goto err;
1098 }
1099 } else
1100 cma_listen_on_all(id_priv);
1101
1102 return 0;
1103err:
1104 id_priv->backlog = 0;
1105 cma_comp_exch(id_priv, CMA_LISTEN, CMA_ADDR_BOUND);
1106 return ret;
1107}
1108EXPORT_SYMBOL(rdma_listen);
1109
1110static void cma_query_handler(int status, struct ib_sa_path_rec *path_rec,
1111 void *context)
1112{
1113 struct cma_work *work = context;
1114 struct rdma_route *route;
1115
1116 route = &work->id->id.route;
1117
1118 if (!status) {
1119 route->num_paths = 1;
1120 *route->path_rec = *path_rec;
1121 } else {
1122 work->old_state = CMA_ROUTE_QUERY;
1123 work->new_state = CMA_ADDR_RESOLVED;
1124 work->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
1125 }
1126
1127 queue_work(cma_wq, &work->work);
1128}
1129
1130static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
1131 struct cma_work *work)
1132{
1133 struct rdma_dev_addr *addr = &id_priv->id.route.addr.dev_addr;
1134 struct ib_sa_path_rec path_rec;
1135
1136 memset(&path_rec, 0, sizeof path_rec);
1137 path_rec.sgid = *ib_addr_get_sgid(addr);
1138 path_rec.dgid = *ib_addr_get_dgid(addr);
1139 path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(addr));
1140 path_rec.numb_path = 1;
1141
1142 id_priv->query_id = ib_sa_path_rec_get(id_priv->id.device,
1143 id_priv->id.port_num, &path_rec,
1144 IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
1145 IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH,
1146 timeout_ms, GFP_KERNEL,
1147 cma_query_handler, work, &id_priv->query);
1148
1149 return (id_priv->query_id < 0) ? id_priv->query_id : 0;
1150}
1151
1152static void cma_work_handler(void *data)
1153{
1154 struct cma_work *work = data;
1155 struct rdma_id_private *id_priv = work->id;
1156 int destroy = 0;
1157
1158 atomic_inc(&id_priv->dev_remove);
1159 if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
1160 goto out;
1161
1162 if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
1163 cma_exch(id_priv, CMA_DESTROYING);
1164 destroy = 1;
1165 }
1166out:
1167 cma_release_remove(id_priv);
1168 cma_deref_id(id_priv);
1169 if (destroy)
1170 rdma_destroy_id(&id_priv->id);
1171 kfree(work);
1172}
1173
1174static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
1175{
1176 struct rdma_route *route = &id_priv->id.route;
1177 struct cma_work *work;
1178 int ret;
1179
1180 work = kzalloc(sizeof *work, GFP_KERNEL);
1181 if (!work)
1182 return -ENOMEM;
1183
1184 work->id = id_priv;
1185 INIT_WORK(&work->work, cma_work_handler, work);
1186 work->old_state = CMA_ROUTE_QUERY;
1187 work->new_state = CMA_ROUTE_RESOLVED;
1188 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
1189
1190 route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
1191 if (!route->path_rec) {
1192 ret = -ENOMEM;
1193 goto err1;
1194 }
1195
1196 ret = cma_query_ib_route(id_priv, timeout_ms, work);
1197 if (ret)
1198 goto err2;
1199
1200 return 0;
1201err2:
1202 kfree(route->path_rec);
1203 route->path_rec = NULL;
1204err1:
1205 kfree(work);
1206 return ret;
1207}
1208
1209int rdma_set_ib_paths(struct rdma_cm_id *id,
1210 struct ib_sa_path_rec *path_rec, int num_paths)
1211{
1212 struct rdma_id_private *id_priv;
1213 int ret;
1214
1215 id_priv = container_of(id, struct rdma_id_private, id);
1216 if (!cma_comp_exch(id_priv, CMA_ADDR_RESOLVED, CMA_ROUTE_RESOLVED))
1217 return -EINVAL;
1218
1219 id->route.path_rec = kmalloc(sizeof *path_rec * num_paths, GFP_KERNEL);
1220 if (!id->route.path_rec) {
1221 ret = -ENOMEM;
1222 goto err;
1223 }
1224
1225 memcpy(id->route.path_rec, path_rec, sizeof *path_rec * num_paths);
1226 return 0;
1227err:
1228 cma_comp_exch(id_priv, CMA_ROUTE_RESOLVED, CMA_ADDR_RESOLVED);
1229 return ret;
1230}
1231EXPORT_SYMBOL(rdma_set_ib_paths);
1232
1233int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms)
1234{
1235 struct rdma_id_private *id_priv;
1236 int ret;
1237
1238 id_priv = container_of(id, struct rdma_id_private, id);
1239 if (!cma_comp_exch(id_priv, CMA_ADDR_RESOLVED, CMA_ROUTE_QUERY))
1240 return -EINVAL;
1241
1242 atomic_inc(&id_priv->refcount);
1243 switch (id->device->node_type) {
1244 case IB_NODE_CA:
1245 ret = cma_resolve_ib_route(id_priv, timeout_ms);
1246 break;
1247 default:
1248 ret = -ENOSYS;
1249 break;
1250 }
1251 if (ret)
1252 goto err;
1253
1254 return 0;
1255err:
1256 cma_comp_exch(id_priv, CMA_ROUTE_QUERY, CMA_ADDR_RESOLVED);
1257 cma_deref_id(id_priv);
1258 return ret;
1259}
1260EXPORT_SYMBOL(rdma_resolve_route);
1261
1262static int cma_bind_loopback(struct rdma_id_private *id_priv)
1263{
1264 struct cma_device *cma_dev;
1265 struct ib_port_attr port_attr;
1266 union ib_gid *gid;
1267 u16 pkey;
1268 int ret;
1269 u8 p;
1270
1271 mutex_lock(&lock);
1272 list_for_each_entry(cma_dev, &dev_list, list)
1273 for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
1274 if (!ib_query_port (cma_dev->device, p, &port_attr) &&
1275 port_attr.state == IB_PORT_ACTIVE)
1276 goto port_found;
1277
1278 if (!list_empty(&dev_list)) {
1279 p = 1;
1280 cma_dev = list_entry(dev_list.next, struct cma_device, list);
1281 } else {
1282 ret = -ENODEV;
1283 goto out;
1284 }
1285
1286port_found:
1287 gid = ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr);
1288 ret = ib_get_cached_gid(cma_dev->device, p, 0, gid);
1289 if (ret)
1290 goto out;
1291
1292 ret = ib_get_cached_pkey(cma_dev->device, p, 0, &pkey);
1293 if (ret)
1294 goto out;
1295
1296 ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
1297 id_priv->id.port_num = p;
1298 cma_attach_to_dev(id_priv, cma_dev);
1299out:
1300 mutex_unlock(&lock);
1301 return ret;
1302}
1303
1304static void addr_handler(int status, struct sockaddr *src_addr,
1305 struct rdma_dev_addr *dev_addr, void *context)
1306{
1307 struct rdma_id_private *id_priv = context;
1308 enum rdma_cm_event_type event;
1309
1310 atomic_inc(&id_priv->dev_remove);
1311 if (!id_priv->cma_dev && !status)
1312 status = cma_acquire_dev(id_priv);
1313
1314 if (status) {
1315 if (!cma_comp_exch(id_priv, CMA_ADDR_QUERY, CMA_ADDR_BOUND))
1316 goto out;
1317 event = RDMA_CM_EVENT_ADDR_ERROR;
1318 } else {
1319 if (!cma_comp_exch(id_priv, CMA_ADDR_QUERY, CMA_ADDR_RESOLVED))
1320 goto out;
1321 memcpy(&id_priv->id.route.addr.src_addr, src_addr,
1322 ip_addr_size(src_addr));
1323 event = RDMA_CM_EVENT_ADDR_RESOLVED;
1324 }
1325
1326 if (cma_notify_user(id_priv, event, status, NULL, 0)) {
1327 cma_exch(id_priv, CMA_DESTROYING);
1328 cma_release_remove(id_priv);
1329 cma_deref_id(id_priv);
1330 rdma_destroy_id(&id_priv->id);
1331 return;
1332 }
1333out:
1334 cma_release_remove(id_priv);
1335 cma_deref_id(id_priv);
1336}
1337
1338static int cma_resolve_loopback(struct rdma_id_private *id_priv)
1339{
1340 struct cma_work *work;
1341 struct sockaddr_in *src_in, *dst_in;
1342 int ret;
1343
1344 work = kzalloc(sizeof *work, GFP_KERNEL);
1345 if (!work)
1346 return -ENOMEM;
1347
1348 if (!id_priv->cma_dev) {
1349 ret = cma_bind_loopback(id_priv);
1350 if (ret)
1351 goto err;
1352 }
1353
1354 ib_addr_set_dgid(&id_priv->id.route.addr.dev_addr,
1355 ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr));
1356
1357 if (cma_zero_addr(&id_priv->id.route.addr.src_addr)) {
1358 src_in = (struct sockaddr_in *)&id_priv->id.route.addr.src_addr;
1359 dst_in = (struct sockaddr_in *)&id_priv->id.route.addr.dst_addr;
1360 src_in->sin_family = dst_in->sin_family;
1361 src_in->sin_addr.s_addr = dst_in->sin_addr.s_addr;
1362 }
1363
1364 work->id = id_priv;
1365 INIT_WORK(&work->work, cma_work_handler, work);
1366 work->old_state = CMA_ADDR_QUERY;
1367 work->new_state = CMA_ADDR_RESOLVED;
1368 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
1369 queue_work(cma_wq, &work->work);
1370 return 0;
1371err:
1372 kfree(work);
1373 return ret;
1374}
1375
1376static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
1377 struct sockaddr *dst_addr)
1378{
1379 if (src_addr && src_addr->sa_family)
1380 return rdma_bind_addr(id, src_addr);
1381 else
1382 return cma_bind_any(id, dst_addr->sa_family);
1383}
1384
1385int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
1386 struct sockaddr *dst_addr, int timeout_ms)
1387{
1388 struct rdma_id_private *id_priv;
1389 int ret;
1390
1391 id_priv = container_of(id, struct rdma_id_private, id);
1392 if (id_priv->state == CMA_IDLE) {
1393 ret = cma_bind_addr(id, src_addr, dst_addr);
1394 if (ret)
1395 return ret;
1396 }
1397
1398 if (!cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_ADDR_QUERY))
1399 return -EINVAL;
1400
1401 atomic_inc(&id_priv->refcount);
1402 memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr));
1403 if (cma_any_addr(dst_addr))
1404 ret = cma_resolve_loopback(id_priv);
1405 else
1406 ret = rdma_resolve_ip(&id->route.addr.src_addr, dst_addr,
1407 &id->route.addr.dev_addr,
1408 timeout_ms, addr_handler, id_priv);
1409 if (ret)
1410 goto err;
1411
1412 return 0;
1413err:
1414 cma_comp_exch(id_priv, CMA_ADDR_QUERY, CMA_ADDR_BOUND);
1415 cma_deref_id(id_priv);
1416 return ret;
1417}
1418EXPORT_SYMBOL(rdma_resolve_addr);
1419
1420static void cma_bind_port(struct rdma_bind_list *bind_list,
1421 struct rdma_id_private *id_priv)
1422{
1423 struct sockaddr_in *sin;
1424
1425 sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
1426 sin->sin_port = htons(bind_list->port);
1427 id_priv->bind_list = bind_list;
1428 hlist_add_head(&id_priv->node, &bind_list->owners);
1429}
1430
1431static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,
1432 unsigned short snum)
1433{
1434 struct rdma_bind_list *bind_list;
1435 int port, start, ret;
1436
1437 bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
1438 if (!bind_list)
1439 return -ENOMEM;
1440
1441 start = snum ? snum : sysctl_local_port_range[0];
1442
1443 do {
1444 ret = idr_get_new_above(ps, bind_list, start, &port);
1445 } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));
1446
1447 if (ret)
1448 goto err;
1449
1450 if ((snum && port != snum) ||
1451 (!snum && port > sysctl_local_port_range[1])) {
1452 idr_remove(ps, port);
1453 ret = -EADDRNOTAVAIL;
1454 goto err;
1455 }
1456
1457 bind_list->ps = ps;
1458 bind_list->port = (unsigned short) port;
1459 cma_bind_port(bind_list, id_priv);
1460 return 0;
1461err:
1462 kfree(bind_list);
1463 return ret;
1464}
1465
1466static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv)
1467{
1468 struct rdma_id_private *cur_id;
1469 struct sockaddr_in *sin, *cur_sin;
1470 struct rdma_bind_list *bind_list;
1471 struct hlist_node *node;
1472 unsigned short snum;
1473
1474 sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
1475 snum = ntohs(sin->sin_port);
1476 if (snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
1477 return -EACCES;
1478
1479 bind_list = idr_find(ps, snum);
1480 if (!bind_list)
1481 return cma_alloc_port(ps, id_priv, snum);
1482
1483 /*
1484 * We don't support binding to any address if anyone is bound to
1485 * a specific address on the same port.
1486 */
1487 if (cma_any_addr(&id_priv->id.route.addr.src_addr))
1488 return -EADDRNOTAVAIL;
1489
1490 hlist_for_each_entry(cur_id, node, &bind_list->owners, node) {
1491 if (cma_any_addr(&cur_id->id.route.addr.src_addr))
1492 return -EADDRNOTAVAIL;
1493
1494 cur_sin = (struct sockaddr_in *) &cur_id->id.route.addr.src_addr;
1495 if (sin->sin_addr.s_addr == cur_sin->sin_addr.s_addr)
1496 return -EADDRINUSE;
1497 }
1498
1499 cma_bind_port(bind_list, id_priv);
1500 return 0;
1501}
1502
1503static int cma_get_port(struct rdma_id_private *id_priv)
1504{
1505 struct idr *ps;
1506 int ret;
1507
1508 switch (id_priv->id.ps) {
1509 case RDMA_PS_SDP:
1510 ps = &sdp_ps;
1511 break;
1512 case RDMA_PS_TCP:
1513 ps = &tcp_ps;
1514 break;
1515 default:
1516 return -EPROTONOSUPPORT;
1517 }
1518
1519 mutex_lock(&lock);
1520 if (cma_any_port(&id_priv->id.route.addr.src_addr))
1521 ret = cma_alloc_port(ps, id_priv, 0);
1522 else
1523 ret = cma_use_port(ps, id_priv);
1524 mutex_unlock(&lock);
1525
1526 return ret;
1527}
1528
1529int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
1530{
1531 struct rdma_id_private *id_priv;
1532 int ret;
1533
1534 if (addr->sa_family != AF_INET)
1535 return -EAFNOSUPPORT;
1536
1537 id_priv = container_of(id, struct rdma_id_private, id);
1538 if (!cma_comp_exch(id_priv, CMA_IDLE, CMA_ADDR_BOUND))
1539 return -EINVAL;
1540
1541 if (!cma_any_addr(addr)) {
1542 ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
1543 if (!ret)
1544 ret = cma_acquire_dev(id_priv);
1545 if (ret)
1546 goto err;
1547 }
1548
1549 memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr));
1550 ret = cma_get_port(id_priv);
1551 if (ret)
1552 goto err;
1553
1554 return 0;
1555err:
1556 cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE);
1557 return ret;
1558}
1559EXPORT_SYMBOL(rdma_bind_addr);
1560
1561static int cma_format_hdr(void *hdr, enum rdma_port_space ps,
1562 struct rdma_route *route)
1563{
1564 struct sockaddr_in *src4, *dst4;
1565 struct cma_hdr *cma_hdr;
1566 struct sdp_hh *sdp_hdr;
1567
1568 src4 = (struct sockaddr_in *) &route->addr.src_addr;
1569 dst4 = (struct sockaddr_in *) &route->addr.dst_addr;
1570
1571 switch (ps) {
1572 case RDMA_PS_SDP:
1573 sdp_hdr = hdr;
1574 if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION)
1575 return -EINVAL;
1576 sdp_set_ip_ver(sdp_hdr, 4);
1577 sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
1578 sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
1579 sdp_hdr->port = src4->sin_port;
1580 break;
1581 default:
1582 cma_hdr = hdr;
1583 cma_hdr->cma_version = CMA_VERSION;
1584 cma_set_ip_ver(cma_hdr, 4);
1585 cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
1586 cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
1587 cma_hdr->port = src4->sin_port;
1588 break;
1589 }
1590 return 0;
1591}
1592
1593static int cma_connect_ib(struct rdma_id_private *id_priv,
1594 struct rdma_conn_param *conn_param)
1595{
1596 struct ib_cm_req_param req;
1597 struct rdma_route *route;
1598 void *private_data;
1599 int offset, ret;
1600
1601 memset(&req, 0, sizeof req);
1602 offset = cma_user_data_offset(id_priv->id.ps);
1603 req.private_data_len = offset + conn_param->private_data_len;
1604 private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
1605 if (!private_data)
1606 return -ENOMEM;
1607
1608 if (conn_param->private_data && conn_param->private_data_len)
1609 memcpy(private_data + offset, conn_param->private_data,
1610 conn_param->private_data_len);
1611
1612 id_priv->cm_id.ib = ib_create_cm_id(id_priv->id.device, cma_ib_handler,
1613 id_priv);
1614 if (IS_ERR(id_priv->cm_id.ib)) {
1615 ret = PTR_ERR(id_priv->cm_id.ib);
1616 goto out;
1617 }
1618
1619 route = &id_priv->id.route;
1620 ret = cma_format_hdr(private_data, id_priv->id.ps, route);
1621 if (ret)
1622 goto out;
1623 req.private_data = private_data;
1624
1625 req.primary_path = &route->path_rec[0];
1626 if (route->num_paths == 2)
1627 req.alternate_path = &route->path_rec[1];
1628
1629 req.service_id = cma_get_service_id(id_priv->id.ps,
1630 &route->addr.dst_addr);
1631 req.qp_num = id_priv->qp_num;
1632 req.qp_type = id_priv->qp_type;
1633 req.starting_psn = id_priv->seq_num;
1634 req.responder_resources = conn_param->responder_resources;
1635 req.initiator_depth = conn_param->initiator_depth;
1636 req.flow_control = conn_param->flow_control;
1637 req.retry_count = conn_param->retry_count;
1638 req.rnr_retry_count = conn_param->rnr_retry_count;
1639 req.remote_cm_response_timeout = CMA_CM_RESPONSE_TIMEOUT;
1640 req.local_cm_response_timeout = CMA_CM_RESPONSE_TIMEOUT;
1641 req.max_cm_retries = CMA_MAX_CM_RETRIES;
1642 req.srq = id_priv->srq ? 1 : 0;
1643
1644 ret = ib_send_cm_req(id_priv->cm_id.ib, &req);
1645out:
1646 kfree(private_data);
1647 return ret;
1648}
1649
1650int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
1651{
1652 struct rdma_id_private *id_priv;
1653 int ret;
1654
1655 id_priv = container_of(id, struct rdma_id_private, id);
1656 if (!cma_comp_exch(id_priv, CMA_ROUTE_RESOLVED, CMA_CONNECT))
1657 return -EINVAL;
1658
1659 if (!id->qp) {
1660 id_priv->qp_num = conn_param->qp_num;
1661 id_priv->qp_type = conn_param->qp_type;
1662 id_priv->srq = conn_param->srq;
1663 }
1664
1665 switch (id->device->node_type) {
1666 case IB_NODE_CA:
1667 ret = cma_connect_ib(id_priv, conn_param);
1668 break;
1669 default:
1670 ret = -ENOSYS;
1671 break;
1672 }
1673 if (ret)
1674 goto err;
1675
1676 return 0;
1677err:
1678 cma_comp_exch(id_priv, CMA_CONNECT, CMA_ROUTE_RESOLVED);
1679 return ret;
1680}
1681EXPORT_SYMBOL(rdma_connect);
1682
1683static int cma_accept_ib(struct rdma_id_private *id_priv,
1684 struct rdma_conn_param *conn_param)
1685{
1686 struct ib_cm_rep_param rep;
1687 int ret;
1688
1689 ret = cma_modify_qp_rtr(&id_priv->id);
1690 if (ret)
1691 return ret;
1692
1693 memset(&rep, 0, sizeof rep);
1694 rep.qp_num = id_priv->qp_num;
1695 rep.starting_psn = id_priv->seq_num;
1696 rep.private_data = conn_param->private_data;
1697 rep.private_data_len = conn_param->private_data_len;
1698 rep.responder_resources = conn_param->responder_resources;
1699 rep.initiator_depth = conn_param->initiator_depth;
1700 rep.target_ack_delay = CMA_CM_RESPONSE_TIMEOUT;
1701 rep.failover_accepted = 0;
1702 rep.flow_control = conn_param->flow_control;
1703 rep.rnr_retry_count = conn_param->rnr_retry_count;
1704 rep.srq = id_priv->srq ? 1 : 0;
1705
1706 return ib_send_cm_rep(id_priv->cm_id.ib, &rep);
1707}
1708
1709int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
1710{
1711 struct rdma_id_private *id_priv;
1712 int ret;
1713
1714 id_priv = container_of(id, struct rdma_id_private, id);
1715 if (!cma_comp(id_priv, CMA_CONNECT))
1716 return -EINVAL;
1717
1718 if (!id->qp && conn_param) {
1719 id_priv->qp_num = conn_param->qp_num;
1720 id_priv->qp_type = conn_param->qp_type;
1721 id_priv->srq = conn_param->srq;
1722 }
1723
1724 switch (id->device->node_type) {
1725 case IB_NODE_CA:
1726 if (conn_param)
1727 ret = cma_accept_ib(id_priv, conn_param);
1728 else
1729 ret = cma_rep_recv(id_priv);
1730 break;
1731 default:
1732 ret = -ENOSYS;
1733 break;
1734 }
1735
1736 if (ret)
1737 goto reject;
1738
1739 return 0;
1740reject:
1741 cma_modify_qp_err(id);
1742 rdma_reject(id, NULL, 0);
1743 return ret;
1744}
1745EXPORT_SYMBOL(rdma_accept);
1746
1747int rdma_reject(struct rdma_cm_id *id, const void *private_data,
1748 u8 private_data_len)
1749{
1750 struct rdma_id_private *id_priv;
1751 int ret;
1752
1753 id_priv = container_of(id, struct rdma_id_private, id);
1754 if (!cma_comp(id_priv, CMA_CONNECT))
1755 return -EINVAL;
1756
1757 switch (id->device->node_type) {
1758 case IB_NODE_CA:
1759 ret = ib_send_cm_rej(id_priv->cm_id.ib,
1760 IB_CM_REJ_CONSUMER_DEFINED, NULL, 0,
1761 private_data, private_data_len);
1762 break;
1763 default:
1764 ret = -ENOSYS;
1765 break;
1766 }
1767 return ret;
1768}
1769EXPORT_SYMBOL(rdma_reject);
1770
1771int rdma_disconnect(struct rdma_cm_id *id)
1772{
1773 struct rdma_id_private *id_priv;
1774 int ret;
1775
1776 id_priv = container_of(id, struct rdma_id_private, id);
1777 if (!cma_comp(id_priv, CMA_CONNECT) &&
1778 !cma_comp(id_priv, CMA_DISCONNECT))
1779 return -EINVAL;
1780
1781 ret = cma_modify_qp_err(id);
1782 if (ret)
1783 goto out;
1784
1785 switch (id->device->node_type) {
1786 case IB_NODE_CA:
1787 /* Initiate or respond to a disconnect. */
1788 if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
1789 ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
1790 break;
1791 default:
1792 break;
1793 }
1794out:
1795 return ret;
1796}
1797EXPORT_SYMBOL(rdma_disconnect);
1798
1799static void cma_add_one(struct ib_device *device)
1800{
1801 struct cma_device *cma_dev;
1802 struct rdma_id_private *id_priv;
1803
1804 cma_dev = kmalloc(sizeof *cma_dev, GFP_KERNEL);
1805 if (!cma_dev)
1806 return;
1807
1808 cma_dev->device = device;
1809 cma_dev->node_guid = device->node_guid;
1810 if (!cma_dev->node_guid)
1811 goto err;
1812
1813 init_completion(&cma_dev->comp);
1814 atomic_set(&cma_dev->refcount, 1);
1815 INIT_LIST_HEAD(&cma_dev->id_list);
1816 ib_set_client_data(device, &cma_client, cma_dev);
1817
1818 mutex_lock(&lock);
1819 list_add_tail(&cma_dev->list, &dev_list);
1820 list_for_each_entry(id_priv, &listen_any_list, list)
1821 cma_listen_on_dev(id_priv, cma_dev);
1822 mutex_unlock(&lock);
1823 return;
1824err:
1825 kfree(cma_dev);
1826}
1827
1828static int cma_remove_id_dev(struct rdma_id_private *id_priv)
1829{
1830 enum cma_state state;
1831
1832 /* Record that we want to remove the device */
1833 state = cma_exch(id_priv, CMA_DEVICE_REMOVAL);
1834 if (state == CMA_DESTROYING)
1835 return 0;
1836
1837 cma_cancel_operation(id_priv, state);
1838 wait_event(id_priv->wait_remove, !atomic_read(&id_priv->dev_remove));
1839
1840 /* Check for destruction from another callback. */
1841 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL))
1842 return 0;
1843
1844 return cma_notify_user(id_priv, RDMA_CM_EVENT_DEVICE_REMOVAL,
1845 0, NULL, 0);
1846}
1847
1848static void cma_process_remove(struct cma_device *cma_dev)
1849{
1850 struct list_head remove_list;
1851 struct rdma_id_private *id_priv;
1852 int ret;
1853
1854 INIT_LIST_HEAD(&remove_list);
1855
1856 mutex_lock(&lock);
1857 while (!list_empty(&cma_dev->id_list)) {
1858 id_priv = list_entry(cma_dev->id_list.next,
1859 struct rdma_id_private, list);
1860
1861 if (cma_internal_listen(id_priv)) {
1862 cma_destroy_listen(id_priv);
1863 continue;
1864 }
1865
1866 list_del(&id_priv->list);
1867 list_add_tail(&id_priv->list, &remove_list);
1868 atomic_inc(&id_priv->refcount);
1869 mutex_unlock(&lock);
1870
1871 ret = cma_remove_id_dev(id_priv);
1872 cma_deref_id(id_priv);
1873 if (ret)
1874 rdma_destroy_id(&id_priv->id);
1875
1876 mutex_lock(&lock);
1877 }
1878 mutex_unlock(&lock);
1879
1880 cma_deref_dev(cma_dev);
1881 wait_for_completion(&cma_dev->comp);
1882}
1883
1884static void cma_remove_one(struct ib_device *device)
1885{
1886 struct cma_device *cma_dev;
1887
1888 cma_dev = ib_get_client_data(device, &cma_client);
1889 if (!cma_dev)
1890 return;
1891
1892 mutex_lock(&lock);
1893 list_del(&cma_dev->list);
1894 mutex_unlock(&lock);
1895
1896 cma_process_remove(cma_dev);
1897 kfree(cma_dev);
1898}
1899
1900static int cma_init(void)
1901{
1902 int ret;
1903
1904 cma_wq = create_singlethread_workqueue("rdma_cm_wq");
1905 if (!cma_wq)
1906 return -ENOMEM;
1907
1908 ret = ib_register_client(&cma_client);
1909 if (ret)
1910 goto err;
1911 return 0;
1912
1913err:
1914 destroy_workqueue(cma_wq);
1915 return ret;
1916}
1917
1918static void cma_cleanup(void)
1919{
1920 ib_unregister_client(&cma_client);
1921 destroy_workqueue(cma_wq);
1922 idr_destroy(&sdp_ps);
1923 idr_destroy(&tcp_ps);
1924}
1925
1926module_init(cma_init);
1927module_exit(cma_cleanup);
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
index 838bf54458d2..615fe9cc6c56 100644
--- a/drivers/infiniband/core/fmr_pool.c
+++ b/drivers/infiniband/core/fmr_pool.c
@@ -54,7 +54,7 @@ enum {
54/* 54/*
55 * If an FMR is not in use, then the list member will point to either 55 * If an FMR is not in use, then the list member will point to either
56 * its pool's free_list (if the FMR can be mapped again; that is, 56 * its pool's free_list (if the FMR can be mapped again; that is,
57 * remap_count < IB_FMR_MAX_REMAPS) or its pool's dirty_list (if the 57 * remap_count < pool->max_remaps) or its pool's dirty_list (if the
58 * FMR needs to be unmapped before being remapped). In either of 58 * FMR needs to be unmapped before being remapped). In either of
59 * these cases it is a bug if the ref_count is not 0. In other words, 59 * these cases it is a bug if the ref_count is not 0. In other words,
60 * if ref_count is > 0, then the list member must not be linked into 60 * if ref_count is > 0, then the list member must not be linked into
@@ -84,6 +84,7 @@ struct ib_fmr_pool {
84 84
85 int pool_size; 85 int pool_size;
86 int max_pages; 86 int max_pages;
87 int max_remaps;
87 int dirty_watermark; 88 int dirty_watermark;
88 int dirty_len; 89 int dirty_len;
89 struct list_head free_list; 90 struct list_head free_list;
@@ -214,8 +215,10 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
214{ 215{
215 struct ib_device *device; 216 struct ib_device *device;
216 struct ib_fmr_pool *pool; 217 struct ib_fmr_pool *pool;
218 struct ib_device_attr *attr;
217 int i; 219 int i;
218 int ret; 220 int ret;
221 int max_remaps;
219 222
220 if (!params) 223 if (!params)
221 return ERR_PTR(-EINVAL); 224 return ERR_PTR(-EINVAL);
@@ -228,6 +231,26 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
228 return ERR_PTR(-ENOSYS); 231 return ERR_PTR(-ENOSYS);
229 } 232 }
230 233
234 attr = kmalloc(sizeof *attr, GFP_KERNEL);
235 if (!attr) {
236 printk(KERN_WARNING "couldn't allocate device attr struct");
237 return ERR_PTR(-ENOMEM);
238 }
239
240 ret = ib_query_device(device, attr);
241 if (ret) {
242 printk(KERN_WARNING "couldn't query device");
243 kfree(attr);
244 return ERR_PTR(ret);
245 }
246
247 if (!attr->max_map_per_fmr)
248 max_remaps = IB_FMR_MAX_REMAPS;
249 else
250 max_remaps = attr->max_map_per_fmr;
251
252 kfree(attr);
253
231 pool = kmalloc(sizeof *pool, GFP_KERNEL); 254 pool = kmalloc(sizeof *pool, GFP_KERNEL);
232 if (!pool) { 255 if (!pool) {
233 printk(KERN_WARNING "couldn't allocate pool struct"); 256 printk(KERN_WARNING "couldn't allocate pool struct");
@@ -258,6 +281,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
258 281
259 pool->pool_size = 0; 282 pool->pool_size = 0;
260 pool->max_pages = params->max_pages_per_fmr; 283 pool->max_pages = params->max_pages_per_fmr;
284 pool->max_remaps = max_remaps;
261 pool->dirty_watermark = params->dirty_watermark; 285 pool->dirty_watermark = params->dirty_watermark;
262 pool->dirty_len = 0; 286 pool->dirty_len = 0;
263 spin_lock_init(&pool->pool_lock); 287 spin_lock_init(&pool->pool_lock);
@@ -279,7 +303,7 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
279 struct ib_pool_fmr *fmr; 303 struct ib_pool_fmr *fmr;
280 struct ib_fmr_attr attr = { 304 struct ib_fmr_attr attr = {
281 .max_pages = params->max_pages_per_fmr, 305 .max_pages = params->max_pages_per_fmr,
282 .max_maps = IB_FMR_MAX_REMAPS, 306 .max_maps = pool->max_remaps,
283 .page_shift = params->page_shift 307 .page_shift = params->page_shift
284 }; 308 };
285 309
@@ -489,7 +513,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
489 513
490 --fmr->ref_count; 514 --fmr->ref_count;
491 if (!fmr->ref_count) { 515 if (!fmr->ref_count) {
492 if (fmr->remap_count < IB_FMR_MAX_REMAPS) { 516 if (fmr->remap_count < pool->max_remaps) {
493 list_add_tail(&fmr->list, &pool->free_list); 517 list_add_tail(&fmr->list, &pool->free_list);
494 } else { 518 } else {
495 list_add_tail(&fmr->list, &pool->dirty_list); 519 list_add_tail(&fmr->list, &pool->dirty_list);
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 5ad41a64314c..b38e02a5db35 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -34,6 +34,7 @@
34 * $Id: mad.c 5596 2006-03-03 01:00:07Z sean.hefty $ 34 * $Id: mad.c 5596 2006-03-03 01:00:07Z sean.hefty $
35 */ 35 */
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <rdma/ib_cache.h>
37 38
38#include "mad_priv.h" 39#include "mad_priv.h"
39#include "mad_rmpp.h" 40#include "mad_rmpp.h"
@@ -45,8 +46,7 @@ MODULE_DESCRIPTION("kernel IB MAD API");
45MODULE_AUTHOR("Hal Rosenstock"); 46MODULE_AUTHOR("Hal Rosenstock");
46MODULE_AUTHOR("Sean Hefty"); 47MODULE_AUTHOR("Sean Hefty");
47 48
48 49static kmem_cache_t *ib_mad_cache;
49kmem_cache_t *ib_mad_cache;
50 50
51static struct list_head ib_mad_port_list; 51static struct list_head ib_mad_port_list;
52static u32 ib_mad_client_id = 0; 52static u32 ib_mad_client_id = 0;
@@ -1673,20 +1673,21 @@ static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
1673 rwc->recv_buf.mad->mad_hdr.mgmt_class; 1673 rwc->recv_buf.mad->mad_hdr.mgmt_class;
1674} 1674}
1675 1675
1676static inline int rcv_has_same_gid(struct ib_mad_send_wr_private *wr, 1676static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv,
1677 struct ib_mad_send_wr_private *wr,
1677 struct ib_mad_recv_wc *rwc ) 1678 struct ib_mad_recv_wc *rwc )
1678{ 1679{
1679 struct ib_ah_attr attr; 1680 struct ib_ah_attr attr;
1680 u8 send_resp, rcv_resp; 1681 u8 send_resp, rcv_resp;
1682 union ib_gid sgid;
1683 struct ib_device *device = mad_agent_priv->agent.device;
1684 u8 port_num = mad_agent_priv->agent.port_num;
1685 u8 lmc;
1681 1686
1682 send_resp = ((struct ib_mad *)(wr->send_buf.mad))-> 1687 send_resp = ((struct ib_mad *)(wr->send_buf.mad))->
1683 mad_hdr.method & IB_MGMT_METHOD_RESP; 1688 mad_hdr.method & IB_MGMT_METHOD_RESP;
1684 rcv_resp = rwc->recv_buf.mad->mad_hdr.method & IB_MGMT_METHOD_RESP; 1689 rcv_resp = rwc->recv_buf.mad->mad_hdr.method & IB_MGMT_METHOD_RESP;
1685 1690
1686 if (!send_resp && rcv_resp)
1687 /* is request/response. GID/LIDs are both local (same). */
1688 return 1;
1689
1690 if (send_resp == rcv_resp) 1691 if (send_resp == rcv_resp)
1691 /* both requests, or both responses. GIDs different */ 1692 /* both requests, or both responses. GIDs different */
1692 return 0; 1693 return 0;
@@ -1695,48 +1696,78 @@ static inline int rcv_has_same_gid(struct ib_mad_send_wr_private *wr,
1695 /* Assume not equal, to avoid false positives. */ 1696 /* Assume not equal, to avoid false positives. */
1696 return 0; 1697 return 0;
1697 1698
1698 if (!(attr.ah_flags & IB_AH_GRH) && !(rwc->wc->wc_flags & IB_WC_GRH)) 1699 if (!!(attr.ah_flags & IB_AH_GRH) !=
1699 return attr.dlid == rwc->wc->slid; 1700 !!(rwc->wc->wc_flags & IB_WC_GRH))
1700 else if ((attr.ah_flags & IB_AH_GRH) &&
1701 (rwc->wc->wc_flags & IB_WC_GRH))
1702 return memcmp(attr.grh.dgid.raw,
1703 rwc->recv_buf.grh->sgid.raw, 16) == 0;
1704 else
1705 /* one has GID, other does not. Assume different */ 1701 /* one has GID, other does not. Assume different */
1706 return 0; 1702 return 0;
1703
1704 if (!send_resp && rcv_resp) {
1705 /* is request/response. */
1706 if (!(attr.ah_flags & IB_AH_GRH)) {
1707 if (ib_get_cached_lmc(device, port_num, &lmc))
1708 return 0;
1709 return (!lmc || !((attr.src_path_bits ^
1710 rwc->wc->dlid_path_bits) &
1711 ((1 << lmc) - 1)));
1712 } else {
1713 if (ib_get_cached_gid(device, port_num,
1714 attr.grh.sgid_index, &sgid))
1715 return 0;
1716 return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw,
1717 16);
1718 }
1719 }
1720
1721 if (!(attr.ah_flags & IB_AH_GRH))
1722 return attr.dlid == rwc->wc->slid;
1723 else
1724 return !memcmp(attr.grh.dgid.raw, rwc->recv_buf.grh->sgid.raw,
1725 16);
1726}
1727
1728static inline int is_direct(u8 class)
1729{
1730 return (class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE);
1707} 1731}
1732
1708struct ib_mad_send_wr_private* 1733struct ib_mad_send_wr_private*
1709ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, 1734ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
1710 struct ib_mad_recv_wc *mad_recv_wc) 1735 struct ib_mad_recv_wc *wc)
1711{ 1736{
1712 struct ib_mad_send_wr_private *mad_send_wr; 1737 struct ib_mad_send_wr_private *wr;
1713 struct ib_mad *mad; 1738 struct ib_mad *mad;
1714 1739
1715 mad = (struct ib_mad *)mad_recv_wc->recv_buf.mad; 1740 mad = (struct ib_mad *)wc->recv_buf.mad;
1716 1741
1717 list_for_each_entry(mad_send_wr, &mad_agent_priv->wait_list, 1742 list_for_each_entry(wr, &mad_agent_priv->wait_list, agent_list) {
1718 agent_list) { 1743 if ((wr->tid == mad->mad_hdr.tid) &&
1719 if ((mad_send_wr->tid == mad->mad_hdr.tid) && 1744 rcv_has_same_class(wr, wc) &&
1720 rcv_has_same_class(mad_send_wr, mad_recv_wc) && 1745 /*
1721 rcv_has_same_gid(mad_send_wr, mad_recv_wc)) 1746 * Don't check GID for direct routed MADs.
1722 return mad_send_wr; 1747 * These might have permissive LIDs.
1748 */
1749 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
1750 rcv_has_same_gid(mad_agent_priv, wr, wc)))
1751 return wr;
1723 } 1752 }
1724 1753
1725 /* 1754 /*
1726 * It's possible to receive the response before we've 1755 * It's possible to receive the response before we've
1727 * been notified that the send has completed 1756 * been notified that the send has completed
1728 */ 1757 */
1729 list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list, 1758 list_for_each_entry(wr, &mad_agent_priv->send_list, agent_list) {
1730 agent_list) { 1759 if (is_data_mad(mad_agent_priv, wr->send_buf.mad) &&
1731 if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) && 1760 wr->tid == mad->mad_hdr.tid &&
1732 mad_send_wr->tid == mad->mad_hdr.tid && 1761 wr->timeout &&
1733 mad_send_wr->timeout && 1762 rcv_has_same_class(wr, wc) &&
1734 rcv_has_same_class(mad_send_wr, mad_recv_wc) && 1763 /*
1735 rcv_has_same_gid(mad_send_wr, mad_recv_wc)) { 1764 * Don't check GID for direct routed MADs.
1765 * These might have permissive LIDs.
1766 */
1767 (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
1768 rcv_has_same_gid(mad_agent_priv, wr, wc)))
1736 /* Verify request has not been canceled */ 1769 /* Verify request has not been canceled */
1737 return (mad_send_wr->status == IB_WC_SUCCESS) ? 1770 return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
1738 mad_send_wr : NULL;
1739 }
1740 } 1771 }
1741 return NULL; 1772 return NULL;
1742} 1773}
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index b4fa28d3160f..d147f3bad2ce 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -212,8 +212,6 @@ struct ib_mad_port_private {
212 struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE]; 212 struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
213}; 213};
214 214
215extern kmem_cache_t *ib_mad_cache;
216
217int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr); 215int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
218 216
219struct ib_mad_send_wr_private * 217struct ib_mad_send_wr_private *
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 501cc054cb3b..e911c99ff843 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -47,6 +47,7 @@
47 47
48#include <rdma/ib_pack.h> 48#include <rdma/ib_pack.h>
49#include <rdma/ib_sa.h> 49#include <rdma/ib_sa.h>
50#include <rdma/ib_cache.h>
50 51
51MODULE_AUTHOR("Roland Dreier"); 52MODULE_AUTHOR("Roland Dreier");
52MODULE_DESCRIPTION("InfiniBand subnet administration query support"); 53MODULE_DESCRIPTION("InfiniBand subnet administration query support");
@@ -441,6 +442,36 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query)
441} 442}
442EXPORT_SYMBOL(ib_sa_cancel_query); 443EXPORT_SYMBOL(ib_sa_cancel_query);
443 444
445int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
446 struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr)
447{
448 int ret;
449 u16 gid_index;
450
451 memset(ah_attr, 0, sizeof *ah_attr);
452 ah_attr->dlid = be16_to_cpu(rec->dlid);
453 ah_attr->sl = rec->sl;
454 ah_attr->src_path_bits = be16_to_cpu(rec->slid) & 0x7f;
455 ah_attr->port_num = port_num;
456
457 if (rec->hop_limit > 1) {
458 ah_attr->ah_flags = IB_AH_GRH;
459 ah_attr->grh.dgid = rec->dgid;
460
461 ret = ib_find_cached_gid(device, &rec->sgid, &port_num,
462 &gid_index);
463 if (ret)
464 return ret;
465
466 ah_attr->grh.sgid_index = gid_index;
467 ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
468 ah_attr->grh.hop_limit = rec->hop_limit;
469 ah_attr->grh.traffic_class = rec->traffic_class;
470 }
471 return 0;
472}
473EXPORT_SYMBOL(ib_init_ah_from_path);
474
444static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent) 475static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent)
445{ 476{
446 unsigned long flags; 477 unsigned long flags;
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index 9164a09b6ccd..c1c6fda9452c 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -30,7 +30,7 @@
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 * 32 *
33 * $Id: ucm.c 2594 2005-06-13 19:46:02Z libor $ 33 * $Id: ucm.c 4311 2005-12-05 18:42:01Z sean.hefty $
34 */ 34 */
35 35
36#include <linux/completion.h> 36#include <linux/completion.h>
@@ -50,6 +50,7 @@
50 50
51#include <rdma/ib_cm.h> 51#include <rdma/ib_cm.h>
52#include <rdma/ib_user_cm.h> 52#include <rdma/ib_user_cm.h>
53#include <rdma/ib_marshall.h>
53 54
54MODULE_AUTHOR("Libor Michalek"); 55MODULE_AUTHOR("Libor Michalek");
55MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access"); 56MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access");
@@ -63,7 +64,7 @@ struct ib_ucm_device {
63}; 64};
64 65
65struct ib_ucm_file { 66struct ib_ucm_file {
66 struct semaphore mutex; 67 struct mutex file_mutex;
67 struct file *filp; 68 struct file *filp;
68 struct ib_ucm_device *device; 69 struct ib_ucm_device *device;
69 70
@@ -152,7 +153,7 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
152{ 153{
153 struct ib_ucm_event *uevent; 154 struct ib_ucm_event *uevent;
154 155
155 down(&ctx->file->mutex); 156 mutex_lock(&ctx->file->file_mutex);
156 list_del(&ctx->file_list); 157 list_del(&ctx->file_list);
157 while (!list_empty(&ctx->events)) { 158 while (!list_empty(&ctx->events)) {
158 159
@@ -167,7 +168,7 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
167 168
168 kfree(uevent); 169 kfree(uevent);
169 } 170 }
170 up(&ctx->file->mutex); 171 mutex_unlock(&ctx->file->file_mutex);
171} 172}
172 173
173static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) 174static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
@@ -205,36 +206,6 @@ error:
205 return NULL; 206 return NULL;
206} 207}
207 208
208static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath,
209 struct ib_sa_path_rec *kpath)
210{
211 if (!kpath || !upath)
212 return;
213
214 memcpy(upath->dgid, kpath->dgid.raw, sizeof *upath->dgid);
215 memcpy(upath->sgid, kpath->sgid.raw, sizeof *upath->sgid);
216
217 upath->dlid = kpath->dlid;
218 upath->slid = kpath->slid;
219 upath->raw_traffic = kpath->raw_traffic;
220 upath->flow_label = kpath->flow_label;
221 upath->hop_limit = kpath->hop_limit;
222 upath->traffic_class = kpath->traffic_class;
223 upath->reversible = kpath->reversible;
224 upath->numb_path = kpath->numb_path;
225 upath->pkey = kpath->pkey;
226 upath->sl = kpath->sl;
227 upath->mtu_selector = kpath->mtu_selector;
228 upath->mtu = kpath->mtu;
229 upath->rate_selector = kpath->rate_selector;
230 upath->rate = kpath->rate;
231 upath->packet_life_time = kpath->packet_life_time;
232 upath->preference = kpath->preference;
233
234 upath->packet_life_time_selector =
235 kpath->packet_life_time_selector;
236}
237
238static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq, 209static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
239 struct ib_cm_req_event_param *kreq) 210 struct ib_cm_req_event_param *kreq)
240{ 211{
@@ -253,8 +224,10 @@ static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
253 ureq->srq = kreq->srq; 224 ureq->srq = kreq->srq;
254 ureq->port = kreq->port; 225 ureq->port = kreq->port;
255 226
256 ib_ucm_event_path_get(&ureq->primary_path, kreq->primary_path); 227 ib_copy_path_rec_to_user(&ureq->primary_path, kreq->primary_path);
257 ib_ucm_event_path_get(&ureq->alternate_path, kreq->alternate_path); 228 if (kreq->alternate_path)
229 ib_copy_path_rec_to_user(&ureq->alternate_path,
230 kreq->alternate_path);
258} 231}
259 232
260static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep, 233static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep,
@@ -324,8 +297,8 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
324 info = evt->param.rej_rcvd.ari; 297 info = evt->param.rej_rcvd.ari;
325 break; 298 break;
326 case IB_CM_LAP_RECEIVED: 299 case IB_CM_LAP_RECEIVED:
327 ib_ucm_event_path_get(&uvt->resp.u.lap_resp.path, 300 ib_copy_path_rec_to_user(&uvt->resp.u.lap_resp.path,
328 evt->param.lap_rcvd.alternate_path); 301 evt->param.lap_rcvd.alternate_path);
329 uvt->data_len = IB_CM_LAP_PRIVATE_DATA_SIZE; 302 uvt->data_len = IB_CM_LAP_PRIVATE_DATA_SIZE;
330 uvt->resp.present = IB_UCM_PRES_ALTERNATE; 303 uvt->resp.present = IB_UCM_PRES_ALTERNATE;
331 break; 304 break;
@@ -402,11 +375,11 @@ static int ib_ucm_event_handler(struct ib_cm_id *cm_id,
402 if (result) 375 if (result)
403 goto err2; 376 goto err2;
404 377
405 down(&ctx->file->mutex); 378 mutex_lock(&ctx->file->file_mutex);
406 list_add_tail(&uevent->file_list, &ctx->file->events); 379 list_add_tail(&uevent->file_list, &ctx->file->events);
407 list_add_tail(&uevent->ctx_list, &ctx->events); 380 list_add_tail(&uevent->ctx_list, &ctx->events);
408 wake_up_interruptible(&ctx->file->poll_wait); 381 wake_up_interruptible(&ctx->file->poll_wait);
409 up(&ctx->file->mutex); 382 mutex_unlock(&ctx->file->file_mutex);
410 return 0; 383 return 0;
411 384
412err2: 385err2:
@@ -432,7 +405,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,
432 if (copy_from_user(&cmd, inbuf, sizeof(cmd))) 405 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
433 return -EFAULT; 406 return -EFAULT;
434 407
435 down(&file->mutex); 408 mutex_lock(&file->file_mutex);
436 while (list_empty(&file->events)) { 409 while (list_empty(&file->events)) {
437 410
438 if (file->filp->f_flags & O_NONBLOCK) { 411 if (file->filp->f_flags & O_NONBLOCK) {
@@ -447,9 +420,9 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,
447 420
448 prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE); 421 prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE);
449 422
450 up(&file->mutex); 423 mutex_unlock(&file->file_mutex);
451 schedule(); 424 schedule();
452 down(&file->mutex); 425 mutex_lock(&file->file_mutex);
453 426
454 finish_wait(&file->poll_wait, &wait); 427 finish_wait(&file->poll_wait, &wait);
455 } 428 }
@@ -509,7 +482,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,
509 kfree(uevent->info); 482 kfree(uevent->info);
510 kfree(uevent); 483 kfree(uevent);
511done: 484done:
512 up(&file->mutex); 485 mutex_unlock(&file->file_mutex);
513 return result; 486 return result;
514} 487}
515 488
@@ -528,9 +501,9 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
528 if (copy_from_user(&cmd, inbuf, sizeof(cmd))) 501 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
529 return -EFAULT; 502 return -EFAULT;
530 503
531 down(&file->mutex); 504 mutex_lock(&file->file_mutex);
532 ctx = ib_ucm_ctx_alloc(file); 505 ctx = ib_ucm_ctx_alloc(file);
533 up(&file->mutex); 506 mutex_unlock(&file->file_mutex);
534 if (!ctx) 507 if (!ctx)
535 return -ENOMEM; 508 return -ENOMEM;
536 509
@@ -637,65 +610,11 @@ static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file,
637 return result; 610 return result;
638} 611}
639 612
640static void ib_ucm_copy_ah_attr(struct ib_ucm_ah_attr *dest_attr,
641 struct ib_ah_attr *src_attr)
642{
643 memcpy(dest_attr->grh_dgid, src_attr->grh.dgid.raw,
644 sizeof src_attr->grh.dgid);
645 dest_attr->grh_flow_label = src_attr->grh.flow_label;
646 dest_attr->grh_sgid_index = src_attr->grh.sgid_index;
647 dest_attr->grh_hop_limit = src_attr->grh.hop_limit;
648 dest_attr->grh_traffic_class = src_attr->grh.traffic_class;
649
650 dest_attr->dlid = src_attr->dlid;
651 dest_attr->sl = src_attr->sl;
652 dest_attr->src_path_bits = src_attr->src_path_bits;
653 dest_attr->static_rate = src_attr->static_rate;
654 dest_attr->is_global = (src_attr->ah_flags & IB_AH_GRH);
655 dest_attr->port_num = src_attr->port_num;
656}
657
658static void ib_ucm_copy_qp_attr(struct ib_ucm_init_qp_attr_resp *dest_attr,
659 struct ib_qp_attr *src_attr)
660{
661 dest_attr->cur_qp_state = src_attr->cur_qp_state;
662 dest_attr->path_mtu = src_attr->path_mtu;
663 dest_attr->path_mig_state = src_attr->path_mig_state;
664 dest_attr->qkey = src_attr->qkey;
665 dest_attr->rq_psn = src_attr->rq_psn;
666 dest_attr->sq_psn = src_attr->sq_psn;
667 dest_attr->dest_qp_num = src_attr->dest_qp_num;
668 dest_attr->qp_access_flags = src_attr->qp_access_flags;
669
670 dest_attr->max_send_wr = src_attr->cap.max_send_wr;
671 dest_attr->max_recv_wr = src_attr->cap.max_recv_wr;
672 dest_attr->max_send_sge = src_attr->cap.max_send_sge;
673 dest_attr->max_recv_sge = src_attr->cap.max_recv_sge;
674 dest_attr->max_inline_data = src_attr->cap.max_inline_data;
675
676 ib_ucm_copy_ah_attr(&dest_attr->ah_attr, &src_attr->ah_attr);
677 ib_ucm_copy_ah_attr(&dest_attr->alt_ah_attr, &src_attr->alt_ah_attr);
678
679 dest_attr->pkey_index = src_attr->pkey_index;
680 dest_attr->alt_pkey_index = src_attr->alt_pkey_index;
681 dest_attr->en_sqd_async_notify = src_attr->en_sqd_async_notify;
682 dest_attr->sq_draining = src_attr->sq_draining;
683 dest_attr->max_rd_atomic = src_attr->max_rd_atomic;
684 dest_attr->max_dest_rd_atomic = src_attr->max_dest_rd_atomic;
685 dest_attr->min_rnr_timer = src_attr->min_rnr_timer;
686 dest_attr->port_num = src_attr->port_num;
687 dest_attr->timeout = src_attr->timeout;
688 dest_attr->retry_cnt = src_attr->retry_cnt;
689 dest_attr->rnr_retry = src_attr->rnr_retry;
690 dest_attr->alt_port_num = src_attr->alt_port_num;
691 dest_attr->alt_timeout = src_attr->alt_timeout;
692}
693
694static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file, 613static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file,
695 const char __user *inbuf, 614 const char __user *inbuf,
696 int in_len, int out_len) 615 int in_len, int out_len)
697{ 616{
698 struct ib_ucm_init_qp_attr_resp resp; 617 struct ib_uverbs_qp_attr resp;
699 struct ib_ucm_init_qp_attr cmd; 618 struct ib_ucm_init_qp_attr cmd;
700 struct ib_ucm_context *ctx; 619 struct ib_ucm_context *ctx;
701 struct ib_qp_attr qp_attr; 620 struct ib_qp_attr qp_attr;
@@ -718,7 +637,7 @@ static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file,
718 if (result) 637 if (result)
719 goto out; 638 goto out;
720 639
721 ib_ucm_copy_qp_attr(&resp, &qp_attr); 640 ib_copy_qp_attr_to_user(&resp, &qp_attr);
722 641
723 if (copy_to_user((void __user *)(unsigned long)cmd.response, 642 if (copy_to_user((void __user *)(unsigned long)cmd.response,
724 &resp, sizeof(resp))) 643 &resp, sizeof(resp)))
@@ -729,6 +648,17 @@ out:
729 return result; 648 return result;
730} 649}
731 650
651static int ucm_validate_listen(__be64 service_id, __be64 service_mask)
652{
653 service_id &= service_mask;
654
655 if (((service_id & IB_CMA_SERVICE_ID_MASK) == IB_CMA_SERVICE_ID) ||
656 ((service_id & IB_SDP_SERVICE_ID_MASK) == IB_SDP_SERVICE_ID))
657 return -EINVAL;
658
659 return 0;
660}
661
732static ssize_t ib_ucm_listen(struct ib_ucm_file *file, 662static ssize_t ib_ucm_listen(struct ib_ucm_file *file,
733 const char __user *inbuf, 663 const char __user *inbuf,
734 int in_len, int out_len) 664 int in_len, int out_len)
@@ -744,7 +674,13 @@ static ssize_t ib_ucm_listen(struct ib_ucm_file *file,
744 if (IS_ERR(ctx)) 674 if (IS_ERR(ctx))
745 return PTR_ERR(ctx); 675 return PTR_ERR(ctx);
746 676
747 result = ib_cm_listen(ctx->cm_id, cmd.service_id, cmd.service_mask); 677 result = ucm_validate_listen(cmd.service_id, cmd.service_mask);
678 if (result)
679 goto out;
680
681 result = ib_cm_listen(ctx->cm_id, cmd.service_id, cmd.service_mask,
682 NULL);
683out:
748 ib_ucm_ctx_put(ctx); 684 ib_ucm_ctx_put(ctx);
749 return result; 685 return result;
750} 686}
@@ -793,7 +729,7 @@ static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len)
793 729
794static int ib_ucm_path_get(struct ib_sa_path_rec **path, u64 src) 730static int ib_ucm_path_get(struct ib_sa_path_rec **path, u64 src)
795{ 731{
796 struct ib_ucm_path_rec ucm_path; 732 struct ib_user_path_rec upath;
797 struct ib_sa_path_rec *sa_path; 733 struct ib_sa_path_rec *sa_path;
798 734
799 *path = NULL; 735 *path = NULL;
@@ -805,36 +741,14 @@ static int ib_ucm_path_get(struct ib_sa_path_rec **path, u64 src)
805 if (!sa_path) 741 if (!sa_path)
806 return -ENOMEM; 742 return -ENOMEM;
807 743
808 if (copy_from_user(&ucm_path, (void __user *)(unsigned long)src, 744 if (copy_from_user(&upath, (void __user *)(unsigned long)src,
809 sizeof(ucm_path))) { 745 sizeof(upath))) {
810 746
811 kfree(sa_path); 747 kfree(sa_path);
812 return -EFAULT; 748 return -EFAULT;
813 } 749 }
814 750
815 memcpy(sa_path->dgid.raw, ucm_path.dgid, sizeof sa_path->dgid); 751 ib_copy_path_rec_from_user(sa_path, &upath);
816 memcpy(sa_path->sgid.raw, ucm_path.sgid, sizeof sa_path->sgid);
817
818 sa_path->dlid = ucm_path.dlid;
819 sa_path->slid = ucm_path.slid;
820 sa_path->raw_traffic = ucm_path.raw_traffic;
821 sa_path->flow_label = ucm_path.flow_label;
822 sa_path->hop_limit = ucm_path.hop_limit;
823 sa_path->traffic_class = ucm_path.traffic_class;
824 sa_path->reversible = ucm_path.reversible;
825 sa_path->numb_path = ucm_path.numb_path;
826 sa_path->pkey = ucm_path.pkey;
827 sa_path->sl = ucm_path.sl;
828 sa_path->mtu_selector = ucm_path.mtu_selector;
829 sa_path->mtu = ucm_path.mtu;
830 sa_path->rate_selector = ucm_path.rate_selector;
831 sa_path->rate = ucm_path.rate;
832 sa_path->packet_life_time = ucm_path.packet_life_time;
833 sa_path->preference = ucm_path.preference;
834
835 sa_path->packet_life_time_selector =
836 ucm_path.packet_life_time_selector;
837
838 *path = sa_path; 752 *path = sa_path;
839 return 0; 753 return 0;
840} 754}
@@ -1130,7 +1044,6 @@ static ssize_t ib_ucm_send_sidr_req(struct ib_ucm_file *file,
1130 param.service_id = cmd.sid; 1044 param.service_id = cmd.sid;
1131 param.timeout_ms = cmd.timeout; 1045 param.timeout_ms = cmd.timeout;
1132 param.max_cm_retries = cmd.max_cm_retries; 1046 param.max_cm_retries = cmd.max_cm_retries;
1133 param.pkey = cmd.pkey;
1134 1047
1135 ctx = ib_ucm_ctx_get(file, cmd.id); 1048 ctx = ib_ucm_ctx_get(file, cmd.id);
1136 if (!IS_ERR(ctx)) { 1049 if (!IS_ERR(ctx)) {
@@ -1263,7 +1176,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
1263 INIT_LIST_HEAD(&file->ctxs); 1176 INIT_LIST_HEAD(&file->ctxs);
1264 init_waitqueue_head(&file->poll_wait); 1177 init_waitqueue_head(&file->poll_wait);
1265 1178
1266 init_MUTEX(&file->mutex); 1179 mutex_init(&file->file_mutex);
1267 1180
1268 filp->private_data = file; 1181 filp->private_data = file;
1269 file->filp = filp; 1182 file->filp = filp;
@@ -1277,11 +1190,11 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
1277 struct ib_ucm_file *file = filp->private_data; 1190 struct ib_ucm_file *file = filp->private_data;
1278 struct ib_ucm_context *ctx; 1191 struct ib_ucm_context *ctx;
1279 1192
1280 down(&file->mutex); 1193 mutex_lock(&file->file_mutex);
1281 while (!list_empty(&file->ctxs)) { 1194 while (!list_empty(&file->ctxs)) {
1282 ctx = list_entry(file->ctxs.next, 1195 ctx = list_entry(file->ctxs.next,
1283 struct ib_ucm_context, file_list); 1196 struct ib_ucm_context, file_list);
1284 up(&file->mutex); 1197 mutex_unlock(&file->file_mutex);
1285 1198
1286 mutex_lock(&ctx_id_mutex); 1199 mutex_lock(&ctx_id_mutex);
1287 idr_remove(&ctx_id_table, ctx->id); 1200 idr_remove(&ctx_id_table, ctx->id);
@@ -1291,9 +1204,9 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
1291 ib_ucm_cleanup_events(ctx); 1204 ib_ucm_cleanup_events(ctx);
1292 kfree(ctx); 1205 kfree(ctx);
1293 1206
1294 down(&file->mutex); 1207 mutex_lock(&file->file_mutex);
1295 } 1208 }
1296 up(&file->mutex); 1209 mutex_unlock(&file->file_mutex);
1297 kfree(file); 1210 kfree(file);
1298 return 0; 1211 return 0;
1299} 1212}
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 3372d67ff139..bb9bee56a824 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -132,7 +132,7 @@ struct ib_ucq_object {
132 u32 async_events_reported; 132 u32 async_events_reported;
133}; 133};
134 134
135extern struct mutex ib_uverbs_idr_mutex; 135extern spinlock_t ib_uverbs_idr_lock;
136extern struct idr ib_uverbs_pd_idr; 136extern struct idr ib_uverbs_pd_idr;
137extern struct idr ib_uverbs_mr_idr; 137extern struct idr ib_uverbs_mr_idr;
138extern struct idr ib_uverbs_mw_idr; 138extern struct idr ib_uverbs_mw_idr;
@@ -141,6 +141,8 @@ extern struct idr ib_uverbs_cq_idr;
141extern struct idr ib_uverbs_qp_idr; 141extern struct idr ib_uverbs_qp_idr;
142extern struct idr ib_uverbs_srq_idr; 142extern struct idr ib_uverbs_srq_idr;
143 143
144void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
145
144struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file, 146struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
145 int is_async, int *fd); 147 int is_async, int *fd);
146void ib_uverbs_release_event_file(struct kref *ref); 148void ib_uverbs_release_event_file(struct kref *ref);
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 9f69bd48eb1b..76bf61e9b552 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -50,6 +50,196 @@
50 (udata)->outlen = (olen); \ 50 (udata)->outlen = (olen); \
51 } while (0) 51 } while (0)
52 52
53/*
54 * The ib_uobject locking scheme is as follows:
55 *
56 * - ib_uverbs_idr_lock protects the uverbs idrs themselves, so it
57 * needs to be held during all idr operations. When an object is
58 * looked up, a reference must be taken on the object's kref before
59 * dropping this lock.
60 *
61 * - Each object also has an rwsem. This rwsem must be held for
62 * reading while an operation that uses the object is performed.
63 * For example, while registering an MR, the associated PD's
64 * uobject.mutex must be held for reading. The rwsem must be held
65 * for writing while initializing or destroying an object.
66 *
67 * - In addition, each object has a "live" flag. If this flag is not
68 * set, then lookups of the object will fail even if it is found in
69 * the idr. This handles a reader that blocks and does not acquire
70 * the rwsem until after the object is destroyed. The destroy
71 * operation will set the live flag to 0 and then drop the rwsem;
72 * this will allow the reader to acquire the rwsem, see that the
73 * live flag is 0, and then drop the rwsem and its reference to
74 * object. The underlying storage will not be freed until the last
75 * reference to the object is dropped.
76 */
77
78static void init_uobj(struct ib_uobject *uobj, u64 user_handle,
79 struct ib_ucontext *context)
80{
81 uobj->user_handle = user_handle;
82 uobj->context = context;
83 kref_init(&uobj->ref);
84 init_rwsem(&uobj->mutex);
85 uobj->live = 0;
86}
87
88static void release_uobj(struct kref *kref)
89{
90 kfree(container_of(kref, struct ib_uobject, ref));
91}
92
93static void put_uobj(struct ib_uobject *uobj)
94{
95 kref_put(&uobj->ref, release_uobj);
96}
97
98static void put_uobj_read(struct ib_uobject *uobj)
99{
100 up_read(&uobj->mutex);
101 put_uobj(uobj);
102}
103
104static void put_uobj_write(struct ib_uobject *uobj)
105{
106 up_write(&uobj->mutex);
107 put_uobj(uobj);
108}
109
110static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
111{
112 int ret;
113
114retry:
115 if (!idr_pre_get(idr, GFP_KERNEL))
116 return -ENOMEM;
117
118 spin_lock(&ib_uverbs_idr_lock);
119 ret = idr_get_new(idr, uobj, &uobj->id);
120 spin_unlock(&ib_uverbs_idr_lock);
121
122 if (ret == -EAGAIN)
123 goto retry;
124
125 return ret;
126}
127
128void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
129{
130 spin_lock(&ib_uverbs_idr_lock);
131 idr_remove(idr, uobj->id);
132 spin_unlock(&ib_uverbs_idr_lock);
133}
134
135static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id,
136 struct ib_ucontext *context)
137{
138 struct ib_uobject *uobj;
139
140 spin_lock(&ib_uverbs_idr_lock);
141 uobj = idr_find(idr, id);
142 if (uobj)
143 kref_get(&uobj->ref);
144 spin_unlock(&ib_uverbs_idr_lock);
145
146 return uobj;
147}
148
149static struct ib_uobject *idr_read_uobj(struct idr *idr, int id,
150 struct ib_ucontext *context)
151{
152 struct ib_uobject *uobj;
153
154 uobj = __idr_get_uobj(idr, id, context);
155 if (!uobj)
156 return NULL;
157
158 down_read(&uobj->mutex);
159 if (!uobj->live) {
160 put_uobj_read(uobj);
161 return NULL;
162 }
163
164 return uobj;
165}
166
167static struct ib_uobject *idr_write_uobj(struct idr *idr, int id,
168 struct ib_ucontext *context)
169{
170 struct ib_uobject *uobj;
171
172 uobj = __idr_get_uobj(idr, id, context);
173 if (!uobj)
174 return NULL;
175
176 down_write(&uobj->mutex);
177 if (!uobj->live) {
178 put_uobj_write(uobj);
179 return NULL;
180 }
181
182 return uobj;
183}
184
185static void *idr_read_obj(struct idr *idr, int id, struct ib_ucontext *context)
186{
187 struct ib_uobject *uobj;
188
189 uobj = idr_read_uobj(idr, id, context);
190 return uobj ? uobj->object : NULL;
191}
192
193static struct ib_pd *idr_read_pd(int pd_handle, struct ib_ucontext *context)
194{
195 return idr_read_obj(&ib_uverbs_pd_idr, pd_handle, context);
196}
197
198static void put_pd_read(struct ib_pd *pd)
199{
200 put_uobj_read(pd->uobject);
201}
202
203static struct ib_cq *idr_read_cq(int cq_handle, struct ib_ucontext *context)
204{
205 return idr_read_obj(&ib_uverbs_cq_idr, cq_handle, context);
206}
207
208static void put_cq_read(struct ib_cq *cq)
209{
210 put_uobj_read(cq->uobject);
211}
212
213static struct ib_ah *idr_read_ah(int ah_handle, struct ib_ucontext *context)
214{
215 return idr_read_obj(&ib_uverbs_ah_idr, ah_handle, context);
216}
217
218static void put_ah_read(struct ib_ah *ah)
219{
220 put_uobj_read(ah->uobject);
221}
222
223static struct ib_qp *idr_read_qp(int qp_handle, struct ib_ucontext *context)
224{
225 return idr_read_obj(&ib_uverbs_qp_idr, qp_handle, context);
226}
227
228static void put_qp_read(struct ib_qp *qp)
229{
230 put_uobj_read(qp->uobject);
231}
232
233static struct ib_srq *idr_read_srq(int srq_handle, struct ib_ucontext *context)
234{
235 return idr_read_obj(&ib_uverbs_srq_idr, srq_handle, context);
236}
237
238static void put_srq_read(struct ib_srq *srq)
239{
240 put_uobj_read(srq->uobject);
241}
242
53ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, 243ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
54 const char __user *buf, 244 const char __user *buf,
55 int in_len, int out_len) 245 int in_len, int out_len)
@@ -80,8 +270,10 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
80 in_len - sizeof cmd, out_len - sizeof resp); 270 in_len - sizeof cmd, out_len - sizeof resp);
81 271
82 ucontext = ibdev->alloc_ucontext(ibdev, &udata); 272 ucontext = ibdev->alloc_ucontext(ibdev, &udata);
83 if (IS_ERR(ucontext)) 273 if (IS_ERR(ucontext)) {
84 return PTR_ERR(file->ucontext); 274 ret = PTR_ERR(file->ucontext);
275 goto err;
276 }
85 277
86 ucontext->device = ibdev; 278 ucontext->device = ibdev;
87 INIT_LIST_HEAD(&ucontext->pd_list); 279 INIT_LIST_HEAD(&ucontext->pd_list);
@@ -278,7 +470,8 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
278 if (!uobj) 470 if (!uobj)
279 return -ENOMEM; 471 return -ENOMEM;
280 472
281 uobj->context = file->ucontext; 473 init_uobj(uobj, 0, file->ucontext);
474 down_write(&uobj->mutex);
282 475
283 pd = file->device->ib_dev->alloc_pd(file->device->ib_dev, 476 pd = file->device->ib_dev->alloc_pd(file->device->ib_dev,
284 file->ucontext, &udata); 477 file->ucontext, &udata);
@@ -291,20 +484,10 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
291 pd->uobject = uobj; 484 pd->uobject = uobj;
292 atomic_set(&pd->usecnt, 0); 485 atomic_set(&pd->usecnt, 0);
293 486
294 mutex_lock(&ib_uverbs_idr_mutex); 487 uobj->object = pd;
295 488 ret = idr_add_uobj(&ib_uverbs_pd_idr, uobj);
296retry:
297 if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) {
298 ret = -ENOMEM;
299 goto err_up;
300 }
301
302 ret = idr_get_new(&ib_uverbs_pd_idr, pd, &uobj->id);
303
304 if (ret == -EAGAIN)
305 goto retry;
306 if (ret) 489 if (ret)
307 goto err_up; 490 goto err_idr;
308 491
309 memset(&resp, 0, sizeof resp); 492 memset(&resp, 0, sizeof resp);
310 resp.pd_handle = uobj->id; 493 resp.pd_handle = uobj->id;
@@ -312,26 +495,27 @@ retry:
312 if (copy_to_user((void __user *) (unsigned long) cmd.response, 495 if (copy_to_user((void __user *) (unsigned long) cmd.response,
313 &resp, sizeof resp)) { 496 &resp, sizeof resp)) {
314 ret = -EFAULT; 497 ret = -EFAULT;
315 goto err_idr; 498 goto err_copy;
316 } 499 }
317 500
318 mutex_lock(&file->mutex); 501 mutex_lock(&file->mutex);
319 list_add_tail(&uobj->list, &file->ucontext->pd_list); 502 list_add_tail(&uobj->list, &file->ucontext->pd_list);
320 mutex_unlock(&file->mutex); 503 mutex_unlock(&file->mutex);
321 504
322 mutex_unlock(&ib_uverbs_idr_mutex); 505 uobj->live = 1;
506
507 up_write(&uobj->mutex);
323 508
324 return in_len; 509 return in_len;
325 510
326err_idr: 511err_copy:
327 idr_remove(&ib_uverbs_pd_idr, uobj->id); 512 idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
328 513
329err_up: 514err_idr:
330 mutex_unlock(&ib_uverbs_idr_mutex);
331 ib_dealloc_pd(pd); 515 ib_dealloc_pd(pd);
332 516
333err: 517err:
334 kfree(uobj); 518 put_uobj_write(uobj);
335 return ret; 519 return ret;
336} 520}
337 521
@@ -340,37 +524,34 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
340 int in_len, int out_len) 524 int in_len, int out_len)
341{ 525{
342 struct ib_uverbs_dealloc_pd cmd; 526 struct ib_uverbs_dealloc_pd cmd;
343 struct ib_pd *pd;
344 struct ib_uobject *uobj; 527 struct ib_uobject *uobj;
345 int ret = -EINVAL; 528 int ret;
346 529
347 if (copy_from_user(&cmd, buf, sizeof cmd)) 530 if (copy_from_user(&cmd, buf, sizeof cmd))
348 return -EFAULT; 531 return -EFAULT;
349 532
350 mutex_lock(&ib_uverbs_idr_mutex); 533 uobj = idr_write_uobj(&ib_uverbs_pd_idr, cmd.pd_handle, file->ucontext);
534 if (!uobj)
535 return -EINVAL;
351 536
352 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); 537 ret = ib_dealloc_pd(uobj->object);
353 if (!pd || pd->uobject->context != file->ucontext) 538 if (!ret)
354 goto out; 539 uobj->live = 0;
355 540
356 uobj = pd->uobject; 541 put_uobj_write(uobj);
357 542
358 ret = ib_dealloc_pd(pd);
359 if (ret) 543 if (ret)
360 goto out; 544 return ret;
361 545
362 idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); 546 idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
363 547
364 mutex_lock(&file->mutex); 548 mutex_lock(&file->mutex);
365 list_del(&uobj->list); 549 list_del(&uobj->list);
366 mutex_unlock(&file->mutex); 550 mutex_unlock(&file->mutex);
367 551
368 kfree(uobj); 552 put_uobj(uobj);
369
370out:
371 mutex_unlock(&ib_uverbs_idr_mutex);
372 553
373 return ret ? ret : in_len; 554 return in_len;
374} 555}
375 556
376ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file, 557ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
@@ -410,7 +591,8 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
410 if (!obj) 591 if (!obj)
411 return -ENOMEM; 592 return -ENOMEM;
412 593
413 obj->uobject.context = file->ucontext; 594 init_uobj(&obj->uobject, 0, file->ucontext);
595 down_write(&obj->uobject.mutex);
414 596
415 /* 597 /*
416 * We ask for writable memory if any access flags other than 598 * We ask for writable memory if any access flags other than
@@ -427,23 +609,14 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
427 609
428 obj->umem.virt_base = cmd.hca_va; 610 obj->umem.virt_base = cmd.hca_va;
429 611
430 mutex_lock(&ib_uverbs_idr_mutex); 612 pd = idr_read_pd(cmd.pd_handle, file->ucontext);
431 613 if (!pd)
432 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); 614 goto err_release;
433 if (!pd || pd->uobject->context != file->ucontext) {
434 ret = -EINVAL;
435 goto err_up;
436 }
437
438 if (!pd->device->reg_user_mr) {
439 ret = -ENOSYS;
440 goto err_up;
441 }
442 615
443 mr = pd->device->reg_user_mr(pd, &obj->umem, cmd.access_flags, &udata); 616 mr = pd->device->reg_user_mr(pd, &obj->umem, cmd.access_flags, &udata);
444 if (IS_ERR(mr)) { 617 if (IS_ERR(mr)) {
445 ret = PTR_ERR(mr); 618 ret = PTR_ERR(mr);
446 goto err_up; 619 goto err_put;
447 } 620 }
448 621
449 mr->device = pd->device; 622 mr->device = pd->device;
@@ -452,53 +625,48 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
452 atomic_inc(&pd->usecnt); 625 atomic_inc(&pd->usecnt);
453 atomic_set(&mr->usecnt, 0); 626 atomic_set(&mr->usecnt, 0);
454 627
455 memset(&resp, 0, sizeof resp); 628 obj->uobject.object = mr;
456 resp.lkey = mr->lkey; 629 ret = idr_add_uobj(&ib_uverbs_mr_idr, &obj->uobject);
457 resp.rkey = mr->rkey;
458
459retry:
460 if (!idr_pre_get(&ib_uverbs_mr_idr, GFP_KERNEL)) {
461 ret = -ENOMEM;
462 goto err_unreg;
463 }
464
465 ret = idr_get_new(&ib_uverbs_mr_idr, mr, &obj->uobject.id);
466
467 if (ret == -EAGAIN)
468 goto retry;
469 if (ret) 630 if (ret)
470 goto err_unreg; 631 goto err_unreg;
471 632
633 memset(&resp, 0, sizeof resp);
634 resp.lkey = mr->lkey;
635 resp.rkey = mr->rkey;
472 resp.mr_handle = obj->uobject.id; 636 resp.mr_handle = obj->uobject.id;
473 637
474 if (copy_to_user((void __user *) (unsigned long) cmd.response, 638 if (copy_to_user((void __user *) (unsigned long) cmd.response,
475 &resp, sizeof resp)) { 639 &resp, sizeof resp)) {
476 ret = -EFAULT; 640 ret = -EFAULT;
477 goto err_idr; 641 goto err_copy;
478 } 642 }
479 643
644 put_pd_read(pd);
645
480 mutex_lock(&file->mutex); 646 mutex_lock(&file->mutex);
481 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); 647 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list);
482 mutex_unlock(&file->mutex); 648 mutex_unlock(&file->mutex);
483 649
484 mutex_unlock(&ib_uverbs_idr_mutex); 650 obj->uobject.live = 1;
651
652 up_write(&obj->uobject.mutex);
485 653
486 return in_len; 654 return in_len;
487 655
488err_idr: 656err_copy:
489 idr_remove(&ib_uverbs_mr_idr, obj->uobject.id); 657 idr_remove_uobj(&ib_uverbs_mr_idr, &obj->uobject);
490 658
491err_unreg: 659err_unreg:
492 ib_dereg_mr(mr); 660 ib_dereg_mr(mr);
493 atomic_dec(&pd->usecnt);
494 661
495err_up: 662err_put:
496 mutex_unlock(&ib_uverbs_idr_mutex); 663 put_pd_read(pd);
497 664
665err_release:
498 ib_umem_release(file->device->ib_dev, &obj->umem); 666 ib_umem_release(file->device->ib_dev, &obj->umem);
499 667
500err_free: 668err_free:
501 kfree(obj); 669 put_uobj_write(&obj->uobject);
502 return ret; 670 return ret;
503} 671}
504 672
@@ -508,37 +676,40 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
508{ 676{
509 struct ib_uverbs_dereg_mr cmd; 677 struct ib_uverbs_dereg_mr cmd;
510 struct ib_mr *mr; 678 struct ib_mr *mr;
679 struct ib_uobject *uobj;
511 struct ib_umem_object *memobj; 680 struct ib_umem_object *memobj;
512 int ret = -EINVAL; 681 int ret = -EINVAL;
513 682
514 if (copy_from_user(&cmd, buf, sizeof cmd)) 683 if (copy_from_user(&cmd, buf, sizeof cmd))
515 return -EFAULT; 684 return -EFAULT;
516 685
517 mutex_lock(&ib_uverbs_idr_mutex); 686 uobj = idr_write_uobj(&ib_uverbs_mr_idr, cmd.mr_handle, file->ucontext);
518 687 if (!uobj)
519 mr = idr_find(&ib_uverbs_mr_idr, cmd.mr_handle); 688 return -EINVAL;
520 if (!mr || mr->uobject->context != file->ucontext)
521 goto out;
522 689
523 memobj = container_of(mr->uobject, struct ib_umem_object, uobject); 690 memobj = container_of(uobj, struct ib_umem_object, uobject);
691 mr = uobj->object;
524 692
525 ret = ib_dereg_mr(mr); 693 ret = ib_dereg_mr(mr);
694 if (!ret)
695 uobj->live = 0;
696
697 put_uobj_write(uobj);
698
526 if (ret) 699 if (ret)
527 goto out; 700 return ret;
528 701
529 idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); 702 idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
530 703
531 mutex_lock(&file->mutex); 704 mutex_lock(&file->mutex);
532 list_del(&memobj->uobject.list); 705 list_del(&uobj->list);
533 mutex_unlock(&file->mutex); 706 mutex_unlock(&file->mutex);
534 707
535 ib_umem_release(file->device->ib_dev, &memobj->umem); 708 ib_umem_release(file->device->ib_dev, &memobj->umem);
536 kfree(memobj);
537 709
538out: 710 put_uobj(uobj);
539 mutex_unlock(&ib_uverbs_idr_mutex);
540 711
541 return ret ? ret : in_len; 712 return in_len;
542} 713}
543 714
544ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file, 715ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
@@ -577,7 +748,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
577 struct ib_uverbs_create_cq cmd; 748 struct ib_uverbs_create_cq cmd;
578 struct ib_uverbs_create_cq_resp resp; 749 struct ib_uverbs_create_cq_resp resp;
579 struct ib_udata udata; 750 struct ib_udata udata;
580 struct ib_ucq_object *uobj; 751 struct ib_ucq_object *obj;
581 struct ib_uverbs_event_file *ev_file = NULL; 752 struct ib_uverbs_event_file *ev_file = NULL;
582 struct ib_cq *cq; 753 struct ib_cq *cq;
583 int ret; 754 int ret;
@@ -595,10 +766,13 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
595 if (cmd.comp_vector >= file->device->num_comp_vectors) 766 if (cmd.comp_vector >= file->device->num_comp_vectors)
596 return -EINVAL; 767 return -EINVAL;
597 768
598 uobj = kmalloc(sizeof *uobj, GFP_KERNEL); 769 obj = kmalloc(sizeof *obj, GFP_KERNEL);
599 if (!uobj) 770 if (!obj)
600 return -ENOMEM; 771 return -ENOMEM;
601 772
773 init_uobj(&obj->uobject, cmd.user_handle, file->ucontext);
774 down_write(&obj->uobject.mutex);
775
602 if (cmd.comp_channel >= 0) { 776 if (cmd.comp_channel >= 0) {
603 ev_file = ib_uverbs_lookup_comp_file(cmd.comp_channel); 777 ev_file = ib_uverbs_lookup_comp_file(cmd.comp_channel);
604 if (!ev_file) { 778 if (!ev_file) {
@@ -607,72 +781,64 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
607 } 781 }
608 } 782 }
609 783
610 uobj->uobject.user_handle = cmd.user_handle; 784 obj->uverbs_file = file;
611 uobj->uobject.context = file->ucontext; 785 obj->comp_events_reported = 0;
612 uobj->uverbs_file = file; 786 obj->async_events_reported = 0;
613 uobj->comp_events_reported = 0; 787 INIT_LIST_HEAD(&obj->comp_list);
614 uobj->async_events_reported = 0; 788 INIT_LIST_HEAD(&obj->async_list);
615 INIT_LIST_HEAD(&uobj->comp_list);
616 INIT_LIST_HEAD(&uobj->async_list);
617 789
618 cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe, 790 cq = file->device->ib_dev->create_cq(file->device->ib_dev, cmd.cqe,
619 file->ucontext, &udata); 791 file->ucontext, &udata);
620 if (IS_ERR(cq)) { 792 if (IS_ERR(cq)) {
621 ret = PTR_ERR(cq); 793 ret = PTR_ERR(cq);
622 goto err; 794 goto err_file;
623 } 795 }
624 796
625 cq->device = file->device->ib_dev; 797 cq->device = file->device->ib_dev;
626 cq->uobject = &uobj->uobject; 798 cq->uobject = &obj->uobject;
627 cq->comp_handler = ib_uverbs_comp_handler; 799 cq->comp_handler = ib_uverbs_comp_handler;
628 cq->event_handler = ib_uverbs_cq_event_handler; 800 cq->event_handler = ib_uverbs_cq_event_handler;
629 cq->cq_context = ev_file; 801 cq->cq_context = ev_file;
630 atomic_set(&cq->usecnt, 0); 802 atomic_set(&cq->usecnt, 0);
631 803
632 mutex_lock(&ib_uverbs_idr_mutex); 804 obj->uobject.object = cq;
633 805 ret = idr_add_uobj(&ib_uverbs_cq_idr, &obj->uobject);
634retry:
635 if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) {
636 ret = -ENOMEM;
637 goto err_up;
638 }
639
640 ret = idr_get_new(&ib_uverbs_cq_idr, cq, &uobj->uobject.id);
641
642 if (ret == -EAGAIN)
643 goto retry;
644 if (ret) 806 if (ret)
645 goto err_up; 807 goto err_free;
646 808
647 memset(&resp, 0, sizeof resp); 809 memset(&resp, 0, sizeof resp);
648 resp.cq_handle = uobj->uobject.id; 810 resp.cq_handle = obj->uobject.id;
649 resp.cqe = cq->cqe; 811 resp.cqe = cq->cqe;
650 812
651 if (copy_to_user((void __user *) (unsigned long) cmd.response, 813 if (copy_to_user((void __user *) (unsigned long) cmd.response,
652 &resp, sizeof resp)) { 814 &resp, sizeof resp)) {
653 ret = -EFAULT; 815 ret = -EFAULT;
654 goto err_idr; 816 goto err_copy;
655 } 817 }
656 818
657 mutex_lock(&file->mutex); 819 mutex_lock(&file->mutex);
658 list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); 820 list_add_tail(&obj->uobject.list, &file->ucontext->cq_list);
659 mutex_unlock(&file->mutex); 821 mutex_unlock(&file->mutex);
660 822
661 mutex_unlock(&ib_uverbs_idr_mutex); 823 obj->uobject.live = 1;
824
825 up_write(&obj->uobject.mutex);
662 826
663 return in_len; 827 return in_len;
664 828
665err_idr: 829err_copy:
666 idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); 830 idr_remove_uobj(&ib_uverbs_cq_idr, &obj->uobject);
831
667 832
668err_up: 833err_free:
669 mutex_unlock(&ib_uverbs_idr_mutex);
670 ib_destroy_cq(cq); 834 ib_destroy_cq(cq);
671 835
672err: 836err_file:
673 if (ev_file) 837 if (ev_file)
674 ib_uverbs_release_ucq(file, ev_file, uobj); 838 ib_uverbs_release_ucq(file, ev_file, obj);
675 kfree(uobj); 839
840err:
841 put_uobj_write(&obj->uobject);
676 return ret; 842 return ret;
677} 843}
678 844
@@ -693,11 +859,9 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
693 (unsigned long) cmd.response + sizeof resp, 859 (unsigned long) cmd.response + sizeof resp,
694 in_len - sizeof cmd, out_len - sizeof resp); 860 in_len - sizeof cmd, out_len - sizeof resp);
695 861
696 mutex_lock(&ib_uverbs_idr_mutex); 862 cq = idr_read_cq(cmd.cq_handle, file->ucontext);
697 863 if (!cq)
698 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); 864 return -EINVAL;
699 if (!cq || cq->uobject->context != file->ucontext || !cq->device->resize_cq)
700 goto out;
701 865
702 ret = cq->device->resize_cq(cq, cmd.cqe, &udata); 866 ret = cq->device->resize_cq(cq, cmd.cqe, &udata);
703 if (ret) 867 if (ret)
@@ -711,7 +875,7 @@ ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
711 ret = -EFAULT; 875 ret = -EFAULT;
712 876
713out: 877out:
714 mutex_unlock(&ib_uverbs_idr_mutex); 878 put_cq_read(cq);
715 879
716 return ret ? ret : in_len; 880 return ret ? ret : in_len;
717} 881}
@@ -722,6 +886,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
722{ 886{
723 struct ib_uverbs_poll_cq cmd; 887 struct ib_uverbs_poll_cq cmd;
724 struct ib_uverbs_poll_cq_resp *resp; 888 struct ib_uverbs_poll_cq_resp *resp;
889 struct ib_uobject *uobj;
725 struct ib_cq *cq; 890 struct ib_cq *cq;
726 struct ib_wc *wc; 891 struct ib_wc *wc;
727 int ret = 0; 892 int ret = 0;
@@ -742,15 +907,17 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
742 goto out_wc; 907 goto out_wc;
743 } 908 }
744 909
745 mutex_lock(&ib_uverbs_idr_mutex); 910 uobj = idr_read_uobj(&ib_uverbs_cq_idr, cmd.cq_handle, file->ucontext);
746 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); 911 if (!uobj) {
747 if (!cq || cq->uobject->context != file->ucontext) {
748 ret = -EINVAL; 912 ret = -EINVAL;
749 goto out; 913 goto out;
750 } 914 }
915 cq = uobj->object;
751 916
752 resp->count = ib_poll_cq(cq, cmd.ne, wc); 917 resp->count = ib_poll_cq(cq, cmd.ne, wc);
753 918
919 put_uobj_read(uobj);
920
754 for (i = 0; i < resp->count; i++) { 921 for (i = 0; i < resp->count; i++) {
755 resp->wc[i].wr_id = wc[i].wr_id; 922 resp->wc[i].wr_id = wc[i].wr_id;
756 resp->wc[i].status = wc[i].status; 923 resp->wc[i].status = wc[i].status;
@@ -772,7 +939,6 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
772 ret = -EFAULT; 939 ret = -EFAULT;
773 940
774out: 941out:
775 mutex_unlock(&ib_uverbs_idr_mutex);
776 kfree(resp); 942 kfree(resp);
777 943
778out_wc: 944out_wc:
@@ -785,22 +951,23 @@ ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
785 int out_len) 951 int out_len)
786{ 952{
787 struct ib_uverbs_req_notify_cq cmd; 953 struct ib_uverbs_req_notify_cq cmd;
954 struct ib_uobject *uobj;
788 struct ib_cq *cq; 955 struct ib_cq *cq;
789 int ret = -EINVAL;
790 956
791 if (copy_from_user(&cmd, buf, sizeof cmd)) 957 if (copy_from_user(&cmd, buf, sizeof cmd))
792 return -EFAULT; 958 return -EFAULT;
793 959
794 mutex_lock(&ib_uverbs_idr_mutex); 960 uobj = idr_read_uobj(&ib_uverbs_cq_idr, cmd.cq_handle, file->ucontext);
795 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); 961 if (!uobj)
796 if (cq && cq->uobject->context == file->ucontext) { 962 return -EINVAL;
797 ib_req_notify_cq(cq, cmd.solicited_only ? 963 cq = uobj->object;
798 IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
799 ret = in_len;
800 }
801 mutex_unlock(&ib_uverbs_idr_mutex);
802 964
803 return ret; 965 ib_req_notify_cq(cq, cmd.solicited_only ?
966 IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
967
968 put_uobj_read(uobj);
969
970 return in_len;
804} 971}
805 972
806ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, 973ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
@@ -809,52 +976,50 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
809{ 976{
810 struct ib_uverbs_destroy_cq cmd; 977 struct ib_uverbs_destroy_cq cmd;
811 struct ib_uverbs_destroy_cq_resp resp; 978 struct ib_uverbs_destroy_cq_resp resp;
979 struct ib_uobject *uobj;
812 struct ib_cq *cq; 980 struct ib_cq *cq;
813 struct ib_ucq_object *uobj; 981 struct ib_ucq_object *obj;
814 struct ib_uverbs_event_file *ev_file; 982 struct ib_uverbs_event_file *ev_file;
815 u64 user_handle;
816 int ret = -EINVAL; 983 int ret = -EINVAL;
817 984
818 if (copy_from_user(&cmd, buf, sizeof cmd)) 985 if (copy_from_user(&cmd, buf, sizeof cmd))
819 return -EFAULT; 986 return -EFAULT;
820 987
821 memset(&resp, 0, sizeof resp); 988 uobj = idr_write_uobj(&ib_uverbs_cq_idr, cmd.cq_handle, file->ucontext);
822 989 if (!uobj)
823 mutex_lock(&ib_uverbs_idr_mutex); 990 return -EINVAL;
991 cq = uobj->object;
992 ev_file = cq->cq_context;
993 obj = container_of(cq->uobject, struct ib_ucq_object, uobject);
824 994
825 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle); 995 ret = ib_destroy_cq(cq);
826 if (!cq || cq->uobject->context != file->ucontext) 996 if (!ret)
827 goto out; 997 uobj->live = 0;
828 998
829 user_handle = cq->uobject->user_handle; 999 put_uobj_write(uobj);
830 uobj = container_of(cq->uobject, struct ib_ucq_object, uobject);
831 ev_file = cq->cq_context;
832 1000
833 ret = ib_destroy_cq(cq);
834 if (ret) 1001 if (ret)
835 goto out; 1002 return ret;
836 1003
837 idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); 1004 idr_remove_uobj(&ib_uverbs_cq_idr, uobj);
838 1005
839 mutex_lock(&file->mutex); 1006 mutex_lock(&file->mutex);
840 list_del(&uobj->uobject.list); 1007 list_del(&uobj->list);
841 mutex_unlock(&file->mutex); 1008 mutex_unlock(&file->mutex);
842 1009
843 ib_uverbs_release_ucq(file, ev_file, uobj); 1010 ib_uverbs_release_ucq(file, ev_file, obj);
844 1011
845 resp.comp_events_reported = uobj->comp_events_reported; 1012 memset(&resp, 0, sizeof resp);
846 resp.async_events_reported = uobj->async_events_reported; 1013 resp.comp_events_reported = obj->comp_events_reported;
1014 resp.async_events_reported = obj->async_events_reported;
847 1015
848 kfree(uobj); 1016 put_uobj(uobj);
849 1017
850 if (copy_to_user((void __user *) (unsigned long) cmd.response, 1018 if (copy_to_user((void __user *) (unsigned long) cmd.response,
851 &resp, sizeof resp)) 1019 &resp, sizeof resp))
852 ret = -EFAULT; 1020 return -EFAULT;
853
854out:
855 mutex_unlock(&ib_uverbs_idr_mutex);
856 1021
857 return ret ? ret : in_len; 1022 return in_len;
858} 1023}
859 1024
860ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, 1025ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
@@ -864,7 +1029,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
864 struct ib_uverbs_create_qp cmd; 1029 struct ib_uverbs_create_qp cmd;
865 struct ib_uverbs_create_qp_resp resp; 1030 struct ib_uverbs_create_qp_resp resp;
866 struct ib_udata udata; 1031 struct ib_udata udata;
867 struct ib_uqp_object *uobj; 1032 struct ib_uqp_object *obj;
868 struct ib_pd *pd; 1033 struct ib_pd *pd;
869 struct ib_cq *scq, *rcq; 1034 struct ib_cq *scq, *rcq;
870 struct ib_srq *srq; 1035 struct ib_srq *srq;
@@ -882,23 +1047,21 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
882 (unsigned long) cmd.response + sizeof resp, 1047 (unsigned long) cmd.response + sizeof resp,
883 in_len - sizeof cmd, out_len - sizeof resp); 1048 in_len - sizeof cmd, out_len - sizeof resp);
884 1049
885 uobj = kmalloc(sizeof *uobj, GFP_KERNEL); 1050 obj = kmalloc(sizeof *obj, GFP_KERNEL);
886 if (!uobj) 1051 if (!obj)
887 return -ENOMEM; 1052 return -ENOMEM;
888 1053
889 mutex_lock(&ib_uverbs_idr_mutex); 1054 init_uobj(&obj->uevent.uobject, cmd.user_handle, file->ucontext);
1055 down_write(&obj->uevent.uobject.mutex);
890 1056
891 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); 1057 pd = idr_read_pd(cmd.pd_handle, file->ucontext);
892 scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle); 1058 scq = idr_read_cq(cmd.send_cq_handle, file->ucontext);
893 rcq = idr_find(&ib_uverbs_cq_idr, cmd.recv_cq_handle); 1059 rcq = idr_read_cq(cmd.recv_cq_handle, file->ucontext);
894 srq = cmd.is_srq ? idr_find(&ib_uverbs_srq_idr, cmd.srq_handle) : NULL; 1060 srq = cmd.is_srq ? idr_read_srq(cmd.srq_handle, file->ucontext) : NULL;
895 1061
896 if (!pd || pd->uobject->context != file->ucontext || 1062 if (!pd || !scq || !rcq || (cmd.is_srq && !srq)) {
897 !scq || scq->uobject->context != file->ucontext ||
898 !rcq || rcq->uobject->context != file->ucontext ||
899 (cmd.is_srq && (!srq || srq->uobject->context != file->ucontext))) {
900 ret = -EINVAL; 1063 ret = -EINVAL;
901 goto err_up; 1064 goto err_put;
902 } 1065 }
903 1066
904 attr.event_handler = ib_uverbs_qp_event_handler; 1067 attr.event_handler = ib_uverbs_qp_event_handler;
@@ -915,16 +1078,14 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
915 attr.cap.max_recv_sge = cmd.max_recv_sge; 1078 attr.cap.max_recv_sge = cmd.max_recv_sge;
916 attr.cap.max_inline_data = cmd.max_inline_data; 1079 attr.cap.max_inline_data = cmd.max_inline_data;
917 1080
918 uobj->uevent.uobject.user_handle = cmd.user_handle; 1081 obj->uevent.events_reported = 0;
919 uobj->uevent.uobject.context = file->ucontext; 1082 INIT_LIST_HEAD(&obj->uevent.event_list);
920 uobj->uevent.events_reported = 0; 1083 INIT_LIST_HEAD(&obj->mcast_list);
921 INIT_LIST_HEAD(&uobj->uevent.event_list);
922 INIT_LIST_HEAD(&uobj->mcast_list);
923 1084
924 qp = pd->device->create_qp(pd, &attr, &udata); 1085 qp = pd->device->create_qp(pd, &attr, &udata);
925 if (IS_ERR(qp)) { 1086 if (IS_ERR(qp)) {
926 ret = PTR_ERR(qp); 1087 ret = PTR_ERR(qp);
927 goto err_up; 1088 goto err_put;
928 } 1089 }
929 1090
930 qp->device = pd->device; 1091 qp->device = pd->device;
@@ -932,7 +1093,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
932 qp->send_cq = attr.send_cq; 1093 qp->send_cq = attr.send_cq;
933 qp->recv_cq = attr.recv_cq; 1094 qp->recv_cq = attr.recv_cq;
934 qp->srq = attr.srq; 1095 qp->srq = attr.srq;
935 qp->uobject = &uobj->uevent.uobject; 1096 qp->uobject = &obj->uevent.uobject;
936 qp->event_handler = attr.event_handler; 1097 qp->event_handler = attr.event_handler;
937 qp->qp_context = attr.qp_context; 1098 qp->qp_context = attr.qp_context;
938 qp->qp_type = attr.qp_type; 1099 qp->qp_type = attr.qp_type;
@@ -942,23 +1103,14 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
942 if (attr.srq) 1103 if (attr.srq)
943 atomic_inc(&attr.srq->usecnt); 1104 atomic_inc(&attr.srq->usecnt);
944 1105
945 memset(&resp, 0, sizeof resp); 1106 obj->uevent.uobject.object = qp;
946 resp.qpn = qp->qp_num; 1107 ret = idr_add_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
947
948retry:
949 if (!idr_pre_get(&ib_uverbs_qp_idr, GFP_KERNEL)) {
950 ret = -ENOMEM;
951 goto err_destroy;
952 }
953
954 ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->uevent.uobject.id);
955
956 if (ret == -EAGAIN)
957 goto retry;
958 if (ret) 1108 if (ret)
959 goto err_destroy; 1109 goto err_destroy;
960 1110
961 resp.qp_handle = uobj->uevent.uobject.id; 1111 memset(&resp, 0, sizeof resp);
1112 resp.qpn = qp->qp_num;
1113 resp.qp_handle = obj->uevent.uobject.id;
962 resp.max_recv_sge = attr.cap.max_recv_sge; 1114 resp.max_recv_sge = attr.cap.max_recv_sge;
963 resp.max_send_sge = attr.cap.max_send_sge; 1115 resp.max_send_sge = attr.cap.max_send_sge;
964 resp.max_recv_wr = attr.cap.max_recv_wr; 1116 resp.max_recv_wr = attr.cap.max_recv_wr;
@@ -968,32 +1120,42 @@ retry:
968 if (copy_to_user((void __user *) (unsigned long) cmd.response, 1120 if (copy_to_user((void __user *) (unsigned long) cmd.response,
969 &resp, sizeof resp)) { 1121 &resp, sizeof resp)) {
970 ret = -EFAULT; 1122 ret = -EFAULT;
971 goto err_idr; 1123 goto err_copy;
972 } 1124 }
973 1125
1126 put_pd_read(pd);
1127 put_cq_read(scq);
1128 put_cq_read(rcq);
1129 if (srq)
1130 put_srq_read(srq);
1131
974 mutex_lock(&file->mutex); 1132 mutex_lock(&file->mutex);
975 list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list); 1133 list_add_tail(&obj->uevent.uobject.list, &file->ucontext->qp_list);
976 mutex_unlock(&file->mutex); 1134 mutex_unlock(&file->mutex);
977 1135
978 mutex_unlock(&ib_uverbs_idr_mutex); 1136 obj->uevent.uobject.live = 1;
1137
1138 up_write(&obj->uevent.uobject.mutex);
979 1139
980 return in_len; 1140 return in_len;
981 1141
982err_idr: 1142err_copy:
983 idr_remove(&ib_uverbs_qp_idr, uobj->uevent.uobject.id); 1143 idr_remove_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
984 1144
985err_destroy: 1145err_destroy:
986 ib_destroy_qp(qp); 1146 ib_destroy_qp(qp);
987 atomic_dec(&pd->usecnt);
988 atomic_dec(&attr.send_cq->usecnt);
989 atomic_dec(&attr.recv_cq->usecnt);
990 if (attr.srq)
991 atomic_dec(&attr.srq->usecnt);
992
993err_up:
994 mutex_unlock(&ib_uverbs_idr_mutex);
995 1147
996 kfree(uobj); 1148err_put:
1149 if (pd)
1150 put_pd_read(pd);
1151 if (scq)
1152 put_cq_read(scq);
1153 if (rcq)
1154 put_cq_read(rcq);
1155 if (srq)
1156 put_srq_read(srq);
1157
1158 put_uobj_write(&obj->uevent.uobject);
997 return ret; 1159 return ret;
998} 1160}
999 1161
@@ -1018,15 +1180,15 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
1018 goto out; 1180 goto out;
1019 } 1181 }
1020 1182
1021 mutex_lock(&ib_uverbs_idr_mutex); 1183 qp = idr_read_qp(cmd.qp_handle, file->ucontext);
1022 1184 if (!qp) {
1023 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1024 if (qp && qp->uobject->context == file->ucontext)
1025 ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr);
1026 else
1027 ret = -EINVAL; 1185 ret = -EINVAL;
1186 goto out;
1187 }
1028 1188
1029 mutex_unlock(&ib_uverbs_idr_mutex); 1189 ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr);
1190
1191 put_qp_read(qp);
1030 1192
1031 if (ret) 1193 if (ret)
1032 goto out; 1194 goto out;
@@ -1113,10 +1275,8 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
1113 if (!attr) 1275 if (!attr)
1114 return -ENOMEM; 1276 return -ENOMEM;
1115 1277
1116 mutex_lock(&ib_uverbs_idr_mutex); 1278 qp = idr_read_qp(cmd.qp_handle, file->ucontext);
1117 1279 if (!qp) {
1118 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1119 if (!qp || qp->uobject->context != file->ucontext) {
1120 ret = -EINVAL; 1280 ret = -EINVAL;
1121 goto out; 1281 goto out;
1122 } 1282 }
@@ -1168,13 +1328,15 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
1168 attr->alt_ah_attr.port_num = cmd.alt_dest.port_num; 1328 attr->alt_ah_attr.port_num = cmd.alt_dest.port_num;
1169 1329
1170 ret = ib_modify_qp(qp, attr, cmd.attr_mask); 1330 ret = ib_modify_qp(qp, attr, cmd.attr_mask);
1331
1332 put_qp_read(qp);
1333
1171 if (ret) 1334 if (ret)
1172 goto out; 1335 goto out;
1173 1336
1174 ret = in_len; 1337 ret = in_len;
1175 1338
1176out: 1339out:
1177 mutex_unlock(&ib_uverbs_idr_mutex);
1178 kfree(attr); 1340 kfree(attr);
1179 1341
1180 return ret; 1342 return ret;
@@ -1186,8 +1348,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1186{ 1348{
1187 struct ib_uverbs_destroy_qp cmd; 1349 struct ib_uverbs_destroy_qp cmd;
1188 struct ib_uverbs_destroy_qp_resp resp; 1350 struct ib_uverbs_destroy_qp_resp resp;
1351 struct ib_uobject *uobj;
1189 struct ib_qp *qp; 1352 struct ib_qp *qp;
1190 struct ib_uqp_object *uobj; 1353 struct ib_uqp_object *obj;
1191 int ret = -EINVAL; 1354 int ret = -EINVAL;
1192 1355
1193 if (copy_from_user(&cmd, buf, sizeof cmd)) 1356 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1195,43 +1358,43 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1195 1358
1196 memset(&resp, 0, sizeof resp); 1359 memset(&resp, 0, sizeof resp);
1197 1360
1198 mutex_lock(&ib_uverbs_idr_mutex); 1361 uobj = idr_write_uobj(&ib_uverbs_qp_idr, cmd.qp_handle, file->ucontext);
1199 1362 if (!uobj)
1200 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1363 return -EINVAL;
1201 if (!qp || qp->uobject->context != file->ucontext) 1364 qp = uobj->object;
1202 goto out; 1365 obj = container_of(uobj, struct ib_uqp_object, uevent.uobject);
1203
1204 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1205 1366
1206 if (!list_empty(&uobj->mcast_list)) { 1367 if (!list_empty(&obj->mcast_list)) {
1207 ret = -EBUSY; 1368 put_uobj_write(uobj);
1208 goto out; 1369 return -EBUSY;
1209 } 1370 }
1210 1371
1211 ret = ib_destroy_qp(qp); 1372 ret = ib_destroy_qp(qp);
1373 if (!ret)
1374 uobj->live = 0;
1375
1376 put_uobj_write(uobj);
1377
1212 if (ret) 1378 if (ret)
1213 goto out; 1379 return ret;
1214 1380
1215 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); 1381 idr_remove_uobj(&ib_uverbs_qp_idr, uobj);
1216 1382
1217 mutex_lock(&file->mutex); 1383 mutex_lock(&file->mutex);
1218 list_del(&uobj->uevent.uobject.list); 1384 list_del(&uobj->list);
1219 mutex_unlock(&file->mutex); 1385 mutex_unlock(&file->mutex);
1220 1386
1221 ib_uverbs_release_uevent(file, &uobj->uevent); 1387 ib_uverbs_release_uevent(file, &obj->uevent);
1222 1388
1223 resp.events_reported = uobj->uevent.events_reported; 1389 resp.events_reported = obj->uevent.events_reported;
1224 1390
1225 kfree(uobj); 1391 put_uobj(uobj);
1226 1392
1227 if (copy_to_user((void __user *) (unsigned long) cmd.response, 1393 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1228 &resp, sizeof resp)) 1394 &resp, sizeof resp))
1229 ret = -EFAULT; 1395 return -EFAULT;
1230
1231out:
1232 mutex_unlock(&ib_uverbs_idr_mutex);
1233 1396
1234 return ret ? ret : in_len; 1397 return in_len;
1235} 1398}
1236 1399
1237ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, 1400ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
@@ -1244,6 +1407,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1244 struct ib_send_wr *wr = NULL, *last, *next, *bad_wr; 1407 struct ib_send_wr *wr = NULL, *last, *next, *bad_wr;
1245 struct ib_qp *qp; 1408 struct ib_qp *qp;
1246 int i, sg_ind; 1409 int i, sg_ind;
1410 int is_ud;
1247 ssize_t ret = -EINVAL; 1411 ssize_t ret = -EINVAL;
1248 1412
1249 if (copy_from_user(&cmd, buf, sizeof cmd)) 1413 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1260,12 +1424,11 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1260 if (!user_wr) 1424 if (!user_wr)
1261 return -ENOMEM; 1425 return -ENOMEM;
1262 1426
1263 mutex_lock(&ib_uverbs_idr_mutex); 1427 qp = idr_read_qp(cmd.qp_handle, file->ucontext);
1264 1428 if (!qp)
1265 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1266 if (!qp || qp->uobject->context != file->ucontext)
1267 goto out; 1429 goto out;
1268 1430
1431 is_ud = qp->qp_type == IB_QPT_UD;
1269 sg_ind = 0; 1432 sg_ind = 0;
1270 last = NULL; 1433 last = NULL;
1271 for (i = 0; i < cmd.wr_count; ++i) { 1434 for (i = 0; i < cmd.wr_count; ++i) {
@@ -1273,12 +1436,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1273 buf + sizeof cmd + i * cmd.wqe_size, 1436 buf + sizeof cmd + i * cmd.wqe_size,
1274 cmd.wqe_size)) { 1437 cmd.wqe_size)) {
1275 ret = -EFAULT; 1438 ret = -EFAULT;
1276 goto out; 1439 goto out_put;
1277 } 1440 }
1278 1441
1279 if (user_wr->num_sge + sg_ind > cmd.sge_count) { 1442 if (user_wr->num_sge + sg_ind > cmd.sge_count) {
1280 ret = -EINVAL; 1443 ret = -EINVAL;
1281 goto out; 1444 goto out_put;
1282 } 1445 }
1283 1446
1284 next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) + 1447 next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
@@ -1286,7 +1449,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1286 GFP_KERNEL); 1449 GFP_KERNEL);
1287 if (!next) { 1450 if (!next) {
1288 ret = -ENOMEM; 1451 ret = -ENOMEM;
1289 goto out; 1452 goto out_put;
1290 } 1453 }
1291 1454
1292 if (!last) 1455 if (!last)
@@ -1302,12 +1465,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1302 next->send_flags = user_wr->send_flags; 1465 next->send_flags = user_wr->send_flags;
1303 next->imm_data = (__be32 __force) user_wr->imm_data; 1466 next->imm_data = (__be32 __force) user_wr->imm_data;
1304 1467
1305 if (qp->qp_type == IB_QPT_UD) { 1468 if (is_ud) {
1306 next->wr.ud.ah = idr_find(&ib_uverbs_ah_idr, 1469 next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
1307 user_wr->wr.ud.ah); 1470 file->ucontext);
1308 if (!next->wr.ud.ah) { 1471 if (!next->wr.ud.ah) {
1309 ret = -EINVAL; 1472 ret = -EINVAL;
1310 goto out; 1473 goto out_put;
1311 } 1474 }
1312 next->wr.ud.remote_qpn = user_wr->wr.ud.remote_qpn; 1475 next->wr.ud.remote_qpn = user_wr->wr.ud.remote_qpn;
1313 next->wr.ud.remote_qkey = user_wr->wr.ud.remote_qkey; 1476 next->wr.ud.remote_qkey = user_wr->wr.ud.remote_qkey;
@@ -1344,7 +1507,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1344 sg_ind * sizeof (struct ib_sge), 1507 sg_ind * sizeof (struct ib_sge),
1345 next->num_sge * sizeof (struct ib_sge))) { 1508 next->num_sge * sizeof (struct ib_sge))) {
1346 ret = -EFAULT; 1509 ret = -EFAULT;
1347 goto out; 1510 goto out_put;
1348 } 1511 }
1349 sg_ind += next->num_sge; 1512 sg_ind += next->num_sge;
1350 } else 1513 } else
@@ -1364,10 +1527,13 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1364 &resp, sizeof resp)) 1527 &resp, sizeof resp))
1365 ret = -EFAULT; 1528 ret = -EFAULT;
1366 1529
1367out: 1530out_put:
1368 mutex_unlock(&ib_uverbs_idr_mutex); 1531 put_qp_read(qp);
1369 1532
1533out:
1370 while (wr) { 1534 while (wr) {
1535 if (is_ud && wr->wr.ud.ah)
1536 put_ah_read(wr->wr.ud.ah);
1371 next = wr->next; 1537 next = wr->next;
1372 kfree(wr); 1538 kfree(wr);
1373 wr = next; 1539 wr = next;
@@ -1482,14 +1648,15 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
1482 if (IS_ERR(wr)) 1648 if (IS_ERR(wr))
1483 return PTR_ERR(wr); 1649 return PTR_ERR(wr);
1484 1650
1485 mutex_lock(&ib_uverbs_idr_mutex); 1651 qp = idr_read_qp(cmd.qp_handle, file->ucontext);
1486 1652 if (!qp)
1487 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1488 if (!qp || qp->uobject->context != file->ucontext)
1489 goto out; 1653 goto out;
1490 1654
1491 resp.bad_wr = 0; 1655 resp.bad_wr = 0;
1492 ret = qp->device->post_recv(qp, wr, &bad_wr); 1656 ret = qp->device->post_recv(qp, wr, &bad_wr);
1657
1658 put_qp_read(qp);
1659
1493 if (ret) 1660 if (ret)
1494 for (next = wr; next; next = next->next) { 1661 for (next = wr; next; next = next->next) {
1495 ++resp.bad_wr; 1662 ++resp.bad_wr;
@@ -1503,8 +1670,6 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
1503 ret = -EFAULT; 1670 ret = -EFAULT;
1504 1671
1505out: 1672out:
1506 mutex_unlock(&ib_uverbs_idr_mutex);
1507
1508 while (wr) { 1673 while (wr) {
1509 next = wr->next; 1674 next = wr->next;
1510 kfree(wr); 1675 kfree(wr);
@@ -1533,14 +1698,15 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
1533 if (IS_ERR(wr)) 1698 if (IS_ERR(wr))
1534 return PTR_ERR(wr); 1699 return PTR_ERR(wr);
1535 1700
1536 mutex_lock(&ib_uverbs_idr_mutex); 1701 srq = idr_read_srq(cmd.srq_handle, file->ucontext);
1537 1702 if (!srq)
1538 srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
1539 if (!srq || srq->uobject->context != file->ucontext)
1540 goto out; 1703 goto out;
1541 1704
1542 resp.bad_wr = 0; 1705 resp.bad_wr = 0;
1543 ret = srq->device->post_srq_recv(srq, wr, &bad_wr); 1706 ret = srq->device->post_srq_recv(srq, wr, &bad_wr);
1707
1708 put_srq_read(srq);
1709
1544 if (ret) 1710 if (ret)
1545 for (next = wr; next; next = next->next) { 1711 for (next = wr; next; next = next->next) {
1546 ++resp.bad_wr; 1712 ++resp.bad_wr;
@@ -1554,8 +1720,6 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
1554 ret = -EFAULT; 1720 ret = -EFAULT;
1555 1721
1556out: 1722out:
1557 mutex_unlock(&ib_uverbs_idr_mutex);
1558
1559 while (wr) { 1723 while (wr) {
1560 next = wr->next; 1724 next = wr->next;
1561 kfree(wr); 1725 kfree(wr);
@@ -1587,17 +1751,15 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
1587 if (!uobj) 1751 if (!uobj)
1588 return -ENOMEM; 1752 return -ENOMEM;
1589 1753
1590 mutex_lock(&ib_uverbs_idr_mutex); 1754 init_uobj(uobj, cmd.user_handle, file->ucontext);
1755 down_write(&uobj->mutex);
1591 1756
1592 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); 1757 pd = idr_read_pd(cmd.pd_handle, file->ucontext);
1593 if (!pd || pd->uobject->context != file->ucontext) { 1758 if (!pd) {
1594 ret = -EINVAL; 1759 ret = -EINVAL;
1595 goto err_up; 1760 goto err;
1596 } 1761 }
1597 1762
1598 uobj->user_handle = cmd.user_handle;
1599 uobj->context = file->ucontext;
1600
1601 attr.dlid = cmd.attr.dlid; 1763 attr.dlid = cmd.attr.dlid;
1602 attr.sl = cmd.attr.sl; 1764 attr.sl = cmd.attr.sl;
1603 attr.src_path_bits = cmd.attr.src_path_bits; 1765 attr.src_path_bits = cmd.attr.src_path_bits;
@@ -1613,21 +1775,13 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
1613 ah = ib_create_ah(pd, &attr); 1775 ah = ib_create_ah(pd, &attr);
1614 if (IS_ERR(ah)) { 1776 if (IS_ERR(ah)) {
1615 ret = PTR_ERR(ah); 1777 ret = PTR_ERR(ah);
1616 goto err_up; 1778 goto err;
1617 }
1618
1619 ah->uobject = uobj;
1620
1621retry:
1622 if (!idr_pre_get(&ib_uverbs_ah_idr, GFP_KERNEL)) {
1623 ret = -ENOMEM;
1624 goto err_destroy;
1625 } 1779 }
1626 1780
1627 ret = idr_get_new(&ib_uverbs_ah_idr, ah, &uobj->id); 1781 ah->uobject = uobj;
1782 uobj->object = ah;
1628 1783
1629 if (ret == -EAGAIN) 1784 ret = idr_add_uobj(&ib_uverbs_ah_idr, uobj);
1630 goto retry;
1631 if (ret) 1785 if (ret)
1632 goto err_destroy; 1786 goto err_destroy;
1633 1787
@@ -1636,27 +1790,29 @@ retry:
1636 if (copy_to_user((void __user *) (unsigned long) cmd.response, 1790 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1637 &resp, sizeof resp)) { 1791 &resp, sizeof resp)) {
1638 ret = -EFAULT; 1792 ret = -EFAULT;
1639 goto err_idr; 1793 goto err_copy;
1640 } 1794 }
1641 1795
1796 put_pd_read(pd);
1797
1642 mutex_lock(&file->mutex); 1798 mutex_lock(&file->mutex);
1643 list_add_tail(&uobj->list, &file->ucontext->ah_list); 1799 list_add_tail(&uobj->list, &file->ucontext->ah_list);
1644 mutex_unlock(&file->mutex); 1800 mutex_unlock(&file->mutex);
1645 1801
1646 mutex_unlock(&ib_uverbs_idr_mutex); 1802 uobj->live = 1;
1803
1804 up_write(&uobj->mutex);
1647 1805
1648 return in_len; 1806 return in_len;
1649 1807
1650err_idr: 1808err_copy:
1651 idr_remove(&ib_uverbs_ah_idr, uobj->id); 1809 idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
1652 1810
1653err_destroy: 1811err_destroy:
1654 ib_destroy_ah(ah); 1812 ib_destroy_ah(ah);
1655 1813
1656err_up: 1814err:
1657 mutex_unlock(&ib_uverbs_idr_mutex); 1815 put_uobj_write(uobj);
1658
1659 kfree(uobj);
1660 return ret; 1816 return ret;
1661} 1817}
1662 1818
@@ -1666,35 +1822,34 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
1666 struct ib_uverbs_destroy_ah cmd; 1822 struct ib_uverbs_destroy_ah cmd;
1667 struct ib_ah *ah; 1823 struct ib_ah *ah;
1668 struct ib_uobject *uobj; 1824 struct ib_uobject *uobj;
1669 int ret = -EINVAL; 1825 int ret;
1670 1826
1671 if (copy_from_user(&cmd, buf, sizeof cmd)) 1827 if (copy_from_user(&cmd, buf, sizeof cmd))
1672 return -EFAULT; 1828 return -EFAULT;
1673 1829
1674 mutex_lock(&ib_uverbs_idr_mutex); 1830 uobj = idr_write_uobj(&ib_uverbs_ah_idr, cmd.ah_handle, file->ucontext);
1831 if (!uobj)
1832 return -EINVAL;
1833 ah = uobj->object;
1675 1834
1676 ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle); 1835 ret = ib_destroy_ah(ah);
1677 if (!ah || ah->uobject->context != file->ucontext) 1836 if (!ret)
1678 goto out; 1837 uobj->live = 0;
1679 1838
1680 uobj = ah->uobject; 1839 put_uobj_write(uobj);
1681 1840
1682 ret = ib_destroy_ah(ah);
1683 if (ret) 1841 if (ret)
1684 goto out; 1842 return ret;
1685 1843
1686 idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle); 1844 idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
1687 1845
1688 mutex_lock(&file->mutex); 1846 mutex_lock(&file->mutex);
1689 list_del(&uobj->list); 1847 list_del(&uobj->list);
1690 mutex_unlock(&file->mutex); 1848 mutex_unlock(&file->mutex);
1691 1849
1692 kfree(uobj); 1850 put_uobj(uobj);
1693 1851
1694out: 1852 return in_len;
1695 mutex_unlock(&ib_uverbs_idr_mutex);
1696
1697 return ret ? ret : in_len;
1698} 1853}
1699 1854
1700ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, 1855ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
@@ -1703,47 +1858,43 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
1703{ 1858{
1704 struct ib_uverbs_attach_mcast cmd; 1859 struct ib_uverbs_attach_mcast cmd;
1705 struct ib_qp *qp; 1860 struct ib_qp *qp;
1706 struct ib_uqp_object *uobj; 1861 struct ib_uqp_object *obj;
1707 struct ib_uverbs_mcast_entry *mcast; 1862 struct ib_uverbs_mcast_entry *mcast;
1708 int ret = -EINVAL; 1863 int ret;
1709 1864
1710 if (copy_from_user(&cmd, buf, sizeof cmd)) 1865 if (copy_from_user(&cmd, buf, sizeof cmd))
1711 return -EFAULT; 1866 return -EFAULT;
1712 1867
1713 mutex_lock(&ib_uverbs_idr_mutex); 1868 qp = idr_read_qp(cmd.qp_handle, file->ucontext);
1714 1869 if (!qp)
1715 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1870 return -EINVAL;
1716 if (!qp || qp->uobject->context != file->ucontext)
1717 goto out;
1718 1871
1719 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject); 1872 obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1720 1873
1721 list_for_each_entry(mcast, &uobj->mcast_list, list) 1874 list_for_each_entry(mcast, &obj->mcast_list, list)
1722 if (cmd.mlid == mcast->lid && 1875 if (cmd.mlid == mcast->lid &&
1723 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) { 1876 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
1724 ret = 0; 1877 ret = 0;
1725 goto out; 1878 goto out_put;
1726 } 1879 }
1727 1880
1728 mcast = kmalloc(sizeof *mcast, GFP_KERNEL); 1881 mcast = kmalloc(sizeof *mcast, GFP_KERNEL);
1729 if (!mcast) { 1882 if (!mcast) {
1730 ret = -ENOMEM; 1883 ret = -ENOMEM;
1731 goto out; 1884 goto out_put;
1732 } 1885 }
1733 1886
1734 mcast->lid = cmd.mlid; 1887 mcast->lid = cmd.mlid;
1735 memcpy(mcast->gid.raw, cmd.gid, sizeof mcast->gid.raw); 1888 memcpy(mcast->gid.raw, cmd.gid, sizeof mcast->gid.raw);
1736 1889
1737 ret = ib_attach_mcast(qp, &mcast->gid, cmd.mlid); 1890 ret = ib_attach_mcast(qp, &mcast->gid, cmd.mlid);
1738 if (!ret) { 1891 if (!ret)
1739 uobj = container_of(qp->uobject, struct ib_uqp_object, 1892 list_add_tail(&mcast->list, &obj->mcast_list);
1740 uevent.uobject); 1893 else
1741 list_add_tail(&mcast->list, &uobj->mcast_list);
1742 } else
1743 kfree(mcast); 1894 kfree(mcast);
1744 1895
1745out: 1896out_put:
1746 mutex_unlock(&ib_uverbs_idr_mutex); 1897 put_qp_read(qp);
1747 1898
1748 return ret ? ret : in_len; 1899 return ret ? ret : in_len;
1749} 1900}
@@ -1753,7 +1904,7 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1753 int out_len) 1904 int out_len)
1754{ 1905{
1755 struct ib_uverbs_detach_mcast cmd; 1906 struct ib_uverbs_detach_mcast cmd;
1756 struct ib_uqp_object *uobj; 1907 struct ib_uqp_object *obj;
1757 struct ib_qp *qp; 1908 struct ib_qp *qp;
1758 struct ib_uverbs_mcast_entry *mcast; 1909 struct ib_uverbs_mcast_entry *mcast;
1759 int ret = -EINVAL; 1910 int ret = -EINVAL;
@@ -1761,19 +1912,17 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1761 if (copy_from_user(&cmd, buf, sizeof cmd)) 1912 if (copy_from_user(&cmd, buf, sizeof cmd))
1762 return -EFAULT; 1913 return -EFAULT;
1763 1914
1764 mutex_lock(&ib_uverbs_idr_mutex); 1915 qp = idr_read_qp(cmd.qp_handle, file->ucontext);
1765 1916 if (!qp)
1766 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1917 return -EINVAL;
1767 if (!qp || qp->uobject->context != file->ucontext)
1768 goto out;
1769 1918
1770 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid); 1919 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
1771 if (ret) 1920 if (ret)
1772 goto out; 1921 goto out_put;
1773 1922
1774 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject); 1923 obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1775 1924
1776 list_for_each_entry(mcast, &uobj->mcast_list, list) 1925 list_for_each_entry(mcast, &obj->mcast_list, list)
1777 if (cmd.mlid == mcast->lid && 1926 if (cmd.mlid == mcast->lid &&
1778 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) { 1927 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
1779 list_del(&mcast->list); 1928 list_del(&mcast->list);
@@ -1781,8 +1930,8 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1781 break; 1930 break;
1782 } 1931 }
1783 1932
1784out: 1933out_put:
1785 mutex_unlock(&ib_uverbs_idr_mutex); 1934 put_qp_read(qp);
1786 1935
1787 return ret ? ret : in_len; 1936 return ret ? ret : in_len;
1788} 1937}
@@ -1794,7 +1943,7 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
1794 struct ib_uverbs_create_srq cmd; 1943 struct ib_uverbs_create_srq cmd;
1795 struct ib_uverbs_create_srq_resp resp; 1944 struct ib_uverbs_create_srq_resp resp;
1796 struct ib_udata udata; 1945 struct ib_udata udata;
1797 struct ib_uevent_object *uobj; 1946 struct ib_uevent_object *obj;
1798 struct ib_pd *pd; 1947 struct ib_pd *pd;
1799 struct ib_srq *srq; 1948 struct ib_srq *srq;
1800 struct ib_srq_init_attr attr; 1949 struct ib_srq_init_attr attr;
@@ -1810,17 +1959,17 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
1810 (unsigned long) cmd.response + sizeof resp, 1959 (unsigned long) cmd.response + sizeof resp,
1811 in_len - sizeof cmd, out_len - sizeof resp); 1960 in_len - sizeof cmd, out_len - sizeof resp);
1812 1961
1813 uobj = kmalloc(sizeof *uobj, GFP_KERNEL); 1962 obj = kmalloc(sizeof *obj, GFP_KERNEL);
1814 if (!uobj) 1963 if (!obj)
1815 return -ENOMEM; 1964 return -ENOMEM;
1816 1965
1817 mutex_lock(&ib_uverbs_idr_mutex); 1966 init_uobj(&obj->uobject, 0, file->ucontext);
1967 down_write(&obj->uobject.mutex);
1818 1968
1819 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); 1969 pd = idr_read_pd(cmd.pd_handle, file->ucontext);
1820 1970 if (!pd) {
1821 if (!pd || pd->uobject->context != file->ucontext) {
1822 ret = -EINVAL; 1971 ret = -EINVAL;
1823 goto err_up; 1972 goto err;
1824 } 1973 }
1825 1974
1826 attr.event_handler = ib_uverbs_srq_event_handler; 1975 attr.event_handler = ib_uverbs_srq_event_handler;
@@ -1829,69 +1978,59 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
1829 attr.attr.max_sge = cmd.max_sge; 1978 attr.attr.max_sge = cmd.max_sge;
1830 attr.attr.srq_limit = cmd.srq_limit; 1979 attr.attr.srq_limit = cmd.srq_limit;
1831 1980
1832 uobj->uobject.user_handle = cmd.user_handle; 1981 obj->events_reported = 0;
1833 uobj->uobject.context = file->ucontext; 1982 INIT_LIST_HEAD(&obj->event_list);
1834 uobj->events_reported = 0;
1835 INIT_LIST_HEAD(&uobj->event_list);
1836 1983
1837 srq = pd->device->create_srq(pd, &attr, &udata); 1984 srq = pd->device->create_srq(pd, &attr, &udata);
1838 if (IS_ERR(srq)) { 1985 if (IS_ERR(srq)) {
1839 ret = PTR_ERR(srq); 1986 ret = PTR_ERR(srq);
1840 goto err_up; 1987 goto err;
1841 } 1988 }
1842 1989
1843 srq->device = pd->device; 1990 srq->device = pd->device;
1844 srq->pd = pd; 1991 srq->pd = pd;
1845 srq->uobject = &uobj->uobject; 1992 srq->uobject = &obj->uobject;
1846 srq->event_handler = attr.event_handler; 1993 srq->event_handler = attr.event_handler;
1847 srq->srq_context = attr.srq_context; 1994 srq->srq_context = attr.srq_context;
1848 atomic_inc(&pd->usecnt); 1995 atomic_inc(&pd->usecnt);
1849 atomic_set(&srq->usecnt, 0); 1996 atomic_set(&srq->usecnt, 0);
1850 1997
1851 memset(&resp, 0, sizeof resp); 1998 obj->uobject.object = srq;
1852 1999 ret = idr_add_uobj(&ib_uverbs_srq_idr, &obj->uobject);
1853retry:
1854 if (!idr_pre_get(&ib_uverbs_srq_idr, GFP_KERNEL)) {
1855 ret = -ENOMEM;
1856 goto err_destroy;
1857 }
1858
1859 ret = idr_get_new(&ib_uverbs_srq_idr, srq, &uobj->uobject.id);
1860
1861 if (ret == -EAGAIN)
1862 goto retry;
1863 if (ret) 2000 if (ret)
1864 goto err_destroy; 2001 goto err_destroy;
1865 2002
1866 resp.srq_handle = uobj->uobject.id; 2003 memset(&resp, 0, sizeof resp);
2004 resp.srq_handle = obj->uobject.id;
1867 resp.max_wr = attr.attr.max_wr; 2005 resp.max_wr = attr.attr.max_wr;
1868 resp.max_sge = attr.attr.max_sge; 2006 resp.max_sge = attr.attr.max_sge;
1869 2007
1870 if (copy_to_user((void __user *) (unsigned long) cmd.response, 2008 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1871 &resp, sizeof resp)) { 2009 &resp, sizeof resp)) {
1872 ret = -EFAULT; 2010 ret = -EFAULT;
1873 goto err_idr; 2011 goto err_copy;
1874 } 2012 }
1875 2013
2014 put_pd_read(pd);
2015
1876 mutex_lock(&file->mutex); 2016 mutex_lock(&file->mutex);
1877 list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); 2017 list_add_tail(&obj->uobject.list, &file->ucontext->srq_list);
1878 mutex_unlock(&file->mutex); 2018 mutex_unlock(&file->mutex);
1879 2019
1880 mutex_unlock(&ib_uverbs_idr_mutex); 2020 obj->uobject.live = 1;
2021
2022 up_write(&obj->uobject.mutex);
1881 2023
1882 return in_len; 2024 return in_len;
1883 2025
1884err_idr: 2026err_copy:
1885 idr_remove(&ib_uverbs_srq_idr, uobj->uobject.id); 2027 idr_remove_uobj(&ib_uverbs_srq_idr, &obj->uobject);
1886 2028
1887err_destroy: 2029err_destroy:
1888 ib_destroy_srq(srq); 2030 ib_destroy_srq(srq);
1889 atomic_dec(&pd->usecnt);
1890
1891err_up:
1892 mutex_unlock(&ib_uverbs_idr_mutex);
1893 2031
1894 kfree(uobj); 2032err:
2033 put_uobj_write(&obj->uobject);
1895 return ret; 2034 return ret;
1896} 2035}
1897 2036
@@ -1907,21 +2046,16 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
1907 if (copy_from_user(&cmd, buf, sizeof cmd)) 2046 if (copy_from_user(&cmd, buf, sizeof cmd))
1908 return -EFAULT; 2047 return -EFAULT;
1909 2048
1910 mutex_lock(&ib_uverbs_idr_mutex); 2049 srq = idr_read_srq(cmd.srq_handle, file->ucontext);
1911 2050 if (!srq)
1912 srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); 2051 return -EINVAL;
1913 if (!srq || srq->uobject->context != file->ucontext) {
1914 ret = -EINVAL;
1915 goto out;
1916 }
1917 2052
1918 attr.max_wr = cmd.max_wr; 2053 attr.max_wr = cmd.max_wr;
1919 attr.srq_limit = cmd.srq_limit; 2054 attr.srq_limit = cmd.srq_limit;
1920 2055
1921 ret = ib_modify_srq(srq, &attr, cmd.attr_mask); 2056 ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
1922 2057
1923out: 2058 put_srq_read(srq);
1924 mutex_unlock(&ib_uverbs_idr_mutex);
1925 2059
1926 return ret ? ret : in_len; 2060 return ret ? ret : in_len;
1927} 2061}
@@ -1942,18 +2076,16 @@ ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
1942 if (copy_from_user(&cmd, buf, sizeof cmd)) 2076 if (copy_from_user(&cmd, buf, sizeof cmd))
1943 return -EFAULT; 2077 return -EFAULT;
1944 2078
1945 mutex_lock(&ib_uverbs_idr_mutex); 2079 srq = idr_read_srq(cmd.srq_handle, file->ucontext);
2080 if (!srq)
2081 return -EINVAL;
1946 2082
1947 srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); 2083 ret = ib_query_srq(srq, &attr);
1948 if (srq && srq->uobject->context == file->ucontext)
1949 ret = ib_query_srq(srq, &attr);
1950 else
1951 ret = -EINVAL;
1952 2084
1953 mutex_unlock(&ib_uverbs_idr_mutex); 2085 put_srq_read(srq);
1954 2086
1955 if (ret) 2087 if (ret)
1956 goto out; 2088 return ret;
1957 2089
1958 memset(&resp, 0, sizeof resp); 2090 memset(&resp, 0, sizeof resp);
1959 2091
@@ -1963,10 +2095,9 @@ ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
1963 2095
1964 if (copy_to_user((void __user *) (unsigned long) cmd.response, 2096 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1965 &resp, sizeof resp)) 2097 &resp, sizeof resp))
1966 ret = -EFAULT; 2098 return -EFAULT;
1967 2099
1968out: 2100 return in_len;
1969 return ret ? ret : in_len;
1970} 2101}
1971 2102
1972ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, 2103ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
@@ -1975,45 +2106,45 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
1975{ 2106{
1976 struct ib_uverbs_destroy_srq cmd; 2107 struct ib_uverbs_destroy_srq cmd;
1977 struct ib_uverbs_destroy_srq_resp resp; 2108 struct ib_uverbs_destroy_srq_resp resp;
2109 struct ib_uobject *uobj;
1978 struct ib_srq *srq; 2110 struct ib_srq *srq;
1979 struct ib_uevent_object *uobj; 2111 struct ib_uevent_object *obj;
1980 int ret = -EINVAL; 2112 int ret = -EINVAL;
1981 2113
1982 if (copy_from_user(&cmd, buf, sizeof cmd)) 2114 if (copy_from_user(&cmd, buf, sizeof cmd))
1983 return -EFAULT; 2115 return -EFAULT;
1984 2116
1985 mutex_lock(&ib_uverbs_idr_mutex); 2117 uobj = idr_write_uobj(&ib_uverbs_srq_idr, cmd.srq_handle, file->ucontext);
1986 2118 if (!uobj)
1987 memset(&resp, 0, sizeof resp); 2119 return -EINVAL;
2120 srq = uobj->object;
2121 obj = container_of(uobj, struct ib_uevent_object, uobject);
1988 2122
1989 srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle); 2123 ret = ib_destroy_srq(srq);
1990 if (!srq || srq->uobject->context != file->ucontext) 2124 if (!ret)
1991 goto out; 2125 uobj->live = 0;
1992 2126
1993 uobj = container_of(srq->uobject, struct ib_uevent_object, uobject); 2127 put_uobj_write(uobj);
1994 2128
1995 ret = ib_destroy_srq(srq);
1996 if (ret) 2129 if (ret)
1997 goto out; 2130 return ret;
1998 2131
1999 idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); 2132 idr_remove_uobj(&ib_uverbs_srq_idr, uobj);
2000 2133
2001 mutex_lock(&file->mutex); 2134 mutex_lock(&file->mutex);
2002 list_del(&uobj->uobject.list); 2135 list_del(&uobj->list);
2003 mutex_unlock(&file->mutex); 2136 mutex_unlock(&file->mutex);
2004 2137
2005 ib_uverbs_release_uevent(file, uobj); 2138 ib_uverbs_release_uevent(file, obj);
2006 2139
2007 resp.events_reported = uobj->events_reported; 2140 memset(&resp, 0, sizeof resp);
2141 resp.events_reported = obj->events_reported;
2008 2142
2009 kfree(uobj); 2143 put_uobj(uobj);
2010 2144
2011 if (copy_to_user((void __user *) (unsigned long) cmd.response, 2145 if (copy_to_user((void __user *) (unsigned long) cmd.response,
2012 &resp, sizeof resp)) 2146 &resp, sizeof resp))
2013 ret = -EFAULT; 2147 ret = -EFAULT;
2014 2148
2015out:
2016 mutex_unlock(&ib_uverbs_idr_mutex);
2017
2018 return ret ? ret : in_len; 2149 return ret ? ret : in_len;
2019} 2150}
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index ff092a0a94da..5ec2d49e9bb6 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -66,7 +66,7 @@ enum {
66 66
67static struct class *uverbs_class; 67static struct class *uverbs_class;
68 68
69DEFINE_MUTEX(ib_uverbs_idr_mutex); 69DEFINE_SPINLOCK(ib_uverbs_idr_lock);
70DEFINE_IDR(ib_uverbs_pd_idr); 70DEFINE_IDR(ib_uverbs_pd_idr);
71DEFINE_IDR(ib_uverbs_mr_idr); 71DEFINE_IDR(ib_uverbs_mr_idr);
72DEFINE_IDR(ib_uverbs_mw_idr); 72DEFINE_IDR(ib_uverbs_mw_idr);
@@ -183,21 +183,21 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
183 if (!context) 183 if (!context)
184 return 0; 184 return 0;
185 185
186 mutex_lock(&ib_uverbs_idr_mutex);
187
188 list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) { 186 list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) {
189 struct ib_ah *ah = idr_find(&ib_uverbs_ah_idr, uobj->id); 187 struct ib_ah *ah = uobj->object;
190 idr_remove(&ib_uverbs_ah_idr, uobj->id); 188
189 idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
191 ib_destroy_ah(ah); 190 ib_destroy_ah(ah);
192 list_del(&uobj->list); 191 list_del(&uobj->list);
193 kfree(uobj); 192 kfree(uobj);
194 } 193 }
195 194
196 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) { 195 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
197 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id); 196 struct ib_qp *qp = uobj->object;
198 struct ib_uqp_object *uqp = 197 struct ib_uqp_object *uqp =
199 container_of(uobj, struct ib_uqp_object, uevent.uobject); 198 container_of(uobj, struct ib_uqp_object, uevent.uobject);
200 idr_remove(&ib_uverbs_qp_idr, uobj->id); 199
200 idr_remove_uobj(&ib_uverbs_qp_idr, uobj);
201 ib_uverbs_detach_umcast(qp, uqp); 201 ib_uverbs_detach_umcast(qp, uqp);
202 ib_destroy_qp(qp); 202 ib_destroy_qp(qp);
203 list_del(&uobj->list); 203 list_del(&uobj->list);
@@ -206,11 +206,12 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
206 } 206 }
207 207
208 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) { 208 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
209 struct ib_cq *cq = idr_find(&ib_uverbs_cq_idr, uobj->id); 209 struct ib_cq *cq = uobj->object;
210 struct ib_uverbs_event_file *ev_file = cq->cq_context; 210 struct ib_uverbs_event_file *ev_file = cq->cq_context;
211 struct ib_ucq_object *ucq = 211 struct ib_ucq_object *ucq =
212 container_of(uobj, struct ib_ucq_object, uobject); 212 container_of(uobj, struct ib_ucq_object, uobject);
213 idr_remove(&ib_uverbs_cq_idr, uobj->id); 213
214 idr_remove_uobj(&ib_uverbs_cq_idr, uobj);
214 ib_destroy_cq(cq); 215 ib_destroy_cq(cq);
215 list_del(&uobj->list); 216 list_del(&uobj->list);
216 ib_uverbs_release_ucq(file, ev_file, ucq); 217 ib_uverbs_release_ucq(file, ev_file, ucq);
@@ -218,10 +219,11 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
218 } 219 }
219 220
220 list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) { 221 list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) {
221 struct ib_srq *srq = idr_find(&ib_uverbs_srq_idr, uobj->id); 222 struct ib_srq *srq = uobj->object;
222 struct ib_uevent_object *uevent = 223 struct ib_uevent_object *uevent =
223 container_of(uobj, struct ib_uevent_object, uobject); 224 container_of(uobj, struct ib_uevent_object, uobject);
224 idr_remove(&ib_uverbs_srq_idr, uobj->id); 225
226 idr_remove_uobj(&ib_uverbs_srq_idr, uobj);
225 ib_destroy_srq(srq); 227 ib_destroy_srq(srq);
226 list_del(&uobj->list); 228 list_del(&uobj->list);
227 ib_uverbs_release_uevent(file, uevent); 229 ib_uverbs_release_uevent(file, uevent);
@@ -231,11 +233,11 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
231 /* XXX Free MWs */ 233 /* XXX Free MWs */
232 234
233 list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) { 235 list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
234 struct ib_mr *mr = idr_find(&ib_uverbs_mr_idr, uobj->id); 236 struct ib_mr *mr = uobj->object;
235 struct ib_device *mrdev = mr->device; 237 struct ib_device *mrdev = mr->device;
236 struct ib_umem_object *memobj; 238 struct ib_umem_object *memobj;
237 239
238 idr_remove(&ib_uverbs_mr_idr, uobj->id); 240 idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
239 ib_dereg_mr(mr); 241 ib_dereg_mr(mr);
240 242
241 memobj = container_of(uobj, struct ib_umem_object, uobject); 243 memobj = container_of(uobj, struct ib_umem_object, uobject);
@@ -246,15 +248,14 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
246 } 248 }
247 249
248 list_for_each_entry_safe(uobj, tmp, &context->pd_list, list) { 250 list_for_each_entry_safe(uobj, tmp, &context->pd_list, list) {
249 struct ib_pd *pd = idr_find(&ib_uverbs_pd_idr, uobj->id); 251 struct ib_pd *pd = uobj->object;
250 idr_remove(&ib_uverbs_pd_idr, uobj->id); 252
253 idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
251 ib_dealloc_pd(pd); 254 ib_dealloc_pd(pd);
252 list_del(&uobj->list); 255 list_del(&uobj->list);
253 kfree(uobj); 256 kfree(uobj);
254 } 257 }
255 258
256 mutex_unlock(&ib_uverbs_idr_mutex);
257
258 return context->device->dealloc_ucontext(context); 259 return context->device->dealloc_ucontext(context);
259} 260}
260 261
diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
new file mode 100644
index 000000000000..ce46b13ae02b
--- /dev/null
+++ b/drivers/infiniband/core/uverbs_marshall.c
@@ -0,0 +1,138 @@
1/*
2 * Copyright (c) 2005 Intel Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#include <rdma/ib_marshall.h>
34
35static void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
36 struct ib_ah_attr *src)
37{
38 memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);
39 dst->grh.flow_label = src->grh.flow_label;
40 dst->grh.sgid_index = src->grh.sgid_index;
41 dst->grh.hop_limit = src->grh.hop_limit;
42 dst->grh.traffic_class = src->grh.traffic_class;
43 dst->dlid = src->dlid;
44 dst->sl = src->sl;
45 dst->src_path_bits = src->src_path_bits;
46 dst->static_rate = src->static_rate;
47 dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;
48 dst->port_num = src->port_num;
49}
50
51void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
52 struct ib_qp_attr *src)
53{
54 dst->cur_qp_state = src->cur_qp_state;
55 dst->path_mtu = src->path_mtu;
56 dst->path_mig_state = src->path_mig_state;
57 dst->qkey = src->qkey;
58 dst->rq_psn = src->rq_psn;
59 dst->sq_psn = src->sq_psn;
60 dst->dest_qp_num = src->dest_qp_num;
61 dst->qp_access_flags = src->qp_access_flags;
62
63 dst->max_send_wr = src->cap.max_send_wr;
64 dst->max_recv_wr = src->cap.max_recv_wr;
65 dst->max_send_sge = src->cap.max_send_sge;
66 dst->max_recv_sge = src->cap.max_recv_sge;
67 dst->max_inline_data = src->cap.max_inline_data;
68
69 ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
70 ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);
71
72 dst->pkey_index = src->pkey_index;
73 dst->alt_pkey_index = src->alt_pkey_index;
74 dst->en_sqd_async_notify = src->en_sqd_async_notify;
75 dst->sq_draining = src->sq_draining;
76 dst->max_rd_atomic = src->max_rd_atomic;
77 dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
78 dst->min_rnr_timer = src->min_rnr_timer;
79 dst->port_num = src->port_num;
80 dst->timeout = src->timeout;
81 dst->retry_cnt = src->retry_cnt;
82 dst->rnr_retry = src->rnr_retry;
83 dst->alt_port_num = src->alt_port_num;
84 dst->alt_timeout = src->alt_timeout;
85}
86EXPORT_SYMBOL(ib_copy_qp_attr_to_user);
87
88void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
89 struct ib_sa_path_rec *src)
90{
91 memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
92 memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
93
94 dst->dlid = src->dlid;
95 dst->slid = src->slid;
96 dst->raw_traffic = src->raw_traffic;
97 dst->flow_label = src->flow_label;
98 dst->hop_limit = src->hop_limit;
99 dst->traffic_class = src->traffic_class;
100 dst->reversible = src->reversible;
101 dst->numb_path = src->numb_path;
102 dst->pkey = src->pkey;
103 dst->sl = src->sl;
104 dst->mtu_selector = src->mtu_selector;
105 dst->mtu = src->mtu;
106 dst->rate_selector = src->rate_selector;
107 dst->rate = src->rate;
108 dst->packet_life_time = src->packet_life_time;
109 dst->preference = src->preference;
110 dst->packet_life_time_selector = src->packet_life_time_selector;
111}
112EXPORT_SYMBOL(ib_copy_path_rec_to_user);
113
114void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
115 struct ib_user_path_rec *src)
116{
117 memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
118 memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
119
120 dst->dlid = src->dlid;
121 dst->slid = src->slid;
122 dst->raw_traffic = src->raw_traffic;
123 dst->flow_label = src->flow_label;
124 dst->hop_limit = src->hop_limit;
125 dst->traffic_class = src->traffic_class;
126 dst->reversible = src->reversible;
127 dst->numb_path = src->numb_path;
128 dst->pkey = src->pkey;
129 dst->sl = src->sl;
130 dst->mtu_selector = src->mtu_selector;
131 dst->mtu = src->mtu;
132 dst->rate_selector = src->rate_selector;
133 dst->rate = src->rate;
134 dst->packet_life_time = src->packet_life_time;
135 dst->preference = src->preference;
136 dst->packet_life_time_selector = src->packet_life_time_selector;
137}
138EXPORT_SYMBOL(ib_copy_path_rec_from_user);
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index b78e7dc69330..468999c38803 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -125,35 +125,47 @@ struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
125} 125}
126EXPORT_SYMBOL(ib_create_ah); 126EXPORT_SYMBOL(ib_create_ah);
127 127
128struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, 128int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
129 struct ib_grh *grh, u8 port_num) 129 struct ib_grh *grh, struct ib_ah_attr *ah_attr)
130{ 130{
131 struct ib_ah_attr ah_attr;
132 u32 flow_class; 131 u32 flow_class;
133 u16 gid_index; 132 u16 gid_index;
134 int ret; 133 int ret;
135 134
136 memset(&ah_attr, 0, sizeof ah_attr); 135 memset(ah_attr, 0, sizeof *ah_attr);
137 ah_attr.dlid = wc->slid; 136 ah_attr->dlid = wc->slid;
138 ah_attr.sl = wc->sl; 137 ah_attr->sl = wc->sl;
139 ah_attr.src_path_bits = wc->dlid_path_bits; 138 ah_attr->src_path_bits = wc->dlid_path_bits;
140 ah_attr.port_num = port_num; 139 ah_attr->port_num = port_num;
141 140
142 if (wc->wc_flags & IB_WC_GRH) { 141 if (wc->wc_flags & IB_WC_GRH) {
143 ah_attr.ah_flags = IB_AH_GRH; 142 ah_attr->ah_flags = IB_AH_GRH;
144 ah_attr.grh.dgid = grh->sgid; 143 ah_attr->grh.dgid = grh->sgid;
145 144
146 ret = ib_find_cached_gid(pd->device, &grh->dgid, &port_num, 145 ret = ib_find_cached_gid(device, &grh->dgid, &port_num,
147 &gid_index); 146 &gid_index);
148 if (ret) 147 if (ret)
149 return ERR_PTR(ret); 148 return ret;
150 149
151 ah_attr.grh.sgid_index = (u8) gid_index; 150 ah_attr->grh.sgid_index = (u8) gid_index;
152 flow_class = be32_to_cpu(grh->version_tclass_flow); 151 flow_class = be32_to_cpu(grh->version_tclass_flow);
153 ah_attr.grh.flow_label = flow_class & 0xFFFFF; 152 ah_attr->grh.flow_label = flow_class & 0xFFFFF;
154 ah_attr.grh.traffic_class = (flow_class >> 20) & 0xFF; 153 ah_attr->grh.hop_limit = grh->hop_limit;
155 ah_attr.grh.hop_limit = grh->hop_limit; 154 ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF;
156 } 155 }
156 return 0;
157}
158EXPORT_SYMBOL(ib_init_ah_from_wc);
159
160struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
161 struct ib_grh *grh, u8 port_num)
162{
163 struct ib_ah_attr ah_attr;
164 int ret;
165
166 ret = ib_init_ah_from_wc(pd->device, port_num, wc, grh, &ah_attr);
167 if (ret)
168 return ERR_PTR(ret);
157 169
158 return ib_create_ah(pd, &ah_attr); 170 return ib_create_ah(pd, &ah_attr);
159} 171}
diff --git a/drivers/infiniband/hw/ipath/ipath_mad.c b/drivers/infiniband/hw/ipath/ipath_mad.c
index f7f8391fe43f..1a9d0a2c33c3 100644
--- a/drivers/infiniband/hw/ipath/ipath_mad.c
+++ b/drivers/infiniband/hw/ipath/ipath_mad.c
@@ -137,47 +137,11 @@ static int recv_subn_get_guidinfo(struct ib_smp *smp,
137 return reply(smp); 137 return reply(smp);
138} 138}
139 139
140struct port_info {
141 __be64 mkey;
142 __be64 gid_prefix;
143 __be16 lid;
144 __be16 sm_lid;
145 __be32 cap_mask;
146 __be16 diag_code;
147 __be16 mkey_lease_period;
148 u8 local_port_num;
149 u8 link_width_enabled;
150 u8 link_width_supported;
151 u8 link_width_active;
152 u8 linkspeed_portstate; /* 4 bits, 4 bits */
153 u8 portphysstate_linkdown; /* 4 bits, 4 bits */
154 u8 mkeyprot_resv_lmc; /* 2 bits, 3, 3 */
155 u8 linkspeedactive_enabled; /* 4 bits, 4 bits */
156 u8 neighbormtu_mastersmsl; /* 4 bits, 4 bits */
157 u8 vlcap_inittype; /* 4 bits, 4 bits */
158 u8 vl_high_limit;
159 u8 vl_arb_high_cap;
160 u8 vl_arb_low_cap;
161 u8 inittypereply_mtucap; /* 4 bits, 4 bits */
162 u8 vlstallcnt_hoqlife; /* 3 bits, 5 bits */
163 u8 operationalvl_pei_peo_fpi_fpo; /* 4 bits, 1, 1, 1, 1 */
164 __be16 mkey_violations;
165 __be16 pkey_violations;
166 __be16 qkey_violations;
167 u8 guid_cap;
168 u8 clientrereg_resv_subnetto; /* 1 bit, 2 bits, 5 */
169 u8 resv_resptimevalue; /* 3 bits, 5 bits */
170 u8 localphyerrors_overrunerrors; /* 4 bits, 4 bits */
171 __be16 max_credit_hint;
172 u8 resv;
173 u8 link_roundtrip_latency[3];
174} __attribute__ ((packed));
175
176static int recv_subn_get_portinfo(struct ib_smp *smp, 140static int recv_subn_get_portinfo(struct ib_smp *smp,
177 struct ib_device *ibdev, u8 port) 141 struct ib_device *ibdev, u8 port)
178{ 142{
179 struct ipath_ibdev *dev; 143 struct ipath_ibdev *dev;
180 struct port_info *pip = (struct port_info *)smp->data; 144 struct ib_port_info *pip = (struct ib_port_info *)smp->data;
181 u16 lid; 145 u16 lid;
182 u8 ibcstat; 146 u8 ibcstat;
183 u8 mtu; 147 u8 mtu;
@@ -312,7 +276,7 @@ static int recv_subn_set_guidinfo(struct ib_smp *smp,
312static int recv_subn_set_portinfo(struct ib_smp *smp, 276static int recv_subn_set_portinfo(struct ib_smp *smp,
313 struct ib_device *ibdev, u8 port) 277 struct ib_device *ibdev, u8 port)
314{ 278{
315 struct port_info *pip = (struct port_info *)smp->data; 279 struct ib_port_info *pip = (struct ib_port_info *)smp->data;
316 struct ib_event event; 280 struct ib_event event;
317 struct ipath_ibdev *dev; 281 struct ipath_ibdev *dev;
318 u32 flags; 282 u32 flags;
@@ -445,7 +409,7 @@ static int recv_subn_set_portinfo(struct ib_smp *smp,
445 409
446 if (pip->clientrereg_resv_subnetto & 0x80) { 410 if (pip->clientrereg_resv_subnetto & 0x80) {
447 clientrereg = 1; 411 clientrereg = 1;
448 event.event = IB_EVENT_LID_CHANGE; 412 event.event = IB_EVENT_CLIENT_REREGISTER;
449 ib_dispatch_event(&event); 413 ib_dispatch_event(&event);
450 } 414 }
451 415
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 798e13e14faf..d0f7731802c9 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -174,7 +174,6 @@ enum {
174 174
175struct mthca_cmd_context { 175struct mthca_cmd_context {
176 struct completion done; 176 struct completion done;
177 struct timer_list timer;
178 int result; 177 int result;
179 int next; 178 int next;
180 u64 out_param; 179 u64 out_param;
@@ -362,15 +361,6 @@ void mthca_cmd_event(struct mthca_dev *dev,
362 complete(&context->done); 361 complete(&context->done);
363} 362}
364 363
365static void event_timeout(unsigned long context_ptr)
366{
367 struct mthca_cmd_context *context =
368 (struct mthca_cmd_context *) context_ptr;
369
370 context->result = -EBUSY;
371 complete(&context->done);
372}
373
374static int mthca_cmd_wait(struct mthca_dev *dev, 364static int mthca_cmd_wait(struct mthca_dev *dev,
375 u64 in_param, 365 u64 in_param,
376 u64 *out_param, 366 u64 *out_param,
@@ -401,11 +391,10 @@ static int mthca_cmd_wait(struct mthca_dev *dev,
401 if (err) 391 if (err)
402 goto out; 392 goto out;
403 393
404 context->timer.expires = jiffies + timeout; 394 if (!wait_for_completion_timeout(&context->done, timeout)) {
405 add_timer(&context->timer); 395 err = -EBUSY;
406 396 goto out;
407 wait_for_completion(&context->done); 397 }
408 del_timer_sync(&context->timer);
409 398
410 err = context->result; 399 err = context->result;
411 if (err) 400 if (err)
@@ -535,10 +524,6 @@ int mthca_cmd_use_events(struct mthca_dev *dev)
535 for (i = 0; i < dev->cmd.max_cmds; ++i) { 524 for (i = 0; i < dev->cmd.max_cmds; ++i) {
536 dev->cmd.context[i].token = i; 525 dev->cmd.context[i].token = i;
537 dev->cmd.context[i].next = i + 1; 526 dev->cmd.context[i].next = i + 1;
538 init_timer(&dev->cmd.context[i].timer);
539 dev->cmd.context[i].timer.data =
540 (unsigned long) &dev->cmd.context[i];
541 dev->cmd.context[i].timer.function = event_timeout;
542 } 527 }
543 528
544 dev->cmd.context[dev->cmd.max_cmds - 1].next = -1; 529 dev->cmd.context[dev->cmd.max_cmds - 1].next = -1;
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 205854e9c662..3e27a084257e 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -540,8 +540,17 @@ static inline int mthca_poll_one(struct mthca_dev *dev,
540 entry->wr_id = srq->wrid[wqe_index]; 540 entry->wr_id = srq->wrid[wqe_index];
541 mthca_free_srq_wqe(srq, wqe); 541 mthca_free_srq_wqe(srq, wqe);
542 } else { 542 } else {
543 s32 wqe;
543 wq = &(*cur_qp)->rq; 544 wq = &(*cur_qp)->rq;
544 wqe_index = be32_to_cpu(cqe->wqe) >> wq->wqe_shift; 545 wqe = be32_to_cpu(cqe->wqe);
546 wqe_index = wqe >> wq->wqe_shift;
547 /*
548 * WQE addr == base - 1 might be reported in receive completion
549 * with error instead of (rq size - 1) by Sinai FW 1.0.800 and
550 * Arbel FW 5.1.400. This bug should be fixed in later FW revs.
551 */
552 if (unlikely(wqe_index < 0))
553 wqe_index = wq->max - 1;
545 entry->wr_id = (*cur_qp)->wrid[wqe_index]; 554 entry->wr_id = (*cur_qp)->wrid[wqe_index];
546 } 555 }
547 556
@@ -813,6 +822,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
813 spin_lock_init(&cq->lock); 822 spin_lock_init(&cq->lock);
814 cq->refcount = 1; 823 cq->refcount = 1;
815 init_waitqueue_head(&cq->wait); 824 init_waitqueue_head(&cq->wait);
825 mutex_init(&cq->mutex);
816 826
817 memset(cq_context, 0, sizeof *cq_context); 827 memset(cq_context, 0, sizeof *cq_context);
818 cq_context->flags = cpu_to_be32(MTHCA_CQ_STATUS_OK | 828 cq_context->flags = cpu_to_be32(MTHCA_CQ_STATUS_OK |
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 99f109c3815d..d536217e700e 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -695,10 +695,6 @@ static void mthca_unmap_reg(struct mthca_dev *dev, unsigned long offset,
695 695
696static int __devinit mthca_map_eq_regs(struct mthca_dev *dev) 696static int __devinit mthca_map_eq_regs(struct mthca_dev *dev)
697{ 697{
698 unsigned long mthca_base;
699
700 mthca_base = pci_resource_start(dev->pdev, 0);
701
702 if (mthca_is_memfree(dev)) { 698 if (mthca_is_memfree(dev)) {
703 /* 699 /*
704 * We assume that the EQ arm and EQ set CI registers 700 * We assume that the EQ arm and EQ set CI registers
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 4730863ece9a..d9bc030bcccc 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -114,14 +114,22 @@ static void smp_snoop(struct ib_device *ibdev,
114 mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) && 114 mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
115 mad->mad_hdr.method == IB_MGMT_METHOD_SET) { 115 mad->mad_hdr.method == IB_MGMT_METHOD_SET) {
116 if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) { 116 if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) {
117 struct ib_port_info *pinfo =
118 (struct ib_port_info *) ((struct ib_smp *) mad)->data;
119
117 mthca_update_rate(to_mdev(ibdev), port_num); 120 mthca_update_rate(to_mdev(ibdev), port_num);
118 update_sm_ah(to_mdev(ibdev), port_num, 121 update_sm_ah(to_mdev(ibdev), port_num,
119 be16_to_cpup((__be16 *) (mad->data + 58)), 122 be16_to_cpu(pinfo->lid),
120 (*(u8 *) (mad->data + 76)) & 0xf); 123 pinfo->neighbormtu_mastersmsl & 0xf);
121 124
122 event.device = ibdev; 125 event.device = ibdev;
123 event.event = IB_EVENT_LID_CHANGE;
124 event.element.port_num = port_num; 126 event.element.port_num = port_num;
127
128 if(pinfo->clientrereg_resv_subnetto & 0x80)
129 event.event = IB_EVENT_CLIENT_REREGISTER;
130 else
131 event.event = IB_EVENT_LID_CHANGE;
132
125 ib_dispatch_event(&event); 133 ib_dispatch_event(&event);
126 } 134 }
127 135
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index a2eae8a30167..230ae21db8fd 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -115,6 +115,16 @@ static int mthca_query_device(struct ib_device *ibdev,
115 props->max_mcast_qp_attach = MTHCA_QP_PER_MGM; 115 props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
116 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach * 116 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
117 props->max_mcast_grp; 117 props->max_mcast_grp;
118 /*
119 * If Sinai memory key optimization is being used, then only
120 * the 8-bit key portion will change. For other HCAs, the
121 * unused index bits will also be used for FMR remapping.
122 */
123 if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
124 props->max_map_per_fmr = 255;
125 else
126 props->max_map_per_fmr =
127 (1 << (32 - long_log2(mdev->limits.num_mpts))) - 1;
118 128
119 err = 0; 129 err = 0;
120 out: 130 out:
@@ -783,18 +793,24 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
783 if (entries < 1 || entries > dev->limits.max_cqes) 793 if (entries < 1 || entries > dev->limits.max_cqes)
784 return -EINVAL; 794 return -EINVAL;
785 795
796 mutex_lock(&cq->mutex);
797
786 entries = roundup_pow_of_two(entries + 1); 798 entries = roundup_pow_of_two(entries + 1);
787 if (entries == ibcq->cqe + 1) 799 if (entries == ibcq->cqe + 1) {
788 return 0; 800 ret = 0;
801 goto out;
802 }
789 803
790 if (cq->is_kernel) { 804 if (cq->is_kernel) {
791 ret = mthca_alloc_resize_buf(dev, cq, entries); 805 ret = mthca_alloc_resize_buf(dev, cq, entries);
792 if (ret) 806 if (ret)
793 return ret; 807 goto out;
794 lkey = cq->resize_buf->buf.mr.ibmr.lkey; 808 lkey = cq->resize_buf->buf.mr.ibmr.lkey;
795 } else { 809 } else {
796 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) 810 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
797 return -EFAULT; 811 ret = -EFAULT;
812 goto out;
813 }
798 lkey = ucmd.lkey; 814 lkey = ucmd.lkey;
799 } 815 }
800 816
@@ -811,7 +827,7 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
811 cq->resize_buf = NULL; 827 cq->resize_buf = NULL;
812 spin_unlock_irq(&cq->lock); 828 spin_unlock_irq(&cq->lock);
813 } 829 }
814 return ret; 830 goto out;
815 } 831 }
816 832
817 if (cq->is_kernel) { 833 if (cq->is_kernel) {
@@ -838,7 +854,10 @@ static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *uda
838 } else 854 } else
839 ibcq->cqe = entries - 1; 855 ibcq->cqe = entries - 1;
840 856
841 return 0; 857out:
858 mutex_unlock(&cq->mutex);
859
860 return ret;
842} 861}
843 862
844static int mthca_destroy_cq(struct ib_cq *cq) 863static int mthca_destroy_cq(struct ib_cq *cq)
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 179a8f610d0f..8de2887ba15c 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -214,6 +214,7 @@ struct mthca_cq {
214 int arm_sn; 214 int arm_sn;
215 215
216 wait_queue_head_t wait; 216 wait_queue_head_t wait;
217 struct mutex mutex;
217}; 218};
218 219
219struct mthca_srq { 220struct mthca_srq {
@@ -237,6 +238,7 @@ struct mthca_srq {
237 struct mthca_mr mr; 238 struct mthca_mr mr;
238 239
239 wait_queue_head_t wait; 240 wait_queue_head_t wait;
241 struct mutex mutex;
240}; 242};
241 243
242struct mthca_wq { 244struct mthca_wq {
@@ -278,6 +280,7 @@ struct mthca_qp {
278 union mthca_buf queue; 280 union mthca_buf queue;
279 281
280 wait_queue_head_t wait; 282 wait_queue_head_t wait;
283 struct mutex mutex;
281}; 284};
282 285
283struct mthca_sqp { 286struct mthca_sqp {
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 07c13be07a4a..16c387d8170c 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -534,7 +534,9 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
534 struct mthca_qp_context *qp_context; 534 struct mthca_qp_context *qp_context;
535 u32 sqd_event = 0; 535 u32 sqd_event = 0;
536 u8 status; 536 u8 status;
537 int err; 537 int err = -EINVAL;
538
539 mutex_lock(&qp->mutex);
538 540
539 if (attr_mask & IB_QP_CUR_STATE) { 541 if (attr_mask & IB_QP_CUR_STATE) {
540 cur_state = attr->cur_qp_state; 542 cur_state = attr->cur_qp_state;
@@ -553,39 +555,41 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
553 "%d->%d with attr 0x%08x\n", 555 "%d->%d with attr 0x%08x\n",
554 qp->transport, cur_state, new_state, 556 qp->transport, cur_state, new_state,
555 attr_mask); 557 attr_mask);
556 return -EINVAL; 558 goto out;
557 } 559 }
558 560
559 if ((attr_mask & IB_QP_PKEY_INDEX) && 561 if ((attr_mask & IB_QP_PKEY_INDEX) &&
560 attr->pkey_index >= dev->limits.pkey_table_len) { 562 attr->pkey_index >= dev->limits.pkey_table_len) {
561 mthca_dbg(dev, "P_Key index (%u) too large. max is %d\n", 563 mthca_dbg(dev, "P_Key index (%u) too large. max is %d\n",
562 attr->pkey_index, dev->limits.pkey_table_len-1); 564 attr->pkey_index, dev->limits.pkey_table_len-1);
563 return -EINVAL; 565 goto out;
564 } 566 }
565 567
566 if ((attr_mask & IB_QP_PORT) && 568 if ((attr_mask & IB_QP_PORT) &&
567 (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) { 569 (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) {
568 mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num); 570 mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num);
569 return -EINVAL; 571 goto out;
570 } 572 }
571 573
572 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC && 574 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
573 attr->max_rd_atomic > dev->limits.max_qp_init_rdma) { 575 attr->max_rd_atomic > dev->limits.max_qp_init_rdma) {
574 mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n", 576 mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n",
575 attr->max_rd_atomic, dev->limits.max_qp_init_rdma); 577 attr->max_rd_atomic, dev->limits.max_qp_init_rdma);
576 return -EINVAL; 578 goto out;
577 } 579 }
578 580
579 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC && 581 if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
580 attr->max_dest_rd_atomic > 1 << dev->qp_table.rdb_shift) { 582 attr->max_dest_rd_atomic > 1 << dev->qp_table.rdb_shift) {
581 mthca_dbg(dev, "Max rdma_atomic as responder %u too large (max %d)\n", 583 mthca_dbg(dev, "Max rdma_atomic as responder %u too large (max %d)\n",
582 attr->max_dest_rd_atomic, 1 << dev->qp_table.rdb_shift); 584 attr->max_dest_rd_atomic, 1 << dev->qp_table.rdb_shift);
583 return -EINVAL; 585 goto out;
584 } 586 }
585 587
586 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); 588 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
587 if (IS_ERR(mailbox)) 589 if (IS_ERR(mailbox)) {
588 return PTR_ERR(mailbox); 590 err = PTR_ERR(mailbox);
591 goto out;
592 }
589 qp_param = mailbox->buf; 593 qp_param = mailbox->buf;
590 qp_context = &qp_param->context; 594 qp_context = &qp_param->context;
591 memset(qp_param, 0, sizeof *qp_param); 595 memset(qp_param, 0, sizeof *qp_param);
@@ -618,7 +622,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
618 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) { 622 if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) {
619 mthca_dbg(dev, "path MTU (%u) is invalid\n", 623 mthca_dbg(dev, "path MTU (%u) is invalid\n",
620 attr->path_mtu); 624 attr->path_mtu);
621 return -EINVAL; 625 goto out_mailbox;
622 } 626 }
623 qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31; 627 qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31;
624 } 628 }
@@ -672,7 +676,7 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
672 if (attr_mask & IB_QP_AV) { 676 if (attr_mask & IB_QP_AV) {
673 if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path, 677 if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path,
674 attr_mask & IB_QP_PORT ? attr->port_num : qp->port)) 678 attr_mask & IB_QP_PORT ? attr->port_num : qp->port))
675 return -EINVAL; 679 goto out_mailbox;
676 680
677 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH); 681 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH);
678 } 682 }
@@ -686,18 +690,18 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
686 if (attr->alt_pkey_index >= dev->limits.pkey_table_len) { 690 if (attr->alt_pkey_index >= dev->limits.pkey_table_len) {
687 mthca_dbg(dev, "Alternate P_Key index (%u) too large. max is %d\n", 691 mthca_dbg(dev, "Alternate P_Key index (%u) too large. max is %d\n",
688 attr->alt_pkey_index, dev->limits.pkey_table_len-1); 692 attr->alt_pkey_index, dev->limits.pkey_table_len-1);
689 return -EINVAL; 693 goto out_mailbox;
690 } 694 }
691 695
692 if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) { 696 if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) {
693 mthca_dbg(dev, "Alternate port number (%u) is invalid\n", 697 mthca_dbg(dev, "Alternate port number (%u) is invalid\n",
694 attr->alt_port_num); 698 attr->alt_port_num);
695 return -EINVAL; 699 goto out_mailbox;
696 } 700 }
697 701
698 if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path, 702 if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path,
699 attr->alt_ah_attr.port_num)) 703 attr->alt_ah_attr.port_num))
700 return -EINVAL; 704 goto out_mailbox;
701 705
702 qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index | 706 qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index |
703 attr->alt_port_num << 24); 707 attr->alt_port_num << 24);
@@ -793,12 +797,12 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
793 err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0, 797 err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0,
794 mailbox, sqd_event, &status); 798 mailbox, sqd_event, &status);
795 if (err) 799 if (err)
796 goto out; 800 goto out_mailbox;
797 if (status) { 801 if (status) {
798 mthca_warn(dev, "modify QP %d->%d returned status %02x.\n", 802 mthca_warn(dev, "modify QP %d->%d returned status %02x.\n",
799 cur_state, new_state, status); 803 cur_state, new_state, status);
800 err = -EINVAL; 804 err = -EINVAL;
801 goto out; 805 goto out_mailbox;
802 } 806 }
803 807
804 qp->state = new_state; 808 qp->state = new_state;
@@ -853,8 +857,11 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
853 } 857 }
854 } 858 }
855 859
856out: 860out_mailbox:
857 mthca_free_mailbox(dev, mailbox); 861 mthca_free_mailbox(dev, mailbox);
862
863out:
864 mutex_unlock(&qp->mutex);
858 return err; 865 return err;
859} 866}
860 867
@@ -1100,6 +1107,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev,
1100 1107
1101 qp->refcount = 1; 1108 qp->refcount = 1;
1102 init_waitqueue_head(&qp->wait); 1109 init_waitqueue_head(&qp->wait);
1110 mutex_init(&qp->mutex);
1103 qp->state = IB_QPS_RESET; 1111 qp->state = IB_QPS_RESET;
1104 qp->atomic_rd_en = 0; 1112 qp->atomic_rd_en = 0;
1105 qp->resp_depth = 0; 1113 qp->resp_depth = 0;
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
index df5e494a9d38..f4fddd5327f5 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -49,6 +49,12 @@ int mthca_reset(struct mthca_dev *mdev)
49 u32 *hca_header = NULL; 49 u32 *hca_header = NULL;
50 u32 *bridge_header = NULL; 50 u32 *bridge_header = NULL;
51 struct pci_dev *bridge = NULL; 51 struct pci_dev *bridge = NULL;
52 int bridge_pcix_cap = 0;
53 int hca_pcie_cap = 0;
54 int hca_pcix_cap = 0;
55
56 u16 devctl;
57 u16 linkctl;
52 58
53#define MTHCA_RESET_OFFSET 0xf0010 59#define MTHCA_RESET_OFFSET 0xf0010
54#define MTHCA_RESET_VALUE swab32(1) 60#define MTHCA_RESET_VALUE swab32(1)
@@ -110,6 +116,9 @@ int mthca_reset(struct mthca_dev *mdev)
110 } 116 }
111 } 117 }
112 118
119 hca_pcix_cap = pci_find_capability(mdev->pdev, PCI_CAP_ID_PCIX);
120 hca_pcie_cap = pci_find_capability(mdev->pdev, PCI_CAP_ID_EXP);
121
113 if (bridge) { 122 if (bridge) {
114 bridge_header = kmalloc(256, GFP_KERNEL); 123 bridge_header = kmalloc(256, GFP_KERNEL);
115 if (!bridge_header) { 124 if (!bridge_header) {
@@ -129,6 +138,13 @@ int mthca_reset(struct mthca_dev *mdev)
129 goto out; 138 goto out;
130 } 139 }
131 } 140 }
141 bridge_pcix_cap = pci_find_capability(bridge, PCI_CAP_ID_PCIX);
142 if (!bridge_pcix_cap) {
143 err = -ENODEV;
144 mthca_err(mdev, "Couldn't locate HCA bridge "
145 "PCI-X capability, aborting.\n");
146 goto out;
147 }
132 } 148 }
133 149
134 /* actually hit reset */ 150 /* actually hit reset */
@@ -178,6 +194,20 @@ int mthca_reset(struct mthca_dev *mdev)
178good: 194good:
179 /* Now restore the PCI headers */ 195 /* Now restore the PCI headers */
180 if (bridge) { 196 if (bridge) {
197 if (pci_write_config_dword(bridge, bridge_pcix_cap + 0x8,
198 bridge_header[(bridge_pcix_cap + 0x8) / 4])) {
199 err = -ENODEV;
200 mthca_err(mdev, "Couldn't restore HCA bridge Upstream "
201 "split transaction control, aborting.\n");
202 goto out;
203 }
204 if (pci_write_config_dword(bridge, bridge_pcix_cap + 0xc,
205 bridge_header[(bridge_pcix_cap + 0xc) / 4])) {
206 err = -ENODEV;
207 mthca_err(mdev, "Couldn't restore HCA bridge Downstream "
208 "split transaction control, aborting.\n");
209 goto out;
210 }
181 /* 211 /*
182 * Bridge control register is at 0x3e, so we'll 212 * Bridge control register is at 0x3e, so we'll
183 * naturally restore it last in this loop. 213 * naturally restore it last in this loop.
@@ -203,6 +233,35 @@ good:
203 } 233 }
204 } 234 }
205 235
236 if (hca_pcix_cap) {
237 if (pci_write_config_dword(mdev->pdev, hca_pcix_cap,
238 hca_header[hca_pcix_cap / 4])) {
239 err = -ENODEV;
240 mthca_err(mdev, "Couldn't restore HCA PCI-X "
241 "command register, aborting.\n");
242 goto out;
243 }
244 }
245
246 if (hca_pcie_cap) {
247 devctl = hca_header[(hca_pcie_cap + PCI_EXP_DEVCTL) / 4];
248 if (pci_write_config_word(mdev->pdev, hca_pcie_cap + PCI_EXP_DEVCTL,
249 devctl)) {
250 err = -ENODEV;
251 mthca_err(mdev, "Couldn't restore HCA PCI Express "
252 "Device Control register, aborting.\n");
253 goto out;
254 }
255 linkctl = hca_header[(hca_pcie_cap + PCI_EXP_LNKCTL) / 4];
256 if (pci_write_config_word(mdev->pdev, hca_pcie_cap + PCI_EXP_LNKCTL,
257 linkctl)) {
258 err = -ENODEV;
259 mthca_err(mdev, "Couldn't restore HCA PCI Express "
260 "Link control register, aborting.\n");
261 goto out;
262 }
263 }
264
206 for (i = 0; i < 16; ++i) { 265 for (i = 0; i < 16; ++i) {
207 if (i * 4 == PCI_COMMAND) 266 if (i * 4 == PCI_COMMAND)
208 continue; 267 continue;
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index b292fefa3b41..fab417c5cf43 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -243,6 +243,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
243 spin_lock_init(&srq->lock); 243 spin_lock_init(&srq->lock);
244 srq->refcount = 1; 244 srq->refcount = 1;
245 init_waitqueue_head(&srq->wait); 245 init_waitqueue_head(&srq->wait);
246 mutex_init(&srq->mutex);
246 247
247 if (mthca_is_memfree(dev)) 248 if (mthca_is_memfree(dev))
248 mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf); 249 mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf);
@@ -371,7 +372,11 @@ int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
371 if (attr_mask & IB_SRQ_LIMIT) { 372 if (attr_mask & IB_SRQ_LIMIT) {
372 if (attr->srq_limit > srq->max) 373 if (attr->srq_limit > srq->max)
373 return -EINVAL; 374 return -EINVAL;
375
376 mutex_lock(&srq->mutex);
374 ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status); 377 ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
378 mutex_unlock(&srq->mutex);
379
375 if (ret) 380 if (ret)
376 return ret; 381 return ret;
377 if (status) 382 if (status)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 12a1e0572ef2..491d2afaf5b4 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -272,8 +272,7 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
272void ipoib_dev_cleanup(struct net_device *dev); 272void ipoib_dev_cleanup(struct net_device *dev);
273 273
274void ipoib_mcast_join_task(void *dev_ptr); 274void ipoib_mcast_join_task(void *dev_ptr);
275void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid, 275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb);
276 struct sk_buff *skb);
277 276
278void ipoib_mcast_restart_task(void *dev_ptr); 277void ipoib_mcast_restart_task(void *dev_ptr);
279int ipoib_mcast_start_thread(struct net_device *dev); 278int ipoib_mcast_start_thread(struct net_device *dev);
@@ -369,15 +368,26 @@ extern int ipoib_debug_level;
369#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */ 368#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG_DATA */
370 369
371 370
372#define IPOIB_GID_FMT "%x:%x:%x:%x:%x:%x:%x:%x" 371#define IPOIB_GID_FMT "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:" \
373 372 "%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x:%2.2x%2.2x"
374#define IPOIB_GID_ARG(gid) be16_to_cpup((__be16 *) ((gid).raw + 0)), \ 373
375 be16_to_cpup((__be16 *) ((gid).raw + 2)), \ 374#define IPOIB_GID_RAW_ARG(gid) ((u8 *)(gid))[0], \
376 be16_to_cpup((__be16 *) ((gid).raw + 4)), \ 375 ((u8 *)(gid))[1], \
377 be16_to_cpup((__be16 *) ((gid).raw + 6)), \ 376 ((u8 *)(gid))[2], \
378 be16_to_cpup((__be16 *) ((gid).raw + 8)), \ 377 ((u8 *)(gid))[3], \
379 be16_to_cpup((__be16 *) ((gid).raw + 10)), \ 378 ((u8 *)(gid))[4], \
380 be16_to_cpup((__be16 *) ((gid).raw + 12)), \ 379 ((u8 *)(gid))[5], \
381 be16_to_cpup((__be16 *) ((gid).raw + 14)) 380 ((u8 *)(gid))[6], \
381 ((u8 *)(gid))[7], \
382 ((u8 *)(gid))[8], \
383 ((u8 *)(gid))[9], \
384 ((u8 *)(gid))[10],\
385 ((u8 *)(gid))[11],\
386 ((u8 *)(gid))[12],\
387 ((u8 *)(gid))[13],\
388 ((u8 *)(gid))[14],\
389 ((u8 *)(gid))[15]
390
391#define IPOIB_GID_ARG(gid) IPOIB_GID_RAW_ARG((gid).raw)
382 392
383#endif /* _IPOIB_H */ 393#endif /* _IPOIB_H */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 8406839b91cf..5033666b1481 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -84,15 +84,9 @@ void ipoib_free_ah(struct kref *kref)
84 84
85 unsigned long flags; 85 unsigned long flags;
86 86
87 if ((int) priv->tx_tail - (int) ah->last_send >= 0) { 87 spin_lock_irqsave(&priv->lock, flags);
88 ipoib_dbg(priv, "Freeing ah %p\n", ah->ah); 88 list_add_tail(&ah->list, &priv->dead_ahs);
89 ib_destroy_ah(ah->ah); 89 spin_unlock_irqrestore(&priv->lock, flags);
90 kfree(ah);
91 } else {
92 spin_lock_irqsave(&priv->lock, flags);
93 list_add_tail(&ah->list, &priv->dead_ahs);
94 spin_unlock_irqrestore(&priv->lock, flags);
95 }
96} 90}
97 91
98static int ipoib_ib_post_receive(struct net_device *dev, int id) 92static int ipoib_ib_post_receive(struct net_device *dev, int id)
@@ -377,19 +371,16 @@ static void __ipoib_reap_ah(struct net_device *dev)
377 struct ipoib_ah *ah, *tah; 371 struct ipoib_ah *ah, *tah;
378 LIST_HEAD(remove_list); 372 LIST_HEAD(remove_list);
379 373
380 spin_lock_irq(&priv->lock); 374 spin_lock_irq(&priv->tx_lock);
375 spin_lock(&priv->lock);
381 list_for_each_entry_safe(ah, tah, &priv->dead_ahs, list) 376 list_for_each_entry_safe(ah, tah, &priv->dead_ahs, list)
382 if ((int) priv->tx_tail - (int) ah->last_send >= 0) { 377 if ((int) priv->tx_tail - (int) ah->last_send >= 0) {
383 list_del(&ah->list); 378 list_del(&ah->list);
384 list_add_tail(&ah->list, &remove_list); 379 ib_destroy_ah(ah->ah);
380 kfree(ah);
385 } 381 }
386 spin_unlock_irq(&priv->lock); 382 spin_unlock(&priv->lock);
387 383 spin_unlock_irq(&priv->tx_lock);
388 list_for_each_entry_safe(ah, tah, &remove_list, list) {
389 ipoib_dbg(priv, "Reaping ah %p\n", ah->ah);
390 ib_destroy_ah(ah->ah);
391 kfree(ah);
392 }
393} 384}
394 385
395void ipoib_reap_ah(void *dev_ptr) 386void ipoib_reap_ah(void *dev_ptr)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index cb078a7d0bf5..1c6ea1c682a5 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -185,8 +185,7 @@ static int ipoib_change_mtu(struct net_device *dev, int new_mtu)
185 return 0; 185 return 0;
186} 186}
187 187
188static struct ipoib_path *__path_find(struct net_device *dev, 188static struct ipoib_path *__path_find(struct net_device *dev, void *gid)
189 union ib_gid *gid)
190{ 189{
191 struct ipoib_dev_priv *priv = netdev_priv(dev); 190 struct ipoib_dev_priv *priv = netdev_priv(dev);
192 struct rb_node *n = priv->path_tree.rb_node; 191 struct rb_node *n = priv->path_tree.rb_node;
@@ -196,7 +195,7 @@ static struct ipoib_path *__path_find(struct net_device *dev,
196 while (n) { 195 while (n) {
197 path = rb_entry(n, struct ipoib_path, rb_node); 196 path = rb_entry(n, struct ipoib_path, rb_node);
198 197
199 ret = memcmp(gid->raw, path->pathrec.dgid.raw, 198 ret = memcmp(gid, path->pathrec.dgid.raw,
200 sizeof (union ib_gid)); 199 sizeof (union ib_gid));
201 200
202 if (ret < 0) 201 if (ret < 0)
@@ -424,8 +423,7 @@ static void path_rec_completion(int status,
424 } 423 }
425} 424}
426 425
427static struct ipoib_path *path_rec_create(struct net_device *dev, 426static struct ipoib_path *path_rec_create(struct net_device *dev, void *gid)
428 union ib_gid *gid)
429{ 427{
430 struct ipoib_dev_priv *priv = netdev_priv(dev); 428 struct ipoib_dev_priv *priv = netdev_priv(dev);
431 struct ipoib_path *path; 429 struct ipoib_path *path;
@@ -440,7 +438,7 @@ static struct ipoib_path *path_rec_create(struct net_device *dev,
440 438
441 INIT_LIST_HEAD(&path->neigh_list); 439 INIT_LIST_HEAD(&path->neigh_list);
442 440
443 memcpy(path->pathrec.dgid.raw, gid->raw, sizeof (union ib_gid)); 441 memcpy(path->pathrec.dgid.raw, gid, sizeof (union ib_gid));
444 path->pathrec.sgid = priv->local_gid; 442 path->pathrec.sgid = priv->local_gid;
445 path->pathrec.pkey = cpu_to_be16(priv->pkey); 443 path->pathrec.pkey = cpu_to_be16(priv->pkey);
446 path->pathrec.numb_path = 1; 444 path->pathrec.numb_path = 1;
@@ -498,10 +496,9 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
498 */ 496 */
499 spin_lock(&priv->lock); 497 spin_lock(&priv->lock);
500 498
501 path = __path_find(dev, (union ib_gid *) (skb->dst->neighbour->ha + 4)); 499 path = __path_find(dev, skb->dst->neighbour->ha + 4);
502 if (!path) { 500 if (!path) {
503 path = path_rec_create(dev, 501 path = path_rec_create(dev, skb->dst->neighbour->ha + 4);
504 (union ib_gid *) (skb->dst->neighbour->ha + 4));
505 if (!path) 502 if (!path)
506 goto err_path; 503 goto err_path;
507 504
@@ -551,7 +548,7 @@ static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev)
551 /* Add in the P_Key for multicasts */ 548 /* Add in the P_Key for multicasts */
552 skb->dst->neighbour->ha[8] = (priv->pkey >> 8) & 0xff; 549 skb->dst->neighbour->ha[8] = (priv->pkey >> 8) & 0xff;
553 skb->dst->neighbour->ha[9] = priv->pkey & 0xff; 550 skb->dst->neighbour->ha[9] = priv->pkey & 0xff;
554 ipoib_mcast_send(dev, (union ib_gid *) (skb->dst->neighbour->ha + 4), skb); 551 ipoib_mcast_send(dev, skb->dst->neighbour->ha + 4, skb);
555} 552}
556 553
557static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, 554static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
@@ -566,10 +563,9 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
566 */ 563 */
567 spin_lock(&priv->lock); 564 spin_lock(&priv->lock);
568 565
569 path = __path_find(dev, (union ib_gid *) (phdr->hwaddr + 4)); 566 path = __path_find(dev, phdr->hwaddr + 4);
570 if (!path) { 567 if (!path) {
571 path = path_rec_create(dev, 568 path = path_rec_create(dev, phdr->hwaddr + 4);
572 (union ib_gid *) (phdr->hwaddr + 4));
573 if (path) { 569 if (path) {
574 /* put pseudoheader back on for next time */ 570 /* put pseudoheader back on for next time */
575 skb_push(skb, sizeof *phdr); 571 skb_push(skb, sizeof *phdr);
@@ -660,7 +656,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
660 phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff; 656 phdr->hwaddr[8] = (priv->pkey >> 8) & 0xff;
661 phdr->hwaddr[9] = priv->pkey & 0xff; 657 phdr->hwaddr[9] = priv->pkey & 0xff;
662 658
663 ipoib_mcast_send(dev, (union ib_gid *) (phdr->hwaddr + 4), skb); 659 ipoib_mcast_send(dev, phdr->hwaddr + 4, skb);
664 } else { 660 } else {
665 /* unicast GID -- should be ARP or RARP reply */ 661 /* unicast GID -- should be ARP or RARP reply */
666 662
@@ -671,7 +667,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
671 skb->dst ? "neigh" : "dst", 667 skb->dst ? "neigh" : "dst",
672 be16_to_cpup((__be16 *) skb->data), 668 be16_to_cpup((__be16 *) skb->data),
673 be32_to_cpup((__be32 *) phdr->hwaddr), 669 be32_to_cpup((__be32 *) phdr->hwaddr),
674 IPOIB_GID_ARG(*(union ib_gid *) (phdr->hwaddr + 4))); 670 IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
675 dev_kfree_skb_any(skb); 671 dev_kfree_skb_any(skb);
676 ++priv->stats.tx_dropped; 672 ++priv->stats.tx_dropped;
677 goto out; 673 goto out;
@@ -754,7 +750,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
754 ipoib_dbg(priv, 750 ipoib_dbg(priv,
755 "neigh_destructor for %06x " IPOIB_GID_FMT "\n", 751 "neigh_destructor for %06x " IPOIB_GID_FMT "\n",
756 be32_to_cpup((__be32 *) n->ha), 752 be32_to_cpup((__be32 *) n->ha),
757 IPOIB_GID_ARG(*((union ib_gid *) (n->ha + 4)))); 753 IPOIB_GID_RAW_ARG(n->ha + 4));
758 754
759 spin_lock_irqsave(&priv->lock, flags); 755 spin_lock_irqsave(&priv->lock, flags);
760 756
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 1dae4b238252..216471fa01cc 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -154,7 +154,7 @@ static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
154 return mcast; 154 return mcast;
155} 155}
156 156
157static struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, union ib_gid *mgid) 157static struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, void *mgid)
158{ 158{
159 struct ipoib_dev_priv *priv = netdev_priv(dev); 159 struct ipoib_dev_priv *priv = netdev_priv(dev);
160 struct rb_node *n = priv->multicast_tree.rb_node; 160 struct rb_node *n = priv->multicast_tree.rb_node;
@@ -165,7 +165,7 @@ static struct ipoib_mcast *__ipoib_mcast_find(struct net_device *dev, union ib_g
165 165
166 mcast = rb_entry(n, struct ipoib_mcast, rb_node); 166 mcast = rb_entry(n, struct ipoib_mcast, rb_node);
167 167
168 ret = memcmp(mgid->raw, mcast->mcmember.mgid.raw, 168 ret = memcmp(mgid, mcast->mcmember.mgid.raw,
169 sizeof (union ib_gid)); 169 sizeof (union ib_gid));
170 if (ret < 0) 170 if (ret < 0)
171 n = n->rb_left; 171 n = n->rb_left;
@@ -694,8 +694,7 @@ static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
694 return 0; 694 return 0;
695} 695}
696 696
697void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid, 697void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
698 struct sk_buff *skb)
699{ 698{
700 struct ipoib_dev_priv *priv = netdev_priv(dev); 699 struct ipoib_dev_priv *priv = netdev_priv(dev);
701 struct ipoib_mcast *mcast; 700 struct ipoib_mcast *mcast;
@@ -718,7 +717,7 @@ void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
718 if (!mcast) { 717 if (!mcast) {
719 /* Let's create a new send only group now */ 718 /* Let's create a new send only group now */
720 ipoib_dbg_mcast(priv, "setting up send only multicast group for " 719 ipoib_dbg_mcast(priv, "setting up send only multicast group for "
721 IPOIB_GID_FMT "\n", IPOIB_GID_ARG(*mgid)); 720 IPOIB_GID_FMT "\n", IPOIB_GID_RAW_ARG(mgid));
722 721
723 mcast = ipoib_mcast_alloc(dev, 0); 722 mcast = ipoib_mcast_alloc(dev, 0);
724 if (!mcast) { 723 if (!mcast) {
@@ -730,7 +729,7 @@ void ipoib_mcast_send(struct net_device *dev, union ib_gid *mgid,
730 } 729 }
731 730
732 set_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags); 731 set_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags);
733 mcast->mcmember.mgid = *mgid; 732 memcpy(mcast->mcmember.mgid.raw, mgid, sizeof (union ib_gid));
734 __ipoib_mcast_add(dev, mcast); 733 __ipoib_mcast_add(dev, mcast);
735 list_add_tail(&mcast->list, &priv->multicast_list); 734 list_add_tail(&mcast->list, &priv->multicast_list);
736 } 735 }
@@ -821,7 +820,8 @@ void ipoib_mcast_restart_task(void *dev_ptr)
821 820
822 ipoib_mcast_stop_thread(dev, 0); 821 ipoib_mcast_stop_thread(dev, 0);
823 822
824 spin_lock_irqsave(&dev->xmit_lock, flags); 823 local_irq_save(flags);
824 netif_tx_lock(dev);
825 spin_lock(&priv->lock); 825 spin_lock(&priv->lock);
826 826
827 /* 827 /*
@@ -896,7 +896,8 @@ void ipoib_mcast_restart_task(void *dev_ptr)
896 } 896 }
897 897
898 spin_unlock(&priv->lock); 898 spin_unlock(&priv->lock);
899 spin_unlock_irqrestore(&dev->xmit_lock, flags); 899 netif_tx_unlock(dev);
900 local_irq_restore(flags);
900 901
901 /* We have to cancel outside of the spinlock */ 902 /* We have to cancel outside of the spinlock */
902 list_for_each_entry_safe(mcast, tmcast, &remove_list, list) { 903 list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 1d49d1643c59..7b717c648f72 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -255,7 +255,8 @@ void ipoib_event(struct ib_event_handler *handler,
255 record->event == IB_EVENT_PKEY_CHANGE || 255 record->event == IB_EVENT_PKEY_CHANGE ||
256 record->event == IB_EVENT_PORT_ACTIVE || 256 record->event == IB_EVENT_PORT_ACTIVE ||
257 record->event == IB_EVENT_LID_CHANGE || 257 record->event == IB_EVENT_LID_CHANGE ||
258 record->event == IB_EVENT_SM_CHANGE) { 258 record->event == IB_EVENT_SM_CHANGE ||
259 record->event == IB_EVENT_CLIENT_REREGISTER) {
259 ipoib_dbg(priv, "Port state change event\n"); 260 ipoib_dbg(priv, "Port state change event\n");
260 queue_work(ipoib_workqueue, &priv->flush_task); 261 queue_work(ipoib_workqueue, &priv->flush_task);
261 } 262 }
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 9cbdffa08dc2..4e22afef7206 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -62,6 +62,13 @@ MODULE_DESCRIPTION("InfiniBand SCSI RDMA Protocol initiator "
62 "v" DRV_VERSION " (" DRV_RELDATE ")"); 62 "v" DRV_VERSION " (" DRV_RELDATE ")");
63MODULE_LICENSE("Dual BSD/GPL"); 63MODULE_LICENSE("Dual BSD/GPL");
64 64
65static int srp_sg_tablesize = SRP_DEF_SG_TABLESIZE;
66static int srp_max_iu_len;
67
68module_param(srp_sg_tablesize, int, 0444);
69MODULE_PARM_DESC(srp_sg_tablesize,
70 "Max number of gather/scatter entries per I/O (default is 12)");
71
65static int topspin_workarounds = 1; 72static int topspin_workarounds = 1;
66 73
67module_param(topspin_workarounds, int, 0444); 74module_param(topspin_workarounds, int, 0444);
@@ -105,7 +112,8 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
105 if (!iu->buf) 112 if (!iu->buf)
106 goto out_free_iu; 113 goto out_free_iu;
107 114
108 iu->dma = dma_map_single(host->dev->dma_device, iu->buf, size, direction); 115 iu->dma = dma_map_single(host->dev->dev->dma_device,
116 iu->buf, size, direction);
109 if (dma_mapping_error(iu->dma)) 117 if (dma_mapping_error(iu->dma))
110 goto out_free_buf; 118 goto out_free_buf;
111 119
@@ -127,7 +135,8 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu)
127 if (!iu) 135 if (!iu)
128 return; 136 return;
129 137
130 dma_unmap_single(host->dev->dma_device, iu->dma, iu->size, iu->direction); 138 dma_unmap_single(host->dev->dev->dma_device,
139 iu->dma, iu->size, iu->direction);
131 kfree(iu->buf); 140 kfree(iu->buf);
132 kfree(iu); 141 kfree(iu);
133} 142}
@@ -147,7 +156,7 @@ static int srp_init_qp(struct srp_target_port *target,
147 if (!attr) 156 if (!attr)
148 return -ENOMEM; 157 return -ENOMEM;
149 158
150 ret = ib_find_cached_pkey(target->srp_host->dev, 159 ret = ib_find_cached_pkey(target->srp_host->dev->dev,
151 target->srp_host->port, 160 target->srp_host->port,
152 be16_to_cpu(target->path.pkey), 161 be16_to_cpu(target->path.pkey),
153 &attr->pkey_index); 162 &attr->pkey_index);
@@ -179,7 +188,7 @@ static int srp_create_target_ib(struct srp_target_port *target)
179 if (!init_attr) 188 if (!init_attr)
180 return -ENOMEM; 189 return -ENOMEM;
181 190
182 target->cq = ib_create_cq(target->srp_host->dev, srp_completion, 191 target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion,
183 NULL, target, SRP_CQ_SIZE); 192 NULL, target, SRP_CQ_SIZE);
184 if (IS_ERR(target->cq)) { 193 if (IS_ERR(target->cq)) {
185 ret = PTR_ERR(target->cq); 194 ret = PTR_ERR(target->cq);
@@ -198,7 +207,7 @@ static int srp_create_target_ib(struct srp_target_port *target)
198 init_attr->send_cq = target->cq; 207 init_attr->send_cq = target->cq;
199 init_attr->recv_cq = target->cq; 208 init_attr->recv_cq = target->cq;
200 209
201 target->qp = ib_create_qp(target->srp_host->pd, init_attr); 210 target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr);
202 if (IS_ERR(target->qp)) { 211 if (IS_ERR(target->qp)) {
203 ret = PTR_ERR(target->qp); 212 ret = PTR_ERR(target->qp);
204 ib_destroy_cq(target->cq); 213 ib_destroy_cq(target->cq);
@@ -250,7 +259,7 @@ static int srp_lookup_path(struct srp_target_port *target)
250 259
251 init_completion(&target->done); 260 init_completion(&target->done);
252 261
253 target->path_query_id = ib_sa_path_rec_get(target->srp_host->dev, 262 target->path_query_id = ib_sa_path_rec_get(target->srp_host->dev->dev,
254 target->srp_host->port, 263 target->srp_host->port,
255 &target->path, 264 &target->path,
256 IB_SA_PATH_REC_DGID | 265 IB_SA_PATH_REC_DGID |
@@ -309,10 +318,32 @@ static int srp_send_req(struct srp_target_port *target)
309 318
310 req->priv.opcode = SRP_LOGIN_REQ; 319 req->priv.opcode = SRP_LOGIN_REQ;
311 req->priv.tag = 0; 320 req->priv.tag = 0;
312 req->priv.req_it_iu_len = cpu_to_be32(SRP_MAX_IU_LEN); 321 req->priv.req_it_iu_len = cpu_to_be32(srp_max_iu_len);
313 req->priv.req_buf_fmt = cpu_to_be16(SRP_BUF_FORMAT_DIRECT | 322 req->priv.req_buf_fmt = cpu_to_be16(SRP_BUF_FORMAT_DIRECT |
314 SRP_BUF_FORMAT_INDIRECT); 323 SRP_BUF_FORMAT_INDIRECT);
315 memcpy(req->priv.initiator_port_id, target->srp_host->initiator_port_id, 16); 324 /*
325 * In the published SRP specification (draft rev. 16a), the
326 * port identifier format is 8 bytes of ID extension followed
327 * by 8 bytes of GUID. Older drafts put the two halves in the
328 * opposite order, so that the GUID comes first.
329 *
330 * Targets conforming to these obsolete drafts can be
331 * recognized by the I/O Class they report.
332 */
333 if (target->io_class == SRP_REV10_IB_IO_CLASS) {
334 memcpy(req->priv.initiator_port_id,
335 target->srp_host->initiator_port_id + 8, 8);
336 memcpy(req->priv.initiator_port_id + 8,
337 target->srp_host->initiator_port_id, 8);
338 memcpy(req->priv.target_port_id, &target->ioc_guid, 8);
339 memcpy(req->priv.target_port_id + 8, &target->id_ext, 8);
340 } else {
341 memcpy(req->priv.initiator_port_id,
342 target->srp_host->initiator_port_id, 16);
343 memcpy(req->priv.target_port_id, &target->id_ext, 8);
344 memcpy(req->priv.target_port_id + 8, &target->ioc_guid, 8);
345 }
346
316 /* 347 /*
317 * Topspin/Cisco SRP targets will reject our login unless we 348 * Topspin/Cisco SRP targets will reject our login unless we
318 * zero out the first 8 bytes of our initiator port ID. The 349 * zero out the first 8 bytes of our initiator port ID. The
@@ -325,8 +356,6 @@ static int srp_send_req(struct srp_target_port *target)
325 (unsigned long long) be64_to_cpu(target->ioc_guid)); 356 (unsigned long long) be64_to_cpu(target->ioc_guid));
326 memset(req->priv.initiator_port_id, 0, 8); 357 memset(req->priv.initiator_port_id, 0, 8);
327 } 358 }
328 memcpy(req->priv.target_port_id, &target->id_ext, 8);
329 memcpy(req->priv.target_port_id + 8, &target->ioc_guid, 8);
330 359
331 status = ib_send_cm_req(target->cm_id, &req->param); 360 status = ib_send_cm_req(target->cm_id, &req->param);
332 361
@@ -359,9 +388,9 @@ static void srp_remove_work(void *target_ptr)
359 target->state = SRP_TARGET_REMOVED; 388 target->state = SRP_TARGET_REMOVED;
360 spin_unlock_irq(target->scsi_host->host_lock); 389 spin_unlock_irq(target->scsi_host->host_lock);
361 390
362 mutex_lock(&target->srp_host->target_mutex); 391 spin_lock(&target->srp_host->target_lock);
363 list_del(&target->list); 392 list_del(&target->list);
364 mutex_unlock(&target->srp_host->target_mutex); 393 spin_unlock(&target->srp_host->target_lock);
365 394
366 scsi_remove_host(target->scsi_host); 395 scsi_remove_host(target->scsi_host);
367 ib_destroy_cm_id(target->cm_id); 396 ib_destroy_cm_id(target->cm_id);
@@ -421,6 +450,11 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
421 scmnd->sc_data_direction != DMA_FROM_DEVICE)) 450 scmnd->sc_data_direction != DMA_FROM_DEVICE))
422 return; 451 return;
423 452
453 if (req->fmr) {
454 ib_fmr_pool_unmap(req->fmr);
455 req->fmr = NULL;
456 }
457
424 /* 458 /*
425 * This handling of non-SG commands can be killed when the 459 * This handling of non-SG commands can be killed when the
426 * SCSI midlayer no longer generates non-SG commands. 460 * SCSI midlayer no longer generates non-SG commands.
@@ -433,18 +467,30 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
433 scat = &req->fake_sg; 467 scat = &req->fake_sg;
434 } 468 }
435 469
436 dma_unmap_sg(target->srp_host->dev->dma_device, scat, nents, 470 dma_unmap_sg(target->srp_host->dev->dev->dma_device, scat, nents,
437 scmnd->sc_data_direction); 471 scmnd->sc_data_direction);
438} 472}
439 473
474static void srp_remove_req(struct srp_target_port *target, struct srp_request *req)
475{
476 srp_unmap_data(req->scmnd, target, req);
477 list_move_tail(&req->list, &target->free_reqs);
478}
479
480static void srp_reset_req(struct srp_target_port *target, struct srp_request *req)
481{
482 req->scmnd->result = DID_RESET << 16;
483 req->scmnd->scsi_done(req->scmnd);
484 srp_remove_req(target, req);
485}
486
440static int srp_reconnect_target(struct srp_target_port *target) 487static int srp_reconnect_target(struct srp_target_port *target)
441{ 488{
442 struct ib_cm_id *new_cm_id; 489 struct ib_cm_id *new_cm_id;
443 struct ib_qp_attr qp_attr; 490 struct ib_qp_attr qp_attr;
444 struct srp_request *req; 491 struct srp_request *req, *tmp;
445 struct ib_wc wc; 492 struct ib_wc wc;
446 int ret; 493 int ret;
447 int i;
448 494
449 spin_lock_irq(target->scsi_host->host_lock); 495 spin_lock_irq(target->scsi_host->host_lock);
450 if (target->state != SRP_TARGET_LIVE) { 496 if (target->state != SRP_TARGET_LIVE) {
@@ -459,7 +505,7 @@ static int srp_reconnect_target(struct srp_target_port *target)
459 * Now get a new local CM ID so that we avoid confusing the 505 * Now get a new local CM ID so that we avoid confusing the
460 * target in case things are really fouled up. 506 * target in case things are really fouled up.
461 */ 507 */
462 new_cm_id = ib_create_cm_id(target->srp_host->dev, 508 new_cm_id = ib_create_cm_id(target->srp_host->dev->dev,
463 srp_cm_handler, target); 509 srp_cm_handler, target);
464 if (IS_ERR(new_cm_id)) { 510 if (IS_ERR(new_cm_id)) {
465 ret = PTR_ERR(new_cm_id); 511 ret = PTR_ERR(new_cm_id);
@@ -480,19 +526,12 @@ static int srp_reconnect_target(struct srp_target_port *target)
480 while (ib_poll_cq(target->cq, 1, &wc) > 0) 526 while (ib_poll_cq(target->cq, 1, &wc) > 0)
481 ; /* nothing */ 527 ; /* nothing */
482 528
483 list_for_each_entry(req, &target->req_queue, list) { 529 list_for_each_entry_safe(req, tmp, &target->req_queue, list)
484 req->scmnd->result = DID_RESET << 16; 530 srp_reset_req(target, req);
485 req->scmnd->scsi_done(req->scmnd);
486 srp_unmap_data(req->scmnd, target, req);
487 }
488 531
489 target->rx_head = 0; 532 target->rx_head = 0;
490 target->tx_head = 0; 533 target->tx_head = 0;
491 target->tx_tail = 0; 534 target->tx_tail = 0;
492 INIT_LIST_HEAD(&target->free_reqs);
493 INIT_LIST_HEAD(&target->req_queue);
494 for (i = 0; i < SRP_SQ_SIZE; ++i)
495 list_add_tail(&target->req_ring[i].list, &target->free_reqs);
496 535
497 ret = srp_connect_target(target); 536 ret = srp_connect_target(target);
498 if (ret) 537 if (ret)
@@ -528,14 +567,79 @@ err:
528 return ret; 567 return ret;
529} 568}
530 569
570static int srp_map_fmr(struct srp_device *dev, struct scatterlist *scat,
571 int sg_cnt, struct srp_request *req,
572 struct srp_direct_buf *buf)
573{
574 u64 io_addr = 0;
575 u64 *dma_pages;
576 u32 len;
577 int page_cnt;
578 int i, j;
579 int ret;
580
581 if (!dev->fmr_pool)
582 return -ENODEV;
583
584 len = page_cnt = 0;
585 for (i = 0; i < sg_cnt; ++i) {
586 if (sg_dma_address(&scat[i]) & ~dev->fmr_page_mask) {
587 if (i > 0)
588 return -EINVAL;
589 else
590 ++page_cnt;
591 }
592 if ((sg_dma_address(&scat[i]) + sg_dma_len(&scat[i])) &
593 ~dev->fmr_page_mask) {
594 if (i < sg_cnt - 1)
595 return -EINVAL;
596 else
597 ++page_cnt;
598 }
599
600 len += sg_dma_len(&scat[i]);
601 }
602
603 page_cnt += len >> dev->fmr_page_shift;
604 if (page_cnt > SRP_FMR_SIZE)
605 return -ENOMEM;
606
607 dma_pages = kmalloc(sizeof (u64) * page_cnt, GFP_ATOMIC);
608 if (!dma_pages)
609 return -ENOMEM;
610
611 page_cnt = 0;
612 for (i = 0; i < sg_cnt; ++i)
613 for (j = 0; j < sg_dma_len(&scat[i]); j += dev->fmr_page_size)
614 dma_pages[page_cnt++] =
615 (sg_dma_address(&scat[i]) & dev->fmr_page_mask) + j;
616
617 req->fmr = ib_fmr_pool_map_phys(dev->fmr_pool,
618 dma_pages, page_cnt, &io_addr);
619 if (IS_ERR(req->fmr)) {
620 ret = PTR_ERR(req->fmr);
621 goto out;
622 }
623
624 buf->va = cpu_to_be64(sg_dma_address(&scat[0]) & ~dev->fmr_page_mask);
625 buf->key = cpu_to_be32(req->fmr->fmr->rkey);
626 buf->len = cpu_to_be32(len);
627
628 ret = 0;
629
630out:
631 kfree(dma_pages);
632
633 return ret;
634}
635
531static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, 636static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
532 struct srp_request *req) 637 struct srp_request *req)
533{ 638{
534 struct scatterlist *scat; 639 struct scatterlist *scat;
535 struct srp_cmd *cmd = req->cmd->buf; 640 struct srp_cmd *cmd = req->cmd->buf;
536 int len, nents, count; 641 int len, nents, count;
537 int i; 642 u8 fmt = SRP_DATA_DESC_DIRECT;
538 u8 fmt;
539 643
540 if (!scmnd->request_buffer || scmnd->sc_data_direction == DMA_NONE) 644 if (!scmnd->request_buffer || scmnd->sc_data_direction == DMA_NONE)
541 return sizeof (struct srp_cmd); 645 return sizeof (struct srp_cmd);
@@ -560,53 +664,63 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
560 sg_init_one(scat, scmnd->request_buffer, scmnd->request_bufflen); 664 sg_init_one(scat, scmnd->request_buffer, scmnd->request_bufflen);
561 } 665 }
562 666
563 count = dma_map_sg(target->srp_host->dev->dma_device, scat, nents, 667 count = dma_map_sg(target->srp_host->dev->dev->dma_device,
564 scmnd->sc_data_direction); 668 scat, nents, scmnd->sc_data_direction);
669
670 fmt = SRP_DATA_DESC_DIRECT;
671 len = sizeof (struct srp_cmd) + sizeof (struct srp_direct_buf);
565 672
566 if (count == 1) { 673 if (count == 1) {
674 /*
675 * The midlayer only generated a single gather/scatter
676 * entry, or DMA mapping coalesced everything to a
677 * single entry. So a direct descriptor along with
678 * the DMA MR suffices.
679 */
567 struct srp_direct_buf *buf = (void *) cmd->add_data; 680 struct srp_direct_buf *buf = (void *) cmd->add_data;
568 681
569 fmt = SRP_DATA_DESC_DIRECT;
570
571 buf->va = cpu_to_be64(sg_dma_address(scat)); 682 buf->va = cpu_to_be64(sg_dma_address(scat));
572 buf->key = cpu_to_be32(target->srp_host->mr->rkey); 683 buf->key = cpu_to_be32(target->srp_host->dev->mr->rkey);
573 buf->len = cpu_to_be32(sg_dma_len(scat)); 684 buf->len = cpu_to_be32(sg_dma_len(scat));
574 685 } else if (srp_map_fmr(target->srp_host->dev, scat, count, req,
575 len = sizeof (struct srp_cmd) + 686 (void *) cmd->add_data)) {
576 sizeof (struct srp_direct_buf); 687 /*
577 } else { 688 * FMR mapping failed, and the scatterlist has more
689 * than one entry. Generate an indirect memory
690 * descriptor.
691 */
578 struct srp_indirect_buf *buf = (void *) cmd->add_data; 692 struct srp_indirect_buf *buf = (void *) cmd->add_data;
579 u32 datalen = 0; 693 u32 datalen = 0;
694 int i;
580 695
581 fmt = SRP_DATA_DESC_INDIRECT; 696 fmt = SRP_DATA_DESC_INDIRECT;
697 len = sizeof (struct srp_cmd) +
698 sizeof (struct srp_indirect_buf) +
699 count * sizeof (struct srp_direct_buf);
700
701 for (i = 0; i < count; ++i) {
702 buf->desc_list[i].va =
703 cpu_to_be64(sg_dma_address(&scat[i]));
704 buf->desc_list[i].key =
705 cpu_to_be32(target->srp_host->dev->mr->rkey);
706 buf->desc_list[i].len =
707 cpu_to_be32(sg_dma_len(&scat[i]));
708 datalen += sg_dma_len(&scat[i]);
709 }
582 710
583 if (scmnd->sc_data_direction == DMA_TO_DEVICE) 711 if (scmnd->sc_data_direction == DMA_TO_DEVICE)
584 cmd->data_out_desc_cnt = count; 712 cmd->data_out_desc_cnt = count;
585 else 713 else
586 cmd->data_in_desc_cnt = count; 714 cmd->data_in_desc_cnt = count;
587 715
588 buf->table_desc.va = cpu_to_be64(req->cmd->dma + 716 buf->table_desc.va =
589 sizeof *cmd + 717 cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf);
590 sizeof *buf);
591 buf->table_desc.key = 718 buf->table_desc.key =
592 cpu_to_be32(target->srp_host->mr->rkey); 719 cpu_to_be32(target->srp_host->dev->mr->rkey);
593 buf->table_desc.len = 720 buf->table_desc.len =
594 cpu_to_be32(count * sizeof (struct srp_direct_buf)); 721 cpu_to_be32(count * sizeof (struct srp_direct_buf));
595 722
596 for (i = 0; i < count; ++i) {
597 buf->desc_list[i].va = cpu_to_be64(sg_dma_address(&scat[i]));
598 buf->desc_list[i].key =
599 cpu_to_be32(target->srp_host->mr->rkey);
600 buf->desc_list[i].len = cpu_to_be32(sg_dma_len(&scat[i]));
601
602 datalen += sg_dma_len(&scat[i]);
603 }
604
605 buf->len = cpu_to_be32(datalen); 723 buf->len = cpu_to_be32(datalen);
606
607 len = sizeof (struct srp_cmd) +
608 sizeof (struct srp_indirect_buf) +
609 count * sizeof (struct srp_direct_buf);
610 } 724 }
611 725
612 if (scmnd->sc_data_direction == DMA_TO_DEVICE) 726 if (scmnd->sc_data_direction == DMA_TO_DEVICE)
@@ -617,12 +731,6 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
617 return len; 731 return len;
618} 732}
619 733
620static void srp_remove_req(struct srp_target_port *target, struct srp_request *req)
621{
622 srp_unmap_data(req->scmnd, target, req);
623 list_move_tail(&req->list, &target->free_reqs);
624}
625
626static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) 734static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp)
627{ 735{
628 struct srp_request *req; 736 struct srp_request *req;
@@ -689,7 +797,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
689 797
690 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; 798 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV];
691 799
692 dma_sync_single_for_cpu(target->srp_host->dev->dma_device, iu->dma, 800 dma_sync_single_for_cpu(target->srp_host->dev->dev->dma_device, iu->dma,
693 target->max_ti_iu_len, DMA_FROM_DEVICE); 801 target->max_ti_iu_len, DMA_FROM_DEVICE);
694 802
695 opcode = *(u8 *) iu->buf; 803 opcode = *(u8 *) iu->buf;
@@ -726,7 +834,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
726 break; 834 break;
727 } 835 }
728 836
729 dma_sync_single_for_device(target->srp_host->dev->dma_device, iu->dma, 837 dma_sync_single_for_device(target->srp_host->dev->dev->dma_device, iu->dma,
730 target->max_ti_iu_len, DMA_FROM_DEVICE); 838 target->max_ti_iu_len, DMA_FROM_DEVICE);
731} 839}
732 840
@@ -770,7 +878,7 @@ static int __srp_post_recv(struct srp_target_port *target)
770 878
771 list.addr = iu->dma; 879 list.addr = iu->dma;
772 list.length = iu->size; 880 list.length = iu->size;
773 list.lkey = target->srp_host->mr->lkey; 881 list.lkey = target->srp_host->dev->mr->lkey;
774 882
775 wr.next = NULL; 883 wr.next = NULL;
776 wr.sg_list = &list; 884 wr.sg_list = &list;
@@ -805,12 +913,8 @@ static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target)
805 if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE) 913 if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE)
806 return NULL; 914 return NULL;
807 915
808 if (unlikely(target->req_lim < 1)) { 916 if (unlikely(target->req_lim < 1))
809 if (printk_ratelimit()) 917 ++target->zero_req_lim;
810 printk(KERN_DEBUG PFX "Target has req_lim %d\n",
811 target->req_lim);
812 return NULL;
813 }
814 918
815 return target->tx_ring[target->tx_head & SRP_SQ_SIZE]; 919 return target->tx_ring[target->tx_head & SRP_SQ_SIZE];
816} 920}
@@ -828,7 +932,7 @@ static int __srp_post_send(struct srp_target_port *target,
828 932
829 list.addr = iu->dma; 933 list.addr = iu->dma;
830 list.length = len; 934 list.length = len;
831 list.lkey = target->srp_host->mr->lkey; 935 list.lkey = target->srp_host->dev->mr->lkey;
832 936
833 wr.next = NULL; 937 wr.next = NULL;
834 wr.wr_id = target->tx_head & SRP_SQ_SIZE; 938 wr.wr_id = target->tx_head & SRP_SQ_SIZE;
@@ -870,8 +974,8 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
870 if (!iu) 974 if (!iu)
871 goto err; 975 goto err;
872 976
873 dma_sync_single_for_cpu(target->srp_host->dev->dma_device, iu->dma, 977 dma_sync_single_for_cpu(target->srp_host->dev->dev->dma_device, iu->dma,
874 SRP_MAX_IU_LEN, DMA_TO_DEVICE); 978 srp_max_iu_len, DMA_TO_DEVICE);
875 979
876 req = list_entry(target->free_reqs.next, struct srp_request, list); 980 req = list_entry(target->free_reqs.next, struct srp_request, list);
877 981
@@ -903,8 +1007,8 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
903 goto err_unmap; 1007 goto err_unmap;
904 } 1008 }
905 1009
906 dma_sync_single_for_device(target->srp_host->dev->dma_device, iu->dma, 1010 dma_sync_single_for_device(target->srp_host->dev->dev->dma_device, iu->dma,
907 SRP_MAX_IU_LEN, DMA_TO_DEVICE); 1011 srp_max_iu_len, DMA_TO_DEVICE);
908 1012
909 if (__srp_post_send(target, iu, len)) { 1013 if (__srp_post_send(target, iu, len)) {
910 printk(KERN_ERR PFX "Send failed\n"); 1014 printk(KERN_ERR PFX "Send failed\n");
@@ -936,7 +1040,7 @@ static int srp_alloc_iu_bufs(struct srp_target_port *target)
936 1040
937 for (i = 0; i < SRP_SQ_SIZE + 1; ++i) { 1041 for (i = 0; i < SRP_SQ_SIZE + 1; ++i) {
938 target->tx_ring[i] = srp_alloc_iu(target->srp_host, 1042 target->tx_ring[i] = srp_alloc_iu(target->srp_host,
939 SRP_MAX_IU_LEN, 1043 srp_max_iu_len,
940 GFP_KERNEL, DMA_TO_DEVICE); 1044 GFP_KERNEL, DMA_TO_DEVICE);
941 if (!target->tx_ring[i]) 1045 if (!target->tx_ring[i])
942 goto err; 1046 goto err;
@@ -1107,11 +1211,10 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
1107 srp_cm_rej_handler(cm_id, event, target); 1211 srp_cm_rej_handler(cm_id, event, target);
1108 break; 1212 break;
1109 1213
1110 case IB_CM_MRA_RECEIVED: 1214 case IB_CM_DREQ_RECEIVED:
1111 printk(KERN_ERR PFX "MRA received\n"); 1215 printk(KERN_WARNING PFX "DREQ received - connection closed\n");
1112 break; 1216 if (ib_send_cm_drep(cm_id, NULL, 0))
1113 1217 printk(KERN_ERR PFX "Sending CM DREP failed\n");
1114 case IB_CM_DREP_RECEIVED:
1115 break; 1218 break;
1116 1219
1117 case IB_CM_TIMEWAIT_EXIT: 1220 case IB_CM_TIMEWAIT_EXIT:
@@ -1121,6 +1224,11 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
1121 target->status = 0; 1224 target->status = 0;
1122 break; 1225 break;
1123 1226
1227 case IB_CM_MRA_RECEIVED:
1228 case IB_CM_DREQ_ERROR:
1229 case IB_CM_DREP_RECEIVED:
1230 break;
1231
1124 default: 1232 default:
1125 printk(KERN_WARNING PFX "Unhandled CM event %d\n", event->event); 1233 printk(KERN_WARNING PFX "Unhandled CM event %d\n", event->event);
1126 break; 1234 break;
@@ -1239,11 +1347,8 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
1239 spin_lock_irq(target->scsi_host->host_lock); 1347 spin_lock_irq(target->scsi_host->host_lock);
1240 1348
1241 list_for_each_entry_safe(req, tmp, &target->req_queue, list) 1349 list_for_each_entry_safe(req, tmp, &target->req_queue, list)
1242 if (req->scmnd->device == scmnd->device) { 1350 if (req->scmnd->device == scmnd->device)
1243 req->scmnd->result = DID_RESET << 16; 1351 srp_reset_req(target, req);
1244 req->scmnd->scsi_done(req->scmnd);
1245 srp_remove_req(target, req);
1246 }
1247 1352
1248 spin_unlock_irq(target->scsi_host->host_lock); 1353 spin_unlock_irq(target->scsi_host->host_lock);
1249 1354
@@ -1329,11 +1434,23 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf)
1329 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); 1434 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
1330} 1435}
1331 1436
1437static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
1438{
1439 struct srp_target_port *target = host_to_target(class_to_shost(cdev));
1440
1441 if (target->state == SRP_TARGET_DEAD ||
1442 target->state == SRP_TARGET_REMOVED)
1443 return -ENODEV;
1444
1445 return sprintf(buf, "%d\n", target->zero_req_lim);
1446}
1447
1332static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); 1448static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
1333static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); 1449static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
1334static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); 1450static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
1335static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 1451static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
1336static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); 1452static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
1453static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
1337 1454
1338static struct class_device_attribute *srp_host_attrs[] = { 1455static struct class_device_attribute *srp_host_attrs[] = {
1339 &class_device_attr_id_ext, 1456 &class_device_attr_id_ext,
@@ -1341,6 +1458,7 @@ static struct class_device_attribute *srp_host_attrs[] = {
1341 &class_device_attr_service_id, 1458 &class_device_attr_service_id,
1342 &class_device_attr_pkey, 1459 &class_device_attr_pkey,
1343 &class_device_attr_dgid, 1460 &class_device_attr_dgid,
1461 &class_device_attr_zero_req_lim,
1344 NULL 1462 NULL
1345}; 1463};
1346 1464
@@ -1354,7 +1472,6 @@ static struct scsi_host_template srp_template = {
1354 .eh_host_reset_handler = srp_reset_host, 1472 .eh_host_reset_handler = srp_reset_host,
1355 .can_queue = SRP_SQ_SIZE, 1473 .can_queue = SRP_SQ_SIZE,
1356 .this_id = -1, 1474 .this_id = -1,
1357 .sg_tablesize = SRP_MAX_INDIRECT,
1358 .cmd_per_lun = SRP_SQ_SIZE, 1475 .cmd_per_lun = SRP_SQ_SIZE,
1359 .use_clustering = ENABLE_CLUSTERING, 1476 .use_clustering = ENABLE_CLUSTERING,
1360 .shost_attrs = srp_host_attrs 1477 .shost_attrs = srp_host_attrs
@@ -1365,18 +1482,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1365 sprintf(target->target_name, "SRP.T10:%016llX", 1482 sprintf(target->target_name, "SRP.T10:%016llX",
1366 (unsigned long long) be64_to_cpu(target->id_ext)); 1483 (unsigned long long) be64_to_cpu(target->id_ext));
1367 1484
1368 if (scsi_add_host(target->scsi_host, host->dev->dma_device)) 1485 if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device))
1369 return -ENODEV; 1486 return -ENODEV;
1370 1487
1371 mutex_lock(&host->target_mutex); 1488 spin_lock(&host->target_lock);
1372 list_add_tail(&target->list, &host->target_list); 1489 list_add_tail(&target->list, &host->target_list);
1373 mutex_unlock(&host->target_mutex); 1490 spin_unlock(&host->target_lock);
1374 1491
1375 target->state = SRP_TARGET_LIVE; 1492 target->state = SRP_TARGET_LIVE;
1376 1493
1377 /* XXX: are we supposed to have a definition of SCAN_WILD_CARD ?? */
1378 scsi_scan_target(&target->scsi_host->shost_gendev, 1494 scsi_scan_target(&target->scsi_host->shost_gendev,
1379 0, target->scsi_id, ~0, 0); 1495 0, target->scsi_id, SCAN_WILD_CARD, 0);
1380 1496
1381 return 0; 1497 return 0;
1382} 1498}
@@ -1410,6 +1526,8 @@ enum {
1410 SRP_OPT_PKEY = 1 << 3, 1526 SRP_OPT_PKEY = 1 << 3,
1411 SRP_OPT_SERVICE_ID = 1 << 4, 1527 SRP_OPT_SERVICE_ID = 1 << 4,
1412 SRP_OPT_MAX_SECT = 1 << 5, 1528 SRP_OPT_MAX_SECT = 1 << 5,
1529 SRP_OPT_MAX_CMD_PER_LUN = 1 << 6,
1530 SRP_OPT_IO_CLASS = 1 << 7,
1413 SRP_OPT_ALL = (SRP_OPT_ID_EXT | 1531 SRP_OPT_ALL = (SRP_OPT_ID_EXT |
1414 SRP_OPT_IOC_GUID | 1532 SRP_OPT_IOC_GUID |
1415 SRP_OPT_DGID | 1533 SRP_OPT_DGID |
@@ -1418,13 +1536,15 @@ enum {
1418}; 1536};
1419 1537
1420static match_table_t srp_opt_tokens = { 1538static match_table_t srp_opt_tokens = {
1421 { SRP_OPT_ID_EXT, "id_ext=%s" }, 1539 { SRP_OPT_ID_EXT, "id_ext=%s" },
1422 { SRP_OPT_IOC_GUID, "ioc_guid=%s" }, 1540 { SRP_OPT_IOC_GUID, "ioc_guid=%s" },
1423 { SRP_OPT_DGID, "dgid=%s" }, 1541 { SRP_OPT_DGID, "dgid=%s" },
1424 { SRP_OPT_PKEY, "pkey=%x" }, 1542 { SRP_OPT_PKEY, "pkey=%x" },
1425 { SRP_OPT_SERVICE_ID, "service_id=%s" }, 1543 { SRP_OPT_SERVICE_ID, "service_id=%s" },
1426 { SRP_OPT_MAX_SECT, "max_sect=%d" }, 1544 { SRP_OPT_MAX_SECT, "max_sect=%d" },
1427 { SRP_OPT_ERR, NULL } 1545 { SRP_OPT_MAX_CMD_PER_LUN, "max_cmd_per_lun=%d" },
1546 { SRP_OPT_IO_CLASS, "io_class=%x" },
1547 { SRP_OPT_ERR, NULL }
1428}; 1548};
1429 1549
1430static int srp_parse_options(const char *buf, struct srp_target_port *target) 1550static int srp_parse_options(const char *buf, struct srp_target_port *target)
@@ -1500,6 +1620,29 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
1500 target->scsi_host->max_sectors = token; 1620 target->scsi_host->max_sectors = token;
1501 break; 1621 break;
1502 1622
1623 case SRP_OPT_MAX_CMD_PER_LUN:
1624 if (match_int(args, &token)) {
1625 printk(KERN_WARNING PFX "bad max cmd_per_lun parameter '%s'\n", p);
1626 goto out;
1627 }
1628 target->scsi_host->cmd_per_lun = min(token, SRP_SQ_SIZE);
1629 break;
1630
1631 case SRP_OPT_IO_CLASS:
1632 if (match_hex(args, &token)) {
1633 printk(KERN_WARNING PFX "bad IO class parameter '%s' \n", p);
1634 goto out;
1635 }
1636 if (token != SRP_REV10_IB_IO_CLASS &&
1637 token != SRP_REV16A_IB_IO_CLASS) {
1638 printk(KERN_WARNING PFX "unknown IO class parameter value"
1639 " %x specified (use %x or %x).\n",
1640 token, SRP_REV10_IB_IO_CLASS, SRP_REV16A_IB_IO_CLASS);
1641 goto out;
1642 }
1643 target->io_class = token;
1644 break;
1645
1503 default: 1646 default:
1504 printk(KERN_WARNING PFX "unknown parameter or missing value " 1647 printk(KERN_WARNING PFX "unknown parameter or missing value "
1505 "'%s' in target creation request\n", p); 1648 "'%s' in target creation request\n", p);
@@ -1542,6 +1685,7 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1542 target = host_to_target(target_host); 1685 target = host_to_target(target_host);
1543 memset(target, 0, sizeof *target); 1686 memset(target, 0, sizeof *target);
1544 1687
1688 target->io_class = SRP_REV16A_IB_IO_CLASS;
1545 target->scsi_host = target_host; 1689 target->scsi_host = target_host;
1546 target->srp_host = host; 1690 target->srp_host = host;
1547 1691
@@ -1558,7 +1702,7 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1558 if (ret) 1702 if (ret)
1559 goto err; 1703 goto err;
1560 1704
1561 ib_get_cached_gid(host->dev, host->port, 0, &target->path.sgid); 1705 ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid);
1562 1706
1563 printk(KERN_DEBUG PFX "new target: id_ext %016llx ioc_guid %016llx pkey %04x " 1707 printk(KERN_DEBUG PFX "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
1564 "service_id %016llx dgid %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", 1708 "service_id %016llx dgid %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
@@ -1579,7 +1723,7 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1579 if (ret) 1723 if (ret)
1580 goto err; 1724 goto err;
1581 1725
1582 target->cm_id = ib_create_cm_id(host->dev, srp_cm_handler, target); 1726 target->cm_id = ib_create_cm_id(host->dev->dev, srp_cm_handler, target);
1583 if (IS_ERR(target->cm_id)) { 1727 if (IS_ERR(target->cm_id)) {
1584 ret = PTR_ERR(target->cm_id); 1728 ret = PTR_ERR(target->cm_id);
1585 goto err_free; 1729 goto err_free;
@@ -1619,7 +1763,7 @@ static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
1619 struct srp_host *host = 1763 struct srp_host *host =
1620 container_of(class_dev, struct srp_host, class_dev); 1764 container_of(class_dev, struct srp_host, class_dev);
1621 1765
1622 return sprintf(buf, "%s\n", host->dev->name); 1766 return sprintf(buf, "%s\n", host->dev->dev->name);
1623} 1767}
1624 1768
1625static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1769static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
@@ -1634,7 +1778,7 @@ static ssize_t show_port(struct class_device *class_dev, char *buf)
1634 1778
1635static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 1779static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
1636 1780
1637static struct srp_host *srp_add_port(struct ib_device *device, u8 port) 1781static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1638{ 1782{
1639 struct srp_host *host; 1783 struct srp_host *host;
1640 1784
@@ -1643,32 +1787,21 @@ static struct srp_host *srp_add_port(struct ib_device *device, u8 port)
1643 return NULL; 1787 return NULL;
1644 1788
1645 INIT_LIST_HEAD(&host->target_list); 1789 INIT_LIST_HEAD(&host->target_list);
1646 mutex_init(&host->target_mutex); 1790 spin_lock_init(&host->target_lock);
1647 init_completion(&host->released); 1791 init_completion(&host->released);
1648 host->dev = device; 1792 host->dev = device;
1649 host->port = port; 1793 host->port = port;
1650 1794
1651 host->initiator_port_id[7] = port; 1795 host->initiator_port_id[7] = port;
1652 memcpy(host->initiator_port_id + 8, &device->node_guid, 8); 1796 memcpy(host->initiator_port_id + 8, &device->dev->node_guid, 8);
1653
1654 host->pd = ib_alloc_pd(device);
1655 if (IS_ERR(host->pd))
1656 goto err_free;
1657
1658 host->mr = ib_get_dma_mr(host->pd,
1659 IB_ACCESS_LOCAL_WRITE |
1660 IB_ACCESS_REMOTE_READ |
1661 IB_ACCESS_REMOTE_WRITE);
1662 if (IS_ERR(host->mr))
1663 goto err_pd;
1664 1797
1665 host->class_dev.class = &srp_class; 1798 host->class_dev.class = &srp_class;
1666 host->class_dev.dev = device->dma_device; 1799 host->class_dev.dev = device->dev->dma_device;
1667 snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", 1800 snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d",
1668 device->name, port); 1801 device->dev->name, port);
1669 1802
1670 if (class_device_register(&host->class_dev)) 1803 if (class_device_register(&host->class_dev))
1671 goto err_mr; 1804 goto free_host;
1672 if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) 1805 if (class_device_create_file(&host->class_dev, &class_device_attr_add_target))
1673 goto err_class; 1806 goto err_class;
1674 if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) 1807 if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev))
@@ -1681,13 +1814,7 @@ static struct srp_host *srp_add_port(struct ib_device *device, u8 port)
1681err_class: 1814err_class:
1682 class_device_unregister(&host->class_dev); 1815 class_device_unregister(&host->class_dev);
1683 1816
1684err_mr: 1817free_host:
1685 ib_dereg_mr(host->mr);
1686
1687err_pd:
1688 ib_dealloc_pd(host->pd);
1689
1690err_free:
1691 kfree(host); 1818 kfree(host);
1692 1819
1693 return NULL; 1820 return NULL;
@@ -1695,15 +1822,62 @@ err_free:
1695 1822
1696static void srp_add_one(struct ib_device *device) 1823static void srp_add_one(struct ib_device *device)
1697{ 1824{
1698 struct list_head *dev_list; 1825 struct srp_device *srp_dev;
1826 struct ib_device_attr *dev_attr;
1827 struct ib_fmr_pool_param fmr_param;
1699 struct srp_host *host; 1828 struct srp_host *host;
1700 int s, e, p; 1829 int s, e, p;
1701 1830
1702 dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL); 1831 dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL);
1703 if (!dev_list) 1832 if (!dev_attr)
1704 return; 1833 return;
1705 1834
1706 INIT_LIST_HEAD(dev_list); 1835 if (ib_query_device(device, dev_attr)) {
1836 printk(KERN_WARNING PFX "Query device failed for %s\n",
1837 device->name);
1838 goto free_attr;
1839 }
1840
1841 srp_dev = kmalloc(sizeof *srp_dev, GFP_KERNEL);
1842 if (!srp_dev)
1843 goto free_attr;
1844
1845 /*
1846 * Use the smallest page size supported by the HCA, down to a
1847 * minimum of 512 bytes (which is the smallest sector that a
1848 * SCSI command will ever carry).
1849 */
1850 srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1);
1851 srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift;
1852 srp_dev->fmr_page_mask = ~((unsigned long) srp_dev->fmr_page_size - 1);
1853
1854 INIT_LIST_HEAD(&srp_dev->dev_list);
1855
1856 srp_dev->dev = device;
1857 srp_dev->pd = ib_alloc_pd(device);
1858 if (IS_ERR(srp_dev->pd))
1859 goto free_dev;
1860
1861 srp_dev->mr = ib_get_dma_mr(srp_dev->pd,
1862 IB_ACCESS_LOCAL_WRITE |
1863 IB_ACCESS_REMOTE_READ |
1864 IB_ACCESS_REMOTE_WRITE);
1865 if (IS_ERR(srp_dev->mr))
1866 goto err_pd;
1867
1868 memset(&fmr_param, 0, sizeof fmr_param);
1869 fmr_param.pool_size = SRP_FMR_POOL_SIZE;
1870 fmr_param.dirty_watermark = SRP_FMR_DIRTY_SIZE;
1871 fmr_param.cache = 1;
1872 fmr_param.max_pages_per_fmr = SRP_FMR_SIZE;
1873 fmr_param.page_shift = srp_dev->fmr_page_shift;
1874 fmr_param.access = (IB_ACCESS_LOCAL_WRITE |
1875 IB_ACCESS_REMOTE_WRITE |
1876 IB_ACCESS_REMOTE_READ);
1877
1878 srp_dev->fmr_pool = ib_create_fmr_pool(srp_dev->pd, &fmr_param);
1879 if (IS_ERR(srp_dev->fmr_pool))
1880 srp_dev->fmr_pool = NULL;
1707 1881
1708 if (device->node_type == IB_NODE_SWITCH) { 1882 if (device->node_type == IB_NODE_SWITCH) {
1709 s = 0; 1883 s = 0;
@@ -1714,25 +1888,35 @@ static void srp_add_one(struct ib_device *device)
1714 } 1888 }
1715 1889
1716 for (p = s; p <= e; ++p) { 1890 for (p = s; p <= e; ++p) {
1717 host = srp_add_port(device, p); 1891 host = srp_add_port(srp_dev, p);
1718 if (host) 1892 if (host)
1719 list_add_tail(&host->list, dev_list); 1893 list_add_tail(&host->list, &srp_dev->dev_list);
1720 } 1894 }
1721 1895
1722 ib_set_client_data(device, &srp_client, dev_list); 1896 ib_set_client_data(device, &srp_client, srp_dev);
1897
1898 goto free_attr;
1899
1900err_pd:
1901 ib_dealloc_pd(srp_dev->pd);
1902
1903free_dev:
1904 kfree(srp_dev);
1905
1906free_attr:
1907 kfree(dev_attr);
1723} 1908}
1724 1909
1725static void srp_remove_one(struct ib_device *device) 1910static void srp_remove_one(struct ib_device *device)
1726{ 1911{
1727 struct list_head *dev_list; 1912 struct srp_device *srp_dev;
1728 struct srp_host *host, *tmp_host; 1913 struct srp_host *host, *tmp_host;
1729 LIST_HEAD(target_list); 1914 LIST_HEAD(target_list);
1730 struct srp_target_port *target, *tmp_target; 1915 struct srp_target_port *target, *tmp_target;
1731 unsigned long flags;
1732 1916
1733 dev_list = ib_get_client_data(device, &srp_client); 1917 srp_dev = ib_get_client_data(device, &srp_client);
1734 1918
1735 list_for_each_entry_safe(host, tmp_host, dev_list, list) { 1919 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
1736 class_device_unregister(&host->class_dev); 1920 class_device_unregister(&host->class_dev);
1737 /* 1921 /*
1738 * Wait for the sysfs entry to go away, so that no new 1922 * Wait for the sysfs entry to go away, so that no new
@@ -1744,15 +1928,13 @@ static void srp_remove_one(struct ib_device *device)
1744 * Mark all target ports as removed, so we stop queueing 1928 * Mark all target ports as removed, so we stop queueing
1745 * commands and don't try to reconnect. 1929 * commands and don't try to reconnect.
1746 */ 1930 */
1747 mutex_lock(&host->target_mutex); 1931 spin_lock(&host->target_lock);
1748 list_for_each_entry_safe(target, tmp_target, 1932 list_for_each_entry(target, &host->target_list, list) {
1749 &host->target_list, list) { 1933 spin_lock_irq(target->scsi_host->host_lock);
1750 spin_lock_irqsave(target->scsi_host->host_lock, flags); 1934 target->state = SRP_TARGET_REMOVED;
1751 if (target->state != SRP_TARGET_REMOVED) 1935 spin_unlock_irq(target->scsi_host->host_lock);
1752 target->state = SRP_TARGET_REMOVED;
1753 spin_unlock_irqrestore(target->scsi_host->host_lock, flags);
1754 } 1936 }
1755 mutex_unlock(&host->target_mutex); 1937 spin_unlock(&host->target_lock);
1756 1938
1757 /* 1939 /*
1758 * Wait for any reconnection tasks that may have 1940 * Wait for any reconnection tasks that may have
@@ -1770,18 +1952,26 @@ static void srp_remove_one(struct ib_device *device)
1770 scsi_host_put(target->scsi_host); 1952 scsi_host_put(target->scsi_host);
1771 } 1953 }
1772 1954
1773 ib_dereg_mr(host->mr);
1774 ib_dealloc_pd(host->pd);
1775 kfree(host); 1955 kfree(host);
1776 } 1956 }
1777 1957
1778 kfree(dev_list); 1958 if (srp_dev->fmr_pool)
1959 ib_destroy_fmr_pool(srp_dev->fmr_pool);
1960 ib_dereg_mr(srp_dev->mr);
1961 ib_dealloc_pd(srp_dev->pd);
1962
1963 kfree(srp_dev);
1779} 1964}
1780 1965
1781static int __init srp_init_module(void) 1966static int __init srp_init_module(void)
1782{ 1967{
1783 int ret; 1968 int ret;
1784 1969
1970 srp_template.sg_tablesize = srp_sg_tablesize;
1971 srp_max_iu_len = (sizeof (struct srp_cmd) +
1972 sizeof (struct srp_indirect_buf) +
1973 srp_sg_tablesize * 16);
1974
1785 ret = class_register(&srp_class); 1975 ret = class_register(&srp_class);
1786 if (ret) { 1976 if (ret) {
1787 printk(KERN_ERR PFX "couldn't register class infiniband_srp\n"); 1977 printk(KERN_ERR PFX "couldn't register class infiniband_srp\n");
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index c5cd43aae860..5b581fb8eb0d 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -46,6 +46,7 @@
46#include <rdma/ib_verbs.h> 46#include <rdma/ib_verbs.h>
47#include <rdma/ib_sa.h> 47#include <rdma/ib_sa.h>
48#include <rdma/ib_cm.h> 48#include <rdma/ib_cm.h>
49#include <rdma/ib_fmr_pool.h>
49 50
50enum { 51enum {
51 SRP_PATH_REC_TIMEOUT_MS = 1000, 52 SRP_PATH_REC_TIMEOUT_MS = 1000,
@@ -55,20 +56,21 @@ enum {
55 SRP_DLID_REDIRECT = 2, 56 SRP_DLID_REDIRECT = 2,
56 57
57 SRP_MAX_LUN = 512, 58 SRP_MAX_LUN = 512,
58 SRP_MAX_IU_LEN = 256, 59 SRP_DEF_SG_TABLESIZE = 12,
59 60
60 SRP_RQ_SHIFT = 6, 61 SRP_RQ_SHIFT = 6,
61 SRP_RQ_SIZE = 1 << SRP_RQ_SHIFT, 62 SRP_RQ_SIZE = 1 << SRP_RQ_SHIFT,
62 SRP_SQ_SIZE = SRP_RQ_SIZE - 1, 63 SRP_SQ_SIZE = SRP_RQ_SIZE - 1,
63 SRP_CQ_SIZE = SRP_SQ_SIZE + SRP_RQ_SIZE, 64 SRP_CQ_SIZE = SRP_SQ_SIZE + SRP_RQ_SIZE,
64 65
65 SRP_TAG_TSK_MGMT = 1 << (SRP_RQ_SHIFT + 1) 66 SRP_TAG_TSK_MGMT = 1 << (SRP_RQ_SHIFT + 1),
67
68 SRP_FMR_SIZE = 256,
69 SRP_FMR_POOL_SIZE = 1024,
70 SRP_FMR_DIRTY_SIZE = SRP_FMR_POOL_SIZE / 4
66}; 71};
67 72
68#define SRP_OP_RECV (1 << 31) 73#define SRP_OP_RECV (1 << 31)
69#define SRP_MAX_INDIRECT ((SRP_MAX_IU_LEN - \
70 sizeof (struct srp_cmd) - \
71 sizeof (struct srp_indirect_buf)) / 16)
72 74
73enum srp_target_state { 75enum srp_target_state {
74 SRP_TARGET_LIVE, 76 SRP_TARGET_LIVE,
@@ -77,15 +79,24 @@ enum srp_target_state {
77 SRP_TARGET_REMOVED 79 SRP_TARGET_REMOVED
78}; 80};
79 81
80struct srp_host { 82struct srp_device {
81 u8 initiator_port_id[16]; 83 struct list_head dev_list;
82 struct ib_device *dev; 84 struct ib_device *dev;
83 u8 port;
84 struct ib_pd *pd; 85 struct ib_pd *pd;
85 struct ib_mr *mr; 86 struct ib_mr *mr;
87 struct ib_fmr_pool *fmr_pool;
88 int fmr_page_shift;
89 int fmr_page_size;
90 unsigned long fmr_page_mask;
91};
92
93struct srp_host {
94 u8 initiator_port_id[16];
95 struct srp_device *dev;
96 u8 port;
86 struct class_device class_dev; 97 struct class_device class_dev;
87 struct list_head target_list; 98 struct list_head target_list;
88 struct mutex target_mutex; 99 spinlock_t target_lock;
89 struct completion released; 100 struct completion released;
90 struct list_head list; 101 struct list_head list;
91}; 102};
@@ -95,6 +106,7 @@ struct srp_request {
95 struct scsi_cmnd *scmnd; 106 struct scsi_cmnd *scmnd;
96 struct srp_iu *cmd; 107 struct srp_iu *cmd;
97 struct srp_iu *tsk_mgmt; 108 struct srp_iu *tsk_mgmt;
109 struct ib_pool_fmr *fmr;
98 /* 110 /*
99 * Fake scatterlist used when scmnd->use_sg==0. Can be killed 111 * Fake scatterlist used when scmnd->use_sg==0. Can be killed
100 * when the SCSI midlayer no longer generates non-SG commands. 112 * when the SCSI midlayer no longer generates non-SG commands.
@@ -110,6 +122,7 @@ struct srp_target_port {
110 __be64 id_ext; 122 __be64 id_ext;
111 __be64 ioc_guid; 123 __be64 ioc_guid;
112 __be64 service_id; 124 __be64 service_id;
125 u16 io_class;
113 struct srp_host *srp_host; 126 struct srp_host *srp_host;
114 struct Scsi_Host *scsi_host; 127 struct Scsi_Host *scsi_host;
115 char target_name[32]; 128 char target_name[32];
@@ -126,6 +139,8 @@ struct srp_target_port {
126 int max_ti_iu_len; 139 int max_ti_iu_len;
127 s32 req_lim; 140 s32 req_lim;
128 141
142 int zero_req_lim;
143
129 unsigned rx_head; 144 unsigned rx_head;
130 struct srp_iu *rx_ring[SRP_RQ_SIZE]; 145 struct srp_iu *rx_ring[SRP_RQ_SIZE];
131 146
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 2f0f35811bf7..9fd87521a163 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1052,7 +1052,7 @@ static void wq_set_multicast_list (void *data)
1052 1052
1053 dvb_net_feed_stop(dev); 1053 dvb_net_feed_stop(dev);
1054 priv->rx_mode = RX_MODE_UNI; 1054 priv->rx_mode = RX_MODE_UNI;
1055 spin_lock_bh(&dev->xmit_lock); 1055 netif_tx_lock_bh(dev);
1056 1056
1057 if (dev->flags & IFF_PROMISC) { 1057 if (dev->flags & IFF_PROMISC) {
1058 dprintk("%s: promiscuous mode\n", dev->name); 1058 dprintk("%s: promiscuous mode\n", dev->name);
@@ -1077,7 +1077,7 @@ static void wq_set_multicast_list (void *data)
1077 } 1077 }
1078 } 1078 }
1079 1079
1080 spin_unlock_bh(&dev->xmit_lock); 1080 netif_tx_unlock_bh(dev);
1081 dvb_net_feed_start(dev); 1081 dvb_net_feed_start(dev);
1082} 1082}
1083 1083
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index f2a4d382ea19..3201de053943 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -831,6 +831,7 @@ mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
831 return rc; 831 return rc;
832} 832}
833 833
834#ifdef CONFIG_PM
834/* 835/*
835 * spi module resume handler 836 * spi module resume handler
836 */ 837 */
@@ -846,6 +847,7 @@ mptspi_resume(struct pci_dev *pdev)
846 847
847 return rc; 848 return rc;
848} 849}
850#endif
849 851
850/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 852/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
851/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 853/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 5ea133c59afb..7bd4d85d0b42 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -55,6 +55,7 @@ struct i2o_exec_wait {
55 u32 m; /* message id */ 55 u32 m; /* message id */
56 struct i2o_message *msg; /* pointer to the reply message */ 56 struct i2o_message *msg; /* pointer to the reply message */
57 struct list_head list; /* node in global wait list */ 57 struct list_head list; /* node in global wait list */
58 spinlock_t lock; /* lock before modifying */
58}; 59};
59 60
60/* Work struct needed to handle LCT NOTIFY replies */ 61/* Work struct needed to handle LCT NOTIFY replies */
@@ -87,6 +88,7 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
87 return NULL; 88 return NULL;
88 89
89 INIT_LIST_HEAD(&wait->list); 90 INIT_LIST_HEAD(&wait->list);
91 spin_lock_init(&wait->lock);
90 92
91 return wait; 93 return wait;
92}; 94};
@@ -125,6 +127,7 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
125 DECLARE_WAIT_QUEUE_HEAD(wq); 127 DECLARE_WAIT_QUEUE_HEAD(wq);
126 struct i2o_exec_wait *wait; 128 struct i2o_exec_wait *wait;
127 static u32 tcntxt = 0x80000000; 129 static u32 tcntxt = 0x80000000;
130 long flags;
128 int rc = 0; 131 int rc = 0;
129 132
130 wait = i2o_exec_wait_alloc(); 133 wait = i2o_exec_wait_alloc();
@@ -146,33 +149,28 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
146 wait->tcntxt = tcntxt++; 149 wait->tcntxt = tcntxt++;
147 msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt); 150 msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt);
148 151
152 wait->wq = &wq;
153 /*
154 * we add elements to the head, because if a entry in the list will
155 * never be removed, we have to iterate over it every time
156 */
157 list_add(&wait->list, &i2o_exec_wait_list);
158
149 /* 159 /*
150 * Post the message to the controller. At some point later it will 160 * Post the message to the controller. At some point later it will
151 * return. If we time out before it returns then complete will be zero. 161 * return. If we time out before it returns then complete will be zero.
152 */ 162 */
153 i2o_msg_post(c, msg); 163 i2o_msg_post(c, msg);
154 164
155 if (!wait->complete) { 165 wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ);
156 wait->wq = &wq;
157 /*
158 * we add elements add the head, because if a entry in the list
159 * will never be removed, we have to iterate over it every time
160 */
161 list_add(&wait->list, &i2o_exec_wait_list);
162
163 wait_event_interruptible_timeout(wq, wait->complete,
164 timeout * HZ);
165 166
166 wait->wq = NULL; 167 spin_lock_irqsave(&wait->lock, flags);
167 }
168 168
169 barrier(); 169 wait->wq = NULL;
170 170
171 if (wait->complete) { 171 if (wait->complete)
172 rc = le32_to_cpu(wait->msg->body[0]) >> 24; 172 rc = le32_to_cpu(wait->msg->body[0]) >> 24;
173 i2o_flush_reply(c, wait->m); 173 else {
174 i2o_exec_wait_free(wait);
175 } else {
176 /* 174 /*
177 * We cannot remove it now. This is important. When it does 175 * We cannot remove it now. This is important. When it does
178 * terminate (which it must do if the controller has not 176 * terminate (which it must do if the controller has not
@@ -186,6 +184,13 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
186 rc = -ETIMEDOUT; 184 rc = -ETIMEDOUT;
187 } 185 }
188 186
187 spin_unlock_irqrestore(&wait->lock, flags);
188
189 if (rc != -ETIMEDOUT) {
190 i2o_flush_reply(c, wait->m);
191 i2o_exec_wait_free(wait);
192 }
193
189 return rc; 194 return rc;
190}; 195};
191 196
@@ -213,7 +218,6 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
213{ 218{
214 struct i2o_exec_wait *wait, *tmp; 219 struct i2o_exec_wait *wait, *tmp;
215 unsigned long flags; 220 unsigned long flags;
216 static spinlock_t lock = SPIN_LOCK_UNLOCKED;
217 int rc = 1; 221 int rc = 1;
218 222
219 /* 223 /*
@@ -223,23 +227,24 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
223 * already expired. Not much we can do about that except log it for 227 * already expired. Not much we can do about that except log it for
224 * debug purposes, increase timeout, and recompile. 228 * debug purposes, increase timeout, and recompile.
225 */ 229 */
226 spin_lock_irqsave(&lock, flags);
227 list_for_each_entry_safe(wait, tmp, &i2o_exec_wait_list, list) { 230 list_for_each_entry_safe(wait, tmp, &i2o_exec_wait_list, list) {
228 if (wait->tcntxt == context) { 231 if (wait->tcntxt == context) {
229 list_del(&wait->list); 232 spin_lock_irqsave(&wait->lock, flags);
230 233
231 spin_unlock_irqrestore(&lock, flags); 234 list_del(&wait->list);
232 235
233 wait->m = m; 236 wait->m = m;
234 wait->msg = msg; 237 wait->msg = msg;
235 wait->complete = 1; 238 wait->complete = 1;
236 239
237 barrier(); 240 if (wait->wq)
238
239 if (wait->wq) {
240 wake_up_interruptible(wait->wq);
241 rc = 0; 241 rc = 0;
242 } else { 242 else
243 rc = -1;
244
245 spin_unlock_irqrestore(&wait->lock, flags);
246
247 if (rc) {
243 struct device *dev; 248 struct device *dev;
244 249
245 dev = &c->pdev->dev; 250 dev = &c->pdev->dev;
@@ -248,15 +253,13 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
248 c->name); 253 c->name);
249 i2o_dma_free(dev, &wait->dma); 254 i2o_dma_free(dev, &wait->dma);
250 i2o_exec_wait_free(wait); 255 i2o_exec_wait_free(wait);
251 rc = -1; 256 } else
252 } 257 wake_up_interruptible(wait->wq);
253 258
254 return rc; 259 return rc;
255 } 260 }
256 } 261 }
257 262
258 spin_unlock_irqrestore(&lock, flags);
259
260 osm_warn("%s: Bogus reply in POST WAIT (tr-context: %08x)!\n", c->name, 263 osm_warn("%s: Bogus reply in POST WAIT (tr-context: %08x)!\n", c->name,
261 context); 264 context);
262 265
@@ -322,14 +325,9 @@ static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
322static int i2o_exec_probe(struct device *dev) 325static int i2o_exec_probe(struct device *dev)
323{ 326{
324 struct i2o_device *i2o_dev = to_i2o_device(dev); 327 struct i2o_device *i2o_dev = to_i2o_device(dev);
325 struct i2o_controller *c = i2o_dev->iop;
326 328
327 i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff); 329 i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
328 330
329 c->exec = i2o_dev;
330
331 i2o_exec_lct_notify(c, c->lct->change_ind + 1);
332
333 device_create_file(dev, &dev_attr_vendor_id); 331 device_create_file(dev, &dev_attr_vendor_id);
334 device_create_file(dev, &dev_attr_product_id); 332 device_create_file(dev, &dev_attr_product_id);
335 333
@@ -523,6 +521,8 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
523 struct device *dev; 521 struct device *dev;
524 struct i2o_message *msg; 522 struct i2o_message *msg;
525 523
524 down(&c->lct_lock);
525
526 dev = &c->pdev->dev; 526 dev = &c->pdev->dev;
527 527
528 if (i2o_dma_realloc 528 if (i2o_dma_realloc
@@ -545,6 +545,8 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
545 545
546 i2o_msg_post(c, msg); 546 i2o_msg_post(c, msg);
547 547
548 up(&c->lct_lock);
549
548 return 0; 550 return 0;
549}; 551};
550 552
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 492167446936..febbdd4e0605 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -804,8 +804,6 @@ void i2o_iop_remove(struct i2o_controller *c)
804 804
805 /* Ask the IOP to switch to RESET state */ 805 /* Ask the IOP to switch to RESET state */
806 i2o_iop_reset(c); 806 i2o_iop_reset(c);
807
808 put_device(&c->device);
809} 807}
810 808
811/** 809/**
@@ -1059,7 +1057,7 @@ struct i2o_controller *i2o_iop_alloc(void)
1059 1057
1060 snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name); 1058 snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name);
1061 if (i2o_pool_alloc 1059 if (i2o_pool_alloc
1062 (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4, 1060 (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4 + sizeof(u32),
1063 I2O_MSG_INPOOL_MIN)) { 1061 I2O_MSG_INPOOL_MIN)) {
1064 kfree(c); 1062 kfree(c);
1065 return ERR_PTR(-ENOMEM); 1063 return ERR_PTR(-ENOMEM);
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index f6d51ce34b00..bb44509fd404 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -909,7 +909,7 @@ MODULE_PARM_DESC(irq, "EtherLink IRQ number");
909 * here also causes the module to be unloaded 909 * here also causes the module to be unloaded
910 */ 910 */
911 911
912int init_module(void) 912int __init init_module(void)
913{ 913{
914 dev_3c501 = el1_probe(-1); 914 dev_3c501 = el1_probe(-1);
915 if (IS_ERR(dev_3c501)) 915 if (IS_ERR(dev_3c501))
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index dcc98afa65d7..cb5ef75450dc 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -688,7 +688,7 @@ MODULE_LICENSE("GPL");
688 688
689/* This is set up so that only a single autoprobe takes place per call. 689/* This is set up so that only a single autoprobe takes place per call.
690ISA device autoprobes on a running machine are not recommended. */ 690ISA device autoprobes on a running machine are not recommended. */
691int 691int __init
692init_module(void) 692init_module(void)
693{ 693{
694 struct net_device *dev; 694 struct net_device *dev;
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 111601ca4ca3..19c0b856c488 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -1633,7 +1633,7 @@ MODULE_PARM_DESC(io, "EtherLink Plus I/O base address(es)");
1633MODULE_PARM_DESC(irq, "EtherLink Plus IRQ number(s) (assigned)"); 1633MODULE_PARM_DESC(irq, "EtherLink Plus IRQ number(s) (assigned)");
1634MODULE_PARM_DESC(dma, "EtherLink Plus DMA channel(s)"); 1634MODULE_PARM_DESC(dma, "EtherLink Plus DMA channel(s)");
1635 1635
1636int init_module(void) 1636int __init init_module(void)
1637{ 1637{
1638 int this_dev, found = 0; 1638 int this_dev, found = 0;
1639 1639
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c
index 4db82893909c..6039049259ed 100644
--- a/drivers/net/3c507.c
+++ b/drivers/net/3c507.c
@@ -932,7 +932,7 @@ module_param(irq, int, 0);
932MODULE_PARM_DESC(io, "EtherLink16 I/O base address"); 932MODULE_PARM_DESC(io, "EtherLink16 I/O base address");
933MODULE_PARM_DESC(irq, "(ignored)"); 933MODULE_PARM_DESC(irq, "(ignored)");
934 934
935int init_module(void) 935int __init init_module(void)
936{ 936{
937 if (io == 0) 937 if (io == 0)
938 printk("3c507: You should not use auto-probing with insmod!\n"); 938 printk("3c507: You should not use auto-probing with insmod!\n");
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index b40885d41680..4bf8510655c5 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -1277,7 +1277,7 @@ MODULE_PARM_DESC(io, "EtherLink/MC I/O base address(es)");
1277MODULE_PARM_DESC(irq, "EtherLink/MC IRQ number(s)"); 1277MODULE_PARM_DESC(irq, "EtherLink/MC IRQ number(s)");
1278MODULE_LICENSE("GPL"); 1278MODULE_LICENSE("GPL");
1279 1279
1280int init_module(void) 1280int __init init_module(void)
1281{ 1281{
1282 int this_dev,found = 0; 1282 int this_dev,found = 0;
1283 1283
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index 6db3301e7965..1b1cb0026072 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -1646,7 +1646,7 @@ static struct net_device *this_device;
1646 * insmod multiple modules for now but it's a hack. 1646 * insmod multiple modules for now but it's a hack.
1647 */ 1647 */
1648 1648
1649int init_module(void) 1649int __init init_module(void)
1650{ 1650{
1651 this_device = mc32_probe(-1); 1651 this_device = mc32_probe(-1);
1652 if (IS_ERR(this_device)) 1652 if (IS_ERR(this_device))
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 066e22b01a94..46d8c01437e9 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -19,11 +19,11 @@
19 See the file COPYING in this distribution for more information. 19 See the file COPYING in this distribution for more information.
20 20
21 Contributors: 21 Contributors:
22 22
23 Wake-on-LAN support - Felipe Damasio <felipewd@terra.com.br> 23 Wake-on-LAN support - Felipe Damasio <felipewd@terra.com.br>
24 PCI suspend/resume - Felipe Damasio <felipewd@terra.com.br> 24 PCI suspend/resume - Felipe Damasio <felipewd@terra.com.br>
25 LinkChg interrupt - Felipe Damasio <felipewd@terra.com.br> 25 LinkChg interrupt - Felipe Damasio <felipewd@terra.com.br>
26 26
27 TODO: 27 TODO:
28 * Test Tx checksumming thoroughly 28 * Test Tx checksumming thoroughly
29 * Implement dev->tx_timeout 29 * Implement dev->tx_timeout
@@ -461,7 +461,7 @@ static void cp_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
461static inline void cp_set_rxbufsize (struct cp_private *cp) 461static inline void cp_set_rxbufsize (struct cp_private *cp)
462{ 462{
463 unsigned int mtu = cp->dev->mtu; 463 unsigned int mtu = cp->dev->mtu;
464 464
465 if (mtu > ETH_DATA_LEN) 465 if (mtu > ETH_DATA_LEN)
466 /* MTU + ethernet header + FCS + optional VLAN tag */ 466 /* MTU + ethernet header + FCS + optional VLAN tag */
467 cp->rx_buf_sz = mtu + ETH_HLEN + 8; 467 cp->rx_buf_sz = mtu + ETH_HLEN + 8;
@@ -510,7 +510,7 @@ static void cp_rx_err_acct (struct cp_private *cp, unsigned rx_tail,
510static inline unsigned int cp_rx_csum_ok (u32 status) 510static inline unsigned int cp_rx_csum_ok (u32 status)
511{ 511{
512 unsigned int protocol = (status >> 16) & 0x3; 512 unsigned int protocol = (status >> 16) & 0x3;
513 513
514 if (likely((protocol == RxProtoTCP) && (!(status & TCPFail)))) 514 if (likely((protocol == RxProtoTCP) && (!(status & TCPFail))))
515 return 1; 515 return 1;
516 else if ((protocol == RxProtoUDP) && (!(status & UDPFail))) 516 else if ((protocol == RxProtoUDP) && (!(status & UDPFail)))
@@ -1061,7 +1061,7 @@ static void cp_init_hw (struct cp_private *cp)
1061 cpw8(Config3, PARMEnable); 1061 cpw8(Config3, PARMEnable);
1062 cp->wol_enabled = 0; 1062 cp->wol_enabled = 0;
1063 1063
1064 cpw8(Config5, cpr8(Config5) & PMEStatus); 1064 cpw8(Config5, cpr8(Config5) & PMEStatus);
1065 1065
1066 cpw32_f(HiTxRingAddr, 0); 1066 cpw32_f(HiTxRingAddr, 0);
1067 cpw32_f(HiTxRingAddr + 4, 0); 1067 cpw32_f(HiTxRingAddr + 4, 0);
@@ -1351,7 +1351,7 @@ static void netdev_get_wol (struct cp_private *cp,
1351 WAKE_MCAST | WAKE_UCAST; 1351 WAKE_MCAST | WAKE_UCAST;
1352 /* We don't need to go on if WOL is disabled */ 1352 /* We don't need to go on if WOL is disabled */
1353 if (!cp->wol_enabled) return; 1353 if (!cp->wol_enabled) return;
1354 1354
1355 options = cpr8 (Config3); 1355 options = cpr8 (Config3);
1356 if (options & LinkUp) wol->wolopts |= WAKE_PHY; 1356 if (options & LinkUp) wol->wolopts |= WAKE_PHY;
1357 if (options & MagicPacket) wol->wolopts |= WAKE_MAGIC; 1357 if (options & MagicPacket) wol->wolopts |= WAKE_MAGIC;
@@ -1919,7 +1919,7 @@ static int cp_resume (struct pci_dev *pdev)
1919 mii_check_media(&cp->mii_if, netif_msg_link(cp), FALSE); 1919 mii_check_media(&cp->mii_if, netif_msg_link(cp), FALSE);
1920 1920
1921 spin_unlock_irqrestore (&cp->lock, flags); 1921 spin_unlock_irqrestore (&cp->lock, flags);
1922 1922
1923 return 0; 1923 return 0;
1924} 1924}
1925#endif /* CONFIG_PM */ 1925#endif /* CONFIG_PM */
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index feae7832fc84..abd6261465f1 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -165,7 +165,7 @@ static int multicast_filter_limit = 32;
165static int debug = -1; 165static int debug = -1;
166 166
167/* 167/*
168 * Receive ring size 168 * Receive ring size
169 * Warning: 64K ring has hardware issues and may lock up. 169 * Warning: 64K ring has hardware issues and may lock up.
170 */ 170 */
171#if defined(CONFIG_SH_DREAMCAST) 171#if defined(CONFIG_SH_DREAMCAST)
@@ -257,7 +257,7 @@ static struct pci_device_id rtl8139_pci_tbl[] = {
257 {0x018a, 0x0106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 257 {0x018a, 0x0106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
258 {0x126c, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 258 {0x126c, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
259 {0x1743, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 259 {0x1743, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
260 {0x021b, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 260 {0x021b, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
261 261
262#ifdef CONFIG_SH_SECUREEDGE5410 262#ifdef CONFIG_SH_SECUREEDGE5410
263 /* Bogus 8139 silicon reports 8129 without external PROM :-( */ 263 /* Bogus 8139 silicon reports 8129 without external PROM :-( */
@@ -1824,7 +1824,7 @@ static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
1824 int tmp_work; 1824 int tmp_work;
1825#endif 1825#endif
1826 1826
1827 if (netif_msg_rx_err (tp)) 1827 if (netif_msg_rx_err (tp))
1828 printk(KERN_DEBUG "%s: Ethernet frame had errors, status %8.8x.\n", 1828 printk(KERN_DEBUG "%s: Ethernet frame had errors, status %8.8x.\n",
1829 dev->name, rx_status); 1829 dev->name, rx_status);
1830 tp->stats.rx_errors++; 1830 tp->stats.rx_errors++;
@@ -1944,7 +1944,7 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1944 RTL_R16 (RxBufAddr), 1944 RTL_R16 (RxBufAddr),
1945 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); 1945 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
1946 1946
1947 while (netif_running(dev) && received < budget 1947 while (netif_running(dev) && received < budget
1948 && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { 1948 && (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
1949 u32 ring_offset = cur_rx % RX_BUF_LEN; 1949 u32 ring_offset = cur_rx % RX_BUF_LEN;
1950 u32 rx_status; 1950 u32 rx_status;
@@ -2031,7 +2031,7 @@ no_early_rx:
2031 2031
2032 netif_receive_skb (skb); 2032 netif_receive_skb (skb);
2033 } else { 2033 } else {
2034 if (net_ratelimit()) 2034 if (net_ratelimit())
2035 printk (KERN_WARNING 2035 printk (KERN_WARNING
2036 "%s: Memory squeeze, dropping packet.\n", 2036 "%s: Memory squeeze, dropping packet.\n",
2037 dev->name); 2037 dev->name);
@@ -2158,13 +2158,13 @@ static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
2158 status = RTL_R16 (IntrStatus); 2158 status = RTL_R16 (IntrStatus);
2159 2159
2160 /* shared irq? */ 2160 /* shared irq? */
2161 if (unlikely((status & rtl8139_intr_mask) == 0)) 2161 if (unlikely((status & rtl8139_intr_mask) == 0))
2162 goto out; 2162 goto out;
2163 2163
2164 handled = 1; 2164 handled = 1;
2165 2165
2166 /* h/w no longer present (hotplug?) or major error, bail */ 2166 /* h/w no longer present (hotplug?) or major error, bail */
2167 if (unlikely(status == 0xFFFF)) 2167 if (unlikely(status == 0xFFFF))
2168 goto out; 2168 goto out;
2169 2169
2170 /* close possible race's with dev_close */ 2170 /* close possible race's with dev_close */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index bdaaad8f2123..0c6b45a11d15 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -447,6 +447,7 @@ config MIPS_GT96100ETH
447config MIPS_AU1X00_ENET 447config MIPS_AU1X00_ENET
448 bool "MIPS AU1000 Ethernet support" 448 bool "MIPS AU1000 Ethernet support"
449 depends on NET_ETHERNET && SOC_AU1X00 449 depends on NET_ETHERNET && SOC_AU1X00
450 select PHYLIB
450 select CRC32 451 select CRC32
451 help 452 help
452 If you have an Alchemy Semi AU1X00 based system 453 If you have an Alchemy Semi AU1X00 based system
@@ -865,6 +866,22 @@ config DM9000
865 <file:Documentation/networking/net-modules.txt>. The module will be 866 <file:Documentation/networking/net-modules.txt>. The module will be
866 called dm9000. 867 called dm9000.
867 868
869config SMC911X
870 tristate "SMSC LAN911[5678] support"
871 select CRC32
872 select MII
873 depends on NET_ETHERNET && ARCH_PXA
874 help
875 This is a driver for SMSC's LAN911x series of Ethernet chipsets
876 including the new LAN9115, LAN9116, LAN9117, and LAN9118.
877 Say Y if you want it compiled into the kernel,
878 and read the Ethernet-HOWTO, available from
879 <http://www.linuxdoc.org/docs.html#howto>.
880
881 This driver is also available as a module. The module will be
882 called smc911x. If you want to compile it as a module, say M
883 here and read <file:Documentation/modules.txt>
884
868config NET_VENDOR_RACAL 885config NET_VENDOR_RACAL
869 bool "Racal-Interlan (Micom) NI cards" 886 bool "Racal-Interlan (Micom) NI cards"
870 depends on NET_ETHERNET && ISA 887 depends on NET_ETHERNET && ISA
@@ -2163,6 +2180,8 @@ config TIGON3
2163config BNX2 2180config BNX2
2164 tristate "Broadcom NetXtremeII support" 2181 tristate "Broadcom NetXtremeII support"
2165 depends on PCI 2182 depends on PCI
2183 select CRC32
2184 select ZLIB_INFLATE
2166 help 2185 help
2167 This driver supports Broadcom NetXtremeII gigabit Ethernet cards. 2186 This driver supports Broadcom NetXtremeII gigabit Ethernet cards.
2168 2187
@@ -2311,6 +2330,23 @@ config S2IO_NAPI
2311 2330
2312 If in doubt, say N. 2331 If in doubt, say N.
2313 2332
2333config MYRI10GE
2334 tristate "Myricom Myri-10G Ethernet support"
2335 depends on PCI
2336 select FW_LOADER
2337 select CRC32
2338 ---help---
2339 This driver supports Myricom Myri-10G Dual Protocol interface in
2340 Ethernet mode. If the eeprom on your board is not recent enough,
2341 you will need a newer firmware image.
2342 You may get this image or more information, at:
2343
2344 <http://www.myri.com/Myri-10G/>
2345
2346 To compile this driver as a module, choose M here and read
2347 <file:Documentation/networking/net-modules.txt>. The module
2348 will be called myri10ge.
2349
2314endmenu 2350endmenu
2315 2351
2316source "drivers/net/tokenring/Kconfig" 2352source "drivers/net/tokenring/Kconfig"
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index b90468aea077..1eced3287507 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -192,7 +192,9 @@ obj-$(CONFIG_R8169) += r8169.o
192obj-$(CONFIG_AMD8111_ETH) += amd8111e.o 192obj-$(CONFIG_AMD8111_ETH) += amd8111e.o
193obj-$(CONFIG_IBMVETH) += ibmveth.o 193obj-$(CONFIG_IBMVETH) += ibmveth.o
194obj-$(CONFIG_S2IO) += s2io.o 194obj-$(CONFIG_S2IO) += s2io.o
195obj-$(CONFIG_MYRI10GE) += myri10ge/
195obj-$(CONFIG_SMC91X) += smc91x.o 196obj-$(CONFIG_SMC91X) += smc91x.o
197obj-$(CONFIG_SMC911X) += smc911x.o
196obj-$(CONFIG_DM9000) += dm9000.o 198obj-$(CONFIG_DM9000) += dm9000.o
197obj-$(CONFIG_FEC_8XX) += fec_8xx/ 199obj-$(CONFIG_FEC_8XX) += fec_8xx/
198 200
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 14dbad14afb6..038d5fcb15e6 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -2,13 +2,16 @@
2 * 2 *
3 * Alchemy Au1x00 ethernet driver 3 * Alchemy Au1x00 ethernet driver
4 * 4 *
5 * Copyright 2001,2002,2003 MontaVista Software Inc. 5 * Copyright 2001-2003, 2006 MontaVista Software Inc.
6 * Copyright 2002 TimeSys Corp. 6 * Copyright 2002 TimeSys Corp.
7 * Added ethtool/mii-tool support, 7 * Added ethtool/mii-tool support,
8 * Copyright 2004 Matt Porter <mporter@kernel.crashing.org> 8 * Copyright 2004 Matt Porter <mporter@kernel.crashing.org>
9 * Update: 2004 Bjoern Riemer, riemer@fokus.fraunhofer.de 9 * Update: 2004 Bjoern Riemer, riemer@fokus.fraunhofer.de
10 * or riemer@riemer-nt.de: fixed the link beat detection with 10 * or riemer@riemer-nt.de: fixed the link beat detection with
11 * ioctls (SIOCGMIIPHY) 11 * ioctls (SIOCGMIIPHY)
12 * Copyright 2006 Herbert Valerio Riedel <hvr@gnu.org>
13 * converted to use linux-2.6.x's PHY framework
14 *
12 * Author: MontaVista Software, Inc. 15 * Author: MontaVista Software, Inc.
13 * ppopov@mvista.com or source@mvista.com 16 * ppopov@mvista.com or source@mvista.com
14 * 17 *
@@ -53,6 +56,7 @@
53#include <linux/skbuff.h> 56#include <linux/skbuff.h>
54#include <linux/delay.h> 57#include <linux/delay.h>
55#include <linux/crc32.h> 58#include <linux/crc32.h>
59#include <linux/phy.h>
56#include <asm/mipsregs.h> 60#include <asm/mipsregs.h>
57#include <asm/irq.h> 61#include <asm/irq.h>
58#include <asm/io.h> 62#include <asm/io.h>
@@ -68,7 +72,7 @@ static int au1000_debug = 5;
68static int au1000_debug = 3; 72static int au1000_debug = 3;
69#endif 73#endif
70 74
71#define DRV_NAME "au1000eth" 75#define DRV_NAME "au1000_eth"
72#define DRV_VERSION "1.5" 76#define DRV_VERSION "1.5"
73#define DRV_AUTHOR "Pete Popov <ppopov@embeddedalley.com>" 77#define DRV_AUTHOR "Pete Popov <ppopov@embeddedalley.com>"
74#define DRV_DESC "Au1xxx on-chip Ethernet driver" 78#define DRV_DESC "Au1xxx on-chip Ethernet driver"
@@ -80,7 +84,7 @@ MODULE_LICENSE("GPL");
80// prototypes 84// prototypes
81static void hard_stop(struct net_device *); 85static void hard_stop(struct net_device *);
82static void enable_rx_tx(struct net_device *dev); 86static void enable_rx_tx(struct net_device *dev);
83static struct net_device * au1000_probe(u32 ioaddr, int irq, int port_num); 87static struct net_device * au1000_probe(int port_num);
84static int au1000_init(struct net_device *); 88static int au1000_init(struct net_device *);
85static int au1000_open(struct net_device *); 89static int au1000_open(struct net_device *);
86static int au1000_close(struct net_device *); 90static int au1000_close(struct net_device *);
@@ -88,17 +92,15 @@ static int au1000_tx(struct sk_buff *, struct net_device *);
88static int au1000_rx(struct net_device *); 92static int au1000_rx(struct net_device *);
89static irqreturn_t au1000_interrupt(int, void *, struct pt_regs *); 93static irqreturn_t au1000_interrupt(int, void *, struct pt_regs *);
90static void au1000_tx_timeout(struct net_device *); 94static void au1000_tx_timeout(struct net_device *);
91static int au1000_set_config(struct net_device *dev, struct ifmap *map);
92static void set_rx_mode(struct net_device *); 95static void set_rx_mode(struct net_device *);
93static struct net_device_stats *au1000_get_stats(struct net_device *); 96static struct net_device_stats *au1000_get_stats(struct net_device *);
94static void au1000_timer(unsigned long);
95static int au1000_ioctl(struct net_device *, struct ifreq *, int); 97static int au1000_ioctl(struct net_device *, struct ifreq *, int);
96static int mdio_read(struct net_device *, int, int); 98static int mdio_read(struct net_device *, int, int);
97static void mdio_write(struct net_device *, int, int, u16); 99static void mdio_write(struct net_device *, int, int, u16);
98static void dump_mii(struct net_device *dev, int phy_id); 100static void au1000_adjust_link(struct net_device *);
101static void enable_mac(struct net_device *, int);
99 102
100// externs 103// externs
101extern void ack_rise_edge_irq(unsigned int);
102extern int get_ethernet_addr(char *ethernet_addr); 104extern int get_ethernet_addr(char *ethernet_addr);
103extern void str2eaddr(unsigned char *ea, unsigned char *str); 105extern void str2eaddr(unsigned char *ea, unsigned char *str);
104extern char * __init prom_getcmdline(void); 106extern char * __init prom_getcmdline(void);
@@ -126,705 +128,83 @@ static unsigned char au1000_mac_addr[6] __devinitdata = {
126 0x00, 0x50, 0xc2, 0x0c, 0x30, 0x00 128 0x00, 0x50, 0xc2, 0x0c, 0x30, 0x00
127}; 129};
128 130
129#define nibswap(x) ((((x) >> 4) & 0x0f) | (((x) << 4) & 0xf0))
130#define RUN_AT(x) (jiffies + (x))
131
132// For reading/writing 32-bit words from/to DMA memory
133#define cpu_to_dma32 cpu_to_be32
134#define dma32_to_cpu be32_to_cpu
135
136struct au1000_private *au_macs[NUM_ETH_INTERFACES]; 131struct au1000_private *au_macs[NUM_ETH_INTERFACES];
137 132
138/* FIXME 133/*
139 * All of the PHY code really should be detached from the MAC 134 * board-specific configurations
140 * code. 135 *
136 * PHY detection algorithm
137 *
138 * If AU1XXX_PHY_STATIC_CONFIG is undefined, the PHY setup is
139 * autodetected:
140 *
141 * mii_probe() first searches the current MAC's MII bus for a PHY,
142 * selecting the first (or last, if AU1XXX_PHY_SEARCH_HIGHEST_ADDR is
143 * defined) PHY address not already claimed by another netdev.
144 *
145 * If nothing was found that way when searching for the 2nd ethernet
146 * controller's PHY and AU1XXX_PHY1_SEARCH_ON_MAC0 is defined, then
147 * the first MII bus is searched as well for an unclaimed PHY; this is
148 * needed in case of a dual-PHY accessible only through the MAC0's MII
149 * bus.
150 *
151 * Finally, if no PHY is found, then the corresponding ethernet
152 * controller is not registered to the network subsystem.
141 */ 153 */
142 154
143/* Default advertise */ 155/* autodetection defaults */
144#define GENMII_DEFAULT_ADVERTISE \ 156#undef AU1XXX_PHY_SEARCH_HIGHEST_ADDR
145 ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | \ 157#define AU1XXX_PHY1_SEARCH_ON_MAC0
146 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | \
147 ADVERTISED_Autoneg
148
149#define GENMII_DEFAULT_FEATURES \
150 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | \
151 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
152 SUPPORTED_Autoneg
153
154int bcm_5201_init(struct net_device *dev, int phy_addr)
155{
156 s16 data;
157
158 /* Stop auto-negotiation */
159 data = mdio_read(dev, phy_addr, MII_CONTROL);
160 mdio_write(dev, phy_addr, MII_CONTROL, data & ~MII_CNTL_AUTO);
161
162 /* Set advertisement to 10/100 and Half/Full duplex
163 * (full capabilities) */
164 data = mdio_read(dev, phy_addr, MII_ANADV);
165 data |= MII_NWAY_TX | MII_NWAY_TX_FDX | MII_NWAY_T_FDX | MII_NWAY_T;
166 mdio_write(dev, phy_addr, MII_ANADV, data);
167
168 /* Restart auto-negotiation */
169 data = mdio_read(dev, phy_addr, MII_CONTROL);
170 data |= MII_CNTL_RST_AUTO | MII_CNTL_AUTO;
171 mdio_write(dev, phy_addr, MII_CONTROL, data);
172
173 if (au1000_debug > 4)
174 dump_mii(dev, phy_addr);
175 return 0;
176}
177
178int bcm_5201_reset(struct net_device *dev, int phy_addr)
179{
180 s16 mii_control, timeout;
181
182 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
183 mdio_write(dev, phy_addr, MII_CONTROL, mii_control | MII_CNTL_RESET);
184 mdelay(1);
185 for (timeout = 100; timeout > 0; --timeout) {
186 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
187 if ((mii_control & MII_CNTL_RESET) == 0)
188 break;
189 mdelay(1);
190 }
191 if (mii_control & MII_CNTL_RESET) {
192 printk(KERN_ERR "%s PHY reset timeout !\n", dev->name);
193 return -1;
194 }
195 return 0;
196}
197
198int
199bcm_5201_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
200{
201 u16 mii_data;
202 struct au1000_private *aup;
203
204 if (!dev) {
205 printk(KERN_ERR "bcm_5201_status error: NULL dev\n");
206 return -1;
207 }
208 aup = (struct au1000_private *) dev->priv;
209
210 mii_data = mdio_read(dev, aup->phy_addr, MII_STATUS);
211 if (mii_data & MII_STAT_LINK) {
212 *link = 1;
213 mii_data = mdio_read(dev, aup->phy_addr, MII_AUX_CNTRL);
214 if (mii_data & MII_AUX_100) {
215 if (mii_data & MII_AUX_FDX) {
216 *speed = IF_PORT_100BASEFX;
217 dev->if_port = IF_PORT_100BASEFX;
218 }
219 else {
220 *speed = IF_PORT_100BASETX;
221 dev->if_port = IF_PORT_100BASETX;
222 }
223 }
224 else {
225 *speed = IF_PORT_10BASET;
226 dev->if_port = IF_PORT_10BASET;
227 }
228
229 }
230 else {
231 *link = 0;
232 *speed = 0;
233 dev->if_port = IF_PORT_UNKNOWN;
234 }
235 return 0;
236}
237
238int lsi_80227_init(struct net_device *dev, int phy_addr)
239{
240 if (au1000_debug > 4)
241 printk("lsi_80227_init\n");
242
243 /* restart auto-negotiation */
244 mdio_write(dev, phy_addr, MII_CONTROL,
245 MII_CNTL_F100 | MII_CNTL_AUTO | MII_CNTL_RST_AUTO); // | MII_CNTL_FDX);
246 mdelay(1);
247
248 /* set up LEDs to correct display */
249#ifdef CONFIG_MIPS_MTX1
250 mdio_write(dev, phy_addr, 17, 0xff80);
251#else
252 mdio_write(dev, phy_addr, 17, 0xffc0);
253#endif
254
255 if (au1000_debug > 4)
256 dump_mii(dev, phy_addr);
257 return 0;
258}
259
260int lsi_80227_reset(struct net_device *dev, int phy_addr)
261{
262 s16 mii_control, timeout;
263
264 if (au1000_debug > 4) {
265 printk("lsi_80227_reset\n");
266 dump_mii(dev, phy_addr);
267 }
268
269 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
270 mdio_write(dev, phy_addr, MII_CONTROL, mii_control | MII_CNTL_RESET);
271 mdelay(1);
272 for (timeout = 100; timeout > 0; --timeout) {
273 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
274 if ((mii_control & MII_CNTL_RESET) == 0)
275 break;
276 mdelay(1);
277 }
278 if (mii_control & MII_CNTL_RESET) {
279 printk(KERN_ERR "%s PHY reset timeout !\n", dev->name);
280 return -1;
281 }
282 return 0;
283}
284
285int
286lsi_80227_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
287{
288 u16 mii_data;
289 struct au1000_private *aup;
290
291 if (!dev) {
292 printk(KERN_ERR "lsi_80227_status error: NULL dev\n");
293 return -1;
294 }
295 aup = (struct au1000_private *) dev->priv;
296
297 mii_data = mdio_read(dev, aup->phy_addr, MII_STATUS);
298 if (mii_data & MII_STAT_LINK) {
299 *link = 1;
300 mii_data = mdio_read(dev, aup->phy_addr, MII_LSI_PHY_STAT);
301 if (mii_data & MII_LSI_PHY_STAT_SPD) {
302 if (mii_data & MII_LSI_PHY_STAT_FDX) {
303 *speed = IF_PORT_100BASEFX;
304 dev->if_port = IF_PORT_100BASEFX;
305 }
306 else {
307 *speed = IF_PORT_100BASETX;
308 dev->if_port = IF_PORT_100BASETX;
309 }
310 }
311 else {
312 *speed = IF_PORT_10BASET;
313 dev->if_port = IF_PORT_10BASET;
314 }
315
316 }
317 else {
318 *link = 0;
319 *speed = 0;
320 dev->if_port = IF_PORT_UNKNOWN;
321 }
322 return 0;
323}
324
325int am79c901_init(struct net_device *dev, int phy_addr)
326{
327 printk("am79c901_init\n");
328 return 0;
329}
330
331int am79c901_reset(struct net_device *dev, int phy_addr)
332{
333 printk("am79c901_reset\n");
334 return 0;
335}
336
337int
338am79c901_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
339{
340 return 0;
341}
342
343int am79c874_init(struct net_device *dev, int phy_addr)
344{
345 s16 data;
346
347 /* 79c874 has quit resembled bit assignments to BCM5201 */
348 if (au1000_debug > 4)
349 printk("am79c847_init\n");
350
351 /* Stop auto-negotiation */
352 data = mdio_read(dev, phy_addr, MII_CONTROL);
353 mdio_write(dev, phy_addr, MII_CONTROL, data & ~MII_CNTL_AUTO);
354
355 /* Set advertisement to 10/100 and Half/Full duplex
356 * (full capabilities) */
357 data = mdio_read(dev, phy_addr, MII_ANADV);
358 data |= MII_NWAY_TX | MII_NWAY_TX_FDX | MII_NWAY_T_FDX | MII_NWAY_T;
359 mdio_write(dev, phy_addr, MII_ANADV, data);
360
361 /* Restart auto-negotiation */
362 data = mdio_read(dev, phy_addr, MII_CONTROL);
363 data |= MII_CNTL_RST_AUTO | MII_CNTL_AUTO;
364
365 mdio_write(dev, phy_addr, MII_CONTROL, data);
366
367 if (au1000_debug > 4) dump_mii(dev, phy_addr);
368 return 0;
369}
370
371int am79c874_reset(struct net_device *dev, int phy_addr)
372{
373 s16 mii_control, timeout;
374
375 if (au1000_debug > 4)
376 printk("am79c874_reset\n");
377
378 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
379 mdio_write(dev, phy_addr, MII_CONTROL, mii_control | MII_CNTL_RESET);
380 mdelay(1);
381 for (timeout = 100; timeout > 0; --timeout) {
382 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
383 if ((mii_control & MII_CNTL_RESET) == 0)
384 break;
385 mdelay(1);
386 }
387 if (mii_control & MII_CNTL_RESET) {
388 printk(KERN_ERR "%s PHY reset timeout !\n", dev->name);
389 return -1;
390 }
391 return 0;
392}
393
394int
395am79c874_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
396{
397 u16 mii_data;
398 struct au1000_private *aup;
399
400 // printk("am79c874_status\n");
401 if (!dev) {
402 printk(KERN_ERR "am79c874_status error: NULL dev\n");
403 return -1;
404 }
405
406 aup = (struct au1000_private *) dev->priv;
407 mii_data = mdio_read(dev, aup->phy_addr, MII_STATUS);
408
409 if (mii_data & MII_STAT_LINK) {
410 *link = 1;
411 mii_data = mdio_read(dev, aup->phy_addr, MII_AMD_PHY_STAT);
412 if (mii_data & MII_AMD_PHY_STAT_SPD) {
413 if (mii_data & MII_AMD_PHY_STAT_FDX) {
414 *speed = IF_PORT_100BASEFX;
415 dev->if_port = IF_PORT_100BASEFX;
416 }
417 else {
418 *speed = IF_PORT_100BASETX;
419 dev->if_port = IF_PORT_100BASETX;
420 }
421 }
422 else {
423 *speed = IF_PORT_10BASET;
424 dev->if_port = IF_PORT_10BASET;
425 }
426
427 }
428 else {
429 *link = 0;
430 *speed = 0;
431 dev->if_port = IF_PORT_UNKNOWN;
432 }
433 return 0;
434}
435
436int lxt971a_init(struct net_device *dev, int phy_addr)
437{
438 if (au1000_debug > 4)
439 printk("lxt971a_init\n");
440
441 /* restart auto-negotiation */
442 mdio_write(dev, phy_addr, MII_CONTROL,
443 MII_CNTL_F100 | MII_CNTL_AUTO | MII_CNTL_RST_AUTO | MII_CNTL_FDX);
444
445 /* set up LEDs to correct display */
446 mdio_write(dev, phy_addr, 20, 0x0422);
447
448 if (au1000_debug > 4)
449 dump_mii(dev, phy_addr);
450 return 0;
451}
452
453int lxt971a_reset(struct net_device *dev, int phy_addr)
454{
455 s16 mii_control, timeout;
456
457 if (au1000_debug > 4) {
458 printk("lxt971a_reset\n");
459 dump_mii(dev, phy_addr);
460 }
461
462 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
463 mdio_write(dev, phy_addr, MII_CONTROL, mii_control | MII_CNTL_RESET);
464 mdelay(1);
465 for (timeout = 100; timeout > 0; --timeout) {
466 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
467 if ((mii_control & MII_CNTL_RESET) == 0)
468 break;
469 mdelay(1);
470 }
471 if (mii_control & MII_CNTL_RESET) {
472 printk(KERN_ERR "%s PHY reset timeout !\n", dev->name);
473 return -1;
474 }
475 return 0;
476}
477
478int
479lxt971a_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
480{
481 u16 mii_data;
482 struct au1000_private *aup;
483
484 if (!dev) {
485 printk(KERN_ERR "lxt971a_status error: NULL dev\n");
486 return -1;
487 }
488 aup = (struct au1000_private *) dev->priv;
489
490 mii_data = mdio_read(dev, aup->phy_addr, MII_STATUS);
491 if (mii_data & MII_STAT_LINK) {
492 *link = 1;
493 mii_data = mdio_read(dev, aup->phy_addr, MII_INTEL_PHY_STAT);
494 if (mii_data & MII_INTEL_PHY_STAT_SPD) {
495 if (mii_data & MII_INTEL_PHY_STAT_FDX) {
496 *speed = IF_PORT_100BASEFX;
497 dev->if_port = IF_PORT_100BASEFX;
498 }
499 else {
500 *speed = IF_PORT_100BASETX;
501 dev->if_port = IF_PORT_100BASETX;
502 }
503 }
504 else {
505 *speed = IF_PORT_10BASET;
506 dev->if_port = IF_PORT_10BASET;
507 }
508
509 }
510 else {
511 *link = 0;
512 *speed = 0;
513 dev->if_port = IF_PORT_UNKNOWN;
514 }
515 return 0;
516}
517
518int ks8995m_init(struct net_device *dev, int phy_addr)
519{
520 s16 data;
521
522// printk("ks8995m_init\n");
523 /* Stop auto-negotiation */
524 data = mdio_read(dev, phy_addr, MII_CONTROL);
525 mdio_write(dev, phy_addr, MII_CONTROL, data & ~MII_CNTL_AUTO);
526
527 /* Set advertisement to 10/100 and Half/Full duplex
528 * (full capabilities) */
529 data = mdio_read(dev, phy_addr, MII_ANADV);
530 data |= MII_NWAY_TX | MII_NWAY_TX_FDX | MII_NWAY_T_FDX | MII_NWAY_T;
531 mdio_write(dev, phy_addr, MII_ANADV, data);
532
533 /* Restart auto-negotiation */
534 data = mdio_read(dev, phy_addr, MII_CONTROL);
535 data |= MII_CNTL_RST_AUTO | MII_CNTL_AUTO;
536 mdio_write(dev, phy_addr, MII_CONTROL, data);
537
538 if (au1000_debug > 4) dump_mii(dev, phy_addr);
539
540 return 0;
541}
542
543int ks8995m_reset(struct net_device *dev, int phy_addr)
544{
545 s16 mii_control, timeout;
546
547// printk("ks8995m_reset\n");
548 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
549 mdio_write(dev, phy_addr, MII_CONTROL, mii_control | MII_CNTL_RESET);
550 mdelay(1);
551 for (timeout = 100; timeout > 0; --timeout) {
552 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
553 if ((mii_control & MII_CNTL_RESET) == 0)
554 break;
555 mdelay(1);
556 }
557 if (mii_control & MII_CNTL_RESET) {
558 printk(KERN_ERR "%s PHY reset timeout !\n", dev->name);
559 return -1;
560 }
561 return 0;
562}
563
564int ks8995m_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
565{
566 u16 mii_data;
567 struct au1000_private *aup;
568
569 if (!dev) {
570 printk(KERN_ERR "ks8995m_status error: NULL dev\n");
571 return -1;
572 }
573 aup = (struct au1000_private *) dev->priv;
574
575 mii_data = mdio_read(dev, aup->phy_addr, MII_STATUS);
576 if (mii_data & MII_STAT_LINK) {
577 *link = 1;
578 mii_data = mdio_read(dev, aup->phy_addr, MII_AUX_CNTRL);
579 if (mii_data & MII_AUX_100) {
580 if (mii_data & MII_AUX_FDX) {
581 *speed = IF_PORT_100BASEFX;
582 dev->if_port = IF_PORT_100BASEFX;
583 }
584 else {
585 *speed = IF_PORT_100BASETX;
586 dev->if_port = IF_PORT_100BASETX;
587 }
588 }
589 else {
590 *speed = IF_PORT_10BASET;
591 dev->if_port = IF_PORT_10BASET;
592 }
593
594 }
595 else {
596 *link = 0;
597 *speed = 0;
598 dev->if_port = IF_PORT_UNKNOWN;
599 }
600 return 0;
601}
602
603int
604smsc_83C185_init (struct net_device *dev, int phy_addr)
605{
606 s16 data;
607
608 if (au1000_debug > 4)
609 printk("smsc_83C185_init\n");
610
611 /* Stop auto-negotiation */
612 data = mdio_read(dev, phy_addr, MII_CONTROL);
613 mdio_write(dev, phy_addr, MII_CONTROL, data & ~MII_CNTL_AUTO);
614
615 /* Set advertisement to 10/100 and Half/Full duplex
616 * (full capabilities) */
617 data = mdio_read(dev, phy_addr, MII_ANADV);
618 data |= MII_NWAY_TX | MII_NWAY_TX_FDX | MII_NWAY_T_FDX | MII_NWAY_T;
619 mdio_write(dev, phy_addr, MII_ANADV, data);
620
621 /* Restart auto-negotiation */
622 data = mdio_read(dev, phy_addr, MII_CONTROL);
623 data |= MII_CNTL_RST_AUTO | MII_CNTL_AUTO;
624
625 mdio_write(dev, phy_addr, MII_CONTROL, data);
626
627 if (au1000_debug > 4) dump_mii(dev, phy_addr);
628 return 0;
629}
630
631int
632smsc_83C185_reset (struct net_device *dev, int phy_addr)
633{
634 s16 mii_control, timeout;
635
636 if (au1000_debug > 4)
637 printk("smsc_83C185_reset\n");
638
639 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
640 mdio_write(dev, phy_addr, MII_CONTROL, mii_control | MII_CNTL_RESET);
641 mdelay(1);
642 for (timeout = 100; timeout > 0; --timeout) {
643 mii_control = mdio_read(dev, phy_addr, MII_CONTROL);
644 if ((mii_control & MII_CNTL_RESET) == 0)
645 break;
646 mdelay(1);
647 }
648 if (mii_control & MII_CNTL_RESET) {
649 printk(KERN_ERR "%s PHY reset timeout !\n", dev->name);
650 return -1;
651 }
652 return 0;
653}
654
655int
656smsc_83C185_status (struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
657{
658 u16 mii_data;
659 struct au1000_private *aup;
660
661 if (!dev) {
662 printk(KERN_ERR "smsc_83C185_status error: NULL dev\n");
663 return -1;
664 }
665
666 aup = (struct au1000_private *) dev->priv;
667 mii_data = mdio_read(dev, aup->phy_addr, MII_STATUS);
668
669 if (mii_data & MII_STAT_LINK) {
670 *link = 1;
671 mii_data = mdio_read(dev, aup->phy_addr, 0x1f);
672 if (mii_data & (1<<3)) {
673 if (mii_data & (1<<4)) {
674 *speed = IF_PORT_100BASEFX;
675 dev->if_port = IF_PORT_100BASEFX;
676 }
677 else {
678 *speed = IF_PORT_100BASETX;
679 dev->if_port = IF_PORT_100BASETX;
680 }
681 }
682 else {
683 *speed = IF_PORT_10BASET;
684 dev->if_port = IF_PORT_10BASET;
685 }
686 }
687 else {
688 *link = 0;
689 *speed = 0;
690 dev->if_port = IF_PORT_UNKNOWN;
691 }
692 return 0;
693}
694
695
696#ifdef CONFIG_MIPS_BOSPORUS
697int stub_init(struct net_device *dev, int phy_addr)
698{
699 //printk("PHY stub_init\n");
700 return 0;
701}
702
703int stub_reset(struct net_device *dev, int phy_addr)
704{
705 //printk("PHY stub_reset\n");
706 return 0;
707}
708
709int
710stub_status(struct net_device *dev, int phy_addr, u16 *link, u16 *speed)
711{
712 //printk("PHY stub_status\n");
713 *link = 1;
714 /* hmmm, revisit */
715 *speed = IF_PORT_100BASEFX;
716 dev->if_port = IF_PORT_100BASEFX;
717 return 0;
718}
719#endif
720
721struct phy_ops bcm_5201_ops = {
722 bcm_5201_init,
723 bcm_5201_reset,
724 bcm_5201_status,
725};
726
727struct phy_ops am79c874_ops = {
728 am79c874_init,
729 am79c874_reset,
730 am79c874_status,
731};
732
733struct phy_ops am79c901_ops = {
734 am79c901_init,
735 am79c901_reset,
736 am79c901_status,
737};
738
739struct phy_ops lsi_80227_ops = {
740 lsi_80227_init,
741 lsi_80227_reset,
742 lsi_80227_status,
743};
744 158
745struct phy_ops lxt971a_ops = { 159/* static PHY setup
746 lxt971a_init, 160 *
747 lxt971a_reset, 161 * most boards PHY setup should be detectable properly with the
748 lxt971a_status, 162 * autodetection algorithm in mii_probe(), but in some cases (e.g. if
749}; 163 * you have a switch attached, or want to use the PHY's interrupt
164 * notification capabilities) you can provide a static PHY
165 * configuration here
166 *
167 * IRQs may only be set, if a PHY address was configured
168 * If a PHY address is given, also a bus id is required to be set
169 *
170 * ps: make sure the used irqs are configured properly in the board
171 * specific irq-map
172 */
750 173
751struct phy_ops ks8995m_ops = { 174#if defined(CONFIG_MIPS_BOSPORUS)
752 ks8995m_init, 175/*
753 ks8995m_reset, 176 * Micrel/Kendin 5 port switch attached to MAC0,
754 ks8995m_status, 177 * MAC0 is associated with PHY address 5 (== WAN port)
755}; 178 * MAC1 is not associated with any PHY, since it's connected directly
179 * to the switch.
180 * no interrupts are used
181 */
182# define AU1XXX_PHY_STATIC_CONFIG
756 183
757struct phy_ops smsc_83C185_ops = { 184# define AU1XXX_PHY0_ADDR 5
758 smsc_83C185_init, 185# define AU1XXX_PHY0_BUSID 0
759 smsc_83C185_reset, 186# undef AU1XXX_PHY0_IRQ
760 smsc_83C185_status,
761};
762 187
763#ifdef CONFIG_MIPS_BOSPORUS 188# undef AU1XXX_PHY1_ADDR
764struct phy_ops stub_ops = { 189# undef AU1XXX_PHY1_BUSID
765 stub_init, 190# undef AU1XXX_PHY1_IRQ
766 stub_reset,
767 stub_status,
768};
769#endif 191#endif
770 192
771static struct mii_chip_info { 193#if defined(AU1XXX_PHY0_BUSID) && (AU1XXX_PHY0_BUSID > 0)
772 const char * name; 194# error MAC0-associated PHY attached 2nd MACs MII bus not supported yet
773 u16 phy_id0;
774 u16 phy_id1;
775 struct phy_ops *phy_ops;
776 int dual_phy;
777} mii_chip_table[] = {
778 {"Broadcom BCM5201 10/100 BaseT PHY",0x0040,0x6212, &bcm_5201_ops,0},
779 {"Broadcom BCM5221 10/100 BaseT PHY",0x0040,0x61e4, &bcm_5201_ops,0},
780 {"Broadcom BCM5222 10/100 BaseT PHY",0x0040,0x6322, &bcm_5201_ops,1},
781 {"NS DP83847 PHY", 0x2000, 0x5c30, &bcm_5201_ops ,0},
782 {"AMD 79C901 HomePNA PHY",0x0000,0x35c8, &am79c901_ops,0},
783 {"AMD 79C874 10/100 BaseT PHY",0x0022,0x561b, &am79c874_ops,0},
784 {"LSI 80227 10/100 BaseT PHY",0x0016,0xf840, &lsi_80227_ops,0},
785 {"Intel LXT971A Dual Speed PHY",0x0013,0x78e2, &lxt971a_ops,0},
786 {"Kendin KS8995M 10/100 BaseT PHY",0x0022,0x1450, &ks8995m_ops,0},
787 {"SMSC LAN83C185 10/100 BaseT PHY",0x0007,0xc0a3, &smsc_83C185_ops,0},
788#ifdef CONFIG_MIPS_BOSPORUS
789 {"Stub", 0x1234, 0x5678, &stub_ops },
790#endif 195#endif
791 {0,},
792};
793 196
794static int mdio_read(struct net_device *dev, int phy_id, int reg) 197/*
198 * MII operations
199 */
200static int mdio_read(struct net_device *dev, int phy_addr, int reg)
795{ 201{
796 struct au1000_private *aup = (struct au1000_private *) dev->priv; 202 struct au1000_private *aup = (struct au1000_private *) dev->priv;
797 volatile u32 *mii_control_reg; 203 volatile u32 *const mii_control_reg = &aup->mac->mii_control;
798 volatile u32 *mii_data_reg; 204 volatile u32 *const mii_data_reg = &aup->mac->mii_data;
799 u32 timedout = 20; 205 u32 timedout = 20;
800 u32 mii_control; 206 u32 mii_control;
801 207
802 #ifdef CONFIG_BCM5222_DUAL_PHY
803 /* First time we probe, it's for the mac0 phy.
804 * Since we haven't determined yet that we have a dual phy,
805 * aup->mii->mii_control_reg won't be setup and we'll
806 * default to the else statement.
807 * By the time we probe for the mac1 phy, the mii_control_reg
808 * will be setup to be the address of the mac0 phy control since
809 * both phys are controlled through mac0.
810 */
811 if (aup->mii && aup->mii->mii_control_reg) {
812 mii_control_reg = aup->mii->mii_control_reg;
813 mii_data_reg = aup->mii->mii_data_reg;
814 }
815 else if (au_macs[0]->mii && au_macs[0]->mii->mii_control_reg) {
816 /* assume both phys are controlled through mac0 */
817 mii_control_reg = au_macs[0]->mii->mii_control_reg;
818 mii_data_reg = au_macs[0]->mii->mii_data_reg;
819 }
820 else
821 #endif
822 {
823 /* default control and data reg addresses */
824 mii_control_reg = &aup->mac->mii_control;
825 mii_data_reg = &aup->mac->mii_data;
826 }
827
828 while (*mii_control_reg & MAC_MII_BUSY) { 208 while (*mii_control_reg & MAC_MII_BUSY) {
829 mdelay(1); 209 mdelay(1);
830 if (--timedout == 0) { 210 if (--timedout == 0) {
@@ -835,7 +215,7 @@ static int mdio_read(struct net_device *dev, int phy_id, int reg)
835 } 215 }
836 216
837 mii_control = MAC_SET_MII_SELECT_REG(reg) | 217 mii_control = MAC_SET_MII_SELECT_REG(reg) |
838 MAC_SET_MII_SELECT_PHY(phy_id) | MAC_MII_READ; 218 MAC_SET_MII_SELECT_PHY(phy_addr) | MAC_MII_READ;
839 219
840 *mii_control_reg = mii_control; 220 *mii_control_reg = mii_control;
841 221
@@ -851,32 +231,14 @@ static int mdio_read(struct net_device *dev, int phy_id, int reg)
851 return (int)*mii_data_reg; 231 return (int)*mii_data_reg;
852} 232}
853 233
854static void mdio_write(struct net_device *dev, int phy_id, int reg, u16 value) 234static void mdio_write(struct net_device *dev, int phy_addr, int reg, u16 value)
855{ 235{
856 struct au1000_private *aup = (struct au1000_private *) dev->priv; 236 struct au1000_private *aup = (struct au1000_private *) dev->priv;
857 volatile u32 *mii_control_reg; 237 volatile u32 *const mii_control_reg = &aup->mac->mii_control;
858 volatile u32 *mii_data_reg; 238 volatile u32 *const mii_data_reg = &aup->mac->mii_data;
859 u32 timedout = 20; 239 u32 timedout = 20;
860 u32 mii_control; 240 u32 mii_control;
861 241
862 #ifdef CONFIG_BCM5222_DUAL_PHY
863 if (aup->mii && aup->mii->mii_control_reg) {
864 mii_control_reg = aup->mii->mii_control_reg;
865 mii_data_reg = aup->mii->mii_data_reg;
866 }
867 else if (au_macs[0]->mii && au_macs[0]->mii->mii_control_reg) {
868 /* assume both phys are controlled through mac0 */
869 mii_control_reg = au_macs[0]->mii->mii_control_reg;
870 mii_data_reg = au_macs[0]->mii->mii_data_reg;
871 }
872 else
873 #endif
874 {
875 /* default control and data reg addresses */
876 mii_control_reg = &aup->mac->mii_control;
877 mii_data_reg = &aup->mac->mii_data;
878 }
879
880 while (*mii_control_reg & MAC_MII_BUSY) { 242 while (*mii_control_reg & MAC_MII_BUSY) {
881 mdelay(1); 243 mdelay(1);
882 if (--timedout == 0) { 244 if (--timedout == 0) {
@@ -887,165 +249,145 @@ static void mdio_write(struct net_device *dev, int phy_id, int reg, u16 value)
887 } 249 }
888 250
889 mii_control = MAC_SET_MII_SELECT_REG(reg) | 251 mii_control = MAC_SET_MII_SELECT_REG(reg) |
890 MAC_SET_MII_SELECT_PHY(phy_id) | MAC_MII_WRITE; 252 MAC_SET_MII_SELECT_PHY(phy_addr) | MAC_MII_WRITE;
891 253
892 *mii_data_reg = value; 254 *mii_data_reg = value;
893 *mii_control_reg = mii_control; 255 *mii_control_reg = mii_control;
894} 256}
895 257
258static int mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
259{
260 /* WARNING: bus->phy_map[phy_addr].attached_dev == dev does
261 * _NOT_ hold (e.g. when PHY is accessed through other MAC's MII bus) */
262 struct net_device *const dev = bus->priv;
263
264 enable_mac(dev, 0); /* make sure the MAC associated with this
265 * mii_bus is enabled */
266 return mdio_read(dev, phy_addr, regnum);
267}
896 268
897static void dump_mii(struct net_device *dev, int phy_id) 269static int mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
270 u16 value)
898{ 271{
899 int i, val; 272 struct net_device *const dev = bus->priv;
900 273
901 for (i = 0; i < 7; i++) { 274 enable_mac(dev, 0); /* make sure the MAC associated with this
902 if ((val = mdio_read(dev, phy_id, i)) >= 0) 275 * mii_bus is enabled */
903 printk("%s: MII Reg %d=%x\n", dev->name, i, val); 276 mdio_write(dev, phy_addr, regnum, value);
904 } 277 return 0;
905 for (i = 16; i < 25; i++) {
906 if ((val = mdio_read(dev, phy_id, i)) >= 0)
907 printk("%s: MII Reg %d=%x\n", dev->name, i, val);
908 }
909} 278}
910 279
911static int mii_probe (struct net_device * dev) 280static int mdiobus_reset(struct mii_bus *bus)
912{ 281{
913 struct au1000_private *aup = (struct au1000_private *) dev->priv; 282 struct net_device *const dev = bus->priv;
914 int phy_addr;
915#ifdef CONFIG_MIPS_BOSPORUS
916 int phy_found=0;
917#endif
918 283
919 /* search for total of 32 possible mii phy addresses */ 284 enable_mac(dev, 0); /* make sure the MAC associated with this
920 for (phy_addr = 0; phy_addr < 32; phy_addr++) { 285 * mii_bus is enabled */
921 u16 mii_status; 286 return 0;
922 u16 phy_id0, phy_id1; 287}
923 int i;
924 288
925 #ifdef CONFIG_BCM5222_DUAL_PHY 289static int mii_probe (struct net_device *dev)
926 /* Mask the already found phy, try next one */ 290{
927 if (au_macs[0]->mii && au_macs[0]->mii->mii_control_reg) { 291 struct au1000_private *const aup = (struct au1000_private *) dev->priv;
928 if (au_macs[0]->phy_addr == phy_addr) 292 struct phy_device *phydev = NULL;
929 continue; 293
930 } 294#if defined(AU1XXX_PHY_STATIC_CONFIG)
931 #endif 295 BUG_ON(aup->mac_id < 0 || aup->mac_id > 1);
932 296
933 mii_status = mdio_read(dev, phy_addr, MII_STATUS); 297 if(aup->mac_id == 0) { /* get PHY0 */
934 if (mii_status == 0xffff || mii_status == 0x0000) 298# if defined(AU1XXX_PHY0_ADDR)
935 /* the mii is not accessable, try next one */ 299 phydev = au_macs[AU1XXX_PHY0_BUSID]->mii_bus.phy_map[AU1XXX_PHY0_ADDR];
936 continue; 300# else
937 301 printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n",
938 phy_id0 = mdio_read(dev, phy_addr, MII_PHY_ID0); 302 dev->name);
939 phy_id1 = mdio_read(dev, phy_addr, MII_PHY_ID1); 303 return 0;
940 304# endif /* defined(AU1XXX_PHY0_ADDR) */
941 /* search our mii table for the current mii */ 305 } else if (aup->mac_id == 1) { /* get PHY1 */
942 for (i = 0; mii_chip_table[i].phy_id1; i++) { 306# if defined(AU1XXX_PHY1_ADDR)
943 if (phy_id0 == mii_chip_table[i].phy_id0 && 307 phydev = au_macs[AU1XXX_PHY1_BUSID]->mii_bus.phy_map[AU1XXX_PHY1_ADDR];
944 phy_id1 == mii_chip_table[i].phy_id1) { 308# else
945 struct mii_phy * mii_phy = aup->mii; 309 printk (KERN_INFO DRV_NAME ":%s: using PHY-less setup\n",
946 310 dev->name);
947 printk(KERN_INFO "%s: %s at phy address %d\n", 311 return 0;
948 dev->name, mii_chip_table[i].name, 312# endif /* defined(AU1XXX_PHY1_ADDR) */
949 phy_addr); 313 }
950#ifdef CONFIG_MIPS_BOSPORUS 314
951 phy_found = 1; 315#else /* defined(AU1XXX_PHY_STATIC_CONFIG) */
952#endif 316 int phy_addr;
953 mii_phy->chip_info = mii_chip_table+i; 317
954 aup->phy_addr = phy_addr; 318 /* find the first (lowest address) PHY on the current MAC's MII bus */
955 aup->want_autoneg = 1; 319 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
956 aup->phy_ops = mii_chip_table[i].phy_ops; 320 if (aup->mii_bus.phy_map[phy_addr]) {
957 aup->phy_ops->phy_init(dev,phy_addr); 321 phydev = aup->mii_bus.phy_map[phy_addr];
958 322# if !defined(AU1XXX_PHY_SEARCH_HIGHEST_ADDR)
959 // Check for dual-phy and then store required 323 break; /* break out with first one found */
960 // values and set indicators. We need to do 324# endif
961 // this now since mdio_{read,write} need the
962 // control and data register addresses.
963 #ifdef CONFIG_BCM5222_DUAL_PHY
964 if ( mii_chip_table[i].dual_phy) {
965
966 /* assume both phys are controlled
967 * through MAC0. Board specific? */
968
969 /* sanity check */
970 if (!au_macs[0] || !au_macs[0]->mii)
971 return -1;
972 aup->mii->mii_control_reg = (u32 *)
973 &au_macs[0]->mac->mii_control;
974 aup->mii->mii_data_reg = (u32 *)
975 &au_macs[0]->mac->mii_data;
976 }
977 #endif
978 goto found;
979 }
980 } 325 }
981 }
982found:
983
984#ifdef CONFIG_MIPS_BOSPORUS
985 /* This is a workaround for the Micrel/Kendin 5 port switch
986 The second MAC doesn't see a PHY connected... so we need to
987 trick it into thinking we have one.
988
989 If this kernel is run on another Au1500 development board
990 the stub will be found as well as the actual PHY. However,
991 the last found PHY will be used... usually at Addr 31 (Db1500).
992 */
993 if ( (!phy_found) )
994 {
995 u16 phy_id0, phy_id1;
996 int i;
997 326
998 phy_id0 = 0x1234; 327# if defined(AU1XXX_PHY1_SEARCH_ON_MAC0)
999 phy_id1 = 0x5678; 328 /* try harder to find a PHY */
1000 329 if (!phydev && (aup->mac_id == 1)) {
1001 /* search our mii table for the current mii */ 330 /* no PHY found, maybe we have a dual PHY? */
1002 for (i = 0; mii_chip_table[i].phy_id1; i++) { 331 printk (KERN_INFO DRV_NAME ": no PHY found on MAC1, "
1003 if (phy_id0 == mii_chip_table[i].phy_id0 && 332 "let's see if it's attached to MAC0...\n");
1004 phy_id1 == mii_chip_table[i].phy_id1) { 333
1005 struct mii_phy * mii_phy; 334 BUG_ON(!au_macs[0]);
1006 335
1007 printk(KERN_INFO "%s: %s at phy address %d\n", 336 /* find the first (lowest address) non-attached PHY on
1008 dev->name, mii_chip_table[i].name, 337 * the MAC0 MII bus */
1009 phy_addr); 338 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
1010 mii_phy = kmalloc(sizeof(struct mii_phy), 339 struct phy_device *const tmp_phydev =
1011 GFP_KERNEL); 340 au_macs[0]->mii_bus.phy_map[phy_addr];
1012 if (mii_phy) { 341
1013 mii_phy->chip_info = mii_chip_table+i; 342 if (!tmp_phydev)
1014 aup->phy_addr = phy_addr; 343 continue; /* no PHY here... */
1015 mii_phy->next = aup->mii; 344
1016 aup->phy_ops = 345 if (tmp_phydev->attached_dev)
1017 mii_chip_table[i].phy_ops; 346 continue; /* already claimed by MAC0 */
1018 aup->mii = mii_phy; 347
1019 aup->phy_ops->phy_init(dev,phy_addr); 348 phydev = tmp_phydev;
1020 } else { 349 break; /* found it */
1021 printk(KERN_ERR "%s: out of memory\n",
1022 dev->name);
1023 return -1;
1024 }
1025 mii_phy->chip_info = mii_chip_table+i;
1026 aup->phy_addr = phy_addr;
1027 aup->phy_ops = mii_chip_table[i].phy_ops;
1028 aup->phy_ops->phy_init(dev,phy_addr);
1029 break;
1030 }
1031 } 350 }
1032 } 351 }
1033 if (aup->mac_id == 0) { 352# endif /* defined(AU1XXX_PHY1_SEARCH_OTHER_BUS) */
1034 /* the Bosporus phy responds to addresses 0-5 but
1035 * 5 is the correct one.
1036 */
1037 aup->phy_addr = 5;
1038 }
1039#endif
1040 353
1041 if (aup->mii->chip_info == NULL) { 354#endif /* defined(AU1XXX_PHY_STATIC_CONFIG) */
1042 printk(KERN_ERR "%s: Au1x No known MII transceivers found!\n", 355 if (!phydev) {
1043 dev->name); 356 printk (KERN_ERR DRV_NAME ":%s: no PHY found\n", dev->name);
1044 return -1; 357 return -1;
1045 } 358 }
1046 359
1047 printk(KERN_INFO "%s: Using %s as default\n", 360 /* now we are supposed to have a proper phydev, to attach to... */
1048 dev->name, aup->mii->chip_info->name); 361 BUG_ON(!phydev);
362 BUG_ON(phydev->attached_dev);
363
364 phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0);
365
366 if (IS_ERR(phydev)) {
367 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
368 return PTR_ERR(phydev);
369 }
370
371 /* mask with MAC supported features */
372 phydev->supported &= (SUPPORTED_10baseT_Half
373 | SUPPORTED_10baseT_Full
374 | SUPPORTED_100baseT_Half
375 | SUPPORTED_100baseT_Full
376 | SUPPORTED_Autoneg
377 /* | SUPPORTED_Pause | SUPPORTED_Asym_Pause */
378 | SUPPORTED_MII
379 | SUPPORTED_TP);
380
381 phydev->advertising = phydev->supported;
382
383 aup->old_link = 0;
384 aup->old_speed = 0;
385 aup->old_duplex = -1;
386 aup->phy_dev = phydev;
387
388 printk(KERN_INFO "%s: attached PHY driver [%s] "
389 "(mii_bus:phy_addr=%s, irq=%d)\n",
390 dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq);
1049 391
1050 return 0; 392 return 0;
1051} 393}
@@ -1097,35 +439,38 @@ static void hard_stop(struct net_device *dev)
1097 au_sync_delay(10); 439 au_sync_delay(10);
1098} 440}
1099 441
1100 442static void enable_mac(struct net_device *dev, int force_reset)
1101static void reset_mac(struct net_device *dev)
1102{ 443{
1103 int i; 444 unsigned long flags;
1104 u32 flags;
1105 struct au1000_private *aup = (struct au1000_private *) dev->priv; 445 struct au1000_private *aup = (struct au1000_private *) dev->priv;
1106 446
1107 if (au1000_debug > 4)
1108 printk(KERN_INFO "%s: reset mac, aup %x\n",
1109 dev->name, (unsigned)aup);
1110
1111 spin_lock_irqsave(&aup->lock, flags); 447 spin_lock_irqsave(&aup->lock, flags);
1112 if (aup->timer.function == &au1000_timer) {/* check if timer initted */
1113 del_timer(&aup->timer);
1114 }
1115 448
1116 hard_stop(dev); 449 if(force_reset || (!aup->mac_enabled)) {
1117 #ifdef CONFIG_BCM5222_DUAL_PHY
1118 if (aup->mac_id != 0) {
1119 #endif
1120 /* If BCM5222, we can't leave MAC0 in reset because then
1121 * we can't access the dual phy for ETH1 */
1122 *aup->enable = MAC_EN_CLOCK_ENABLE; 450 *aup->enable = MAC_EN_CLOCK_ENABLE;
1123 au_sync_delay(2); 451 au_sync_delay(2);
1124 *aup->enable = 0; 452 *aup->enable = (MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2
453 | MAC_EN_CLOCK_ENABLE);
1125 au_sync_delay(2); 454 au_sync_delay(2);
1126 #ifdef CONFIG_BCM5222_DUAL_PHY 455
456 aup->mac_enabled = 1;
1127 } 457 }
1128 #endif 458
459 spin_unlock_irqrestore(&aup->lock, flags);
460}
461
462static void reset_mac_unlocked(struct net_device *dev)
463{
464 struct au1000_private *const aup = (struct au1000_private *) dev->priv;
465 int i;
466
467 hard_stop(dev);
468
469 *aup->enable = MAC_EN_CLOCK_ENABLE;
470 au_sync_delay(2);
471 *aup->enable = 0;
472 au_sync_delay(2);
473
1129 aup->tx_full = 0; 474 aup->tx_full = 0;
1130 for (i = 0; i < NUM_RX_DMA; i++) { 475 for (i = 0; i < NUM_RX_DMA; i++) {
1131 /* reset control bits */ 476 /* reset control bits */
@@ -1135,9 +480,26 @@ static void reset_mac(struct net_device *dev)
1135 /* reset control bits */ 480 /* reset control bits */
1136 aup->tx_dma_ring[i]->buff_stat &= ~0xf; 481 aup->tx_dma_ring[i]->buff_stat &= ~0xf;
1137 } 482 }
1138 spin_unlock_irqrestore(&aup->lock, flags); 483
484 aup->mac_enabled = 0;
485
1139} 486}
1140 487
488static void reset_mac(struct net_device *dev)
489{
490 struct au1000_private *const aup = (struct au1000_private *) dev->priv;
491 unsigned long flags;
492
493 if (au1000_debug > 4)
494 printk(KERN_INFO "%s: reset mac, aup %x\n",
495 dev->name, (unsigned)aup);
496
497 spin_lock_irqsave(&aup->lock, flags);
498
499 reset_mac_unlocked (dev);
500
501 spin_unlock_irqrestore(&aup->lock, flags);
502}
1141 503
1142/* 504/*
1143 * Setup the receive and transmit "rings". These pointers are the addresses 505 * Setup the receive and transmit "rings". These pointers are the addresses
@@ -1160,12 +522,27 @@ setup_hw_rings(struct au1000_private *aup, u32 rx_base, u32 tx_base)
1160} 522}
1161 523
1162static struct { 524static struct {
1163 int port;
1164 u32 base_addr; 525 u32 base_addr;
1165 u32 macen_addr; 526 u32 macen_addr;
1166 int irq; 527 int irq;
1167 struct net_device *dev; 528 struct net_device *dev;
1168} iflist[2]; 529} iflist[2] = {
530#ifdef CONFIG_SOC_AU1000
531 {AU1000_ETH0_BASE, AU1000_MAC0_ENABLE, AU1000_MAC0_DMA_INT},
532 {AU1000_ETH1_BASE, AU1000_MAC1_ENABLE, AU1000_MAC1_DMA_INT}
533#endif
534#ifdef CONFIG_SOC_AU1100
535 {AU1100_ETH0_BASE, AU1100_MAC0_ENABLE, AU1100_MAC0_DMA_INT}
536#endif
537#ifdef CONFIG_SOC_AU1500
538 {AU1500_ETH0_BASE, AU1500_MAC0_ENABLE, AU1500_MAC0_DMA_INT},
539 {AU1500_ETH1_BASE, AU1500_MAC1_ENABLE, AU1500_MAC1_DMA_INT}
540#endif
541#ifdef CONFIG_SOC_AU1550
542 {AU1550_ETH0_BASE, AU1550_MAC0_ENABLE, AU1550_MAC0_DMA_INT},
543 {AU1550_ETH1_BASE, AU1550_MAC1_ENABLE, AU1550_MAC1_DMA_INT}
544#endif
545};
1169 546
1170static int num_ifs; 547static int num_ifs;
1171 548
@@ -1176,58 +553,14 @@ static int num_ifs;
1176 */ 553 */
1177static int __init au1000_init_module(void) 554static int __init au1000_init_module(void)
1178{ 555{
1179 struct cpuinfo_mips *c = &current_cpu_data;
1180 int ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4); 556 int ni = (int)((au_readl(SYS_PINFUNC) & (u32)(SYS_PF_NI2)) >> 4);
1181 struct net_device *dev; 557 struct net_device *dev;
1182 int i, found_one = 0; 558 int i, found_one = 0;
1183 559
1184 switch (c->cputype) { 560 num_ifs = NUM_ETH_INTERFACES - ni;
1185#ifdef CONFIG_SOC_AU1000 561
1186 case CPU_AU1000:
1187 num_ifs = 2 - ni;
1188 iflist[0].base_addr = AU1000_ETH0_BASE;
1189 iflist[1].base_addr = AU1000_ETH1_BASE;
1190 iflist[0].macen_addr = AU1000_MAC0_ENABLE;
1191 iflist[1].macen_addr = AU1000_MAC1_ENABLE;
1192 iflist[0].irq = AU1000_MAC0_DMA_INT;
1193 iflist[1].irq = AU1000_MAC1_DMA_INT;
1194 break;
1195#endif
1196#ifdef CONFIG_SOC_AU1100
1197 case CPU_AU1100:
1198 num_ifs = 1 - ni;
1199 iflist[0].base_addr = AU1100_ETH0_BASE;
1200 iflist[0].macen_addr = AU1100_MAC0_ENABLE;
1201 iflist[0].irq = AU1100_MAC0_DMA_INT;
1202 break;
1203#endif
1204#ifdef CONFIG_SOC_AU1500
1205 case CPU_AU1500:
1206 num_ifs = 2 - ni;
1207 iflist[0].base_addr = AU1500_ETH0_BASE;
1208 iflist[1].base_addr = AU1500_ETH1_BASE;
1209 iflist[0].macen_addr = AU1500_MAC0_ENABLE;
1210 iflist[1].macen_addr = AU1500_MAC1_ENABLE;
1211 iflist[0].irq = AU1500_MAC0_DMA_INT;
1212 iflist[1].irq = AU1500_MAC1_DMA_INT;
1213 break;
1214#endif
1215#ifdef CONFIG_SOC_AU1550
1216 case CPU_AU1550:
1217 num_ifs = 2 - ni;
1218 iflist[0].base_addr = AU1550_ETH0_BASE;
1219 iflist[1].base_addr = AU1550_ETH1_BASE;
1220 iflist[0].macen_addr = AU1550_MAC0_ENABLE;
1221 iflist[1].macen_addr = AU1550_MAC1_ENABLE;
1222 iflist[0].irq = AU1550_MAC0_DMA_INT;
1223 iflist[1].irq = AU1550_MAC1_DMA_INT;
1224 break;
1225#endif
1226 default:
1227 num_ifs = 0;
1228 }
1229 for(i = 0; i < num_ifs; i++) { 562 for(i = 0; i < num_ifs; i++) {
1230 dev = au1000_probe(iflist[i].base_addr, iflist[i].irq, i); 563 dev = au1000_probe(i);
1231 iflist[i].dev = dev; 564 iflist[i].dev = dev;
1232 if (dev) 565 if (dev)
1233 found_one++; 566 found_one++;
@@ -1237,178 +570,31 @@ static int __init au1000_init_module(void)
1237 return 0; 570 return 0;
1238} 571}
1239 572
1240static int au1000_setup_aneg(struct net_device *dev, u32 advertise) 573/*
1241{ 574 * ethtool operations
1242 struct au1000_private *aup = (struct au1000_private *)dev->priv; 575 */
1243 u16 ctl, adv;
1244
1245 /* Setup standard advertise */
1246 adv = mdio_read(dev, aup->phy_addr, MII_ADVERTISE);
1247 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
1248 if (advertise & ADVERTISED_10baseT_Half)
1249 adv |= ADVERTISE_10HALF;
1250 if (advertise & ADVERTISED_10baseT_Full)
1251 adv |= ADVERTISE_10FULL;
1252 if (advertise & ADVERTISED_100baseT_Half)
1253 adv |= ADVERTISE_100HALF;
1254 if (advertise & ADVERTISED_100baseT_Full)
1255 adv |= ADVERTISE_100FULL;
1256 mdio_write(dev, aup->phy_addr, MII_ADVERTISE, adv);
1257
1258 /* Start/Restart aneg */
1259 ctl = mdio_read(dev, aup->phy_addr, MII_BMCR);
1260 ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
1261 mdio_write(dev, aup->phy_addr, MII_BMCR, ctl);
1262
1263 return 0;
1264}
1265 576
1266static int au1000_setup_forced(struct net_device *dev, int speed, int fd) 577static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1267{ 578{
1268 struct au1000_private *aup = (struct au1000_private *)dev->priv; 579 struct au1000_private *aup = (struct au1000_private *)dev->priv;
1269 u16 ctl;
1270
1271 ctl = mdio_read(dev, aup->phy_addr, MII_BMCR);
1272 ctl &= ~(BMCR_FULLDPLX | BMCR_SPEED100 | BMCR_ANENABLE);
1273
1274 /* First reset the PHY */
1275 mdio_write(dev, aup->phy_addr, MII_BMCR, ctl | BMCR_RESET);
1276
1277 /* Select speed & duplex */
1278 switch (speed) {
1279 case SPEED_10:
1280 break;
1281 case SPEED_100:
1282 ctl |= BMCR_SPEED100;
1283 break;
1284 case SPEED_1000:
1285 default:
1286 return -EINVAL;
1287 }
1288 if (fd == DUPLEX_FULL)
1289 ctl |= BMCR_FULLDPLX;
1290 mdio_write(dev, aup->phy_addr, MII_BMCR, ctl);
1291 580
1292 return 0; 581 if (aup->phy_dev)
1293} 582 return phy_ethtool_gset(aup->phy_dev, cmd);
1294 583
1295 584 return -EINVAL;
1296static void
1297au1000_start_link(struct net_device *dev, struct ethtool_cmd *cmd)
1298{
1299 struct au1000_private *aup = (struct au1000_private *)dev->priv;
1300 u32 advertise;
1301 int autoneg;
1302 int forced_speed;
1303 int forced_duplex;
1304
1305 /* Default advertise */
1306 advertise = GENMII_DEFAULT_ADVERTISE;
1307 autoneg = aup->want_autoneg;
1308 forced_speed = SPEED_100;
1309 forced_duplex = DUPLEX_FULL;
1310
1311 /* Setup link parameters */
1312 if (cmd) {
1313 if (cmd->autoneg == AUTONEG_ENABLE) {
1314 advertise = cmd->advertising;
1315 autoneg = 1;
1316 } else {
1317 autoneg = 0;
1318
1319 forced_speed = cmd->speed;
1320 forced_duplex = cmd->duplex;
1321 }
1322 }
1323
1324 /* Configure PHY & start aneg */
1325 aup->want_autoneg = autoneg;
1326 if (autoneg)
1327 au1000_setup_aneg(dev, advertise);
1328 else
1329 au1000_setup_forced(dev, forced_speed, forced_duplex);
1330 mod_timer(&aup->timer, jiffies + HZ);
1331} 585}
1332 586
1333static int au1000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 587static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1334{ 588{
1335 struct au1000_private *aup = (struct au1000_private *)dev->priv; 589 struct au1000_private *aup = (struct au1000_private *)dev->priv;
1336 u16 link, speed;
1337
1338 cmd->supported = GENMII_DEFAULT_FEATURES;
1339 cmd->advertising = GENMII_DEFAULT_ADVERTISE;
1340 cmd->port = PORT_MII;
1341 cmd->transceiver = XCVR_EXTERNAL;
1342 cmd->phy_address = aup->phy_addr;
1343 spin_lock_irq(&aup->lock);
1344 cmd->autoneg = aup->want_autoneg;
1345 aup->phy_ops->phy_status(dev, aup->phy_addr, &link, &speed);
1346 if ((speed == IF_PORT_100BASETX) || (speed == IF_PORT_100BASEFX))
1347 cmd->speed = SPEED_100;
1348 else if (speed == IF_PORT_10BASET)
1349 cmd->speed = SPEED_10;
1350 if (link && (dev->if_port == IF_PORT_100BASEFX))
1351 cmd->duplex = DUPLEX_FULL;
1352 else
1353 cmd->duplex = DUPLEX_HALF;
1354 spin_unlock_irq(&aup->lock);
1355 return 0;
1356}
1357 590
1358static int au1000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 591 if (!capable(CAP_NET_ADMIN))
1359{ 592 return -EPERM;
1360 struct au1000_private *aup = (struct au1000_private *)dev->priv;
1361 unsigned long features = GENMII_DEFAULT_FEATURES;
1362
1363 if (!capable(CAP_NET_ADMIN))
1364 return -EPERM;
1365
1366 if (cmd->autoneg != AUTONEG_ENABLE && cmd->autoneg != AUTONEG_DISABLE)
1367 return -EINVAL;
1368 if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0)
1369 return -EINVAL;
1370 if (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL)
1371 return -EINVAL;
1372 if (cmd->autoneg == AUTONEG_DISABLE)
1373 switch (cmd->speed) {
1374 case SPEED_10:
1375 if (cmd->duplex == DUPLEX_HALF &&
1376 (features & SUPPORTED_10baseT_Half) == 0)
1377 return -EINVAL;
1378 if (cmd->duplex == DUPLEX_FULL &&
1379 (features & SUPPORTED_10baseT_Full) == 0)
1380 return -EINVAL;
1381 break;
1382 case SPEED_100:
1383 if (cmd->duplex == DUPLEX_HALF &&
1384 (features & SUPPORTED_100baseT_Half) == 0)
1385 return -EINVAL;
1386 if (cmd->duplex == DUPLEX_FULL &&
1387 (features & SUPPORTED_100baseT_Full) == 0)
1388 return -EINVAL;
1389 break;
1390 default:
1391 return -EINVAL;
1392 }
1393 else if ((features & SUPPORTED_Autoneg) == 0)
1394 return -EINVAL;
1395
1396 spin_lock_irq(&aup->lock);
1397 au1000_start_link(dev, cmd);
1398 spin_unlock_irq(&aup->lock);
1399 return 0;
1400}
1401 593
1402static int au1000_nway_reset(struct net_device *dev) 594 if (aup->phy_dev)
1403{ 595 return phy_ethtool_sset(aup->phy_dev, cmd);
1404 struct au1000_private *aup = (struct au1000_private *)dev->priv;
1405 596
1406 if (!aup->want_autoneg) 597 return -EINVAL;
1407 return -EINVAL;
1408 spin_lock_irq(&aup->lock);
1409 au1000_start_link(dev, NULL);
1410 spin_unlock_irq(&aup->lock);
1411 return 0;
1412} 598}
1413 599
1414static void 600static void
@@ -1423,21 +609,14 @@ au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1423 info->regdump_len = 0; 609 info->regdump_len = 0;
1424} 610}
1425 611
1426static u32 au1000_get_link(struct net_device *dev)
1427{
1428 return netif_carrier_ok(dev);
1429}
1430
1431static struct ethtool_ops au1000_ethtool_ops = { 612static struct ethtool_ops au1000_ethtool_ops = {
1432 .get_settings = au1000_get_settings, 613 .get_settings = au1000_get_settings,
1433 .set_settings = au1000_set_settings, 614 .set_settings = au1000_set_settings,
1434 .get_drvinfo = au1000_get_drvinfo, 615 .get_drvinfo = au1000_get_drvinfo,
1435 .nway_reset = au1000_nway_reset, 616 .get_link = ethtool_op_get_link,
1436 .get_link = au1000_get_link
1437}; 617};
1438 618
1439static struct net_device * 619static struct net_device * au1000_probe(int port_num)
1440au1000_probe(u32 ioaddr, int irq, int port_num)
1441{ 620{
1442 static unsigned version_printed = 0; 621 static unsigned version_printed = 0;
1443 struct au1000_private *aup = NULL; 622 struct au1000_private *aup = NULL;
@@ -1445,106 +624,115 @@ au1000_probe(u32 ioaddr, int irq, int port_num)
1445 db_dest_t *pDB, *pDBfree; 624 db_dest_t *pDB, *pDBfree;
1446 char *pmac, *argptr; 625 char *pmac, *argptr;
1447 char ethaddr[6]; 626 char ethaddr[6];
1448 int i, err; 627 int irq, i, err;
628 u32 base, macen;
629
630 if (port_num >= NUM_ETH_INTERFACES)
631 return NULL;
632
633 base = CPHYSADDR(iflist[port_num].base_addr );
634 macen = CPHYSADDR(iflist[port_num].macen_addr);
635 irq = iflist[port_num].irq;
1449 636
1450 if (!request_mem_region(CPHYSADDR(ioaddr), MAC_IOSIZE, "Au1x00 ENET")) 637 if (!request_mem_region( base, MAC_IOSIZE, "Au1x00 ENET") ||
638 !request_mem_region(macen, 4, "Au1x00 ENET"))
1451 return NULL; 639 return NULL;
1452 640
1453 if (version_printed++ == 0) 641 if (version_printed++ == 0)
1454 printk("%s version %s %s\n", DRV_NAME, DRV_VERSION, DRV_AUTHOR); 642 printk("%s version %s %s\n", DRV_NAME, DRV_VERSION, DRV_AUTHOR);
1455 643
1456 dev = alloc_etherdev(sizeof(struct au1000_private)); 644 dev = alloc_etherdev(sizeof(struct au1000_private));
1457 if (!dev) { 645 if (!dev) {
1458 printk (KERN_ERR "au1000 eth: alloc_etherdev failed\n"); 646 printk(KERN_ERR "%s: alloc_etherdev failed\n", DRV_NAME);
1459 return NULL; 647 return NULL;
1460 } 648 }
1461 649
1462 if ((err = register_netdev(dev))) { 650 if ((err = register_netdev(dev)) != 0) {
1463 printk(KERN_ERR "Au1x_eth Cannot register net device err %d\n", 651 printk(KERN_ERR "%s: Cannot register net device, error %d\n",
1464 err); 652 DRV_NAME, err);
1465 free_netdev(dev); 653 free_netdev(dev);
1466 return NULL; 654 return NULL;
1467 } 655 }
1468 656
1469 printk("%s: Au1x Ethernet found at 0x%x, irq %d\n", 657 printk("%s: Au1xx0 Ethernet found at 0x%x, irq %d\n",
1470 dev->name, ioaddr, irq); 658 dev->name, base, irq);
1471 659
1472 aup = dev->priv; 660 aup = dev->priv;
1473 661
1474 /* Allocate the data buffers */ 662 /* Allocate the data buffers */
1475 /* Snooping works fine with eth on all au1xxx */ 663 /* Snooping works fine with eth on all au1xxx */
1476 aup->vaddr = (u32)dma_alloc_noncoherent(NULL, 664 aup->vaddr = (u32)dma_alloc_noncoherent(NULL, MAX_BUF_SIZE *
1477 MAX_BUF_SIZE * (NUM_TX_BUFFS+NUM_RX_BUFFS), 665 (NUM_TX_BUFFS + NUM_RX_BUFFS),
1478 &aup->dma_addr, 666 &aup->dma_addr, 0);
1479 0);
1480 if (!aup->vaddr) { 667 if (!aup->vaddr) {
1481 free_netdev(dev); 668 free_netdev(dev);
1482 release_mem_region(CPHYSADDR(ioaddr), MAC_IOSIZE); 669 release_mem_region( base, MAC_IOSIZE);
670 release_mem_region(macen, 4);
1483 return NULL; 671 return NULL;
1484 } 672 }
1485 673
1486 /* aup->mac is the base address of the MAC's registers */ 674 /* aup->mac is the base address of the MAC's registers */
1487 aup->mac = (volatile mac_reg_t *)((unsigned long)ioaddr); 675 aup->mac = (volatile mac_reg_t *)iflist[port_num].base_addr;
676
1488 /* Setup some variables for quick register address access */ 677 /* Setup some variables for quick register address access */
1489 if (ioaddr == iflist[0].base_addr) 678 aup->enable = (volatile u32 *)iflist[port_num].macen_addr;
1490 { 679 aup->mac_id = port_num;
1491 /* check env variables first */ 680 au_macs[port_num] = aup;
1492 if (!get_ethernet_addr(ethaddr)) { 681
682 if (port_num == 0) {
683 /* Check the environment variables first */
684 if (get_ethernet_addr(ethaddr) == 0)
1493 memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr)); 685 memcpy(au1000_mac_addr, ethaddr, sizeof(au1000_mac_addr));
1494 } else { 686 else {
1495 /* Check command line */ 687 /* Check command line */
1496 argptr = prom_getcmdline(); 688 argptr = prom_getcmdline();
1497 if ((pmac = strstr(argptr, "ethaddr=")) == NULL) { 689 if ((pmac = strstr(argptr, "ethaddr=")) == NULL)
1498 printk(KERN_INFO "%s: No mac address found\n", 690 printk(KERN_INFO "%s: No MAC address found\n",
1499 dev->name); 691 dev->name);
1500 /* use the hard coded mac addresses */ 692 /* Use the hard coded MAC addresses */
1501 } else { 693 else {
1502 str2eaddr(ethaddr, pmac + strlen("ethaddr=")); 694 str2eaddr(ethaddr, pmac + strlen("ethaddr="));
1503 memcpy(au1000_mac_addr, ethaddr, 695 memcpy(au1000_mac_addr, ethaddr,
1504 sizeof(au1000_mac_addr)); 696 sizeof(au1000_mac_addr));
1505 } 697 }
1506 } 698 }
1507 aup->enable = (volatile u32 *) 699
1508 ((unsigned long)iflist[0].macen_addr);
1509 memcpy(dev->dev_addr, au1000_mac_addr, sizeof(au1000_mac_addr));
1510 setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR); 700 setup_hw_rings(aup, MAC0_RX_DMA_ADDR, MAC0_TX_DMA_ADDR);
1511 aup->mac_id = 0; 701 } else if (port_num == 1)
1512 au_macs[0] = aup;
1513 }
1514 else
1515 if (ioaddr == iflist[1].base_addr)
1516 {
1517 aup->enable = (volatile u32 *)
1518 ((unsigned long)iflist[1].macen_addr);
1519 memcpy(dev->dev_addr, au1000_mac_addr, sizeof(au1000_mac_addr));
1520 dev->dev_addr[4] += 0x10;
1521 setup_hw_rings(aup, MAC1_RX_DMA_ADDR, MAC1_TX_DMA_ADDR); 702 setup_hw_rings(aup, MAC1_RX_DMA_ADDR, MAC1_TX_DMA_ADDR);
1522 aup->mac_id = 1;
1523 au_macs[1] = aup;
1524 }
1525 else
1526 {
1527 printk(KERN_ERR "%s: bad ioaddr\n", dev->name);
1528 }
1529
1530 /* bring the device out of reset, otherwise probing the mii
1531 * will hang */
1532 *aup->enable = MAC_EN_CLOCK_ENABLE;
1533 au_sync_delay(2);
1534 *aup->enable = MAC_EN_RESET0 | MAC_EN_RESET1 |
1535 MAC_EN_RESET2 | MAC_EN_CLOCK_ENABLE;
1536 au_sync_delay(2);
1537 703
1538 aup->mii = kmalloc(sizeof(struct mii_phy), GFP_KERNEL); 704 /*
1539 if (!aup->mii) { 705 * Assign to the Ethernet ports two consecutive MAC addresses
1540 printk(KERN_ERR "%s: out of memory\n", dev->name); 706 * to match those that are printed on their stickers
1541 goto err_out; 707 */
1542 } 708 memcpy(dev->dev_addr, au1000_mac_addr, sizeof(au1000_mac_addr));
1543 aup->mii->next = NULL; 709 dev->dev_addr[5] += port_num;
1544 aup->mii->chip_info = NULL; 710
1545 aup->mii->status = 0; 711 *aup->enable = 0;
1546 aup->mii->mii_control_reg = 0; 712 aup->mac_enabled = 0;
1547 aup->mii->mii_data_reg = 0; 713
714 aup->mii_bus.priv = dev;
715 aup->mii_bus.read = mdiobus_read;
716 aup->mii_bus.write = mdiobus_write;
717 aup->mii_bus.reset = mdiobus_reset;
718 aup->mii_bus.name = "au1000_eth_mii";
719 aup->mii_bus.id = aup->mac_id;
720 aup->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
721 for(i = 0; i < PHY_MAX_ADDR; ++i)
722 aup->mii_bus.irq[i] = PHY_POLL;
723
724 /* if known, set corresponding PHY IRQs */
725#if defined(AU1XXX_PHY_STATIC_CONFIG)
726# if defined(AU1XXX_PHY0_IRQ)
727 if (AU1XXX_PHY0_BUSID == aup->mii_bus.id)
728 aup->mii_bus.irq[AU1XXX_PHY0_ADDR] = AU1XXX_PHY0_IRQ;
729# endif
730# if defined(AU1XXX_PHY1_IRQ)
731 if (AU1XXX_PHY1_BUSID == aup->mii_bus.id)
732 aup->mii_bus.irq[AU1XXX_PHY1_ADDR] = AU1XXX_PHY1_IRQ;
733# endif
734#endif
735 mdiobus_register(&aup->mii_bus);
1548 736
1549 if (mii_probe(dev) != 0) { 737 if (mii_probe(dev) != 0) {
1550 goto err_out; 738 goto err_out;
@@ -1581,7 +769,7 @@ au1000_probe(u32 ioaddr, int irq, int port_num)
1581 } 769 }
1582 770
1583 spin_lock_init(&aup->lock); 771 spin_lock_init(&aup->lock);
1584 dev->base_addr = ioaddr; 772 dev->base_addr = base;
1585 dev->irq = irq; 773 dev->irq = irq;
1586 dev->open = au1000_open; 774 dev->open = au1000_open;
1587 dev->hard_start_xmit = au1000_tx; 775 dev->hard_start_xmit = au1000_tx;
@@ -1590,7 +778,6 @@ au1000_probe(u32 ioaddr, int irq, int port_num)
1590 dev->set_multicast_list = &set_rx_mode; 778 dev->set_multicast_list = &set_rx_mode;
1591 dev->do_ioctl = &au1000_ioctl; 779 dev->do_ioctl = &au1000_ioctl;
1592 SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops); 780 SET_ETHTOOL_OPS(dev, &au1000_ethtool_ops);
1593 dev->set_config = &au1000_set_config;
1594 dev->tx_timeout = au1000_tx_timeout; 781 dev->tx_timeout = au1000_tx_timeout;
1595 dev->watchdog_timeo = ETH_TX_TIMEOUT; 782 dev->watchdog_timeo = ETH_TX_TIMEOUT;
1596 783
@@ -1606,7 +793,7 @@ err_out:
1606 /* here we should have a valid dev plus aup-> register addresses 793 /* here we should have a valid dev plus aup-> register addresses
1607 * so we can reset the mac properly.*/ 794 * so we can reset the mac properly.*/
1608 reset_mac(dev); 795 reset_mac(dev);
1609 kfree(aup->mii); 796
1610 for (i = 0; i < NUM_RX_DMA; i++) { 797 for (i = 0; i < NUM_RX_DMA; i++) {
1611 if (aup->rx_db_inuse[i]) 798 if (aup->rx_db_inuse[i])
1612 ReleaseDB(aup, aup->rx_db_inuse[i]); 799 ReleaseDB(aup, aup->rx_db_inuse[i]);
@@ -1615,13 +802,12 @@ err_out:
1615 if (aup->tx_db_inuse[i]) 802 if (aup->tx_db_inuse[i])
1616 ReleaseDB(aup, aup->tx_db_inuse[i]); 803 ReleaseDB(aup, aup->tx_db_inuse[i]);
1617 } 804 }
1618 dma_free_noncoherent(NULL, 805 dma_free_noncoherent(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1619 MAX_BUF_SIZE * (NUM_TX_BUFFS+NUM_RX_BUFFS), 806 (void *)aup->vaddr, aup->dma_addr);
1620 (void *)aup->vaddr,
1621 aup->dma_addr);
1622 unregister_netdev(dev); 807 unregister_netdev(dev);
1623 free_netdev(dev); 808 free_netdev(dev);
1624 release_mem_region(CPHYSADDR(ioaddr), MAC_IOSIZE); 809 release_mem_region( base, MAC_IOSIZE);
810 release_mem_region(macen, 4);
1625 return NULL; 811 return NULL;
1626} 812}
1627 813
@@ -1640,19 +826,14 @@ static int au1000_init(struct net_device *dev)
1640 u32 flags; 826 u32 flags;
1641 int i; 827 int i;
1642 u32 control; 828 u32 control;
1643 u16 link, speed;
1644 829
1645 if (au1000_debug > 4) 830 if (au1000_debug > 4)
1646 printk("%s: au1000_init\n", dev->name); 831 printk("%s: au1000_init\n", dev->name);
1647 832
1648 spin_lock_irqsave(&aup->lock, flags);
1649
1650 /* bring the device out of reset */ 833 /* bring the device out of reset */
1651 *aup->enable = MAC_EN_CLOCK_ENABLE; 834 enable_mac(dev, 1);
1652 au_sync_delay(2); 835
1653 *aup->enable = MAC_EN_RESET0 | MAC_EN_RESET1 | 836 spin_lock_irqsave(&aup->lock, flags);
1654 MAC_EN_RESET2 | MAC_EN_CLOCK_ENABLE;
1655 au_sync_delay(20);
1656 837
1657 aup->mac->control = 0; 838 aup->mac->control = 0;
1658 aup->tx_head = (aup->tx_dma_ring[0]->buff_stat & 0xC) >> 2; 839 aup->tx_head = (aup->tx_dma_ring[0]->buff_stat & 0xC) >> 2;
@@ -1668,12 +849,16 @@ static int au1000_init(struct net_device *dev)
1668 } 849 }
1669 au_sync(); 850 au_sync();
1670 851
1671 aup->phy_ops->phy_status(dev, aup->phy_addr, &link, &speed); 852 control = MAC_RX_ENABLE | MAC_TX_ENABLE;
1672 control = MAC_DISABLE_RX_OWN | MAC_RX_ENABLE | MAC_TX_ENABLE;
1673#ifndef CONFIG_CPU_LITTLE_ENDIAN 853#ifndef CONFIG_CPU_LITTLE_ENDIAN
1674 control |= MAC_BIG_ENDIAN; 854 control |= MAC_BIG_ENDIAN;
1675#endif 855#endif
1676 if (link && (dev->if_port == IF_PORT_100BASEFX)) { 856 if (aup->phy_dev) {
857 if (aup->phy_dev->link && (DUPLEX_FULL == aup->phy_dev->duplex))
858 control |= MAC_FULL_DUPLEX;
859 else
860 control |= MAC_DISABLE_RX_OWN;
861 } else { /* PHY-less op, assume full-duplex */
1677 control |= MAC_FULL_DUPLEX; 862 control |= MAC_FULL_DUPLEX;
1678 } 863 }
1679 864
@@ -1685,57 +870,84 @@ static int au1000_init(struct net_device *dev)
1685 return 0; 870 return 0;
1686} 871}
1687 872
1688static void au1000_timer(unsigned long data) 873static void
874au1000_adjust_link(struct net_device *dev)
1689{ 875{
1690 struct net_device *dev = (struct net_device *)data;
1691 struct au1000_private *aup = (struct au1000_private *) dev->priv; 876 struct au1000_private *aup = (struct au1000_private *) dev->priv;
1692 unsigned char if_port; 877 struct phy_device *phydev = aup->phy_dev;
1693 u16 link, speed; 878 unsigned long flags;
1694 879
1695 if (!dev) { 880 int status_change = 0;
1696 /* fatal error, don't restart the timer */
1697 printk(KERN_ERR "au1000_timer error: NULL dev\n");
1698 return;
1699 }
1700 881
1701 if_port = dev->if_port; 882 BUG_ON(!aup->phy_dev);
1702 if (aup->phy_ops->phy_status(dev, aup->phy_addr, &link, &speed) == 0) { 883
1703 if (link) { 884 spin_lock_irqsave(&aup->lock, flags);
1704 if (!netif_carrier_ok(dev)) { 885
1705 netif_carrier_on(dev); 886 if (phydev->link && (aup->old_speed != phydev->speed)) {
1706 printk(KERN_INFO "%s: link up\n", dev->name); 887 // speed changed
1707 } 888
1708 } 889 switch(phydev->speed) {
1709 else { 890 case SPEED_10:
1710 if (netif_carrier_ok(dev)) { 891 case SPEED_100:
1711 netif_carrier_off(dev); 892 break;
1712 dev->if_port = 0; 893 default:
1713 printk(KERN_INFO "%s: link down\n", dev->name); 894 printk(KERN_WARNING
1714 } 895 "%s: Speed (%d) is not 10/100 ???\n",
896 dev->name, phydev->speed);
897 break;
1715 } 898 }
899
900 aup->old_speed = phydev->speed;
901
902 status_change = 1;
1716 } 903 }
1717 904
1718 if (link && (dev->if_port != if_port) && 905 if (phydev->link && (aup->old_duplex != phydev->duplex)) {
1719 (dev->if_port != IF_PORT_UNKNOWN)) { 906 // duplex mode changed
907
908 /* switching duplex mode requires to disable rx and tx! */
1720 hard_stop(dev); 909 hard_stop(dev);
1721 if (dev->if_port == IF_PORT_100BASEFX) { 910
1722 printk(KERN_INFO "%s: going to full duplex\n", 911 if (DUPLEX_FULL == phydev->duplex)
1723 dev->name); 912 aup->mac->control = ((aup->mac->control
1724 aup->mac->control |= MAC_FULL_DUPLEX; 913 | MAC_FULL_DUPLEX)
1725 au_sync_delay(1); 914 & ~MAC_DISABLE_RX_OWN);
1726 } 915 else
1727 else { 916 aup->mac->control = ((aup->mac->control
1728 aup->mac->control &= ~MAC_FULL_DUPLEX; 917 & ~MAC_FULL_DUPLEX)
1729 au_sync_delay(1); 918 | MAC_DISABLE_RX_OWN);
1730 } 919 au_sync_delay(1);
920
1731 enable_rx_tx(dev); 921 enable_rx_tx(dev);
922 aup->old_duplex = phydev->duplex;
923
924 status_change = 1;
1732 } 925 }
1733 926
1734 aup->timer.expires = RUN_AT((1*HZ)); 927 if(phydev->link != aup->old_link) {
1735 aup->timer.data = (unsigned long)dev; 928 // link state changed
1736 aup->timer.function = &au1000_timer; /* timer handler */
1737 add_timer(&aup->timer);
1738 929
930 if (phydev->link) // link went up
931 netif_schedule(dev);
932 else { // link went down
933 aup->old_speed = 0;
934 aup->old_duplex = -1;
935 }
936
937 aup->old_link = phydev->link;
938 status_change = 1;
939 }
940
941 spin_unlock_irqrestore(&aup->lock, flags);
942
943 if (status_change) {
944 if (phydev->link)
945 printk(KERN_INFO "%s: link up (%d/%s)\n",
946 dev->name, phydev->speed,
947 DUPLEX_FULL == phydev->duplex ? "Full" : "Half");
948 else
949 printk(KERN_INFO "%s: link down\n", dev->name);
950 }
1739} 951}
1740 952
1741static int au1000_open(struct net_device *dev) 953static int au1000_open(struct net_device *dev)
@@ -1746,25 +958,26 @@ static int au1000_open(struct net_device *dev)
1746 if (au1000_debug > 4) 958 if (au1000_debug > 4)
1747 printk("%s: open: dev=%p\n", dev->name, dev); 959 printk("%s: open: dev=%p\n", dev->name, dev);
1748 960
961 if ((retval = request_irq(dev->irq, &au1000_interrupt, 0,
962 dev->name, dev))) {
963 printk(KERN_ERR "%s: unable to get IRQ %d\n",
964 dev->name, dev->irq);
965 return retval;
966 }
967
1749 if ((retval = au1000_init(dev))) { 968 if ((retval = au1000_init(dev))) {
1750 printk(KERN_ERR "%s: error in au1000_init\n", dev->name); 969 printk(KERN_ERR "%s: error in au1000_init\n", dev->name);
1751 free_irq(dev->irq, dev); 970 free_irq(dev->irq, dev);
1752 return retval; 971 return retval;
1753 } 972 }
1754 netif_start_queue(dev);
1755 973
1756 if ((retval = request_irq(dev->irq, &au1000_interrupt, 0, 974 if (aup->phy_dev) {
1757 dev->name, dev))) { 975 /* cause the PHY state machine to schedule a link state check */
1758 printk(KERN_ERR "%s: unable to get IRQ %d\n", 976 aup->phy_dev->state = PHY_CHANGELINK;
1759 dev->name, dev->irq); 977 phy_start(aup->phy_dev);
1760 return retval;
1761 } 978 }
1762 979
1763 init_timer(&aup->timer); /* used in ioctl() */ 980 netif_start_queue(dev);
1764 aup->timer.expires = RUN_AT((3*HZ));
1765 aup->timer.data = (unsigned long)dev;
1766 aup->timer.function = &au1000_timer; /* timer handler */
1767 add_timer(&aup->timer);
1768 981
1769 if (au1000_debug > 4) 982 if (au1000_debug > 4)
1770 printk("%s: open: Initialization done.\n", dev->name); 983 printk("%s: open: Initialization done.\n", dev->name);
@@ -1774,16 +987,19 @@ static int au1000_open(struct net_device *dev)
1774 987
1775static int au1000_close(struct net_device *dev) 988static int au1000_close(struct net_device *dev)
1776{ 989{
1777 u32 flags; 990 unsigned long flags;
1778 struct au1000_private *aup = (struct au1000_private *) dev->priv; 991 struct au1000_private *const aup = (struct au1000_private *) dev->priv;
1779 992
1780 if (au1000_debug > 4) 993 if (au1000_debug > 4)
1781 printk("%s: close: dev=%p\n", dev->name, dev); 994 printk("%s: close: dev=%p\n", dev->name, dev);
1782 995
1783 reset_mac(dev); 996 if (aup->phy_dev)
997 phy_stop(aup->phy_dev);
1784 998
1785 spin_lock_irqsave(&aup->lock, flags); 999 spin_lock_irqsave(&aup->lock, flags);
1786 1000
1001 reset_mac_unlocked (dev);
1002
1787 /* stop the device */ 1003 /* stop the device */
1788 netif_stop_queue(dev); 1004 netif_stop_queue(dev);
1789 1005
@@ -1805,21 +1021,18 @@ static void __exit au1000_cleanup_module(void)
1805 if (dev) { 1021 if (dev) {
1806 aup = (struct au1000_private *) dev->priv; 1022 aup = (struct au1000_private *) dev->priv;
1807 unregister_netdev(dev); 1023 unregister_netdev(dev);
1808 kfree(aup->mii); 1024 for (j = 0; j < NUM_RX_DMA; j++)
1809 for (j = 0; j < NUM_RX_DMA; j++) {
1810 if (aup->rx_db_inuse[j]) 1025 if (aup->rx_db_inuse[j])
1811 ReleaseDB(aup, aup->rx_db_inuse[j]); 1026 ReleaseDB(aup, aup->rx_db_inuse[j]);
1812 } 1027 for (j = 0; j < NUM_TX_DMA; j++)
1813 for (j = 0; j < NUM_TX_DMA; j++) {
1814 if (aup->tx_db_inuse[j]) 1028 if (aup->tx_db_inuse[j])
1815 ReleaseDB(aup, aup->tx_db_inuse[j]); 1029 ReleaseDB(aup, aup->tx_db_inuse[j]);
1816 } 1030 dma_free_noncoherent(NULL, MAX_BUF_SIZE *
1817 dma_free_noncoherent(NULL, 1031 (NUM_TX_BUFFS + NUM_RX_BUFFS),
1818 MAX_BUF_SIZE * (NUM_TX_BUFFS+NUM_RX_BUFFS), 1032 (void *)aup->vaddr, aup->dma_addr);
1819 (void *)aup->vaddr, 1033 release_mem_region(dev->base_addr, MAC_IOSIZE);
1820 aup->dma_addr); 1034 release_mem_region(CPHYSADDR(iflist[i].macen_addr), 4);
1821 free_netdev(dev); 1035 free_netdev(dev);
1822 release_mem_region(CPHYSADDR(iflist[i].base_addr), MAC_IOSIZE);
1823 } 1036 }
1824 } 1037 }
1825} 1038}
@@ -1830,7 +1043,7 @@ static void update_tx_stats(struct net_device *dev, u32 status)
1830 struct net_device_stats *ps = &aup->stats; 1043 struct net_device_stats *ps = &aup->stats;
1831 1044
1832 if (status & TX_FRAME_ABORTED) { 1045 if (status & TX_FRAME_ABORTED) {
1833 if (dev->if_port == IF_PORT_100BASEFX) { 1046 if (!aup->phy_dev || (DUPLEX_FULL == aup->phy_dev->duplex)) {
1834 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) { 1047 if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) {
1835 /* any other tx errors are only valid 1048 /* any other tx errors are only valid
1836 * in half duplex mode */ 1049 * in half duplex mode */
@@ -2104,126 +1317,15 @@ static void set_rx_mode(struct net_device *dev)
2104 } 1317 }
2105} 1318}
2106 1319
2107
2108static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1320static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2109{ 1321{
2110 struct au1000_private *aup = (struct au1000_private *)dev->priv; 1322 struct au1000_private *aup = (struct au1000_private *)dev->priv;
2111 u16 *data = (u16 *)&rq->ifr_ifru;
2112
2113 switch(cmd) {
2114 case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */
2115 case SIOCGMIIPHY:
2116 if (!netif_running(dev)) return -EINVAL;
2117 data[0] = aup->phy_addr;
2118 case SIOCDEVPRIVATE+1: /* Read the specified MII register. */
2119 case SIOCGMIIREG:
2120 data[3] = mdio_read(dev, data[0], data[1]);
2121 return 0;
2122 case SIOCDEVPRIVATE+2: /* Write the specified MII register */
2123 case SIOCSMIIREG:
2124 if (!capable(CAP_NET_ADMIN))
2125 return -EPERM;
2126 mdio_write(dev, data[0], data[1],data[2]);
2127 return 0;
2128 default:
2129 return -EOPNOTSUPP;
2130 }
2131
2132}
2133
2134
2135static int au1000_set_config(struct net_device *dev, struct ifmap *map)
2136{
2137 struct au1000_private *aup = (struct au1000_private *) dev->priv;
2138 u16 control;
2139 1323
2140 if (au1000_debug > 4) { 1324 if (!netif_running(dev)) return -EINVAL;
2141 printk("%s: set_config called: dev->if_port %d map->port %x\n",
2142 dev->name, dev->if_port, map->port);
2143 }
2144 1325
2145 switch(map->port){ 1326 if (!aup->phy_dev) return -EINVAL; // PHY not controllable
2146 case IF_PORT_UNKNOWN: /* use auto here */
2147 printk(KERN_INFO "%s: config phy for aneg\n",
2148 dev->name);
2149 dev->if_port = map->port;
2150 /* Link Down: the timer will bring it up */
2151 netif_carrier_off(dev);
2152
2153 /* read current control */
2154 control = mdio_read(dev, aup->phy_addr, MII_CONTROL);
2155 control &= ~(MII_CNTL_FDX | MII_CNTL_F100);
2156
2157 /* enable auto negotiation and reset the negotiation */
2158 mdio_write(dev, aup->phy_addr, MII_CONTROL,
2159 control | MII_CNTL_AUTO |
2160 MII_CNTL_RST_AUTO);
2161 1327
2162 break; 1328 return phy_mii_ioctl(aup->phy_dev, if_mii(rq), cmd);
2163
2164 case IF_PORT_10BASET: /* 10BaseT */
2165 printk(KERN_INFO "%s: config phy for 10BaseT\n",
2166 dev->name);
2167 dev->if_port = map->port;
2168
2169 /* Link Down: the timer will bring it up */
2170 netif_carrier_off(dev);
2171
2172 /* set Speed to 10Mbps, Half Duplex */
2173 control = mdio_read(dev, aup->phy_addr, MII_CONTROL);
2174 control &= ~(MII_CNTL_F100 | MII_CNTL_AUTO |
2175 MII_CNTL_FDX);
2176
2177 /* disable auto negotiation and force 10M/HD mode*/
2178 mdio_write(dev, aup->phy_addr, MII_CONTROL, control);
2179 break;
2180
2181 case IF_PORT_100BASET: /* 100BaseT */
2182 case IF_PORT_100BASETX: /* 100BaseTx */
2183 printk(KERN_INFO "%s: config phy for 100BaseTX\n",
2184 dev->name);
2185 dev->if_port = map->port;
2186
2187 /* Link Down: the timer will bring it up */
2188 netif_carrier_off(dev);
2189
2190 /* set Speed to 100Mbps, Half Duplex */
2191 /* disable auto negotiation and enable 100MBit Mode */
2192 control = mdio_read(dev, aup->phy_addr, MII_CONTROL);
2193 control &= ~(MII_CNTL_AUTO | MII_CNTL_FDX);
2194 control |= MII_CNTL_F100;
2195 mdio_write(dev, aup->phy_addr, MII_CONTROL, control);
2196 break;
2197
2198 case IF_PORT_100BASEFX: /* 100BaseFx */
2199 printk(KERN_INFO "%s: config phy for 100BaseFX\n",
2200 dev->name);
2201 dev->if_port = map->port;
2202
2203 /* Link Down: the timer will bring it up */
2204 netif_carrier_off(dev);
2205
2206 /* set Speed to 100Mbps, Full Duplex */
2207 /* disable auto negotiation and enable 100MBit Mode */
2208 control = mdio_read(dev, aup->phy_addr, MII_CONTROL);
2209 control &= ~MII_CNTL_AUTO;
2210 control |= MII_CNTL_F100 | MII_CNTL_FDX;
2211 mdio_write(dev, aup->phy_addr, MII_CONTROL, control);
2212 break;
2213 case IF_PORT_10BASE2: /* 10Base2 */
2214 case IF_PORT_AUI: /* AUI */
2215 /* These Modes are not supported (are they?)*/
2216 printk(KERN_ERR "%s: 10Base2/AUI not supported",
2217 dev->name);
2218 return -EOPNOTSUPP;
2219 break;
2220
2221 default:
2222 printk(KERN_ERR "%s: Invalid media selected",
2223 dev->name);
2224 return -EINVAL;
2225 }
2226 return 0;
2227} 1329}
2228 1330
2229static struct net_device_stats *au1000_get_stats(struct net_device *dev) 1331static struct net_device_stats *au1000_get_stats(struct net_device *dev)
diff --git a/drivers/net/au1000_eth.h b/drivers/net/au1000_eth.h
index 7f9326e39cc0..41c2f848d2c4 100644
--- a/drivers/net/au1000_eth.h
+++ b/drivers/net/au1000_eth.h
@@ -40,120 +40,6 @@
40 40
41#define MULTICAST_FILTER_LIMIT 64 41#define MULTICAST_FILTER_LIMIT 64
42 42
43/* FIXME
44 * The PHY defines should be in a separate file.
45 */
46
47/* MII register offsets */
48#define MII_CONTROL 0x0000
49#define MII_STATUS 0x0001
50#define MII_PHY_ID0 0x0002
51#define MII_PHY_ID1 0x0003
52#define MII_ANADV 0x0004
53#define MII_ANLPAR 0x0005
54#define MII_AEXP 0x0006
55#define MII_ANEXT 0x0007
56#define MII_LSI_PHY_CONFIG 0x0011
57/* Status register */
58#define MII_LSI_PHY_STAT 0x0012
59#define MII_AMD_PHY_STAT MII_LSI_PHY_STAT
60#define MII_INTEL_PHY_STAT 0x0011
61
62#define MII_AUX_CNTRL 0x0018
63/* mii registers specific to AMD 79C901 */
64#define MII_STATUS_SUMMARY = 0x0018
65
66/* MII Control register bit definitions. */
67#define MII_CNTL_FDX 0x0100
68#define MII_CNTL_RST_AUTO 0x0200
69#define MII_CNTL_ISOLATE 0x0400
70#define MII_CNTL_PWRDWN 0x0800
71#define MII_CNTL_AUTO 0x1000
72#define MII_CNTL_F100 0x2000
73#define MII_CNTL_LPBK 0x4000
74#define MII_CNTL_RESET 0x8000
75
76/* MII Status register bit */
77#define MII_STAT_EXT 0x0001
78#define MII_STAT_JAB 0x0002
79#define MII_STAT_LINK 0x0004
80#define MII_STAT_CAN_AUTO 0x0008
81#define MII_STAT_FAULT 0x0010
82#define MII_STAT_AUTO_DONE 0x0020
83#define MII_STAT_CAN_T 0x0800
84#define MII_STAT_CAN_T_FDX 0x1000
85#define MII_STAT_CAN_TX 0x2000
86#define MII_STAT_CAN_TX_FDX 0x4000
87#define MII_STAT_CAN_T4 0x8000
88
89
90#define MII_ID1_OUI_LO 0xFC00 /* low bits of OUI mask */
91#define MII_ID1_MODEL 0x03F0 /* model number */
92#define MII_ID1_REV 0x000F /* model number */
93
94/* MII NWAY Register Bits ...
95 valid for the ANAR (Auto-Negotiation Advertisement) and
96 ANLPAR (Auto-Negotiation Link Partner) registers */
97#define MII_NWAY_NODE_SEL 0x001f
98#define MII_NWAY_CSMA_CD 0x0001
99#define MII_NWAY_T 0x0020
100#define MII_NWAY_T_FDX 0x0040
101#define MII_NWAY_TX 0x0080
102#define MII_NWAY_TX_FDX 0x0100
103#define MII_NWAY_T4 0x0200
104#define MII_NWAY_PAUSE 0x0400
105#define MII_NWAY_RF 0x2000 /* Remote Fault */
106#define MII_NWAY_ACK 0x4000 /* Remote Acknowledge */
107#define MII_NWAY_NP 0x8000 /* Next Page (Enable) */
108
109/* mii stsout register bits */
110#define MII_STSOUT_LINK_FAIL 0x4000
111#define MII_STSOUT_SPD 0x0080
112#define MII_STSOUT_DPLX 0x0040
113
114/* mii stsics register bits */
115#define MII_STSICS_SPD 0x8000
116#define MII_STSICS_DPLX 0x4000
117#define MII_STSICS_LINKSTS 0x0001
118
119/* mii stssum register bits */
120#define MII_STSSUM_LINK 0x0008
121#define MII_STSSUM_DPLX 0x0004
122#define MII_STSSUM_AUTO 0x0002
123#define MII_STSSUM_SPD 0x0001
124
125/* lsi phy status register */
126#define MII_LSI_PHY_STAT_FDX 0x0040
127#define MII_LSI_PHY_STAT_SPD 0x0080
128
129/* amd phy status register */
130#define MII_AMD_PHY_STAT_FDX 0x0800
131#define MII_AMD_PHY_STAT_SPD 0x0400
132
133/* intel phy status register */
134#define MII_INTEL_PHY_STAT_FDX 0x0200
135#define MII_INTEL_PHY_STAT_SPD 0x4000
136
137/* Auxilliary Control/Status Register */
138#define MII_AUX_FDX 0x0001
139#define MII_AUX_100 0x0002
140#define MII_AUX_F100 0x0004
141#define MII_AUX_ANEG 0x0008
142
143typedef struct mii_phy {
144 struct mii_phy * next;
145 struct mii_chip_info * chip_info;
146 u16 status;
147 u32 *mii_control_reg;
148 u32 *mii_data_reg;
149} mii_phy_t;
150
151struct phy_ops {
152 int (*phy_init) (struct net_device *, int);
153 int (*phy_reset) (struct net_device *, int);
154 int (*phy_status) (struct net_device *, int, u16 *, u16 *);
155};
156
157/* 43/*
158 * Data Buffer Descriptor. Data buffers must be aligned on 32 byte 44 * Data Buffer Descriptor. Data buffers must be aligned on 32 byte
159 * boundary for both, receive and transmit. 45 * boundary for both, receive and transmit.
@@ -200,7 +86,6 @@ typedef struct mac_reg {
200 86
201 87
202struct au1000_private { 88struct au1000_private {
203
204 db_dest_t *pDBfree; 89 db_dest_t *pDBfree;
205 db_dest_t db[NUM_RX_BUFFS+NUM_TX_BUFFS]; 90 db_dest_t db[NUM_RX_BUFFS+NUM_TX_BUFFS];
206 volatile rx_dma_t *rx_dma_ring[NUM_RX_DMA]; 91 volatile rx_dma_t *rx_dma_ring[NUM_RX_DMA];
@@ -213,8 +98,15 @@ struct au1000_private {
213 u32 tx_full; 98 u32 tx_full;
214 99
215 int mac_id; 100 int mac_id;
216 mii_phy_t *mii; 101
217 struct phy_ops *phy_ops; 102 int mac_enabled; /* whether MAC is currently enabled and running (req. for mdio) */
103
104 int old_link; /* used by au1000_adjust_link */
105 int old_speed;
106 int old_duplex;
107
108 struct phy_device *phy_dev;
109 struct mii_bus mii_bus;
218 110
219 /* These variables are just for quick access to certain regs addresses. */ 111 /* These variables are just for quick access to certain regs addresses. */
220 volatile mac_reg_t *mac; /* mac registers */ 112 volatile mac_reg_t *mac; /* mac registers */
@@ -223,14 +115,6 @@ struct au1000_private {
223 u32 vaddr; /* virtual address of rx/tx buffers */ 115 u32 vaddr; /* virtual address of rx/tx buffers */
224 dma_addr_t dma_addr; /* dma address of rx/tx buffers */ 116 dma_addr_t dma_addr; /* dma address of rx/tx buffers */
225 117
226 u8 *hash_table;
227 u32 hash_mode;
228 u32 intr_work_done; /* number of Rx and Tx pkts processed in the isr */
229 int phy_addr; /* phy address */
230 u32 options; /* User-settable misc. driver options. */
231 u32 drv_flags;
232 int want_autoneg;
233 struct net_device_stats stats; 118 struct net_device_stats stats;
234 struct timer_list timer;
235 spinlock_t lock; /* Serialise access to device */ 119 spinlock_t lock; /* Serialise access to device */
236}; 120};
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 54161aef3cac..702d546567ad 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -32,6 +32,7 @@
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <asm/byteorder.h> 34#include <asm/byteorder.h>
35#include <asm/page.h>
35#include <linux/time.h> 36#include <linux/time.h>
36#include <linux/ethtool.h> 37#include <linux/ethtool.h>
37#include <linux/mii.h> 38#include <linux/mii.h>
@@ -49,14 +50,15 @@
49#include <linux/crc32.h> 50#include <linux/crc32.h>
50#include <linux/prefetch.h> 51#include <linux/prefetch.h>
51#include <linux/cache.h> 52#include <linux/cache.h>
53#include <linux/zlib.h>
52 54
53#include "bnx2.h" 55#include "bnx2.h"
54#include "bnx2_fw.h" 56#include "bnx2_fw.h"
55 57
56#define DRV_MODULE_NAME "bnx2" 58#define DRV_MODULE_NAME "bnx2"
57#define PFX DRV_MODULE_NAME ": " 59#define PFX DRV_MODULE_NAME ": "
58#define DRV_MODULE_VERSION "1.4.40" 60#define DRV_MODULE_VERSION "1.4.42"
59#define DRV_MODULE_RELDATE "May 22, 2006" 61#define DRV_MODULE_RELDATE "June 12, 2006"
60 62
61#define RUN_AT(x) (jiffies + (x)) 63#define RUN_AT(x) (jiffies + (x))
62 64
@@ -1820,7 +1822,7 @@ reuse_rx:
1820 skb->protocol = eth_type_trans(skb, bp->dev); 1822 skb->protocol = eth_type_trans(skb, bp->dev);
1821 1823
1822 if ((len > (bp->dev->mtu + ETH_HLEN)) && 1824 if ((len > (bp->dev->mtu + ETH_HLEN)) &&
1823 (htons(skb->protocol) != 0x8100)) { 1825 (ntohs(skb->protocol) != 0x8100)) {
1824 1826
1825 dev_kfree_skb_irq(skb); 1827 dev_kfree_skb_irq(skb);
1826 goto next_rx; 1828 goto next_rx;
@@ -2009,7 +2011,7 @@ bnx2_poll(struct net_device *dev, int *budget)
2009 return 1; 2011 return 1;
2010} 2012}
2011 2013
2012/* Called with rtnl_lock from vlan functions and also dev->xmit_lock 2014/* Called with rtnl_lock from vlan functions and also netif_tx_lock
2013 * from set_multicast. 2015 * from set_multicast.
2014 */ 2016 */
2015static void 2017static void
@@ -2083,6 +2085,92 @@ bnx2_set_rx_mode(struct net_device *dev)
2083 spin_unlock_bh(&bp->phy_lock); 2085 spin_unlock_bh(&bp->phy_lock);
2084} 2086}
2085 2087
2088#define FW_BUF_SIZE 0x8000
2089
2090static int
2091bnx2_gunzip_init(struct bnx2 *bp)
2092{
2093 if ((bp->gunzip_buf = vmalloc(FW_BUF_SIZE)) == NULL)
2094 goto gunzip_nomem1;
2095
2096 if ((bp->strm = kmalloc(sizeof(*bp->strm), GFP_KERNEL)) == NULL)
2097 goto gunzip_nomem2;
2098
2099 bp->strm->workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
2100 if (bp->strm->workspace == NULL)
2101 goto gunzip_nomem3;
2102
2103 return 0;
2104
2105gunzip_nomem3:
2106 kfree(bp->strm);
2107 bp->strm = NULL;
2108
2109gunzip_nomem2:
2110 vfree(bp->gunzip_buf);
2111 bp->gunzip_buf = NULL;
2112
2113gunzip_nomem1:
2114 printk(KERN_ERR PFX "%s: Cannot allocate firmware buffer for "
2115 "uncompression.\n", bp->dev->name);
2116 return -ENOMEM;
2117}
2118
2119static void
2120bnx2_gunzip_end(struct bnx2 *bp)
2121{
2122 kfree(bp->strm->workspace);
2123
2124 kfree(bp->strm);
2125 bp->strm = NULL;
2126
2127 if (bp->gunzip_buf) {
2128 vfree(bp->gunzip_buf);
2129 bp->gunzip_buf = NULL;
2130 }
2131}
2132
2133static int
2134bnx2_gunzip(struct bnx2 *bp, u8 *zbuf, int len, void **outbuf, int *outlen)
2135{
2136 int n, rc;
2137
2138 /* check gzip header */
2139 if ((zbuf[0] != 0x1f) || (zbuf[1] != 0x8b) || (zbuf[2] != Z_DEFLATED))
2140 return -EINVAL;
2141
2142 n = 10;
2143
2144#define FNAME 0x8
2145 if (zbuf[3] & FNAME)
2146 while ((zbuf[n++] != 0) && (n < len));
2147
2148 bp->strm->next_in = zbuf + n;
2149 bp->strm->avail_in = len - n;
2150 bp->strm->next_out = bp->gunzip_buf;
2151 bp->strm->avail_out = FW_BUF_SIZE;
2152
2153 rc = zlib_inflateInit2(bp->strm, -MAX_WBITS);
2154 if (rc != Z_OK)
2155 return rc;
2156
2157 rc = zlib_inflate(bp->strm, Z_FINISH);
2158
2159 *outlen = FW_BUF_SIZE - bp->strm->avail_out;
2160 *outbuf = bp->gunzip_buf;
2161
2162 if ((rc != Z_OK) && (rc != Z_STREAM_END))
2163 printk(KERN_ERR PFX "%s: Firmware decompression error: %s\n",
2164 bp->dev->name, bp->strm->msg);
2165
2166 zlib_inflateEnd(bp->strm);
2167
2168 if (rc == Z_STREAM_END)
2169 return 0;
2170
2171 return rc;
2172}
2173
2086static void 2174static void
2087load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len, 2175load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2088 u32 rv2p_proc) 2176 u32 rv2p_proc)
@@ -2092,9 +2180,9 @@ load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2092 2180
2093 2181
2094 for (i = 0; i < rv2p_code_len; i += 8) { 2182 for (i = 0; i < rv2p_code_len; i += 8) {
2095 REG_WR(bp, BNX2_RV2P_INSTR_HIGH, *rv2p_code); 2183 REG_WR(bp, BNX2_RV2P_INSTR_HIGH, cpu_to_le32(*rv2p_code));
2096 rv2p_code++; 2184 rv2p_code++;
2097 REG_WR(bp, BNX2_RV2P_INSTR_LOW, *rv2p_code); 2185 REG_WR(bp, BNX2_RV2P_INSTR_LOW, cpu_to_le32(*rv2p_code));
2098 rv2p_code++; 2186 rv2p_code++;
2099 2187
2100 if (rv2p_proc == RV2P_PROC1) { 2188 if (rv2p_proc == RV2P_PROC1) {
@@ -2134,7 +2222,7 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2134 int j; 2222 int j;
2135 2223
2136 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) { 2224 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
2137 REG_WR_IND(bp, offset, fw->text[j]); 2225 REG_WR_IND(bp, offset, cpu_to_le32(fw->text[j]));
2138 } 2226 }
2139 } 2227 }
2140 2228
@@ -2190,15 +2278,32 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2190 REG_WR_IND(bp, cpu_reg->mode, val); 2278 REG_WR_IND(bp, cpu_reg->mode, val);
2191} 2279}
2192 2280
2193static void 2281static int
2194bnx2_init_cpus(struct bnx2 *bp) 2282bnx2_init_cpus(struct bnx2 *bp)
2195{ 2283{
2196 struct cpu_reg cpu_reg; 2284 struct cpu_reg cpu_reg;
2197 struct fw_info fw; 2285 struct fw_info fw;
2286 int rc = 0;
2287 void *text;
2288 u32 text_len;
2289
2290 if ((rc = bnx2_gunzip_init(bp)) != 0)
2291 return rc;
2198 2292
2199 /* Initialize the RV2P processor. */ 2293 /* Initialize the RV2P processor. */
2200 load_rv2p_fw(bp, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1), RV2P_PROC1); 2294 rc = bnx2_gunzip(bp, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1), &text,
2201 load_rv2p_fw(bp, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2), RV2P_PROC2); 2295 &text_len);
2296 if (rc)
2297 goto init_cpu_err;
2298
2299 load_rv2p_fw(bp, text, text_len, RV2P_PROC1);
2300
2301 rc = bnx2_gunzip(bp, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2), &text,
2302 &text_len);
2303 if (rc)
2304 goto init_cpu_err;
2305
2306 load_rv2p_fw(bp, text, text_len, RV2P_PROC2);
2202 2307
2203 /* Initialize the RX Processor. */ 2308 /* Initialize the RX Processor. */
2204 cpu_reg.mode = BNX2_RXP_CPU_MODE; 2309 cpu_reg.mode = BNX2_RXP_CPU_MODE;
@@ -2222,7 +2327,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2222 fw.text_addr = bnx2_RXP_b06FwTextAddr; 2327 fw.text_addr = bnx2_RXP_b06FwTextAddr;
2223 fw.text_len = bnx2_RXP_b06FwTextLen; 2328 fw.text_len = bnx2_RXP_b06FwTextLen;
2224 fw.text_index = 0; 2329 fw.text_index = 0;
2225 fw.text = bnx2_RXP_b06FwText; 2330
2331 rc = bnx2_gunzip(bp, bnx2_RXP_b06FwText, sizeof(bnx2_RXP_b06FwText),
2332 &text, &text_len);
2333 if (rc)
2334 goto init_cpu_err;
2335
2336 fw.text = text;
2226 2337
2227 fw.data_addr = bnx2_RXP_b06FwDataAddr; 2338 fw.data_addr = bnx2_RXP_b06FwDataAddr;
2228 fw.data_len = bnx2_RXP_b06FwDataLen; 2339 fw.data_len = bnx2_RXP_b06FwDataLen;
@@ -2268,7 +2379,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2268 fw.text_addr = bnx2_TXP_b06FwTextAddr; 2379 fw.text_addr = bnx2_TXP_b06FwTextAddr;
2269 fw.text_len = bnx2_TXP_b06FwTextLen; 2380 fw.text_len = bnx2_TXP_b06FwTextLen;
2270 fw.text_index = 0; 2381 fw.text_index = 0;
2271 fw.text = bnx2_TXP_b06FwText; 2382
2383 rc = bnx2_gunzip(bp, bnx2_TXP_b06FwText, sizeof(bnx2_TXP_b06FwText),
2384 &text, &text_len);
2385 if (rc)
2386 goto init_cpu_err;
2387
2388 fw.text = text;
2272 2389
2273 fw.data_addr = bnx2_TXP_b06FwDataAddr; 2390 fw.data_addr = bnx2_TXP_b06FwDataAddr;
2274 fw.data_len = bnx2_TXP_b06FwDataLen; 2391 fw.data_len = bnx2_TXP_b06FwDataLen;
@@ -2314,7 +2431,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2314 fw.text_addr = bnx2_TPAT_b06FwTextAddr; 2431 fw.text_addr = bnx2_TPAT_b06FwTextAddr;
2315 fw.text_len = bnx2_TPAT_b06FwTextLen; 2432 fw.text_len = bnx2_TPAT_b06FwTextLen;
2316 fw.text_index = 0; 2433 fw.text_index = 0;
2317 fw.text = bnx2_TPAT_b06FwText; 2434
2435 rc = bnx2_gunzip(bp, bnx2_TPAT_b06FwText, sizeof(bnx2_TPAT_b06FwText),
2436 &text, &text_len);
2437 if (rc)
2438 goto init_cpu_err;
2439
2440 fw.text = text;
2318 2441
2319 fw.data_addr = bnx2_TPAT_b06FwDataAddr; 2442 fw.data_addr = bnx2_TPAT_b06FwDataAddr;
2320 fw.data_len = bnx2_TPAT_b06FwDataLen; 2443 fw.data_len = bnx2_TPAT_b06FwDataLen;
@@ -2360,7 +2483,13 @@ bnx2_init_cpus(struct bnx2 *bp)
2360 fw.text_addr = bnx2_COM_b06FwTextAddr; 2483 fw.text_addr = bnx2_COM_b06FwTextAddr;
2361 fw.text_len = bnx2_COM_b06FwTextLen; 2484 fw.text_len = bnx2_COM_b06FwTextLen;
2362 fw.text_index = 0; 2485 fw.text_index = 0;
2363 fw.text = bnx2_COM_b06FwText; 2486
2487 rc = bnx2_gunzip(bp, bnx2_COM_b06FwText, sizeof(bnx2_COM_b06FwText),
2488 &text, &text_len);
2489 if (rc)
2490 goto init_cpu_err;
2491
2492 fw.text = text;
2364 2493
2365 fw.data_addr = bnx2_COM_b06FwDataAddr; 2494 fw.data_addr = bnx2_COM_b06FwDataAddr;
2366 fw.data_len = bnx2_COM_b06FwDataLen; 2495 fw.data_len = bnx2_COM_b06FwDataLen;
@@ -2384,6 +2513,9 @@ bnx2_init_cpus(struct bnx2 *bp)
2384 2513
2385 load_cpu_fw(bp, &cpu_reg, &fw); 2514 load_cpu_fw(bp, &cpu_reg, &fw);
2386 2515
2516init_cpu_err:
2517 bnx2_gunzip_end(bp);
2518 return rc;
2387} 2519}
2388 2520
2389static int 2521static int
@@ -3256,7 +3388,9 @@ bnx2_init_chip(struct bnx2 *bp)
3256 * context block must have already been enabled. */ 3388 * context block must have already been enabled. */
3257 bnx2_init_context(bp); 3389 bnx2_init_context(bp);
3258 3390
3259 bnx2_init_cpus(bp); 3391 if ((rc = bnx2_init_cpus(bp)) != 0)
3392 return rc;
3393
3260 bnx2_init_nvram(bp); 3394 bnx2_init_nvram(bp);
3261 3395
3262 bnx2_set_mac_addr(bp); 3396 bnx2_set_mac_addr(bp);
@@ -3556,7 +3690,9 @@ bnx2_reset_nic(struct bnx2 *bp, u32 reset_code)
3556 if (rc) 3690 if (rc)
3557 return rc; 3691 return rc;
3558 3692
3559 bnx2_init_chip(bp); 3693 if ((rc = bnx2_init_chip(bp)) != 0)
3694 return rc;
3695
3560 bnx2_init_tx_ring(bp); 3696 bnx2_init_tx_ring(bp);
3561 bnx2_init_rx_ring(bp); 3697 bnx2_init_rx_ring(bp);
3562 return 0; 3698 return 0;
@@ -4034,6 +4170,8 @@ bnx2_timer(unsigned long data)
4034 msg = (u32) ++bp->fw_drv_pulse_wr_seq; 4170 msg = (u32) ++bp->fw_drv_pulse_wr_seq;
4035 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg); 4171 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg);
4036 4172
4173 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT);
4174
4037 if ((bp->phy_flags & PHY_SERDES_FLAG) && 4175 if ((bp->phy_flags & PHY_SERDES_FLAG) &&
4038 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 4176 (CHIP_NUM(bp) == CHIP_NUM_5706)) {
4039 4177
@@ -4252,7 +4390,7 @@ bnx2_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
4252} 4390}
4253#endif 4391#endif
4254 4392
4255/* Called with dev->xmit_lock. 4393/* Called with netif_tx_lock.
4256 * hard_start_xmit is pseudo-lockless - a lock is only required when 4394 * hard_start_xmit is pseudo-lockless - a lock is only required when
4257 * the tx queue is full. This way, we get the benefit of lockless 4395 * the tx queue is full. This way, we get the benefit of lockless
4258 * operations most of the time without the complexities to handle 4396 * operations most of the time without the complexities to handle
@@ -4310,7 +4448,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4310 ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr); 4448 ip_tcp_len = (skb->nh.iph->ihl << 2) + sizeof(struct tcphdr);
4311 4449
4312 skb->nh.iph->check = 0; 4450 skb->nh.iph->check = 0;
4313 skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len); 4451 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
4314 skb->h.th->check = 4452 skb->h.th->check =
4315 ~csum_tcpudp_magic(skb->nh.iph->saddr, 4453 ~csum_tcpudp_magic(skb->nh.iph->saddr,
4316 skb->nh.iph->daddr, 4454 skb->nh.iph->daddr,
@@ -4504,6 +4642,10 @@ bnx2_get_stats(struct net_device *dev)
4504 net_stats->tx_aborted_errors + 4642 net_stats->tx_aborted_errors +
4505 net_stats->tx_carrier_errors; 4643 net_stats->tx_carrier_errors;
4506 4644
4645 net_stats->rx_missed_errors =
4646 (unsigned long) (stats_blk->stat_IfInMBUFDiscards +
4647 stats_blk->stat_FwRxDrop);
4648
4507 return net_stats; 4649 return net_stats;
4508} 4650}
4509 4651
@@ -4986,7 +5128,7 @@ bnx2_set_rx_csum(struct net_device *dev, u32 data)
4986 return 0; 5128 return 0;
4987} 5129}
4988 5130
4989#define BNX2_NUM_STATS 45 5131#define BNX2_NUM_STATS 46
4990 5132
4991static struct { 5133static struct {
4992 char string[ETH_GSTRING_LEN]; 5134 char string[ETH_GSTRING_LEN];
@@ -5036,6 +5178,7 @@ static struct {
5036 { "rx_mac_ctrl_frames" }, 5178 { "rx_mac_ctrl_frames" },
5037 { "rx_filtered_packets" }, 5179 { "rx_filtered_packets" },
5038 { "rx_discards" }, 5180 { "rx_discards" },
5181 { "rx_fw_discards" },
5039}; 5182};
5040 5183
5041#define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4) 5184#define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4)
@@ -5086,6 +5229,7 @@ static const unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = {
5086 STATS_OFFSET32(stat_MacControlFramesReceived), 5229 STATS_OFFSET32(stat_MacControlFramesReceived),
5087 STATS_OFFSET32(stat_IfInFramesL2FilterDiscards), 5230 STATS_OFFSET32(stat_IfInFramesL2FilterDiscards),
5088 STATS_OFFSET32(stat_IfInMBUFDiscards), 5231 STATS_OFFSET32(stat_IfInMBUFDiscards),
5232 STATS_OFFSET32(stat_FwRxDrop),
5089}; 5233};
5090 5234
5091/* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are 5235/* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are
@@ -5096,7 +5240,7 @@ static u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = {
5096 4,0,4,4,4,4,4,4,4,4, 5240 4,0,4,4,4,4,4,4,4,4,
5097 4,4,4,4,4,4,4,4,4,4, 5241 4,4,4,4,4,4,4,4,4,4,
5098 4,4,4,4,4,4,4,4,4,4, 5242 4,4,4,4,4,4,4,4,4,4,
5099 4,4,4,4,4, 5243 4,4,4,4,4,4,
5100}; 5244};
5101 5245
5102static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = { 5246static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
@@ -5104,7 +5248,7 @@ static u8 bnx2_5708_stats_len_arr[BNX2_NUM_STATS] = {
5104 4,4,4,4,4,4,4,4,4,4, 5248 4,4,4,4,4,4,4,4,4,4,
5105 4,4,4,4,4,4,4,4,4,4, 5249 4,4,4,4,4,4,4,4,4,4,
5106 4,4,4,4,4,4,4,4,4,4, 5250 4,4,4,4,4,4,4,4,4,4,
5107 4,4,4,4,4, 5251 4,4,4,4,4,4,
5108}; 5252};
5109 5253
5110#define BNX2_NUM_TESTS 6 5254#define BNX2_NUM_TESTS 6
@@ -5634,7 +5778,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5634 } 5778 }
5635 } 5779 }
5636 5780
5637 if (CHIP_NUM(bp) == CHIP_NUM_5708) 5781 if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
5782 (CHIP_ID(bp) == CHIP_ID_5708_B0) ||
5783 (CHIP_ID(bp) == CHIP_ID_5708_B1))
5638 bp->flags |= NO_WOL_FLAG; 5784 bp->flags |= NO_WOL_FLAG;
5639 5785
5640 if (CHIP_ID(bp) == CHIP_ID_5706_A0) { 5786 if (CHIP_ID(bp) == CHIP_ID_5706_A0) {
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index b87925f6a228..5845e334941b 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -231,6 +231,7 @@ struct statistics_block {
231 u32 stat_GenStat13; 231 u32 stat_GenStat13;
232 u32 stat_GenStat14; 232 u32 stat_GenStat14;
233 u32 stat_GenStat15; 233 u32 stat_GenStat15;
234 u32 stat_FwRxDrop;
234}; 235};
235 236
236 237
@@ -3481,6 +3482,8 @@ struct l2_fhdr {
3481 3482
3482#define BNX2_COM_SCRATCH 0x00120000 3483#define BNX2_COM_SCRATCH 0x00120000
3483 3484
3485#define BNX2_FW_RX_DROP_COUNT 0x00120084
3486
3484 3487
3485/* 3488/*
3486 * cp_reg definition 3489 * cp_reg definition
@@ -3747,7 +3750,12 @@ struct l2_fhdr {
3747#define DMA_READ_CHANS 5 3750#define DMA_READ_CHANS 5
3748#define DMA_WRITE_CHANS 3 3751#define DMA_WRITE_CHANS 3
3749 3752
3750#define BCM_PAGE_BITS 12 3753/* Use CPU native page size up to 16K for the ring sizes. */
3754#if (PAGE_SHIFT > 14)
3755#define BCM_PAGE_BITS 14
3756#else
3757#define BCM_PAGE_BITS PAGE_SHIFT
3758#endif
3751#define BCM_PAGE_SIZE (1 << BCM_PAGE_BITS) 3759#define BCM_PAGE_SIZE (1 << BCM_PAGE_BITS)
3752 3760
3753#define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct tx_bd)) 3761#define TX_DESC_CNT (BCM_PAGE_SIZE / sizeof(struct tx_bd))
@@ -3770,7 +3778,7 @@ struct l2_fhdr {
3770 3778
3771#define RX_RING_IDX(x) ((x) & bp->rx_max_ring_idx) 3779#define RX_RING_IDX(x) ((x) & bp->rx_max_ring_idx)
3772 3780
3773#define RX_RING(x) (((x) & ~MAX_RX_DESC_CNT) >> 8) 3781#define RX_RING(x) (((x) & ~MAX_RX_DESC_CNT) >> (BCM_PAGE_BITS - 4))
3774#define RX_IDX(x) ((x) & MAX_RX_DESC_CNT) 3782#define RX_IDX(x) ((x) & MAX_RX_DESC_CNT)
3775 3783
3776/* Context size. */ 3784/* Context size. */
@@ -4048,6 +4056,9 @@ struct bnx2 {
4048 u32 flash_size; 4056 u32 flash_size;
4049 4057
4050 int status_stats_size; 4058 int status_stats_size;
4059
4060 struct z_stream_s *strm;
4061 void *gunzip_buf;
4051}; 4062};
4052 4063
4053static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset); 4064static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
index 8158974c35a8..2d753dca0d75 100644
--- a/drivers/net/bnx2_fw.h
+++ b/drivers/net/bnx2_fw.h
@@ -7,7 +7,7 @@
7 * the Free Software Foundation, except as noted below. 7 * the Free Software Foundation, except as noted below.
8 * 8 *
9 * This file contains firmware data derived from proprietary unpublished 9 * This file contains firmware data derived from proprietary unpublished
10 * source code, Copyright (c) 2004, 2005 Broadcom Corporation. 10 * source code, Copyright (c) 2004, 2005, 2006 Broadcom Corporation.
11 * 11 *
12 * Permission is hereby granted for the distribution of this firmware data 12 * Permission is hereby granted for the distribution of this firmware data
13 * in hexadecimal or equivalent format, provided this copyright notice is 13 * in hexadecimal or equivalent format, provided this copyright notice is
@@ -28,943 +28,641 @@ static const u32 bnx2_COM_b06FwBssAddr = 0x08005860;
28static const int bnx2_COM_b06FwBssLen = 0x88; 28static const int bnx2_COM_b06FwBssLen = 0x88;
29static const u32 bnx2_COM_b06FwSbssAddr = 0x08005840; 29static const u32 bnx2_COM_b06FwSbssAddr = 0x08005840;
30static const int bnx2_COM_b06FwSbssLen = 0x1c; 30static const int bnx2_COM_b06FwSbssLen = 0x1c;
31static u32 bnx2_COM_b06FwText[(0x57bc/4) + 1] = { 31static u8 bnx2_COM_b06FwText[] = {
32 0x0a00022d, 0x00000000, 0x00000000, 0x0000000d, 0x636f6d20, 0x322e352e, 32 0x1f, 0x8b, 0x08, 0x08, 0x09, 0x83, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
33 0x38000000, 0x02050802, 0x00000000, 0x00000003, 0x00000014, 0x00000032, 33 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5b, 0x7d, 0x6c,
34 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 34 0x5b, 0xd7, 0x75, 0x3f, 0xef, 0xf1, 0x51, 0x7a, 0x96, 0x68, 0xf9, 0x99,
35 0x00000010, 0x000003e8, 0x0000ea60, 0x00000001, 0x00000000, 0x00000000, 35 0x7e, 0x96, 0x59, 0x4f, 0xb1, 0x49, 0xf1, 0xc9, 0xd2, 0x62, 0x2d, 0x63,
36 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 36 0x34, 0x35, 0xd1, 0x3a, 0x26, 0x66, 0x48, 0xda, 0x71, 0x36, 0x67, 0xa0,
37 0x0000ffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 37 0x1d, 0x05, 0x51, 0x51, 0xaf, 0xd0, 0x48, 0xd9, 0xcd, 0xb2, 0x0c, 0x73,
38 0x00000000, 0x00000000, 0x00000002, 0x00000020, 0x00000000, 0x00000000, 38 0x96, 0xb4, 0x70, 0xbc, 0xb4, 0xa1, 0x25, 0x79, 0xf5, 0x06, 0x45, 0xcf,
39 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 39 0xb3, 0x34, 0x39, 0xc0, 0x82, 0x41, 0x10, 0x9d, 0x3a, 0x7f, 0x30, 0xa5,
40 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 40 0xed, 0x7c, 0x19, 0xe8, 0x12, 0x29, 0xb2, 0x93, 0xb5, 0x43, 0xd0, 0xa6,
41 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 41 0x68, 0xff, 0xe8, 0x8a, 0x6e, 0x30, 0x52, 0x0c, 0xf3, 0x3a, 0xa0, 0x30,
42 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 42 0xfa, 0xc7, 0xe6, 0x2d, 0x1f, 0xdc, 0xef, 0xdc, 0x77, 0x1f, 0xf9, 0x48,
43 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 43 0x51, 0x96, 0x1c, 0x34, 0x5d, 0xb7, 0x99, 0x80, 0xf0, 0xde, 0xbd, 0xf7,
44 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 44 0xbc, 0x7b, 0xcf, 0x3d, 0xdf, 0xe7, 0xdc, 0xab, 0x5f, 0x53, 0xa9, 0x85,
45 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 45 0xe4, 0x6f, 0x2d, 0xfe, 0xc2, 0x7f, 0xf4, 0xc7, 0xb9, 0xdb, 0x3e, 0x7d,
46 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 46 0x5b, 0x1f, 0x5e, 0x07, 0x54, 0xdd, 0xaf, 0x72, 0xbf, 0x0f, 0x7f, 0x26,
47 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 47 0xfe, 0xfa, 0xe4, 0x7b, 0xa3, 0x9f, 0x81, 0xbf, 0x2b, 0x18, 0x1c, 0xfe,
48 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 48 0x09, 0x91, 0xb2, 0x0c, 0x8c, 0xf7, 0x57, 0x2e, 0x5f, 0x7f, 0x9c, 0x17,
49 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 49 0x0e, 0xaf, 0x62, 0x9e, 0x9b, 0xbf, 0x9b, 0xbf, 0x9b, 0xbf, 0x9b, 0xbf,
50 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 50 0x9b, 0xbf, 0x9b, 0xbf, 0x9b, 0xbf, 0xff, 0x3f, 0x3f, 0x9f, 0x13, 0x72,
51 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 51 0x88, 0x98, 0x85, 0xff, 0x48, 0x57, 0xe3, 0x89, 0xa1, 0xa4, 0x45, 0xba,
52 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 52 0x2f, 0x7e, 0x65, 0x28, 0x67, 0x11, 0x25, 0x8a, 0xdb, 0xc3, 0x29, 0xfa,
53 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 53 0xb0, 0x9c, 0x37, 0x35, 0xe2, 0xfe, 0x5b, 0xe2, 0x1f, 0x3c, 0xfd, 0xfa,
54 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 54 0x9d, 0x91, 0xab, 0xb3, 0x3e, 0xd2, 0x8d, 0xf8, 0xcb, 0xba, 0xb1, 0x8d,
55 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 55 0xf4, 0x0e, 0x7c, 0xf3, 0x5c, 0xf7, 0x7f, 0xa8, 0xd4, 0xe6, 0xce, 0x75,
56 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 56 0xa5, 0xfc, 0x7a, 0x37, 0xe5, 0x37, 0xc7, 0x75, 0x52, 0xe3, 0x5d, 0x3f,
57 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 57 0x48, 0xfa, 0x8c, 0x61, 0x5f, 0xdc, 0xa0, 0xf9, 0x12, 0x65, 0x0e, 0x4c,
58 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 58 0xf0, 0x1a, 0xb1, 0x75, 0xf7, 0x62, 0x2e, 0x2d, 0x3e, 0x3c, 0xf4, 0x67,
59 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 59 0xd6, 0xd3, 0x65, 0xd5, 0xb2, 0x7a, 0xe6, 0x28, 0x30, 0xf0, 0x7c, 0x3f,
60 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 60 0xc6, 0x8b, 0x91, 0x1e, 0xa2, 0x3b, 0x49, 0xb5, 0xf2, 0x01, 0x9f, 0xa5,
61 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 61 0x53, 0xb2, 0x64, 0x51, 0xaa, 0x44, 0xf4, 0x77, 0x45, 0x85, 0x9e, 0xb7,
62 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 62 0xda, 0x69, 0xae, 0xf7, 0x83, 0x72, 0x02, 0xb8, 0xbc, 0x6d, 0x0d, 0x0f,
63 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 63 0x8d, 0x5b, 0x3c, 0x57, 0x7c, 0x9d, 0x83, 0x6f, 0x6f, 0x5b, 0xce, 0xd2,
64 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 64 0x68, 0xb4, 0xc8, 0x7d, 0xbd, 0x2d, 0xdc, 0xe7, 0x8f, 0x3f, 0x1c, 0x7c,
65 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 65 0xde, 0x0a, 0xc8, 0xbe, 0x1f, 0xa5, 0x92, 0x98, 0x6f, 0xac, 0xc8, 0xb0,
66 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 66 0xcf, 0xde, 0x91, 0xb3, 0x4c, 0xd9, 0x6f, 0xc5, 0x93, 0x56, 0x08, 0xfd,
67 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 67 0x1d, 0x72, 0x2c, 0xbd, 0x2e, 0x67, 0x59, 0x72, 0xac, 0x88, 0x6f, 0x7a,
68 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 68 0x65, 0xff, 0x3b, 0xa9, 0x9c, 0x15, 0x93, 0xfd, 0x57, 0x93, 0x49, 0xab,
69 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 69 0x5f, 0xf6, 0x1f, 0xbe, 0x2b, 0x67, 0xc5, 0x65, 0xff, 0xf7, 0x81, 0x8b,
70 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 70 0x41, 0xc7, 0x8a, 0x61, 0xfc, 0x25, 0x30, 0xfe, 0x9a, 0x41, 0x6d, 0x19,
71 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 71 0x8c, 0x61, 0xef, 0xb6, 0x4e, 0x97, 0x7d, 0x21, 0x7a, 0xbd, 0xfb, 0x32,
72 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 72 0x68, 0x63, 0xd0, 0xd9, 0x12, 0x29, 0x99, 0xee, 0x10, 0x68, 0x62, 0xd2,
73 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 73 0xb9, 0x52, 0x2b, 0xf9, 0x4e, 0xfa, 0xb0, 0xe7, 0xcf, 0x51, 0xd6, 0xd4,
74 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 74 0x69, 0xfd, 0x8c, 0x42, 0x9d, 0x7d, 0x6b, 0x28, 0x61, 0xe4, 0x29, 0xd5,
75 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 75 0x8d, 0x28, 0x6e, 0xd2, 0x24, 0x6d, 0x66, 0x71, 0xbd, 0x8a, 0x1e, 0x95,
76 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 76 0x22, 0xa1, 0x2c, 0x28, 0x3c, 0x72, 0xfa, 0x5d, 0x8e, 0x39, 0xb1, 0x26,
77 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 77 0xff, 0x85, 0x29, 0x35, 0x71, 0x2b, 0x0d, 0x1b, 0x8c, 0x0f, 0x80, 0x05,
78 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 78 0x1f, 0x74, 0x25, 0x79, 0x2a, 0x44, 0xc7, 0xec, 0x80, 0x92, 0x3a, 0x75,
79 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 79 0x37, 0x25, 0x63, 0x64, 0xaa, 0xd4, 0x25, 0xbe, 0x2d, 0x14, 0x43, 0x34,
80 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 80 0x6e, 0x93, 0x92, 0xb4, 0x99, 0x5e, 0xed, 0x18, 0x6f, 0x13, 0xb0, 0xe8,
81 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 81 0xeb, 0xf0, 0x51, 0x97, 0x91, 0x22, 0x9d, 0x71, 0x46, 0x7f, 0x50, 0x49,
82 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 82 0x8b, 0x39, 0x44, 0x7f, 0x78, 0x8c, 0x02, 0x74, 0xba, 0x68, 0x4a, 0xd8,
83 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 83 0x72, 0x39, 0x19, 0x33, 0x00, 0x07, 0xda, 0xd9, 0x26, 0x0d, 0xe3, 0x39,
84 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 84 0x6a, 0xf3, 0xfa, 0x21, 0xc8, 0xcc, 0xb7, 0x87, 0xb2, 0xd3, 0x62, 0xbe,
85 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 85 0xb0, 0x2f, 0xce, 0xf3, 0x75, 0x00, 0xee, 0x1d, 0xe0, 0xa5, 0x90, 0x26,
86 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 86 0x78, 0x95, 0xa0, 0xec, 0x84, 0x02, 0x79, 0xc2, 0x53, 0xd0, 0x2d, 0x0d,
87 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 87 0xfc, 0x35, 0xb2, 0xfa, 0x14, 0xca, 0x59, 0x9b, 0x28, 0x6f, 0xa0, 0x5d,
88 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 88 0xbc, 0xa0, 0x26, 0xed, 0x66, 0x4a, 0x69, 0x61, 0xec, 0x5f, 0xc8, 0x0a,
89 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 89 0x8d, 0xe1, 0x1b, 0xd5, 0x62, 0x98, 0x9f, 0x61, 0xef, 0xc3, 0x82, 0xfe,
90 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 90 0x4d, 0xf1, 0xfd, 0x74, 0x69, 0x22, 0xaf, 0x26, 0x4b, 0xed, 0xe4, 0x9b,
91 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 91 0x89, 0x40, 0x9a, 0xc7, 0xd5, 0xd4, 0x19, 0x8d, 0xfc, 0x93, 0x0a, 0x41,
92 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 92 0x3e, 0x0c, 0x5f, 0xfc, 0xb8, 0xba, 0xb3, 0x74, 0x41, 0x4d, 0x95, 0xf8,
93 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 93 0x1b, 0xc0, 0x16, 0x55, 0xd0, 0x96, 0xdf, 0xb7, 0x83, 0x96, 0x34, 0xac,
94 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 94 0xc6, 0x75, 0x3d, 0x51, 0x64, 0x99, 0xe5, 0x6f, 0xc1, 0x0f, 0xec, 0xe5,
95 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 95 0x9c, 0x0d, 0xfe, 0x08, 0x7e, 0x85, 0xc1, 0xaf, 0x6f, 0x82, 0x5f, 0xfd,
96 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 96 0xe0, 0x53, 0x8c, 0xde, 0x28, 0xf5, 0xd2, 0x6b, 0xa5, 0x1e, 0x7a, 0x15,
97 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 97 0x32, 0xf9, 0x4a, 0x29, 0x4c, 0x2f, 0x97, 0x3a, 0xe8, 0xa5, 0x52, 0x88,
98 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 98 0xce, 0x0b, 0x1e, 0xa6, 0x21, 0xff, 0x82, 0xaf, 0xfa, 0x26, 0xf0, 0xa4,
99 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 99 0x1d, 0x3c, 0x59, 0x0f, 0x79, 0xd9, 0x08, 0xf9, 0x9b, 0xee, 0xd6, 0x69,
100 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 100 0xaa, 0x9b, 0x12, 0x41, 0xf4, 0x6f, 0x89, 0x6b, 0x82, 0x4e, 0x1a, 0xc6,
101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 101 0xc7, 0x26, 0xfc, 0x94, 0x32, 0x4e, 0xd3, 0x7b, 0x93, 0x1a, 0x8d, 0x95,
102 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 102 0xa6, 0x36, 0x3a, 0x7c, 0xe3, 0xf6, 0x2c, 0x5d, 0x44, 0x5f, 0xca, 0x98,
103 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 103 0xa5, 0x4b, 0xdb, 0x54, 0x1a, 0x9d, 0xfe, 0x1b, 0x4a, 0x9e, 0x39, 0x4d,
104 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 104 0x3f, 0xfe, 0x3a, 0x51, 0x06, 0x34, 0x51, 0xfb, 0x7e, 0x5a, 0x4e, 0x18,
105 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 105 0xa0, 0x45, 0x5f, 0xaf, 0x90, 0x08, 0xb5, 0x8f, 0x79, 0x19, 0x86, 0xae,
106 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 106 0x68, 0x4a, 0xca, 0x7e, 0x01, 0xfa, 0xd2, 0xaa, 0x24, 0xa7, 0x88, 0x72,
107 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 107 0x53, 0x65, 0xca, 0xc5, 0xfc, 0xf4, 0x98, 0x51, 0xa6, 0x74, 0xac, 0x89,
108 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 108 0xbe, 0x68, 0xb4, 0xd3, 0x68, 0xef, 0x6f, 0xf8, 0xdc, 0x5c, 0x65, 0xba,
109 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 109 0xd4, 0x8f, 0x77, 0xee, 0x23, 0x9a, 0x12, 0xef, 0x4e, 0x7f, 0xbe, 0xe4,
110 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 110 0xa7, 0x84, 0x99, 0x0f, 0x69, 0xf4, 0x8e, 0xcf, 0xc1, 0x29, 0xe1, 0x8e,
111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 111 0x81, 0x57, 0xc3, 0xb0, 0x0f, 0x8e, 0x0c, 0x66, 0x27, 0xd6, 0x5c, 0x4b,
112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 112 0x88, 0x6e, 0xc0, 0x0b, 0xd9, 0xd3, 0x18, 0x8f, 0x61, 0x25, 0x6e, 0x52,
113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 113 0xa7, 0xd0, 0x8d, 0x7e, 0xc0, 0x0c, 0x28, 0xfb, 0x4a, 0xcc, 0x6b, 0xbc,
114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 114 0x17, 0x19, 0xd7, 0xcd, 0x80, 0xd5, 0xf0, 0x4c, 0x48, 0x9c, 0xbd, 0x78,
115 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 115 0xf2, 0x5c, 0x8c, 0x27, 0x3f, 0x7f, 0xcf, 0x83, 0xe7, 0xe7, 0x2b, 0xef,
116 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 116 0x53, 0x9e, 0xf7, 0x7c, 0xe9, 0x4f, 0x03, 0x0e, 0x7e, 0x4c, 0xcf, 0x01,
117 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 117 0x1a, 0x9d, 0x38, 0x2c, 0xd7, 0xc2, 0x7b, 0x91, 0xd7, 0x38, 0x0d, 0x3a,
118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 118 0x09, 0xc8, 0x15, 0xd6, 0x3a, 0xec, 0x59, 0xeb, 0x49, 0xcf, 0x5a, 0x4f,
119 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 119 0x7a, 0xd6, 0xca, 0x83, 0xb6, 0xb4, 0x4e, 0xb5, 0xfc, 0xd0, 0x51, 0xee,
120 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 120 0x39, 0x8e, 0x39, 0x9f, 0x03, 0x5f, 0xbe, 0x0a, 0x98, 0x38, 0x2d, 0xda,
121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 121 0xa0, 0xc7, 0x94, 0x46, 0x7b, 0x4d, 0x7e, 0x7f, 0xb1, 0xd5, 0xc1, 0x8b,
122 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 122 0xdf, 0x2f, 0x48, 0x9c, 0x5a, 0x1d, 0xb8, 0xd2, 0x15, 0xa1, 0xff, 0xf3,
123 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 123 0x25, 0xd6, 0x4f, 0x8a, 0xf9, 0x2c, 0x3a, 0x94, 0x8e, 0xb5, 0xd3, 0x98,
124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 124 0xa1, 0xc4, 0x46, 0x7b, 0x9a, 0x99, 0x8e, 0x09, 0xd5, 0x6a, 0x85, 0x0e,
125 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 0x24425840, 125 0x50, 0x58, 0x65, 0xdb, 0x25, 0xf0, 0x7b, 0x49, 0xe2, 0x61, 0x70, 0x3b,
126 0x3c030800, 0x246358e8, 0xac400000, 0x0043202b, 0x1480fffd, 0x24420004, 126 0xa3, 0x5a, 0xc1, 0xba, 0x7e, 0x96, 0xdf, 0x57, 0xf0, 0xce, 0x32, 0x9c,
127 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800, 0x261008b4, 0x3c1c0800, 127 0xd4, 0x9c, 0xb5, 0x5f, 0x45, 0x9b, 0xed, 0xce, 0x66, 0xd9, 0x76, 0xc7,
128 0x279c5840, 0x0e0002f7, 0x00000000, 0x0000000d, 0x27bdffe8, 0x3c1a8000, 128 0xff, 0xa0, 0xa9, 0xb6, 0xfd, 0x05, 0xb3, 0xb6, 0xed, 0xea, 0x82, 0xd7,
129 0x3c020008, 0x0342d825, 0x3c036010, 0xafbf0010, 0x8c655000, 0x3c020800, 129 0x66, 0xf1, 0xde, 0xc2, 0xe4, 0xb3, 0x58, 0x8e, 0xfc, 0xc0, 0x35, 0x06,
130 0x24470f30, 0x3c040800, 0x24865860, 0x2402ff7f, 0x00a22824, 0x34a5380c, 130 0x3d, 0x6c, 0x96, 0x38, 0x7c, 0x4b, 0xe2, 0x00, 0x5c, 0x01, 0x37, 0x5a,
131 0xac655000, 0x00002821, 0x24020037, 0x24030c80, 0xaf420008, 0xaf430024, 131 0xe2, 0x6f, 0x04, 0x4b, 0xea, 0xda, 0x4c, 0x43, 0xf7, 0x7d, 0xad, 0x18,
132 0xacc70000, 0x24a50001, 0x2ca20016, 0x1440fffc, 0x24c60004, 0x24845860, 132 0xbf, 0xec, 0xe3, 0x75, 0xdc, 0x27, 0x29, 0x69, 0xe8, 0xc9, 0xd8, 0xb4,
133 0x3c020800, 0x24420f3c, 0x3c030800, 0x24630e2c, 0xac820004, 0x3c020800, 133 0x46, 0xd9, 0xd8, 0x26, 0x21, 0xd7, 0xd9, 0x58, 0xd5, 0x06, 0x8c, 0x4e,
134 0x24420a2c, 0x3c050800, 0x24a51268, 0xac82000c, 0x3c020800, 0x244243dc, 134 0xd4, 0xdb, 0x00, 0xfe, 0x8e, 0x6d, 0x80, 0xa3, 0xfb, 0x63, 0xd3, 0x6c,
135 0xac830008, 0x3c030800, 0x24633698, 0xac820014, 0x3c020800, 0x24423c24, 135 0x0b, 0x1c, 0xdd, 0x3f, 0x36, 0xc1, 0x36, 0x41, 0xcc, 0x09, 0xfd, 0x67,
136 0xac830018, 0xac83001c, 0x3c030800, 0x24630f44, 0xac820024, 0x3c020800, 136 0x3b, 0xe0, 0xda, 0x00, 0xfe, 0x86, 0x6d, 0x80, 0x0f, 0xf2, 0xcd, 0xf3,
137 0x244243ac, 0xac83002c, 0x3c030800, 0x246343cc, 0xac820030, 0x3c020800, 137 0xb9, 0x6b, 0x8f, 0xd7, 0xcd, 0x3b, 0xce, 0xb6, 0x45, 0xd9, 0xd9, 0xcd,
138 0x244242f0, 0xac830034, 0x3c030800, 0x24633d78, 0xac82003c, 0x3c020800, 138 0x30, 0xc7, 0xb1, 0x76, 0x80, 0x0a, 0xd3, 0xcc, 0xc3, 0x48, 0xe8, 0x08,
139 0x24420fd4, 0xac850010, 0xac850020, 0xac830040, 0x0e0010b7, 0xac820050, 139 0x1d, 0x17, 0x36, 0xef, 0xf4, 0x04, 0x25, 0x0e, 0x9e, 0x18, 0xa0, 0x34,
140 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe0, 0xafb00010, 0x27500100, 140 0x6c, 0xc0, 0xdc, 0xc4, 0xb5, 0x32, 0xf8, 0x78, 0x47, 0x13, 0x59, 0xb0,
141 0xafbf0018, 0xafb10014, 0x9203000b, 0x24020003, 0x1462005b, 0x96110008, 141 0x75, 0xf0, 0x93, 0xfd, 0x7e, 0xf2, 0xc5, 0xe3, 0x90, 0xb7, 0x98, 0xf0,
142 0x32220001, 0x10400009, 0x27430080, 0x8e020000, 0x96040014, 0x000211c2, 142 0x5d, 0xd5, 0x9f, 0xa6, 0xed, 0xaa, 0x69, 0x37, 0xc1, 0x3f, 0x62, 0xde,
143 0x00021040, 0x00621821, 0xa4640000, 0x0a0002d0, 0x3c020800, 0x3c020800, 143 0xfe, 0x98, 0x90, 0x4d, 0xef, 0x2f, 0x09, 0x1b, 0x94, 0x8c, 0x7d, 0x08,
144 0x8c430020, 0x1060002a, 0x3c030800, 0x0e00148e, 0x00000000, 0x97420108, 144 0xf9, 0x75, 0x69, 0xe4, 0xea, 0x1f, 0xdb, 0xfa, 0x2b, 0x1e, 0x1f, 0xb2,
145 0x8f850018, 0x9743010c, 0x3042003e, 0x00021400, 0x00621825, 0xaca30000, 145 0x05, 0x76, 0xdf, 0x84, 0x3c, 0xb9, 0x76, 0x9f, 0xed, 0x71, 0x88, 0x6d,
146 0x8f840018, 0x8f420100, 0xac820004, 0x97430116, 0x9742010e, 0x8f840018, 146 0x26, 0xf4, 0x8d, 0x6d, 0x70, 0x80, 0xd4, 0x19, 0x4d, 0xda, 0x69, 0x5d,
147 0x00031c00, 0x00431025, 0xac820008, 0x97430110, 0x97440112, 0x8f850018, 147 0xda, 0xe9, 0x00, 0x6c, 0x34, 0xb7, 0x0d, 0xd9, 0x36, 0x45, 0x1b, 0xf6,
148 0x00031c00, 0x00832025, 0xaca4000c, 0x97420114, 0x8f840018, 0x3042ffff, 148 0x1a, 0xf6, 0x70, 0x77, 0x3a, 0x35, 0xc1, 0xfe, 0x10, 0xbe, 0x7b, 0x86,
149 0xac820010, 0x8f830018, 0xac600014, 0x8f820018, 0x3c030800, 0xac400018, 149 0x75, 0xf8, 0xdb, 0x43, 0x23, 0xd3, 0xc2, 0x07, 0xb0, 0xff, 0x80, 0x65,
150 0x946258ce, 0x8f840018, 0x3c032000, 0x00431025, 0xac82001c, 0x0e0014cc, 150 0x66, 0x1b, 0xce, 0xb6, 0x1c, 0xfb, 0x2e, 0x62, 0xdd, 0x8a, 0xad, 0x64,
151 0x24040001, 0x3c030800, 0x8c620040, 0x24420001, 0xac620040, 0x3c020800, 151 0x39, 0xf1, 0xe2, 0xc5, 0x38, 0xad, 0x21, 0xf5, 0xa4, 0x43, 0x6b, 0x35,
152 0x8c430044, 0x32240004, 0x24630001, 0x10800017, 0xac430044, 0x8f4202b8, 152 0xfe, 0xa8, 0x46, 0x2d, 0x4c, 0x63, 0xc6, 0x7f, 0x2b, 0x70, 0xe6, 0x7d,
153 0x04430007, 0x8e020020, 0x3c040800, 0x8c830060, 0x24020001, 0x24630001, 153 0xfd, 0x4f, 0xe0, 0xcc, 0xeb, 0xd6, 0xe3, 0x4d, 0x7a, 0x6b, 0xfc, 0xac,
154 0x0a0002f2, 0xac830060, 0x3c060800, 0x8cc4005c, 0xaf420280, 0x96030016, 154 0xfe, 0xf0, 0x33, 0xa4, 0x37, 0xc7, 0xcf, 0xd2, 0xbf, 0x58, 0x74, 0x9f,
155 0x00001021, 0xa7430284, 0x8e050004, 0x24840001, 0x3c031000, 0xaf450288, 155 0x0e, 0x3f, 0xdb, 0xad, 0xc0, 0xcf, 0x16, 0xa1, 0xef, 0x53, 0x3a, 0x1d,
156 0xaf4302b8, 0x0a0002f2, 0xacc4005c, 0x32220002, 0x0a0002f2, 0x0002102b, 156 0x3c, 0x15, 0xc9, 0xfc, 0x2b, 0x45, 0x61, 0x3f, 0x76, 0xd0, 0xc8, 0x94,
157 0x3c026000, 0xac400808, 0x0000000d, 0x00001021, 0x8fbf0018, 0x8fb10014, 157 0x42, 0x7a, 0x17, 0xb5, 0xc3, 0x7f, 0xf4, 0x37, 0x61, 0xfe, 0x5d, 0x44,
158 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffc8, 0xafbf0034, 0xafbe0030, 158 0x9b, 0x1d, 0xbf, 0xd9, 0x15, 0x1e, 0x05, 0xff, 0xd3, 0x2f, 0x7e, 0x05,
159 0xafb7002c, 0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c, 0xafb20018, 159 0xdf, 0x3c, 0x4d, 0x07, 0xa7, 0x0e, 0x2b, 0x39, 0xfb, 0x08, 0xe0, 0x97,
160 0xafb10014, 0x0e000244, 0xafb00010, 0x3c170800, 0x3c160800, 0x24110020, 160 0x83, 0xd5, 0x01, 0x9b, 0x07, 0xec, 0x97, 0x31, 0xef, 0xd3, 0xa4, 0xdf,
161 0x24150030, 0x2794000c, 0x27930008, 0x3c124000, 0x3c1e0800, 0x8f820004, 161 0x1e, 0x19, 0x48, 0x28, 0xc0, 0xe3, 0x45, 0x01, 0x2f, 0x7d, 0x71, 0x97,
162 0x3c040800, 0x8c830020, 0x10430005, 0x8ee200a4, 0xaf830004, 0x0e001593, 162 0xb1, 0x53, 0xf0, 0x3f, 0x40, 0xef, 0x15, 0x2f, 0x80, 0xbe, 0xbd, 0xf0,
163 0x00000000, 0x8ee200a4, 0x8ec300a0, 0x10430004, 0x26c400a0, 0x94820002, 163 0x39, 0x91, 0x67, 0x61, 0x93, 0xe1, 0x8f, 0x22, 0x57, 0x31, 0x2d, 0x7c,
164 0xa742009e, 0xaee300a4, 0x8f500000, 0x32020007, 0x1040ffee, 0x32020001, 164 0x11, 0x29, 0x0f, 0x76, 0xa7, 0x41, 0xef, 0x38, 0xfc, 0xd3, 0x00, 0xfc,
165 0x1040002c, 0x32020002, 0x8f420100, 0xaf420020, 0x8f430104, 0xaf4300a8, 165 0x53, 0x0c, 0xbe, 0xa9, 0x07, 0x7e, 0xc9, 0x82, 0x5f, 0x0a, 0x83, 0x1f,
166 0x9342010b, 0x93630000, 0x306300ff, 0x10710005, 0x304400ff, 0x10750006, 166 0x06, 0xcd, 0xc2, 0x47, 0xcd, 0x42, 0xfe, 0xe7, 0x66, 0x48, 0x19, 0x04,
167 0x2c820016, 0x0a000333, 0x00000000, 0xaf940000, 0x0a000334, 0x2c820016, 167 0xad, 0xcf, 0xc1, 0x3f, 0x26, 0x63, 0x77, 0x42, 0xcf, 0x22, 0x17, 0x66,
168 0xaf930000, 0x0a000334, 0x00000000, 0xaf800000, 0x14400005, 0x00041880, 168 0xd5, 0x41, 0xca, 0xc1, 0x9f, 0x77, 0x6e, 0x8b, 0x62, 0xbd, 0x26, 0x4a,
169 0x0e0003cc, 0x00000000, 0x0a000340, 0x00000000, 0x3c020800, 0x24425860, 169 0x84, 0x5c, 0x1d, 0xe5, 0xdf, 0x7e, 0x85, 0xac, 0x7f, 0x06, 0xef, 0x22,
170 0x00621821, 0x8c620000, 0x0040f809, 0x00000000, 0x10400005, 0x3c030800, 170 0x61, 0xa2, 0x3d, 0x94, 0xb5, 0xa3, 0x46, 0xa7, 0xda, 0x03, 0x18, 0x6e,
171 0x8f420104, 0x3c016020, 0xac220014, 0x3c030800, 0x8c620034, 0xaf520138, 171 0x87, 0x95, 0x03, 0x53, 0x11, 0x05, 0xfb, 0x03, 0xcd, 0x27, 0x60, 0xeb,
172 0x24420001, 0xac620034, 0x32020002, 0x1040001a, 0x32020004, 0x8f420140, 172 0xcb, 0x34, 0x1e, 0x63, 0x3d, 0x29, 0xd3, 0xf3, 0xb1, 0xc8, 0x40, 0x9e,
173 0xaf420020, 0x93630000, 0x306300ff, 0x10710005, 0x00000000, 0x10750006, 173 0x5a, 0xe9, 0x98, 0x39, 0x21, 0x7c, 0xbc, 0x16, 0x3f, 0x21, 0x74, 0x2c,
174 0x00000000, 0x0a00035d, 0x00000000, 0xaf940000, 0x0a00035e, 0x00000000, 174 0x67, 0xe1, 0x59, 0xec, 0x54, 0xb2, 0x53, 0xbc, 0x7e, 0x14, 0x5a, 0xee,
175 0xaf930000, 0x0a00035e, 0x00000000, 0xaf800000, 0x0e000c7b, 0x00000000, 175 0xc7, 0x93, 0xe7, 0x07, 0xdd, 0xfa, 0x49, 0x39, 0xd8, 0x9d, 0x87, 0x77,
176 0x3c040800, 0x8c820038, 0xaf520178, 0x24420001, 0xac820038, 0x32020004, 176 0x88, 0x18, 0x8b, 0x58, 0x39, 0x35, 0x11, 0x0d, 0x45, 0x55, 0x8d, 0x86,
177 0x1040ffa4, 0x00000000, 0x8f420180, 0xaf420020, 0x93630000, 0x306300ff, 177 0x35, 0x85, 0x46, 0x61, 0x6f, 0xd2, 0xb1, 0xff, 0x2c, 0x1f, 0x33, 0x79,
178 0x10710005, 0x00000000, 0x10750006, 0x00000000, 0x0a000378, 0x00000000, 178 0xbc, 0x99, 0xbe, 0x2a, 0xfc, 0x0d, 0xd6, 0x2e, 0x4c, 0x63, 0x5d, 0x3f,
179 0xaf940000, 0x0a000379, 0x00000000, 0xaf930000, 0x0a000379, 0x00000000, 179 0xf8, 0xcb, 0xeb, 0xf2, 0x3c, 0x68, 0xc3, 0xf6, 0x6b, 0x56, 0xe4, 0xd9,
180 0xaf800000, 0x8f430180, 0x24020f00, 0x14620005, 0x00000000, 0x8f420188, 180 0x3c, 0xed, 0x00, 0x6d, 0xd9, 0x66, 0xc1, 0x3e, 0x0c, 0x60, 0xed, 0x5e,
181 0xa742009c, 0x0a000387, 0x8fc2003c, 0x93620000, 0x14510004, 0x8fc2003c, 181 0xd8, 0x4f, 0x3c, 0x93, 0xbd, 0x1c, 0x07, 0x05, 0x68, 0xd8, 0x64, 0x79,
182 0x0e000bad, 0x00000000, 0x8fc2003c, 0xaf5201b8, 0x24420001, 0x0a00030b, 182 0xd4, 0xe5, 0x98, 0xe9, 0x19, 0xf3, 0xcb, 0xb1, 0x20, 0xfe, 0xe0, 0x7f,
183 0xafc2003c, 0x27bdffe8, 0xafbf0010, 0x97420108, 0x24033000, 0x30447000, 183 0x4d, 0x96, 0x19, 0x6e, 0x73, 0x4c, 0xc6, 0x34, 0x09, 0xd3, 0xdc, 0x64,
184 0x10830016, 0x28823001, 0x10400007, 0x24024000, 0x1080000b, 0x24022000, 184 0x02, 0x34, 0x8b, 0x9c, 0x4d, 0x10, 0xd3, 0x0c, 0x46, 0x7b, 0x7f, 0x82,
185 0x1082000c, 0x00000000, 0x0a0003b3, 0x00000000, 0x10820010, 0x24025000, 185 0xbe, 0x64, 0xaf, 0xf7, 0x3b, 0xb6, 0xb0, 0x55, 0x49, 0xc1, 0x17, 0xa8,
186 0x10820012, 0x00000000, 0x0a0003b3, 0x00000000, 0x0000000d, 0x0a0003b5, 186 0x56, 0x0b, 0x7c, 0x45, 0x98, 0x5e, 0x15, 0xb0, 0x64, 0xa8, 0xf1, 0x68,
187 0x00001021, 0x0e000442, 0x00000000, 0x0a0003b6, 0x8fbf0010, 0x0e00041a, 187 0xe8, 0x4b, 0x74, 0xab, 0xb0, 0x11, 0x09, 0xc3, 0x4b, 0xe3, 0xff, 0x52,
188 0x00000000, 0x0a0003b5, 0x00001021, 0x0e000669, 0x00000000, 0x0a0003b5, 188 0xc9, 0x72, 0xbf, 0x69, 0xa5, 0xec, 0x20, 0xf3, 0x89, 0xd7, 0x33, 0x68,
189 0x00001021, 0x0e001467, 0x00000000, 0x0a0003b5, 0x00001021, 0x0000000d, 189 0xae, 0xe4, 0xbc, 0xfb, 0x10, 0xa3, 0x16, 0x60, 0x6b, 0xce, 0x4f, 0xaa,
190 0x00001021, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x93620000, 0x24030020, 190 0xf4, 0xf8, 0x1d, 0xf0, 0x65, 0xb1, 0x6d, 0x58, 0xcb, 0xc4, 0x78, 0x1e,
191 0x304400ff, 0x10830005, 0x24020030, 0x10820007, 0x00000000, 0x0a0003c9, 191 0x6d, 0x15, 0x6d, 0xe8, 0x99, 0x11, 0x02, 0x8f, 0xb9, 0x9f, 0xe1, 0x4c,
192 0x00000000, 0x2782000c, 0xaf820000, 0x03e00008, 0x00000000, 0x27820008, 192 0xfc, 0xbd, 0xcf, 0xb1, 0x75, 0x3e, 0xab, 0xde, 0x4a, 0x14, 0x64, 0x7a,
193 0xaf820000, 0x03e00008, 0x00000000, 0xaf800000, 0x03e00008, 0x00000000, 193 0xc5, 0x40, 0x2b, 0xcb, 0x50, 0xd5, 0x6d, 0xc2, 0x5f, 0x3b, 0xb6, 0xc4,
194 0x0000000d, 0x03e00008, 0x00001021, 0x03e00008, 0x00001021, 0x27440100, 194 0x82, 0x2e, 0xc2, 0xe6, 0xf6, 0x79, 0x75, 0x91, 0xe3, 0x09, 0x57, 0x17,
195 0x94830008, 0x30620004, 0x10400017, 0x30620002, 0x8f4202b8, 0x04430007, 195 0x23, 0xa1, 0x84, 0x0a, 0x5b, 0xdc, 0xa7, 0xd1, 0x09, 0xd1, 0x56, 0x28,
196 0x8c820020, 0x3c040800, 0x8c830060, 0x24020001, 0x24630001, 0x03e00008, 196 0x31, 0x18, 0x09, 0x2d, 0xa8, 0x1c, 0x4b, 0x33, 0x6c, 0x18, 0xf1, 0x4a,
197 0xac830060, 0xaf420280, 0x94830016, 0x3c060800, 0xa7430284, 0x8c850004, 197 0x40, 0xc2, 0x22, 0x9e, 0xb3, 0xdd, 0x98, 0x30, 0x84, 0x7e, 0x53, 0xf4,
198 0x8cc4005c, 0x00001021, 0x3c031000, 0x24840001, 0xaf450288, 0xaf4302b8, 198 0x1f, 0xab, 0xe8, 0xa8, 0x13, 0xff, 0xa9, 0x88, 0x11, 0x0b, 0x88, 0x11,
199 0x03e00008, 0xacc4005c, 0x14400003, 0x3c040800, 0x03e00008, 0x00001021, 199 0x53, 0x42, 0x47, 0x8d, 0x04, 0x72, 0x04, 0xd0, 0xdc, 0xd1, 0xcf, 0x42,
200 0x8c830084, 0x24020001, 0x24630001, 0x03e00008, 0xac830084, 0x27450100, 200 0x91, 0x71, 0xc9, 0xb1, 0x5c, 0x0e, 0x00, 0x99, 0x13, 0x8e, 0x7d, 0xa4,
201 0x3c040800, 0x8c820088, 0x94a3000c, 0x24420001, 0x007a1821, 0xac820088, 201 0x3c, 0xc7, 0x91, 0xa3, 0xea, 0x53, 0x34, 0x5c, 0x60, 0x3f, 0x8e, 0x3f,
202 0x8ca40018, 0x90664000, 0xaf440038, 0x8ca2001c, 0x2403fff8, 0x00063600, 202 0x9b, 0x6d, 0x2d, 0xec, 0xa3, 0xf0, 0xc5, 0x51, 0xf0, 0x39, 0x0f, 0x1a,
203 0x00431024, 0x34420004, 0x3c030005, 0xaf42003c, 0xaf430030, 0x00000000, 203 0xac, 0x97, 0x74, 0xdd, 0x4f, 0x07, 0xec, 0x3d, 0xa0, 0x79, 0x9c, 0x46,
204 0x00000000, 0x00000000, 0xaf460404, 0x00000000, 0x00000000, 0x00000000, 204 0x4e, 0x8d, 0xb0, 0xcc, 0xf6, 0x14, 0x28, 0xd2, 0x73, 0x8c, 0xb6, 0x1b,
205 0x3c020006, 0x34420001, 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 205 0x73, 0x2c, 0xdf, 0x83, 0xe5, 0x1d, 0xe0, 0x85, 0xd0, 0x51, 0xc8, 0x20,
206 0x8f420000, 0x30420010, 0x1040fffd, 0x00001021, 0x03e00008, 0x00000000, 206 0x65, 0x0b, 0x23, 0xf4, 0x58, 0x89, 0xfb, 0xf2, 0xa0, 0x1d, 0xe2, 0xda,
207 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x1060001e, 207 0xfe, 0xfd, 0x52, 0xce, 0x31, 0x9f, 0xe6, 0xce, 0x37, 0x22, 0xe7, 0x63,
208 0xafbf0014, 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020018, 0xac620000, 208 0x38, 0x86, 0xe1, 0x6f, 0xaa, 0xf3, 0xee, 0x14, 0x3c, 0x8d, 0x18, 0x5d,
209 0x8f840018, 0x9602000c, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 209 0x6a, 0x79, 0x87, 0x1f, 0xe3, 0xcf, 0xf7, 0xf3, 0x3b, 0xe6, 0x81, 0xef,
210 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f840018, 210 0x6f, 0xb6, 0xf6, 0x00, 0x76, 0x10, 0x73, 0xfa, 0xa9, 0xb3, 0xdd, 0xc5,
211 0x3c026000, 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x946458ce, 211 0x37, 0x81, 0xb5, 0xd9, 0xcf, 0x31, 0x9f, 0x1f, 0xa1, 0xec, 0xa9, 0x7c,
212 0x8f850018, 0x00021400, 0x00441025, 0x24040001, 0x0e0014cc, 0xaca2001c, 212 0x8f, 0x0a, 0x19, 0x9b, 0xcd, 0x28, 0xe4, 0xb7, 0x1e, 0xa6, 0xdc, 0xa9,
213 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafb00010, 213 0xa3, 0x6c, 0x37, 0x40, 0xab, 0x3d, 0xb4, 0x6b, 0x22, 0xd2, 0x73, 0x80,
214 0x27500100, 0xafbf0014, 0x92020009, 0x14400003, 0x3c020800, 0x0a00046c, 214 0x34, 0xb1, 0xce, 0x5b, 0x24, 0xe8, 0x1f, 0x9b, 0x15, 0xbe, 0x20, 0x43,
215 0x24020001, 0x8c430020, 0x1060001f, 0x00001021, 0x0e00148e, 0x00000000, 215 0xe9, 0x89, 0xed, 0xa1, 0x4b, 0xe8, 0x1b, 0x1e, 0x8c, 0x84, 0x17, 0xe8,
216 0x8f830018, 0x8e020018, 0xac620000, 0x8f840018, 0x9602000c, 0xac820004, 216 0x09, 0xd0, 0xe5, 0x23, 0xf8, 0x22, 0xab, 0x67, 0x0c, 0x3a, 0x84, 0x9c,
217 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 217 0x0a, 0xeb, 0x8f, 0x4a, 0xda, 0xe0, 0xbb, 0xcc, 0x51, 0xd0, 0x8f, 0xf2,
218 0x8f820018, 0xac400014, 0x8f840018, 0x3c026000, 0x8c434448, 0xac830018, 218 0x0e, 0x4d, 0x99, 0x9e, 0x4c, 0xcb, 0xaf, 0xc0, 0xf6, 0x1c, 0x11, 0xb1,
219 0x96020008, 0x3c030800, 0x946458ce, 0x8f850018, 0x00021400, 0x00441025, 219 0x4b, 0x56, 0xd0, 0xee, 0xd2, 0x06, 0x47, 0x0e, 0x60, 0x8b, 0x30, 0xef,
220 0x24040001, 0x0e0014cc, 0xaca2001c, 0x00001021, 0x8fbf0014, 0x8fb00010, 220 0xe5, 0x41, 0x85, 0xb6, 0x20, 0x4e, 0x3f, 0x24, 0x78, 0xeb, 0xa3, 0x7d,
221 0x03e00008, 0x27bd0018, 0x3c0b0800, 0x8d6808b0, 0x3c070800, 0x24e700b0, 221 0x66, 0xd4, 0xd8, 0x47, 0xf3, 0x7e, 0x27, 0x56, 0xc0, 0x3c, 0x3d, 0xf7,
222 0x00084900, 0x01271821, 0xac640000, 0x93620005, 0x97660008, 0x00e95021, 222 0x60, 0x0f, 0x90, 0x53, 0xfb, 0xeb, 0xeb, 0xa8, 0x2d, 0x12, 0x4e, 0xa8,
223 0x93630023, 0x9364003f, 0x25080001, 0x00021600, 0x00063400, 0x00461025, 223 0x09, 0xfa, 0x93, 0xd2, 0xdd, 0xe4, 0xe8, 0x77, 0x2b, 0xdb, 0x7e, 0xf0,
224 0x00031a00, 0x00431025, 0x00822025, 0xad440004, 0x9362007e, 0x9366007f, 224 0xb0, 0xd3, 0x69, 0x5b, 0x78, 0x16, 0x3a, 0xb1, 0x1e, 0xe3, 0xfe, 0xac,
225 0x8f630178, 0x9364007a, 0x00021600, 0x00063400, 0x00461025, 0x00031a00, 225 0xc0, 0x7d, 0x84, 0xba, 0xa1, 0x6b, 0x22, 0x8f, 0x39, 0x51, 0x8b, 0x17,
226 0x00431025, 0x00822025, 0xad440008, 0x93620080, 0x9363007d, 0x3108007f, 226 0xf3, 0xbc, 0x9e, 0xcf, 0x5f, 0xc6, 0x3c, 0xdc, 0xcf, 0x70, 0x78, 0x2f,
227 0x01403821, 0xad6808b0, 0x00021600, 0x00031c00, 0x00431025, 0x00451025, 227 0x3c, 0x41, 0x23, 0x90, 0xc7, 0x5c, 0x7f, 0x57, 0x68, 0x0c, 0xdf, 0xa4,
228 0x03e00008, 0xace2000c, 0x27bdffb8, 0xafb3002c, 0x00009821, 0xafbe0040, 228 0x4a, 0x4d, 0x74, 0x54, 0xe3, 0xf1, 0x48, 0x38, 0xaf, 0x1e, 0x42, 0xdc,
229 0x0000f021, 0xafb50034, 0x27550100, 0xafbf0044, 0xafb7003c, 0xafb60038, 229 0xf3, 0xb8, 0xea, 0xb7, 0x7e, 0xe6, 0x67, 0xbf, 0xe3, 0xb7, 0xae, 0x29,
230 0xafb40030, 0xafb20028, 0xafb10024, 0xafb00020, 0xafa00010, 0xafa00014, 230 0xd5, 0xb9, 0x10, 0x87, 0x8a, 0xdc, 0x60, 0x41, 0x19, 0x2c, 0x5d, 0x52,
231 0x96a20008, 0x8f540100, 0x8eb10018, 0x30420001, 0x10400037, 0x02a0b821, 231 0x92, 0x85, 0x6b, 0x4a, 0xaa, 0xc4, 0x30, 0x8e, 0xce, 0x67, 0xcf, 0x74,
232 0x8f630054, 0x2622ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d, 232 0x82, 0x4e, 0x1f, 0x89, 0xef, 0xe6, 0x7a, 0x8f, 0x50, 0xea, 0xd4, 0xad,
233 0x00000000, 0x2400015c, 0x0a0004e5, 0x00002021, 0x8f62004c, 0x02221023, 233 0x94, 0x9e, 0xe6, 0xbc, 0x34, 0x02, 0x7c, 0x3f, 0x2a, 0xe7, 0x62, 0x41,
234 0x18400028, 0x00002021, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c, 234 0xca, 0x9d, 0xe1, 0x31, 0xb6, 0x5f, 0xd6, 0xd5, 0x45, 0x1f, 0xef, 0x9f,
235 0x308400ff, 0x24420001, 0x30a500ff, 0x00803821, 0x1485000b, 0xac62008c, 235 0xf9, 0x6f, 0x52, 0xc1, 0x7e, 0x53, 0xd2, 0x8f, 0xdf, 0x7d, 0x9c, 0x93,
236 0x3c040800, 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001, 236 0xe1, 0xf7, 0x6f, 0x86, 0xd3, 0xb7, 0x95, 0x16, 0x36, 0xdc, 0xc8, 0x3e,
237 0x00021023, 0x30420005, 0x0a0004e5, 0x34440004, 0x27660100, 0x00041080, 237 0x57, 0xb3, 0xc7, 0x47, 0x7d, 0x7e, 0x6b, 0x7b, 0x13, 0xb5, 0x84, 0x80,
238 0x00c21021, 0x8c430000, 0x02231823, 0x04600004, 0x24820001, 0x30440007, 238 0xc3, 0x4a, 0x7b, 0x64, 0x98, 0x5f, 0x87, 0x1c, 0xb0, 0x4d, 0xd9, 0x0d,
239 0x1485fff9, 0x00041080, 0x10870007, 0x3c030800, 0xa3640121, 0x8c620094, 239 0x7e, 0x5a, 0x6c, 0xc3, 0x60, 0x93, 0x76, 0x53, 0xae, 0xc4, 0xb2, 0x1d,
240 0x24040005, 0x24420001, 0x0a0004e5, 0xac620094, 0x24040004, 0x00809821, 240 0x35, 0x32, 0x90, 0xb1, 0x34, 0x75, 0xb1, 0x1e, 0xb9, 0xba, 0x07, 0xdb,
241 0x9362003f, 0x304400ff, 0x38830016, 0x2c630001, 0x38820010, 0x2c420001, 241 0x9d, 0x87, 0xed, 0x46, 0x3c, 0x64, 0x53, 0xbe, 0x29, 0xce, 0x36, 0xbc,
242 0x00621825, 0x1460000c, 0x24020001, 0x38830008, 0x2c630001, 0x38820014, 242 0x0b, 0xb2, 0x85, 0xbe, 0x62, 0x55, 0x17, 0x77, 0x2d, 0xc1, 0x5d, 0x5b,
243 0x2c420001, 0x00621825, 0x14600005, 0x24020001, 0x24020012, 0x14820002, 243 0xc2, 0xa3, 0x02, 0xd5, 0xe2, 0x3f, 0x4b, 0x8c, 0xff, 0x5f, 0x00, 0xff,
244 0x00001021, 0x24020001, 0x10400009, 0x00000000, 0x8ea20020, 0x8f630040, 244 0xcf, 0x01, 0x7f, 0xc6, 0xa9, 0x31, 0xfe, 0x3b, 0x2b, 0xf8, 0x33, 0x0c,
245 0x0040b021, 0x00431023, 0x5c400010, 0x8f760040, 0x0a000511, 0x00000000, 245 0xfc, 0x1c, 0x64, 0xf1, 0x0d, 0xe8, 0xe2, 0x6b, 0x36, 0x7c, 0x9d, 0x0d,
246 0x9343010b, 0x24020004, 0x1462000a, 0x8eb60020, 0x8f630040, 0x3c021000, 246 0xff, 0x67, 0xc3, 0xdf, 0xd9, 0xf0, 0x8b, 0x36, 0x7c, 0x1e, 0xf6, 0x74,
247 0x00761823, 0x0043102a, 0x10400004, 0x00000000, 0x0000000d, 0x00000000, 247 0x0e, 0x36, 0xe9, 0xac, 0x9d, 0x34, 0x58, 0x9f, 0x92, 0x31, 0xf6, 0x9d,
248 0x240002fa, 0x9343010b, 0x24020004, 0x5462000b, 0x96a20008, 0x24020001, 248 0xbb, 0x65, 0xde, 0x1d, 0x92, 0x71, 0xf7, 0xa7, 0x64, 0x2c, 0x7b, 0x00,
249 0xafa20010, 0x96a20008, 0x24030001, 0xafa30018, 0x8eb2001c, 0x36730002, 249 0xb1, 0xec, 0x66, 0x1a, 0xed, 0xe1, 0x9c, 0xa4, 0x05, 0xcf, 0x75, 0x78,
250 0x30420020, 0x0a000526, 0xafa20014, 0x36730080, 0x30420002, 0x10400003, 250 0x22, 0x6e, 0xed, 0x49, 0x48, 0xbd, 0xfc, 0x0c, 0x62, 0x5c, 0xd8, 0xff,
251 0xafa00018, 0x0a000526, 0x8eb2001c, 0x8eb20014, 0x2402fffb, 0x02628024, 251 0x1e, 0xe4, 0x37, 0x19, 0xc4, 0x6a, 0x56, 0x1f, 0xc7, 0xe5, 0xb0, 0x65,
252 0x1200002a, 0x3c030800, 0x8c620030, 0x02021024, 0x10400026, 0x3c020800, 252 0xef, 0x37, 0x39, 0x76, 0xfe, 0x2e, 0x19, 0x03, 0xbb, 0xed, 0x56, 0xc0,
253 0x8c430020, 0x10600024, 0x32620004, 0x0e00148e, 0x00000000, 0x8f830018, 253 0xa4, 0xd1, 0xd7, 0x8a, 0x6f, 0x7e, 0x07, 0xb2, 0xdf, 0x86, 0xf6, 0xce,
254 0x8f420100, 0xac620000, 0x8f840018, 0x02401821, 0x32620002, 0xac900004, 254 0x3a, 0x18, 0xe4, 0xb3, 0x56, 0x16, 0x7d, 0x11, 0xc0, 0xb4, 0x61, 0x9d,
255 0x8f840018, 0x54400001, 0x02c01821, 0xac830008, 0x8f830018, 0x8ee20020, 255 0x0e, 0xb4, 0xf7, 0xa0, 0x7d, 0x8b, 0xb3, 0x8e, 0xf1, 0x2b, 0x68, 0xa7,
256 0xac62000c, 0x8f840018, 0x8f620040, 0xac820010, 0x8f830018, 0x8ee20018, 256 0xea, 0xbe, 0xd9, 0x8a, 0xbe, 0x4c, 0x5d, 0xdf, 0x9b, 0xe8, 0x4b, 0xa2,
257 0xac620014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 257 0x6f, 0x51, 0x7e, 0x97, 0x47, 0x3b, 0x52, 0x07, 0xb3, 0x88, 0x3e, 0xc6,
258 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010, 0x00621825, 0x0e0014cc, 258 0xf1, 0x5b, 0x78, 0xde, 0x47, 0xa3, 0x19, 0x8e, 0x03, 0xdc, 0xb1, 0xdc,
259 0xaca3001c, 0x32620004, 0x10400063, 0x00003821, 0x3c029000, 0x34420001, 259 0x7a, 0x6a, 0xe3, 0xdc, 0xf7, 0x43, 0x21, 0x3b, 0xf3, 0xd2, 0x46, 0xa7,
260 0x3c038000, 0x02821025, 0xa360007c, 0xaf420020, 0x8f420020, 0x00431024, 260 0x27, 0xd8, 0x4f, 0x8c, 0x20, 0xee, 0xe1, 0x71, 0xe1, 0x9c, 0x3c, 0xfd,
261 0x1440fffd, 0x00000000, 0x93620023, 0x30420080, 0x10400011, 0x00000000, 261 0x1f, 0x00, 0xf6, 0x61, 0x8c, 0x21, 0x56, 0xb7, 0xcb, 0x4d, 0x8d, 0xc7,
262 0x8f65005c, 0x8f63004c, 0x9764003c, 0x8f620064, 0x00a32823, 0x00852821, 262 0x1f, 0xc5, 0xf8, 0x5f, 0xca, 0x6f, 0x2b, 0x73, 0x03, 0xfe, 0x1b, 0x75,
263 0x00a2102b, 0x54400006, 0x3c023fff, 0x93620023, 0x3042007f, 0xa3620023, 263 0x7d, 0x6a, 0xb0, 0xb6, 0xbd, 0xd6, 0xf3, 0xbe, 0x4d, 0x5f, 0xfa, 0xfd,
264 0xaf710064, 0x3c023fff, 0x0a000580, 0x3442ffff, 0x8f62005c, 0x02221023, 264 0x48, 0x1d, 0xfc, 0xef, 0x6e, 0xa8, 0x6d, 0x3f, 0xc5, 0xdf, 0x20, 0x87,
265 0x04400011, 0x00000000, 0x8f65005c, 0x8f630064, 0x9764003c, 0x3c023fff, 265 0x70, 0xdb, 0x09, 0xc8, 0x1d, 0xdb, 0xa4, 0xfa, 0x79, 0x3e, 0x6b, 0xd4,
266 0x3442ffff, 0xaf710064, 0x00a32823, 0x00852821, 0x0045102b, 0x10400004, 266 0xf6, 0x6d, 0x32, 0x6b, 0xdb, 0x1c, 0x27, 0x31, 0x5c, 0x08, 0xf2, 0xde,
267 0x02251021, 0x3c053fff, 0x34a5ffff, 0x02251021, 0xaf62005c, 0x24070001, 267 0xa1, 0xec, 0xb2, 0x7f, 0x13, 0xe3, 0x61, 0xe5, 0x5e, 0xdb, 0x8b, 0x67,
268 0xaf71004c, 0x8f620054, 0x16220005, 0x00000000, 0x93620023, 0x30420040, 268 0x48, 0xe6, 0x46, 0xe1, 0x4a, 0xcc, 0x3b, 0x5f, 0x0a, 0x40, 0xae, 0x3e,
269 0x10400017, 0x24020001, 0x9762006a, 0x00022880, 0x50a00001, 0x24050001, 269 0x0f, 0x9e, 0x73, 0xdc, 0x53, 0xd5, 0xf1, 0xf7, 0x68, 0x39, 0x1d, 0x67,
270 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 270 0x1f, 0xc0, 0x31, 0xfe, 0x36, 0x11, 0x1f, 0xfb, 0xe2, 0x4f, 0x70, 0x0c,
271 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 271 0xf6, 0xb4, 0xe3, 0x5b, 0x2c, 0xf8, 0x43, 0xb4, 0x4b, 0x7e, 0xc7, 0x6e,
272 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 272 0x22, 0x9f, 0xc8, 0x16, 0xd8, 0x9f, 0xb1, 0x0f, 0x89, 0xc0, 0x4e, 0xb3,
273 0xaf62000c, 0x93620082, 0x30420080, 0x50400001, 0xa3600081, 0x3c028000, 273 0x1f, 0xfd, 0x24, 0x7d, 0xc6, 0x5d, 0xcd, 0x6c, 0xfb, 0x34, 0xeb, 0x05,
274 0x34420001, 0x02821025, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004, 274 0xc4, 0x0b, 0x1c, 0xe7, 0xb1, 0xed, 0xc6, 0x7b, 0xd1, 0x8d, 0x57, 0xee,
275 0x00000000, 0x0e0013c4, 0x00000000, 0x00403821, 0x54e00001, 0x241e0001, 275 0xd7, 0xc8, 0xaa, 0xfa, 0x11, 0x67, 0x8f, 0x5b, 0x59, 0x37, 0x56, 0xb1,
276 0x8f700040, 0x8f620040, 0x14520003, 0x00521023, 0x0a0005bf, 0x00001021, 276 0xef, 0xc6, 0xb6, 0xed, 0xc7, 0x75, 0xb6, 0xe1, 0xb2, 0xb0, 0x0d, 0x0f,
277 0x28420001, 0x10400041, 0x8fa20010, 0x0e000fae, 0x02402021, 0xaf720040, 277 0x6a, 0x7e, 0xeb, 0xf7, 0x9b, 0x1d, 0x79, 0x6d, 0x6c, 0x1b, 0xee, 0xad,
278 0x9362003e, 0x30420001, 0x1440000b, 0x3c029000, 0x93620022, 0x24420001, 278 0xd8, 0x06, 0x57, 0x5e, 0xbd, 0x79, 0xeb, 0x0f, 0xc0, 0x1b, 0x0b, 0xbc,
279 0xa3620022, 0x93630022, 0x3c020800, 0x8c440098, 0x0064182b, 0x14600027, 279 0xa9, 0xaf, 0xd5, 0x70, 0x8e, 0xe2, 0x87, 0x1f, 0xe2, 0x18, 0x91, 0x73,
280 0x3c020800, 0x3c029000, 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 280 0xd9, 0x18, 0xe5, 0x62, 0x45, 0xc4, 0x6a, 0x91, 0xd9, 0xd9, 0x4a, 0x8e,
281 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 281 0xf5, 0x35, 0x69, 0xbb, 0x6b, 0xe2, 0x22, 0x7a, 0xbc, 0x78, 0x09, 0xf8,
282 0x34420001, 0xa362007d, 0x8f640074, 0x34630001, 0x02831825, 0xaf430020, 282 0x73, 0xbc, 0xa5, 0x49, 0x1b, 0xc1, 0xfd, 0xe3, 0x12, 0x47, 0x7e, 0xe7,
283 0x04810006, 0x3c038000, 0x02802021, 0x0e000470, 0x24050273, 0x0a0005f2, 283 0x3a, 0x1e, 0x7c, 0x69, 0xf1, 0x47, 0xe0, 0x15, 0xc7, 0x7d, 0x51, 0x27,
284 0x24050001, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 284 0xde, 0xab, 0x89, 0xa9, 0xd7, 0xf8, 0xc9, 0xe2, 0x78, 0x89, 0x61, 0x74,
285 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 0x24050001, 0x24020001, 0xa7620012, 285 0x19, 0x2f, 0x05, 0x64, 0x5e, 0x63, 0xc8, 0x3c, 0x87, 0x63, 0x6d, 0xae,
286 0xa3600022, 0x0a0005fe, 0x2ca20001, 0x9743007a, 0x9444002a, 0x00002821, 286 0xb1, 0xd6, 0xc7, 0x50, 0x0b, 0x43, 0xc1, 0x6d, 0xcc, 0x13, 0x8e, 0xa1,
287 0x00641821, 0x3063fffe, 0xa7630012, 0x2ca20001, 0x00021023, 0x03c2f024, 287 0xda, 0x28, 0x39, 0xe3, 0xc4, 0x50, 0x4e, 0x9d, 0xcd, 0xcd, 0x71, 0x5c,
288 0x8fa20010, 0x10400004, 0x8fa30014, 0x0e0013c1, 0x00000000, 0x8fa30014, 288 0x5c, 0xd9, 0x0f, 0xef, 0xc0, 0x3e, 0x45, 0x9e, 0x14, 0x74, 0xea, 0x7f,
289 0x10600003, 0x00000000, 0x0e0010eb, 0x00000000, 0x13c0001f, 0x3c029000, 289 0x1a, 0xec, 0xf6, 0x51, 0xf4, 0x8f, 0xba, 0xfd, 0x9e, 0x5c, 0xc3, 0xc5,
290 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 290 0x85, 0x7d, 0xbd, 0x1b, 0xd3, 0xed, 0x96, 0x31, 0x1d, 0x62, 0x18, 0xdb,
291 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 291 0xc9, 0xbb, 0xf6, 0x16, 0x33, 0xe8, 0xe3, 0x75, 0x11, 0x1b, 0x12, 0xc7,
292 0x34630001, 0x02831825, 0xaf430020, 0x04810006, 0x3c038000, 0x02802021, 292 0x49, 0x90, 0xaf, 0xfd, 0x91, 0x50, 0x58, 0xad, 0xc7, 0xab, 0x75, 0xa1,
293 0x0e000470, 0x2405036c, 0x0a00062b, 0x8fa20018, 0x8f4201f8, 0x00431024, 293 0x16, 0xaf, 0x41, 0xf1, 0xdd, 0xf8, 0x92, 0xef, 0x48, 0xc4, 0x92, 0xe3,
294 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 294 0xf6, 0x10, 0xe8, 0xc5, 0xf8, 0xb9, 0xba, 0xe1, 0xc6, 0xc9, 0x8c, 0xd3,
295 0x8fa20018, 0x5040002f, 0x96a20008, 0x8f620048, 0x8f630024, 0x00761821, 295 0x3f, 0x82, 0xc6, 0xbb, 0x15, 0xfe, 0x7e, 0xcc, 0xde, 0x2f, 0xe8, 0x96,
296 0xaf630048, 0x9764003c, 0x00501023, 0x0044102b, 0x10400025, 0x3c029000, 296 0x15, 0xb8, 0x0e, 0x7b, 0x70, 0x1d, 0x91, 0xb8, 0xb2, 0x2e, 0xb0, 0x7e,
297 0x34420001, 0x3c040800, 0x8c830080, 0x8f450100, 0x3c068000, 0x24630001, 297 0x78, 0x6b, 0x9a, 0xa6, 0xd8, 0x1b, 0x70, 0x0e, 0xf3, 0xb9, 0xb9, 0x6a,
298 0x00a21025, 0xac830080, 0xaf420020, 0x8f420020, 0x00461024, 0x1440fffd, 298 0x2d, 0x0c, 0xf9, 0xb6, 0xc1, 0x1f, 0x02, 0xd7, 0xac, 0x88, 0x43, 0x03,
299 0x00000000, 0x9362007d, 0x3c038000, 0x34420004, 0xa362007d, 0x8f640074, 299 0x0b, 0xf5, 0x34, 0x1c, 0xc7, 0x5a, 0x88, 0xdb, 0x81, 0x8f, 0xcb, 0xf3,
300 0x34630001, 0x00a31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021, 300 0x26, 0x89, 0xcf, 0x37, 0xc5, 0xdc, 0x63, 0xa2, 0x06, 0xea, 0xd3, 0x39,
301 0x0e000470, 0x2405038a, 0x0a00065b, 0x96a20008, 0x8f4201f8, 0x00431024, 301 0x77, 0xc9, 0x0a, 0xde, 0x69, 0x92, 0x77, 0x8f, 0x56, 0xf0, 0x73, 0x78,
302 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8, 302 0x1c, 0x90, 0x74, 0xe5, 0xdc, 0x95, 0x75, 0x5a, 0xf0, 0xa7, 0x9d, 0x73,
303 0x96a20008, 0x8fbf0044, 0x8fbe0040, 0x8fb7003c, 0x8fb60038, 0x8fb50034, 303 0xd3, 0x41, 0x6a, 0x14, 0x23, 0x2f, 0x0c, 0xa9, 0xdb, 0x1c, 0x3a, 0x3a,
304 0x8fb40030, 0x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020, 0x00021042, 304 0x31, 0xf2, 0xda, 0xba, 0x18, 0xf9, 0xb6, 0x20, 0xc7, 0x5a, 0xc3, 0x50,
305 0x30420001, 0x03e00008, 0x27bd0048, 0x27bdffe0, 0xafbf0018, 0x97420108, 305 0x82, 0x79, 0xf8, 0xba, 0x97, 0x6d, 0xc8, 0x36, 0x70, 0x3d, 0x5f, 0x53,
306 0x24030019, 0x304400ff, 0x10830065, 0x2882001a, 0x1040001a, 0x2882000a, 306 0xbb, 0xec, 0x59, 0xa6, 0xd6, 0x1c, 0x20, 0xdf, 0x0c, 0xfb, 0x0e, 0x0b,
307 0x1040000f, 0x28820008, 0x10400040, 0x24020001, 0x1082003a, 0x28820002, 307 0x79, 0x06, 0x91, 0x36, 0xc9, 0x3a, 0xcb, 0xbe, 0xbd, 0x1a, 0x67, 0xcf,
308 0x50400005, 0x24020006, 0x10800032, 0x3c026000, 0x0a0006fb, 0x00000000, 308 0x51, 0xa3, 0x18, 0xfb, 0x46, 0xfd, 0xfa, 0x79, 0xbf, 0xdf, 0x3a, 0xac,
309 0x1082003d, 0x00000000, 0x0a0006fb, 0x00000000, 0x2402000b, 0x10820044, 309 0x3b, 0x36, 0x73, 0x25, 0xbf, 0xee, 0xc2, 0xed, 0x41, 0x9c, 0xad, 0x50,
310 0x2882000b, 0x1440004b, 0x2402000e, 0x10820045, 0x00000000, 0x0a0006fb, 310 0x93, 0x55, 0xc0, 0xfe, 0xde, 0xf0, 0x37, 0x5b, 0xae, 0x2e, 0x06, 0x68,
311 0x00000000, 0x24020020, 0x10820062, 0x28820021, 0x1040000e, 0x2402001c, 311 0xfd, 0xcc, 0x2d, 0x42, 0x1f, 0x8d, 0xc9, 0xaa, 0x3e, 0x8e, 0x82, 0x37,
312 0x1082004c, 0x2882001d, 0x10400005, 0x2402001b, 0x10820043, 0x00000000, 312 0x19, 0xa7, 0x06, 0x60, 0xae, 0xa7, 0xeb, 0xd7, 0x0b, 0xc6, 0xed, 0x37,
313 0x0a0006fb, 0x00000000, 0x2402001f, 0x10820050, 0x00000000, 0x0a0006fb, 313 0xfd, 0xaa, 0xe5, 0xca, 0xc0, 0xf5, 0xf2, 0x91, 0x4f, 0xd5, 0xd1, 0xba,
314 0x00000000, 0x240200c1, 0x10820042, 0x288200c2, 0x10400005, 0x24020080, 314 0x51, 0x4d, 0xf8, 0x2c, 0xe8, 0x1a, 0x47, 0xde, 0x1d, 0x79, 0x81, 0x10,
315 0x10820021, 0x00000000, 0x0a0006fb, 0x00000000, 0x240200c2, 0x1082003d, 315 0x3b, 0x39, 0x79, 0x78, 0x1a, 0xb9, 0x77, 0xe4, 0x02, 0xe7, 0xe3, 0x6e,
316 0x240200c9, 0x50820049, 0xafa00010, 0x0a0006fb, 0x00000000, 0x0e001163, 316 0x7e, 0xfe, 0x6a, 0x29, 0x72, 0x36, 0x8f, 0x9c, 0x79, 0x1e, 0x39, 0xf9,
317 0xac400808, 0x0a0006fd, 0x8fbf0018, 0x3c026000, 0x8c444448, 0x3c030800, 317 0xcb, 0xc8, 0xc9, 0xcf, 0x97, 0x7a, 0x41, 0xff, 0x1e, 0x99, 0x8f, 0xb3,
318 0xac640064, 0x0e001163, 0x00000000, 0x3c026000, 0x8c444448, 0x3c030800, 318 0x8e, 0x99, 0x74, 0x11, 0xb9, 0xd3, 0x77, 0x67, 0xd8, 0x46, 0x74, 0xd1,
319 0x0a0006fc, 0xac640068, 0x8f440100, 0x0e0006ff, 0x00000000, 0x3c026000, 319 0x3d, 0xc8, 0x35, 0xbe, 0x3f, 0xa9, 0x68, 0x9d, 0x7d, 0x01, 0x5f, 0xc2,
320 0x8c444448, 0x3c030800, 0x0a0006fc, 0xac64006c, 0x0e001191, 0x00000000, 320 0xb8, 0x91, 0x38, 0x71, 0x29, 0x4f, 0x1a, 0xc7, 0x8a, 0x23, 0x4d, 0x7e,
321 0x0a0006fd, 0x8fbf0018, 0x8f440100, 0x0e0011bb, 0x00000000, 0x0a0006fd, 321 0x6b, 0xae, 0x95, 0x5a, 0xf6, 0x2c, 0xcb, 0x93, 0x6a, 0xac, 0xe8, 0xc2,
322 0x8fbf0018, 0x0e001202, 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0000000d, 322 0x19, 0xd4, 0xd9, 0xf7, 0x87, 0x9c, 0xdb, 0xc4, 0x48, 0xe4, 0xd3, 0xeb,
323 0x0a0006fd, 0x8fbf0018, 0x0e000826, 0x00000000, 0x0a0006fd, 0x8fbf0018, 323 0xe8, 0xed, 0x93, 0x65, 0xda, 0x19, 0xbb, 0x56, 0xbe, 0x68, 0xad, 0xa3,
324 0x8f440100, 0x0e001264, 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0e00134e, 324 0x6c, 0xef, 0x43, 0x32, 0x97, 0x5c, 0x78, 0x28, 0x69, 0xe5, 0x43, 0x3e,
325 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0e00087c, 0x27440100, 0x0a0006fd, 325 0xf7, 0x7c, 0x62, 0x42, 0x47, 0x84, 0xc8, 0xbf, 0x20, 0xcd, 0x0d, 0x20,
326 0x8fbf0018, 0x8f640040, 0x0e000fae, 0x00000000, 0x0a0006fd, 0x8fbf0018, 326 0x71, 0x6e, 0xd9, 0xfe, 0x02, 0x1f, 0x10, 0xb1, 0x6d, 0x9c, 0x33, 0x03,
327 0x8f440100, 0x0e001059, 0x00000000, 0x0a0006fd, 0x8fbf0018, 0x0e001417, 327 0xa2, 0xd6, 0xb6, 0xd1, 0xe2, 0x7e, 0x03, 0xfc, 0xbe, 0x8f, 0xe6, 0x90,
328 0x00000000, 0x0a0006fd, 0x8fbf0018, 0xafa00014, 0x8f440100, 0x8f450118, 328 0x43, 0x14, 0x44, 0x1e, 0xde, 0x0e, 0x78, 0x37, 0x0f, 0xbf, 0x1f, 0xb9,
329 0x8f46011c, 0x0e001439, 0x8f470120, 0x0a0006fd, 0x8fbf0018, 0x0000000d, 329 0x01, 0xd3, 0xd8, 0x04, 0xfc, 0x6f, 0x03, 0xc6, 0x6b, 0x43, 0x9f, 0x6b,
330 0x8fbf0018, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0010, 0x9742010c, 330 0x22, 0xf1, 0x3d, 0x8f, 0xb7, 0x13, 0xd7, 0x65, 0xab, 0xf3, 0xf2, 0x9c,
331 0x1440005e, 0x00803821, 0x3c029000, 0x34420001, 0x00e21025, 0xaf420020, 331 0x3c, 0xf6, 0x61, 0xf9, 0xf6, 0xbe, 0x3e, 0xcf, 0xdc, 0x6d, 0x9e, 0xb9,
332 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620023, 332 0xef, 0xf0, 0xcc, 0xed, 0xc3, 0xb7, 0x2e, 0x3e, 0x41, 0x7c, 0xeb, 0xae,
333 0x30420010, 0x14400026, 0x3c030800, 0x8f630074, 0x3c027fff, 0x3442ffff, 333 0xf1, 0xb7, 0x9e, 0x35, 0x5c, 0xdc, 0xdb, 0x3d, 0xb8, 0xbf, 0x8f, 0xf9,
334 0x00621824, 0xaf630074, 0x93620005, 0x34420001, 0xa3620005, 0x8f63004c, 334 0xb9, 0xcf, 0xf4, 0xf4, 0xf1, 0x9a, 0x1b, 0x68, 0x6e, 0xb0, 0x8d, 0x16,
335 0x8f620054, 0x10620021, 0x24040001, 0x9762006a, 0x00022880, 0x50a00001, 335 0x4f, 0x72, 0x5f, 0xd0, 0x83, 0x0b, 0xe3, 0x17, 0x90, 0x63, 0x6d, 0x74,
336 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 336 0xf1, 0x64, 0x8b, 0xc0, 0x9b, 0xfd, 0xf9, 0xc6, 0xca, 0x9a, 0x57, 0xb0,
337 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 337 0xa6, 0x3b, 0x97, 0x89, 0x6f, 0x19, 0x96, 0xf1, 0xe3, 0x31, 0xee, 0xe3,
338 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 338 0xb1, 0x37, 0xcb, 0x5f, 0x33, 0x82, 0xce, 0x9e, 0x0d, 0xc6, 0xcd, 0xfd,
339 0x00a21021, 0xaf62000c, 0x0a00073d, 0x24040001, 0x8c6200a8, 0x00002021, 339 0x56, 0x6b, 0x26, 0x8b, 0xdb, 0x9d, 0x34, 0x1b, 0xd4, 0xc0, 0x37, 0x55,
340 0x24420001, 0xac6200a8, 0x0000000d, 0x00000000, 0x2400044d, 0x3c028000, 340 0xfa, 0x28, 0xae, 0x23, 0xa8, 0x4a, 0xb4, 0x8f, 0xf9, 0xbc, 0x4e, 0xd6,
341 0x34420001, 0x00e21025, 0xaf420020, 0x1080001f, 0x3c029000, 0x34420001, 341 0xaf, 0x5b, 0x30, 0x6f, 0xd8, 0xcd, 0xd1, 0x88, 0xe5, 0x38, 0x27, 0xec,
342 0x00e21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 342 0xbe, 0x26, 0xc7, 0xd9, 0xee, 0xb3, 0xdf, 0xc7, 0x53, 0xc8, 0xaa, 0x3c,
343 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001, 343 0xaf, 0x29, 0xed, 0xa0, 0x83, 0x50, 0xcf, 0x8b, 0xb2, 0x9e, 0xb2, 0xe8,
344 0x00e31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00e02021, 0x0e000470, 344 0xad, 0x99, 0x18, 0x4e, 0x1c, 0xe3, 0x9c, 0xed, 0xac, 0x85, 0xfe, 0xe0,
345 0x24050455, 0x0a000761, 0x00000000, 0x8f4201f8, 0x00431024, 0x1440fffd, 345 0xbd, 0x98, 0x00, 0x1e, 0x61, 0x8a, 0xe2, 0xaf, 0x50, 0xca, 0xe3, 0x69,
346 0x24020002, 0x3c031000, 0xaf4701c0, 0xa34201c4, 0xaf4301f8, 0x0e001163, 346 0xe1, 0xa9, 0xe0, 0xc9, 0xf5, 0x0c, 0x1d, 0x4f, 0xe8, 0x18, 0xec, 0x53,
347 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffd8, 0xafbf0024, 347 0xb4, 0xef, 0x92, 0x93, 0x3f, 0x41, 0x37, 0xde, 0x9e, 0x74, 0xea, 0x51,
348 0xafb40020, 0xafb3001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x93630005, 348 0x8b, 0xd6, 0x72, 0xf5, 0xa8, 0x3f, 0x67, 0x9e, 0x9c, 0x70, 0xeb, 0x51,
349 0x00809821, 0x24020030, 0x30630030, 0x146200ac, 0x00a0a021, 0x3c020800, 349 0x8b, 0x24, 0xea, 0x51, 0x27, 0x56, 0xa8, 0x47, 0x25, 0x56, 0x5f, 0x8f,
350 0x8c430020, 0x106000a6, 0x00000000, 0x0e00148e, 0x00000000, 0x8f830018, 350 0xe2, 0xf9, 0x35, 0xda, 0xd7, 0x4f, 0xca, 0x17, 0x64, 0x3d, 0xea, 0x3d,
351 0xac730000, 0x936200c4, 0x30420002, 0x10400004, 0x24020001, 0x8f830018, 351 0x72, 0xea, 0x51, 0x17, 0xa9, 0x71, 0x3d, 0xea, 0x78, 0x5d, 0x3d, 0x2a,
352 0x0a000784, 0x00000000, 0x8f830018, 0x24020003, 0xac620004, 0x8f6200dc, 352 0x28, 0xea, 0x51, 0x3c, 0x8f, 0x53, 0x8f, 0x12, 0xed, 0xbe, 0x88, 0xa7,
353 0x8f630040, 0x00431023, 0x18400004, 0x00000000, 0x0000000d, 0x00000000, 353 0xee, 0x42, 0xf4, 0xee, 0x64, 0x07, 0x68, 0x66, 0xd0, 0xf7, 0x1a, 0xda,
354 0x24000509, 0x8f840018, 0x8f6200dc, 0xac820008, 0x8f830018, 0xac60000c, 354 0x34, 0x45, 0xc8, 0xdb, 0x4a, 0x35, 0xd0, 0x07, 0x6e, 0xb8, 0xbe, 0xa2,
355 0x8f820018, 0xac400010, 0x8f830018, 0x8f62004c, 0x3c100800, 0xac620014, 355 0xd0, 0x06, 0xcc, 0x9b, 0xec, 0x7b, 0xd8, 0x53, 0x63, 0x61, 0x9a, 0xff,
356 0x8f850018, 0x3c026000, 0x8c434448, 0x261258c0, 0x00002021, 0xaca30018, 356 0x62, 0xea, 0x2c, 0x07, 0x45, 0x9d, 0xe5, 0x87, 0x6b, 0xbc, 0x75, 0x96,
357 0x9642000e, 0x8f850018, 0x3c034010, 0x00431025, 0x0e0014cc, 0xaca2001c, 357 0x45, 0xba, 0x7e, 0x9d, 0xe5, 0x60, 0x83, 0x3a, 0xcb, 0x5b, 0x54, 0xad,
358 0x8f830018, 0xac730000, 0x9362003e, 0x9363003f, 0x8f840018, 0x00021200, 358 0xb3, 0xbc, 0x45, 0xd5, 0x3a, 0xcb, 0xc1, 0x12, 0xe7, 0xe2, 0x3e, 0x89,
359 0x00621825, 0xac830004, 0x93620081, 0x93630082, 0x8f840018, 0x00021600, 359 0x5f, 0x06, 0xed, 0x41, 0xf1, 0xc7, 0xb5, 0x97, 0xc5, 0xca, 0x1e, 0x7e,
360 0x00031c00, 0x00431025, 0xac820008, 0x8f830018, 0x8f620040, 0xac62000c, 360 0xd9, 0x6a, 0x2f, 0x6c, 0x03, 0x22, 0x17, 0x2e, 0xd7, 0xd4, 0x5e, 0xb8,
361 0x8f840018, 0x8f620048, 0xac820010, 0x8f71004c, 0x8f820018, 0xac510014, 361 0x0d, 0x9d, 0xb1, 0xd7, 0x08, 0x19, 0x99, 0x83, 0x7f, 0x5f, 0x9c, 0x0c,
362 0x8f620050, 0x8f850018, 0x00401821, 0x02221023, 0x5c400001, 0x02201821, 362 0x61, 0xce, 0x0e, 0xf8, 0x8c, 0x0e, 0xe4, 0x06, 0x61, 0xb4, 0x15, 0xda,
363 0x00002021, 0xaca30018, 0x9642000e, 0x8f850018, 0x3c03c00b, 0x00431025, 363 0x64, 0x0d, 0xa1, 0x8f, 0xc7, 0xd9, 0x0e, 0x43, 0xb7, 0x6c, 0x77, 0x7f,
364 0x0e0014cc, 0xaca2001c, 0x8f620054, 0x8f840018, 0x00401821, 0x02221023, 364 0x0f, 0x48, 0x1a, 0x44, 0x68, 0xb8, 0x9d, 0xf4, 0x20, 0xfb, 0x8e, 0xc9,
365 0x5c400001, 0x02201821, 0xac830000, 0x8f840018, 0x8f630058, 0xac830004, 365 0x3d, 0x74, 0xc8, 0xde, 0x22, 0xf6, 0xbd, 0xc1, 0xaa, 0x95, 0xb9, 0xc1,
366 0x93620023, 0x30420010, 0x10400004, 0x00000000, 0x8f830018, 0x0a0007dd, 366 0x1b, 0x90, 0xb9, 0xcc, 0xaa, 0x65, 0x8e, 0xe5, 0xcd, 0x39, 0xf7, 0xdd,
367 0x8f620148, 0x8f830018, 0x8f62005c, 0xac620008, 0x8f830018, 0x8f620060, 367 0x60, 0xf1, 0xfa, 0x1d, 0x02, 0xa7, 0x77, 0x1b, 0xc8, 0xfb, 0x18, 0xec,
368 0xac62000c, 0x8f840018, 0x8f620064, 0xac820010, 0x97630068, 0x9762006a, 368 0x8e, 0x33, 0xbf, 0x2e, 0xd7, 0xab, 0x8f, 0x87, 0x9f, 0x6d, 0x66, 0xff,
369 0x8f840018, 0x00031c00, 0x00431025, 0xac820014, 0x8f850018, 0x00002021, 369 0xbd, 0x72, 0x3d, 0xb1, 0xde, 0x7f, 0xaf, 0xe4, 0x47, 0x15, 0x61, 0x93,
370 0x2402ffff, 0x260358c0, 0xaca20018, 0x9462000e, 0x8f850018, 0x3c03c00c, 370 0xb3, 0x25, 0xae, 0xed, 0x7b, 0xf9, 0x33, 0x8f, 0x9c, 0x00, 0x7d, 0x42,
371 0x00431025, 0x0e0014cc, 0xaca2001c, 0x8f840018, 0x8f630018, 0xac830000, 371 0x0f, 0x98, 0xae, 0x41, 0xf0, 0x01, 0xeb, 0xd8, 0x4f, 0xc9, 0x5a, 0x16,
372 0x936200c4, 0x30420002, 0x10400006, 0x00000000, 0x976200c8, 0x8f830018, 372 0x9e, 0x05, 0x97, 0x7f, 0xad, 0xb0, 0x99, 0xee, 0x18, 0xdb, 0x01, 0x0b,
373 0x3042ffff, 0x0a000803, 0xac620004, 0x8f820018, 0xac400004, 0x8f830018, 373 0xfe, 0x8f, 0xeb, 0x28, 0x7c, 0x8e, 0xca, 0xfd, 0x2e, 0x5f, 0xbb, 0x2e,
374 0x8f62006c, 0xac620008, 0x8f840018, 0x8f6200dc, 0xac82000c, 0x8f830018, 374 0xbc, 0xa7, 0x72, 0xbb, 0x5c, 0xce, 0x8a, 0x7a, 0x2d, 0xa9, 0x9d, 0x7d,
375 0xac600010, 0x93620005, 0x8f830018, 0x00021600, 0x00541025, 0xac620014, 375 0xd3, 0x2d, 0x6c, 0x6b, 0xb6, 0x58, 0xae, 0xcc, 0x26, 0xf0, 0xce, 0x7c,
376 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x260258c0, 0xaca30018, 376 0x7d, 0x17, 0x36, 0x9c, 0xcf, 0xaa, 0xbf, 0x23, 0x6a, 0x04, 0x73, 0x36,
377 0x9443000e, 0x8f850018, 0x3c02400d, 0x00621825, 0x0e0014cc, 0xaca3001c, 377 0xdb, 0x6b, 0x8e, 0x41, 0x7f, 0x0b, 0xb2, 0xc4, 0xef, 0x51, 0x71, 0x2e,
378 0x0e00122e, 0x02602021, 0x8fbf0024, 0x8fb40020, 0x8fb3001c, 0x8fb20018, 378 0x21, 0x6a, 0xf8, 0x83, 0xdc, 0x76, 0xed, 0x4a, 0x94, 0xed, 0x30, 0xf6,
379 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0028, 0x27bdffe0, 0xafb00010, 379 0x5c, 0xa5, 0x31, 0xe2, 0x23, 0xc8, 0x0c, 0xc7, 0xb1, 0x0c, 0xe7, 0xc6,
380 0x27500100, 0xafbf0018, 0xafb10014, 0x9603000c, 0x240200c1, 0x54620024, 380 0x9e, 0x9a, 0xa7, 0x66, 0xab, 0xcb, 0xb8, 0x88, 0x75, 0x39, 0x00, 0x9a,
381 0x8e040000, 0x3c029000, 0x8f450100, 0x34420001, 0x3c038000, 0x00a21025, 381 0xed, 0x10, 0x31, 0xea, 0xb8, 0x5d, 0xa6, 0xea, 0x19, 0x3f, 0xd3, 0xdc,
382 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 382 0x39, 0xe7, 0x3f, 0x66, 0x2f, 0x47, 0xfb, 0xcd, 0x37, 0x48, 0x7b, 0x47,
383 0x3c038000, 0x34420004, 0xa362007d, 0x8f640074, 0x34630001, 0x00a31825, 383 0x1f, 0x6b, 0xe9, 0xae, 0x23, 0x7e, 0x71, 0xe9, 0xee, 0xfa, 0xa8, 0x49,
384 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021, 0x0e000470, 0x240505b2, 384 0x49, 0x83, 0xa8, 0xac, 0x2b, 0x7e, 0x5a, 0x9e, 0x29, 0xfd, 0x5f, 0xd8,
385 0x0a000878, 0x8fbf0018, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 385 0xaf, 0xe2, 0xd9, 0xaf, 0xab, 0xbb, 0xfb, 0xe4, 0x7e, 0xc3, 0x75, 0xba,
386 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8, 0x0a000878, 0x8fbf0018, 386 0x1b, 0x97, 0x75, 0xb9, 0x5f, 0x84, 0xee, 0xba, 0x7b, 0xe2, 0xb5, 0xb7,
387 0x8f65004c, 0x24060001, 0x0e0012a3, 0x240705be, 0x3c020800, 0x8c430020, 387 0x5c, 0x67, 0xdd, 0x67, 0x48, 0x8d, 0xaf, 0x14, 0x7b, 0xff, 0xb4, 0xf9,
388 0x9611000c, 0x1060001d, 0x8e100000, 0x0e00148e, 0x00000000, 0x8f820018, 388 0xe3, 0xc5, 0xde, 0x1f, 0x87, 0x9e, 0x5e, 0xbd, 0x65, 0x1a, 0xb6, 0x89,
389 0xac500000, 0x8f840018, 0x00111400, 0xac820004, 0x8f830018, 0xac600008, 389 0xb8, 0xc2, 0xd1, 0x1f, 0xd8, 0xe3, 0x82, 0x9f, 0x16, 0x1e, 0xd2, 0xe9,
390 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f840018, 0x240205c1, 390 0x9f, 0xee, 0xe4, 0xfa, 0xac, 0x26, 0x73, 0x7c, 0x6e, 0x7f, 0xb1, 0x95,
391 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 391 0x63, 0xab, 0x4d, 0xd6, 0x77, 0x44, 0x6e, 0x95, 0x57, 0x4d, 0x8f, 0x1f,
392 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024019, 0x00621825, 0x0e0014cc, 392 0x31, 0x30, 0xce, 0x63, 0x61, 0xba, 0x1c, 0xbc, 0x91, 0xb8, 0xbc, 0xcb,
393 0xaca3001c, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 393 0x58, 0xf4, 0xad, 0x26, 0x2e, 0xbf, 0x55, 0xf7, 0x5b, 0x7f, 0xdd, 0x7a,
394 0x27bdffb0, 0xafb5003c, 0x0000a821, 0xafbe0048, 0x0000f021, 0xafb70044, 394 0xbd, 0x3a, 0x47, 0x35, 0x2e, 0xe7, 0x7c, 0x3e, 0xe8, 0xd4, 0x18, 0x4c,
395 0x0000b821, 0xafb30034, 0x00009821, 0xafb60040, 0x0080b021, 0xafbf004c, 395 0x8e, 0xcf, 0xd7, 0x4a, 0x9e, 0xf0, 0x3b, 0x72, 0x11, 0x1b, 0x79, 0x08,
396 0xafb40038, 0xafb20030, 0xafb1002c, 0xafb00028, 0xafa00010, 0x8f620040, 396 0x64, 0xfc, 0x55, 0xc8, 0xca, 0x2b, 0x36, 0xf2, 0x0e, 0x1b, 0xf9, 0x88,
397 0x8ec30014, 0x96d1000c, 0x00431023, 0x04410025, 0x8ed40000, 0x32220401, 397 0x8d, 0xdc, 0xc3, 0x46, 0xee, 0x61, 0xf7, 0xc8, 0x1c, 0x26, 0x23, 0xeb,
398 0x1040030c, 0x3c029000, 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 398 0x56, 0x7c, 0x46, 0xcb, 0xf9, 0x61, 0x5e, 0xc9, 0xd8, 0xe3, 0x7c, 0x1f,
399 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 399 0x41, 0x4d, 0xc6, 0x36, 0xca, 0x78, 0xf0, 0x38, 0xdf, 0x77, 0x28, 0xab,
400 0x34420004, 0xa362007d, 0x8f640074, 0x34630001, 0x02831825, 0xaf430020, 400 0x71, 0xae, 0x45, 0x91, 0xaa, 0xc6, 0x6f, 0x87, 0x8f, 0xda, 0x0e, 0xbc,
401 0x04810006, 0x3c038000, 0x02802021, 0x0e000470, 0x24050664, 0x0a000ba2, 401 0x9a, 0x79, 0xdc, 0xa7, 0xc6, 0x5b, 0x99, 0x76, 0x8a, 0x1a, 0x5f, 0x2b,
402 0x8fbf004c, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 402 0xcf, 0x0d, 0x7a, 0x03, 0x0e, 0xfe, 0xdd, 0xdc, 0xd6, 0xd4, 0xf8, 0xdd,
403 0xaf5401c0, 0xa34201c4, 0xaf4301f8, 0x0a000ba2, 0x8fbf004c, 0x32220010, 403 0xec, 0xd3, 0xc2, 0xa4, 0xba, 0xfd, 0xb7, 0x07, 0x98, 0xae, 0xa4, 0xde,
404 0x1040006b, 0x00003021, 0x9362003f, 0x92c6000f, 0x304500ff, 0x24c3fff8, 404 0x16, 0xe0, 0xb8, 0x76, 0xde, 0xf6, 0x8b, 0x3b, 0x05, 0xc9, 0x18, 0xd7,
405 0x2c62000f, 0x10400057, 0x3c020800, 0x244257c0, 0x00031880, 0x00621821, 405 0xcc, 0xb8, 0x5d, 0xa5, 0xab, 0xba, 0x2c, 0x5d, 0xfd, 0x95, 0xfa, 0x3f,
406 0x8c640000, 0x00800008, 0x00000000, 0x38a20012, 0x0a000924, 0x0002a82b, 406 0xd3, 0xd2, 0xc7, 0x70, 0xa2, 0x36, 0xc6, 0x34, 0x75, 0xe7, 0xe3, 0xf3,
407 0x2402000e, 0x14a20004, 0x2402000c, 0x24150001, 0x0a000924, 0x24060010, 407 0x66, 0x5e, 0x47, 0xdc, 0x63, 0xc0, 0xf3, 0x60, 0x33, 0xb5, 0x0d, 0x0e,
408 0x10a20049, 0x38a30010, 0x2c630001, 0x38a20016, 0x2c420001, 0x00621825, 408 0xf9, 0x2d, 0xef, 0xba, 0x6c, 0x43, 0x76, 0x90, 0x37, 0xc7, 0x5a, 0x7e,
409 0x1460004d, 0x0000a821, 0x24020014, 0x10a2004a, 0x00000000, 0x0000000d, 409 0xcd, 0xa8, 0x38, 0x1b, 0x49, 0xf6, 0x47, 0x85, 0xec, 0xb0, 0xac, 0x69,
410 0x00000000, 0x2400069c, 0x0a000924, 0x0000a821, 0x24020016, 0x14a20005, 410 0xe2, 0xce, 0xd5, 0x47, 0xe2, 0x1e, 0x09, 0xcb, 0x19, 0xcb, 0xf2, 0x78,
411 0x2402000c, 0x24150001, 0x24060010, 0x0a000924, 0x3231fffd, 0x10a20032, 411 0x7f, 0x57, 0x58, 0x53, 0x5b, 0xb0, 0x46, 0x98, 0xd2, 0x25, 0x71, 0x56,
412 0x38a30010, 0x2c630001, 0x38a2000e, 0x2c420001, 0x00621825, 0x14600036, 412 0x80, 0x7c, 0xe9, 0xdc, 0x3a, 0x6a, 0xfb, 0x07, 0xbd, 0x9a, 0xc7, 0x46,
413 0x0000a821, 0x24020014, 0x14a20003, 0x24150001, 0x0a000924, 0x24060012, 413 0x9d, 0xb3, 0x7a, 0xbb, 0xde, 0xff, 0x8d, 0x8a, 0x73, 0x65, 0xc7, 0x06,
414 0x0000000d, 0x00000000, 0x240006bc, 0x0a000924, 0x0000a821, 0x2402000e, 414 0xb9, 0xe7, 0xc3, 0xab, 0x3b, 0xff, 0xbe, 0xbe, 0x3e, 0xb5, 0xd4, 0xd7,
415 0x14a20004, 0x24020016, 0x24150001, 0x0a000924, 0x3231fffb, 0x14a20004, 415 0x0d, 0x24, 0x0d, 0x98, 0x36, 0x8d, 0xcf, 0xee, 0xe7, 0x4b, 0x7c, 0xaf,
416 0x24020014, 0x24150001, 0x0a000924, 0x3231fffd, 0x54a20013, 0x92c2000e, 416 0x25, 0x12, 0xe3, 0xdc, 0x6d, 0x44, 0xdc, 0xf9, 0x50, 0x21, 0x85, 0x3a,
417 0x24150001, 0x24060012, 0x0a000924, 0x3231fffd, 0x2402000c, 0x54a2000c, 417 0x8d, 0x19, 0x9c, 0xf3, 0x85, 0x86, 0x7d, 0x71, 0xca, 0x64, 0x27, 0x48,
418 0x92c2000e, 0x92c3000e, 0x2402000a, 0x10620005, 0x24150001, 0x0000000d, 418 0x43, 0xac, 0x98, 0xa9, 0xd6, 0x03, 0x1f, 0x5c, 0x43, 0x96, 0x2b, 0x97,
419 0x00000000, 0x240006e8, 0x24150001, 0x0a000924, 0x24060014, 0x92c2000e, 419 0x51, 0xce, 0x1f, 0x6a, 0xce, 0xed, 0x16, 0xe9, 0xb0, 0x72, 0xa0, 0x74,
420 0x14a20003, 0x00000000, 0x0a000924, 0x24150001, 0x10a6ffc1, 0x24020012, 420 0x84, 0x0e, 0x34, 0x8c, 0x29, 0x1b, 0xd7, 0x03, 0x2f, 0xd6, 0xd5, 0x14,
421 0x10a20005, 0x0000a821, 0x0000000d, 0x00000000, 0x24000704, 0x0000a821, 421 0x16, 0x44, 0x4d, 0x21, 0xb7, 0xc6, 0x6f, 0x3d, 0x19, 0x70, 0xee, 0xb5,
422 0x12a00022, 0x32220004, 0x10400002, 0x24020001, 0xafa20010, 0x32230102, 422 0x34, 0xd6, 0x93, 0x5d, 0x15, 0x3d, 0x71, 0xe1, 0xf8, 0x2c, 0xbe, 0x8d,
423 0x24020002, 0x1462000f, 0x00000000, 0x92c2000a, 0x30420020, 0x1440000b, 423 0x76, 0x8a, 0xb5, 0x0e, 0x2b, 0x59, 0xbb, 0x95, 0x76, 0x1a, 0x0e, 0xd6,
424 0x00000000, 0x8f630048, 0x8f620040, 0x14620004, 0x00000000, 0x8f620048, 424 0xa3, 0x36, 0xe3, 0x75, 0x58, 0x39, 0x68, 0xe7, 0x95, 0xb4, 0xa8, 0x3d,
425 0x24420001, 0xaf620048, 0x8f620040, 0x24420001, 0xaf620040, 0xa366003f, 425 0x70, 0x8c, 0xbf, 0xe6, 0xda, 0x30, 0x95, 0xe9, 0xed, 0x98, 0xfb, 0x3d,
426 0x38c30012, 0x2c630001, 0x38c20010, 0x2c420001, 0x00621825, 0x10600005, 426 0xc3, 0x78, 0x6b, 0x8a, 0x2e, 0x9d, 0xf8, 0x2e, 0x51, 0x58, 0xe6, 0x6f,
427 0x3c030800, 0x8c620074, 0x24420001, 0x0e00140d, 0xac620074, 0x32220040, 427 0xce, 0x7c, 0xb9, 0x29, 0xae, 0x25, 0xde, 0x8f, 0xfd, 0x33, 0xfc, 0x6e,
428 0x32230020, 0xafa30020, 0x32230080, 0xafa30024, 0x32230001, 0xafa30018, 428 0x25, 0x39, 0x55, 0x2e, 0xa7, 0x31, 0x3e, 0xd6, 0x7b, 0xaf, 0xc8, 0x8d,
429 0x32230008, 0xafa3001c, 0x32230100, 0x104000c4, 0xafa30014, 0x8ec60010, 429 0xd4, 0x38, 0x0d, 0x71, 0x8e, 0xac, 0x2d, 0xc9, 0x91, 0xd3, 0xd0, 0x35,
430 0x8f630054, 0x24c2ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d, 430 0xc4, 0x20, 0x76, 0x13, 0xbe, 0x75, 0xe3, 0x91, 0xcf, 0xae, 0x75, 0x64,
431 0x00000000, 0x2400015c, 0x0a000989, 0x00009021, 0x8f62004c, 0x00c21023, 431 0xe4, 0xbb, 0x12, 0x0f, 0x1e, 0xff, 0xfb, 0x80, 0x7b, 0x0f, 0x28, 0x77,
432 0x18400028, 0x00009021, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c, 432 0x2a, 0x8d, 0xfd, 0x37, 0x51, 0xca, 0x74, 0xf2, 0xbb, 0xec, 0x99, 0x23,
433 0x308400ff, 0x24420001, 0x30a500ff, 0x00804021, 0x1485000b, 0xac62008c, 433 0x1b, 0x6a, 0xe1, 0xd1, 0x77, 0xca, 0x85, 0x0f, 0xd6, 0xc1, 0xf3, 0x19,
434 0x3c040800, 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001, 434 0xd7, 0x5f, 0xd5, 0xc1, 0x07, 0x3d, 0xf0, 0x66, 0x1d, 0x3c, 0xe2, 0xae,
435 0x00021023, 0x30420005, 0x0a000989, 0x34520004, 0x27670100, 0x00041080, 435 0x33, 0xdf, 0xa8, 0x83, 0x37, 0x3d, 0xf0, 0xed, 0x75, 0xf0, 0xed, 0x80,
436 0x00e21021, 0x8c430000, 0x00c31823, 0x04600004, 0x24820001, 0x30440007, 436 0x7f, 0xa3, 0x0e, 0x1e, 0x7d, 0xa7, 0x90, 0x13, 0x08, 0xda, 0x70, 0x8c,
437 0x1485fff9, 0x00041080, 0x10880007, 0x3c030800, 0xa3640121, 0x8c620094, 437 0x74, 0x48, 0xe6, 0x89, 0x78, 0x2e, 0xb9, 0x1f, 0xc9, 0xf2, 0xd3, 0x01,
438 0x24120005, 0x24420001, 0x0a000989, 0xac620094, 0x24120004, 0x32420001, 438 0x1a, 0x7b, 0xeb, 0xb5, 0x09, 0xd8, 0xa8, 0xaa, 0x4c, 0x39, 0xfa, 0xea,
439 0x10400021, 0x3c020800, 0x8c430020, 0x8ed00000, 0x1060001c, 0x8ed30010, 439 0x95, 0x25, 0x96, 0xbd, 0x3c, 0xe4, 0x15, 0x7a, 0x54, 0x80, 0x3e, 0x15,
440 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 440 0x5c, 0x5f, 0xca, 0x77, 0xaa, 0x22, 0xc7, 0x1d, 0x3d, 0x56, 0x68, 0xbd,
441 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 441 0x35, 0x2f, 0x73, 0x91, 0xab, 0x8c, 0x3b, 0xfc, 0x86, 0xeb, 0x3b, 0xe8,
442 0xac600010, 0x8f820018, 0xac530014, 0x8f850018, 0x3c026000, 0x8c434448, 442 0x84, 0x63, 0x57, 0x58, 0xbf, 0x79, 0x7e, 0x69, 0x5f, 0x4a, 0x2c, 0x87,
443 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010, 443 0xce, 0x3a, 0xe9, 0x25, 0x32, 0x1b, 0x5e, 0x52, 0x77, 0xf1, 0xd5, 0xd9,
444 0x00621825, 0x0e0014cc, 0xaca3001c, 0x24130001, 0x32420004, 0x10400068, 444 0x77, 0x12, 0xf6, 0x3d, 0xd7, 0xe2, 0xb7, 0x36, 0xac, 0xbd, 0x9e, 0x7d,
445 0x00003821, 0x3c029000, 0x8ec60010, 0x34420001, 0x3c038000, 0x02821025, 445 0xcf, 0x78, 0xec, 0x7b, 0x38, 0x58, 0xf5, 0xf9, 0x8f, 0x09, 0x9f, 0xdf,
446 0xa360007c, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 446 0xd1, 0xc0, 0x66, 0xac, 0xde, 0xe7, 0xef, 0xfd, 0xd8, 0x3e, 0x7f, 0xb9,
447 0x93620023, 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 0x8f63004c, 447 0x75, 0x57, 0xe3, 0xf3, 0x1f, 0x69, 0xf9, 0x78, 0x3e, 0x9f, 0xd7, 0xac,
448 0x9764003c, 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 0x54400006, 448 0xaf, 0x65, 0x7a, 0xcf, 0x59, 0x8e, 0xca, 0x18, 0x7b, 0xb7, 0x27, 0xc6,
449 0x3c023fff, 0x93620023, 0x3042007f, 0xa3620023, 0xaf660064, 0x3c023fff, 449 0x66, 0xfc, 0xbe, 0x27, 0xef, 0x02, 0x9e, 0x5e, 0xeb, 0xc8, 0xdb, 0x51,
450 0x0a0009da, 0x3442ffff, 0x8f62005c, 0x00c21023, 0x04400011, 0x00000000, 450 0x19, 0xa7, 0x73, 0xec, 0x8d, 0xf7, 0xc2, 0x23, 0x90, 0xd1, 0x7c, 0x8f,
451 0x8f65005c, 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 0xaf660064, 451 0x8f, 0x54, 0x9a, 0x35, 0x9d, 0xb3, 0xed, 0x9f, 0x6f, 0xae, 0x17, 0xa1,
452 0x00a32823, 0x00852821, 0x0045102b, 0x10400004, 0x00c51021, 0x3c053fff, 452 0xcb, 0xc2, 0x9f, 0x24, 0x3e, 0x81, 0x5a, 0xea, 0x49, 0xc8, 0x8f, 0xbb,
453 0x34a5ffff, 0x00c51021, 0xaf62005c, 0x24070001, 0xaf66004c, 0x8fa20010, 453 0xaf, 0x95, 0x6a, 0xa9, 0xf5, 0xe7, 0x1f, 0x7c, 0xee, 0x41, 0xca, 0x03,
454 0x10400003, 0x00000000, 0xaf660050, 0xaf660054, 0x8f620054, 0x14c20005, 454 0x95, 0x73, 0x10, 0xaf, 0x4e, 0xe9, 0x94, 0x9d, 0x21, 0xdd, 0x8c, 0x93,
455 0x00000000, 0x93620023, 0x30420040, 0x10400017, 0x24020001, 0x9762006a, 455 0xb2, 0x8f, 0x71, 0x8e, 0xfd, 0xb0, 0x52, 0x6f, 0x3f, 0x24, 0x6b, 0x30,
456 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081, 0x3c020800, 456 0xea, 0xb2, 0x77, 0x82, 0x7e, 0x02, 0x7c, 0x58, 0xaf, 0x9c, 0x1a, 0x8c,
457 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001, 0x00a03021, 457 0xea, 0xdc, 0x09, 0x3a, 0xfe, 0xf3, 0xbb, 0x13, 0xc4, 0xf3, 0x6b, 0xb4,
458 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021, 0x8f420074, 458 0xb7, 0xc1, 0x9d, 0x20, 0xdf, 0x2a, 0xef, 0x04, 0xad, 0x17, 0x35, 0x18,
459 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 0x93620082, 0x30420080, 459 0x9e, 0xc7, 0xa9, 0xc1, 0x70, 0xbb, 0xb3, 0x8f, 0xe5, 0x3a, 0x4c, 0xa3,
460 0x50400001, 0xa3600081, 0x3c028000, 0x34420001, 0x02821025, 0xaf420020, 460 0x93, 0xb7, 0x88, 0x7b, 0xa8, 0x9d, 0x7d, 0xb5, 0xf2, 0xbd, 0xef, 0x13,
461 0x9363007e, 0x9362007a, 0x10620005, 0x00e0b821, 0x0e0013c4, 0x00000000, 461 0x8d, 0xa5, 0x79, 0xbd, 0xa3, 0x0d, 0xef, 0xb6, 0x24, 0x3f, 0xc1, 0x9a,
462 0x00403821, 0x00e0b821, 0x8fa30020, 0x10600009, 0x8fa20010, 0x8ec20018, 462 0xcb, 0x21, 0x51, 0x73, 0xb9, 0xb3, 0xcd, 0x5b, 0x73, 0x51, 0x57, 0xb8,
463 0xaf620018, 0x8ec3001c, 0xaf63001c, 0x8ec20020, 0x24170001, 0xaf620058, 463 0xdb, 0x72, 0xa8, 0x41, 0xcd, 0xc5, 0xef, 0xb9, 0xdb, 0xe2, 0xf7, 0xdc,
464 0x8fa20010, 0x10400057, 0x8fa30024, 0x93620023, 0x30420040, 0x10400053, 464 0x6d, 0x39, 0x24, 0xeb, 0x2b, 0xea, 0x2f, 0xd1, 0xdd, 0x96, 0xe4, 0x8a,
465 0x00000000, 0x16600021, 0x3c120800, 0x8e420020, 0x8f70004c, 0x1040001e, 465 0x77, 0x5b, 0xb6, 0x4a, 0x7d, 0xf5, 0xc2, 0xaf, 0xfe, 0xbc, 0x32, 0x55,
466 0x24130001, 0x0e00148e, 0x00000000, 0x8f820018, 0xac540000, 0x8f840018, 466 0x67, 0xe7, 0x13, 0xc2, 0xce, 0xdf, 0xd5, 0xea, 0xb7, 0x9e, 0x69, 0xbb,
467 0x24020001, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 467 0x9e, 0x9d, 0xdf, 0x57, 0xd1, 0x53, 0xbe, 0xa3, 0xcd, 0x77, 0xbe, 0x58,
468 0x8f830018, 0xac600010, 0x8f820018, 0xac500014, 0x8f850018, 0x3c026000, 468 0x16, 0xf9, 0x7c, 0xa6, 0x89, 0x72, 0x03, 0xbf, 0x2a, 0x68, 0xf6, 0x58,
469 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 469 0x6f, 0xed, 0x99, 0x63, 0xf5, 0x5e, 0xa4, 0xee, 0xb9, 0x17, 0x69, 0xa2,
470 0x3c024010, 0x00621825, 0xaca3001c, 0x0e0014cc, 0x24130001, 0x8e420020, 470 0x5f, 0xaf, 0xab, 0x87, 0x04, 0xe4, 0xdd, 0x7e, 0xf8, 0xc2, 0x19, 0x43,
471 0x1040001c, 0x8ed00000, 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 471 0xda, 0x5e, 0xc4, 0x70, 0x98, 0xae, 0x50, 0xe4, 0x3b, 0x95, 0x6d, 0xe4,
472 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 472 0x9b, 0x71, 0xce, 0x4b, 0x54, 0x11, 0x63, 0x42, 0x8e, 0x8b, 0x7e, 0xe1,
473 0x8f820018, 0xac400010, 0x8f830018, 0x24020798, 0xac620014, 0x8f850018, 473 0x6f, 0xd4, 0xb8, 0x23, 0xb3, 0xe3, 0xf6, 0x05, 0xe0, 0xbf, 0x21, 0x51,
474 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 474 0x6d, 0x9b, 0x95, 0x5a, 0xce, 0x58, 0xe5, 0x0e, 0xbf, 0x09, 0xfb, 0xe0,
475 0x8f850018, 0x3c024019, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 475 0xdc, 0x07, 0xca, 0x98, 0x7c, 0x67, 0xe4, 0x62, 0x5b, 0xf5, 0x3e, 0xd0,
476 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 476 0x67, 0xa4, 0x9c, 0x3a, 0xf7, 0x81, 0x48, 0x4d, 0x40, 0x3e, 0x6e, 0xe4,
477 0x1440fffd, 0x24020001, 0xaf62000c, 0x93630023, 0x3c028000, 0x34420001, 477 0x3e, 0x50, 0xd7, 0x92, 0xfb, 0x40, 0x2b, 0xf3, 0x66, 0xe9, 0x7d, 0xa0,
478 0x02821025, 0x306300bf, 0xa3630023, 0xaf420020, 0x8fa30024, 0x10600012, 478 0xc6, 0xfc, 0xe1, 0xfb, 0x40, 0xff, 0xde, 0xe6, 0xdc, 0x43, 0x5d, 0x89,
479 0x8fa30018, 0x9362007c, 0x24420001, 0xa362007c, 0x9363007e, 0x9362007a, 479 0x3f, 0x6e, 0x9c, 0xf4, 0x11, 0xe0, 0xf9, 0x3e, 0x50, 0xe5, 0x1e, 0x90,
480 0x1462000b, 0x8fa30018, 0x9362007c, 0x3c030800, 0x8c640024, 0x0044102b, 480 0xe7, 0x0e, 0x10, 0xdf, 0x25, 0x59, 0xee, 0x0c, 0xce, 0x7b, 0xff, 0xa4,
481 0x14400005, 0x8fa30018, 0x0e0013c4, 0x00000000, 0x02e2b825, 0x8fa30018, 481 0xa7, 0x72, 0xff, 0xe4, 0x7c, 0xc9, 0xf5, 0xed, 0xee, 0xb9, 0x1c, 0xc7,
482 0x3062ffff, 0x10400003, 0x32220200, 0x0a000a94, 0x241e0004, 0x10400003, 482 0x39, 0xbb, 0x44, 0x8e, 0x7a, 0xae, 0x54, 0x5b, 0xc3, 0x60, 0xbe, 0x8f,
483 0x00000000, 0x241e0040, 0x24170001, 0x12a000d0, 0x32220002, 0x104000cf, 483 0x16, 0xcf, 0x81, 0x3e, 0x6f, 0x89, 0xdc, 0x00, 0x7c, 0xde, 0xe2, 0x23,
484 0x8fa2001c, 0x92c2000a, 0x30420002, 0x5040003b, 0x92c2000a, 0x93620023, 484 0xe6, 0x1d, 0x29, 0xa0, 0x8b, 0x38, 0xcb, 0x75, 0xf8, 0xdd, 0x21, 0x64,
485 0x30420008, 0x54400037, 0x92c2000a, 0x3c020800, 0x8c430020, 0x10600023, 485 0xc1, 0x91, 0x8b, 0xdd, 0x9e, 0xf3, 0xd0, 0xaa, 0x1c, 0x38, 0x67, 0xba,
486 0x3c029000, 0x0e00148e, 0x00000000, 0x8f840018, 0x8ec30000, 0xac830000, 486 0x0e, 0xef, 0x6a, 0x65, 0x46, 0x9c, 0xdd, 0x0c, 0xed, 0xb5, 0x9c, 0xf3,
487 0x92c2000a, 0x8f830018, 0x00021600, 0xac620004, 0x8f840018, 0x8f620040, 487 0xc6, 0xa8, 0x38, 0xb7, 0x6d, 0xaf, 0xb3, 0x5b, 0x3a, 0xe4, 0x06, 0x31,
488 0xac820008, 0x8f850018, 0x8f63004c, 0xaca3000c, 0x9362003f, 0x8f840018, 488 0x67, 0x8c, 0xeb, 0xd5, 0x8c, 0xfb, 0x66, 0xc1, 0xe3, 0x46, 0x67, 0x71,
489 0x304200ff, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f850018, 489 0x2b, 0xd7, 0xf1, 0xdc, 0x9a, 0x0a, 0x21, 0x97, 0xd8, 0x9d, 0xce, 0x09,
490 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 490 0xbb, 0xe9, 0xac, 0xdd, 0x29, 0xd6, 0xde, 0x58, 0x77, 0x96, 0xcd, 0x72,
491 0x3c02401a, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 0x34420001, 491 0xb5, 0x5c, 0x4c, 0x70, 0x3d, 0x9a, 0xde, 0xb3, 0x84, 0xa6, 0xb5, 0xba,
492 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 492 0x84, 0xdc, 0xb5, 0x62, 0xe3, 0x3b, 0x2a, 0xba, 0x34, 0x2e, 0xee, 0x21,
493 0x00000000, 0x93630023, 0x3c028000, 0x34420001, 0x02821025, 0x34630008, 493 0xbb, 0xe7, 0xb5, 0x0e, 0xfd, 0xaa, 0xba, 0xb7, 0x5c, 0x3c, 0x53, 0x4f,
494 0xa3630023, 0xaf420020, 0x92c2000a, 0x30420020, 0x1040008e, 0x8fa2001c, 494 0xbf, 0x4d, 0xff, 0x4b, 0xe8, 0x77, 0x15, 0xf4, 0xe3, 0x77, 0x03, 0xef,
495 0x93620023, 0x30420001, 0x14400035, 0x3c020800, 0x8c430020, 0x10600023, 495 0xef, 0x8a, 0x7a, 0xc0, 0xb9, 0x52, 0xe4, 0x78, 0x9e, 0x38, 0x4e, 0x88,
496 0x3c029000, 0x0e00148e, 0x00000000, 0x8f840018, 0x8ec30000, 0xac830000, 496 0xcc, 0x2e, 0x50, 0x0f, 0xe8, 0xc8, 0xff, 0xeb, 0xe2, 0xde, 0x9d, 0x60,
497 0x92c2000a, 0x8f830018, 0x00021600, 0xac620004, 0x8f840018, 0x8f620040, 497 0xfa, 0xb2, 0x7d, 0x8f, 0xbc, 0x70, 0x99, 0xd8, 0xc6, 0xdf, 0x8d, 0x7d,
498 0xac820008, 0x8f850018, 0x8f63004c, 0xaca3000c, 0x9362003f, 0x8f840018, 498 0x94, 0xcb, 0x2f, 0xc5, 0x5c, 0xfa, 0xb3, 0xee, 0x73, 0x9d, 0xaa, 0x76,
499 0x304200ff, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f850018, 499 0x5f, 0x7b, 0x57, 0xed, 0x53, 0x1d, 0xf9, 0xcc, 0x34, 0x90, 0xcf, 0x8c,
500 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 500 0xdc, 0xa3, 0x6f, 0xa6, 0x71, 0xbc, 0x9a, 0x9a, 0xfc, 0xef, 0x5e, 0xae,
501 0x3c02401a, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 0x34420001, 501 0x26, 0xb6, 0x8d, 0x22, 0x0a, 0xbf, 0xac, 0xd7, 0x4e, 0xe3, 0xa4, 0x61,
502 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 502 0x93, 0x3a, 0xad, 0x69, 0xd2, 0x60, 0xc7, 0x4b, 0x12, 0x29, 0xa5, 0xa4,
503 0x00000000, 0x93630023, 0x3c028000, 0x34420001, 0x02821025, 0x34630001, 503 0x52, 0x55, 0x45, 0x60, 0xa9, 0x21, 0x4e, 0xda, 0x0a, 0x71, 0x70, 0x0b,
504 0xa3630023, 0xaf420020, 0x93620023, 0x30420040, 0x10400052, 0x8fa2001c, 504 0x48, 0x51, 0xc5, 0x21, 0x4d, 0xd3, 0x7b, 0x85, 0x84, 0x54, 0xa1, 0x8a,
505 0x16600020, 0x3c120800, 0x8e420020, 0x8f70004c, 0x1040003c, 0x3c029000, 505 0x46, 0x4e, 0x02, 0x15, 0x4a, 0xe5, 0x0a, 0x96, 0x72, 0x41, 0xa2, 0xd8,
506 0x0e00148e, 0x00000000, 0x8f820018, 0xac540000, 0x8f840018, 0x24020001, 506 0x8e, 0x02, 0x52, 0x2a, 0xf7, 0xca, 0x85, 0xba, 0xbf, 0x08, 0x89, 0x03,
507 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 507 0x70, 0x06, 0x29, 0x2a, 0x3f, 0xe2, 0xc0, 0x8d, 0x1b, 0x54, 0x5d, 0xde,
508 0xac600010, 0x8f820018, 0xac500014, 0x8f850018, 0x3c026000, 0x8c434448, 508 0x37, 0xb3, 0x63, 0xaf, 0x77, 0xd7, 0x8e, 0x03, 0x11, 0x07, 0x27, 0xbb,
509 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010, 509 0xf6, 0xcc, 0xce, 0xec, 0xcc, 0x37, 0x6f, 0xbe, 0xf7, 0x37, 0xfd, 0xbe,
510 0x00621825, 0x0e0014cc, 0xaca3001c, 0x8e420020, 0x1040001e, 0x3c029000, 510 0x78, 0x8d, 0x5a, 0xdb, 0x5b, 0xf3, 0x55, 0xec, 0xe7, 0xaf, 0x37, 0x18,
511 0x0e00148e, 0x00000000, 0x8f820018, 0xac540000, 0x8f840018, 0x3c02008d, 511 0x57, 0xed, 0xba, 0xe4, 0xa9, 0xf5, 0xe3, 0x9a, 0x72, 0xd9, 0x1b, 0xf0,
512 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 512 0xfe, 0xc7, 0x68, 0x51, 0xd8, 0x86, 0x94, 0xad, 0xee, 0xc5, 0x40, 0x9b,
513 0xac600010, 0x8f840018, 0x240207ee, 0xac820014, 0x8f850018, 0x3c026000, 513 0xd9, 0xff, 0x33, 0x16, 0x03, 0x3e, 0x9b, 0x68, 0xad, 0x6d, 0x8a, 0xed,
514 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 514 0x71, 0xd9, 0x16, 0xde, 0xda, 0xc2, 0xb6, 0x10, 0x3c, 0x16, 0xfd, 0x9e,
515 0x3c024019, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x3c029000, 0x34420001, 515 0xb1, 0xa8, 0xc9, 0xea, 0xa1, 0x16, 0xed, 0x74, 0x88, 0x21, 0xbf, 0x9d,
516 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 516 0x67, 0x6c, 0x05, 0xca, 0xce, 0x4f, 0x5d, 0x36, 0x3c, 0xe0, 0x73, 0xdc,
517 0x00000000, 0x93630023, 0x3c028000, 0x34420001, 0x02821025, 0x306300bf, 517 0x59, 0xeb, 0xc0, 0x27, 0xb5, 0x9d, 0x1a, 0x51, 0xed, 0x01, 0x8f, 0xc9,
518 0xa3630023, 0xaf420020, 0x8fa2001c, 0x1040000e, 0x8fa20014, 0x92c2000a, 518 0xc5, 0x45, 0x82, 0xbe, 0x86, 0x36, 0xe3, 0x82, 0xe3, 0xfa, 0x39, 0x14,
519 0xa3620082, 0x57c00005, 0x37de0008, 0x8fa30014, 0x10600004, 0x00000000, 519 0x8f, 0xf1, 0xfa, 0x1b, 0x88, 0xe5, 0x70, 0xda, 0x3f, 0xd9, 0x76, 0xae,
520 0x37de0008, 0x0a000b75, 0x24170001, 0x0e0012cf, 0x02802021, 0x8fa20014, 520 0x9c, 0xe5, 0xbd, 0x42, 0xd4, 0x63, 0xbd, 0xef, 0x52, 0xdb, 0x82, 0xa8,
521 0x10400003, 0x00000000, 0x37de0010, 0x24170001, 0x12e00020, 0x3c029000, 521 0x27, 0xe3, 0x20, 0x1c, 0x1d, 0xd0, 0xe1, 0xe2, 0x8d, 0x74, 0x3f, 0xff,
522 0x34420001, 0x02821025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 522 0x9e, 0x13, 0xcc, 0xdd, 0x7f, 0xdd, 0x1d, 0x36, 0x3f, 0x34, 0x64, 0xae,
523 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x03c21025, 0xa362007d, 523 0xde, 0x56, 0xdc, 0x5d, 0xd9, 0x89, 0x06, 0x85, 0xaf, 0xc1, 0xad, 0x7b,
524 0x8f640074, 0x34630001, 0x02831825, 0xaf430020, 0x04810006, 0x3c038000, 524 0x41, 0x76, 0x5d, 0xe0, 0x3d, 0x7c, 0xa8, 0xba, 0x7f, 0xef, 0x84, 0x7d,
525 0x02802021, 0x0e000470, 0x2405082a, 0x0a000b9b, 0x00000000, 0x8f4201f8, 525 0xe8, 0x99, 0x16, 0x62, 0x1d, 0x44, 0x8e, 0xe5, 0x2b, 0x53, 0xc8, 0x45,
526 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5401c0, 0xa34201c4, 526 0xaa, 0xe6, 0xef, 0x78, 0xf3, 0x3c, 0x20, 0x3f, 0x55, 0x9e, 0x87, 0xca,
527 0xaf4301f8, 0x9363003f, 0x24020012, 0x14620004, 0x8fbf004c, 0x0e00140d, 527 0x23, 0xc5, 0x7b, 0x24, 0x02, 0xf2, 0x3c, 0xdc, 0x32, 0x18, 0xf5, 0xea,
528 0x00000000, 0x8fbf004c, 0x8fbe0048, 0x8fb70044, 0x8fb60040, 0x8fb5003c, 528 0xdf, 0xc3, 0x2d, 0x7f, 0x57, 0x1c, 0xf9, 0x5b, 0xf0, 0xd8, 0xe3, 0x97,
529 0x8fb40038, 0x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028, 0x03e00008, 529 0xf3, 0x6a, 0x2d, 0x20, 0xe7, 0x43, 0xf1, 0x94, 0xde, 0x00, 0x9e, 0x12,
530 0x27bd0050, 0x27bdffe8, 0xafbf0014, 0xafb00010, 0x8f500180, 0x97420184, 530 0x9c, 0xeb, 0xa1, 0xa5, 0x2f, 0xf2, 0x5e, 0x7e, 0x08, 0x7b, 0xb9, 0x51,
531 0x30420200, 0x14400015, 0x00000000, 0x8f430188, 0x3c02ff00, 0x00621824, 531 0x8b, 0xe9, 0x95, 0x72, 0xf0, 0xdc, 0x3a, 0x64, 0xa2, 0xca, 0xb9, 0x81,
532 0x3c020200, 0x10620031, 0x0043102b, 0x14400007, 0x3c020300, 0x1060000b, 532 0x5c, 0x44, 0x2c, 0x3c, 0xe6, 0xba, 0xe4, 0x60, 0x11, 0xbf, 0xa9, 0x58,
533 0x3c020100, 0x1062000d, 0x00000000, 0x0a000c2c, 0x00000000, 0x10620027, 533 0x52, 0xa5, 0x47, 0xbd, 0x23, 0xf2, 0x0c, 0xbe, 0x1b, 0x3f, 0xcc, 0x1c,
534 0x3c020400, 0x1062003e, 0x02002021, 0x0a000c2c, 0x00000000, 0x0e000c31, 534 0x18, 0xf2, 0x13, 0x76, 0xa6, 0x43, 0x0e, 0x1f, 0xbe, 0xcc, 0xbf, 0x8d,
535 0x02002021, 0x0a000c2e, 0x8fbf0014, 0x93620005, 0x30420020, 0x1440005e, 535 0x39, 0xd7, 0x92, 0x8b, 0xca, 0x6b, 0xa5, 0x4b, 0xfd, 0xd0, 0x41, 0xe6,
536 0x8fbf0014, 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000, 536 0x6f, 0x0e, 0x2f, 0xad, 0xb3, 0x41, 0xc4, 0x53, 0xda, 0xdb, 0x74, 0xa1,
537 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000, 537 0xd8, 0x0c, 0x83, 0xf5, 0xf8, 0x4b, 0x79, 0x38, 0x4f, 0x42, 0x70, 0x9e,
538 0x34630001, 0x02031825, 0x34420020, 0xa3620005, 0xaf430020, 0x93620005, 538 0x9f, 0x3a, 0xc2, 0xe6, 0x44, 0x4f, 0xb3, 0x38, 0x9c, 0x53, 0x55, 0xfc,
539 0x30420020, 0x14400003, 0x02002021, 0x0000000d, 0x02002021, 0x0e000766, 539 0xa9, 0x72, 0xaa, 0x6f, 0x8f, 0x3a, 0x10, 0xa7, 0xe6, 0xc7, 0x04, 0xe6,
540 0x24055854, 0x0a000c2e, 0x8fbf0014, 0x93620005, 0x30420001, 0x1040003f, 540 0x1f, 0xfa, 0x9c, 0x5a, 0x87, 0xd0, 0xeb, 0x10, 0xf3, 0x87, 0x76, 0x8d,
541 0x3c029000, 0x34420001, 0x02021025, 0xaf420020, 0x3c038000, 0x8f420020, 541 0x06, 0x6b, 0xb0, 0x66, 0x13, 0x2f, 0x50, 0x2b, 0xb1, 0x7f, 0xc9, 0xd1,
542 0x00431024, 0x1440fffd, 0x00000000, 0x93620023, 0x34420004, 0xa3620023, 542 0x0a, 0x9d, 0xed, 0x69, 0xa6, 0xf3, 0x9e, 0x08, 0xd4, 0x79, 0x83, 0x72,
543 0x93630005, 0x3c048000, 0x3c020800, 0x306300fe, 0xa3630005, 0x8c430020, 543 0xa4, 0xcc, 0x80, 0x1c, 0x29, 0x37, 0x0e, 0x75, 0x17, 0x0e, 0xe3, 0x2e,
544 0x34840001, 0x02042025, 0x0a000c0a, 0xaf440020, 0x00002821, 0x00003021, 544 0x2e, 0x30, 0xc0, 0xdc, 0xb9, 0x8b, 0xf1, 0x04, 0xee, 0x1c, 0xa5, 0xd0,
545 0x0e000fb1, 0x240708d9, 0x3c020800, 0x8c430020, 0x10600023, 0x8fbf0014, 545 0x07, 0x6e, 0xee, 0xec, 0xf7, 0x13, 0x49, 0x5c, 0xfe, 0xdb, 0xdc, 0xa9,
546 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 0x93630082, 0x9362003f, 546 0xa0, 0x7e, 0x27, 0x7c, 0xfd, 0x86, 0x1c, 0x9f, 0x6c, 0xc8, 0x13, 0x82,
547 0x8f840018, 0x00031a00, 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 547 0x38, 0xfe, 0x4e, 0xf7, 0xd3, 0xbb, 0xf6, 0xd1, 0xa6, 0x09, 0xfd, 0x70,
548 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 548 0x74, 0xb1, 0xba, 0xee, 0x5f, 0xf0, 0xd9, 0xb9, 0xc1, 0x67, 0x43, 0xc2,
549 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 549 0x27, 0xd7, 0x25, 0xf6, 0x90, 0x9d, 0x93, 0x61, 0x9d, 0x1e, 0x19, 0x66,
550 0x944358ce, 0x8f850018, 0x3c02400a, 0x00621825, 0x0e0014cc, 0xaca3001c, 550 0xf7, 0xd4, 0xec, 0xfc, 0x88, 0x21, 0xec, 0x73, 0x74, 0x0e, 0xb9, 0xef,
551 0x0a000c2e, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010, 0x03e00008, 551 0x14, 0x1a, 0xc6, 0xa5, 0xe2, 0x3b, 0xe9, 0x1b, 0x38, 0x77, 0x04, 0xb2,
552 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x8f420188, 0x00803021, 0x93640000, 552 0x1b, 0xf2, 0xfc, 0xf4, 0x6c, 0xd8, 0x34, 0x1c, 0x1f, 0x03, 0xfc, 0x08,
553 0x24030020, 0x00021402, 0x10830008, 0x304500ff, 0x3c036018, 0x8c625000, 553 0xc0, 0xa9, 0x7a, 0x7e, 0x90, 0x0d, 0x3d, 0x68, 0x0e, 0x87, 0x7c, 0x73,
554 0x34420400, 0xac625000, 0x0000000d, 0x00000000, 0x24000955, 0x9363003f, 554 0x28, 0xf1, 0x06, 0x6e, 0x8f, 0x58, 0xbc, 0x83, 0x9e, 0x38, 0xc5, 0x9d,
555 0x24020012, 0x14620023, 0x3c029000, 0x34420001, 0x3c038000, 0x00c21025, 555 0x18, 0x93, 0xee, 0x80, 0x78, 0x41, 0xc4, 0xfa, 0xf9, 0xfa, 0xcb, 0xef,
556 0xaf650178, 0xa365007a, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 556 0x7c, 0x51, 0xf3, 0xaf, 0xad, 0x49, 0x6d, 0xba, 0x3c, 0xad, 0x4d, 0x15,
557 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001, 557 0x51, 0xee, 0xa2, 0x56, 0xdb, 0x97, 0x36, 0x5d, 0x1c, 0x11, 0x7c, 0x30,
558 0x00c31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00c02021, 0x0e000470, 558 0x79, 0xad, 0x42, 0x78, 0x4f, 0xdb, 0xbe, 0x25, 0xb8, 0xed, 0x80, 0x0f,
559 0x24050963, 0x0a000c79, 0x8fbf0010, 0x8f4201f8, 0x00431024, 0x1440fffd, 559 0xab, 0x8a, 0x73, 0x18, 0x2d, 0xbc, 0x97, 0xb4, 0xbd, 0xb8, 0xb9, 0x8e,
560 0x24020002, 0x3c031000, 0xaf4601c0, 0xa34201c4, 0xaf4301f8, 0x0a000c79, 560 0x5b, 0xbe, 0x3f, 0x1d, 0x20, 0xdf, 0x9b, 0xd9, 0x0a, 0x91, 0xbf, 0x29,
561 0x8fbf0010, 0x9362007e, 0x1445000e, 0x00000000, 0x8f620178, 0x1045000b, 561 0xe2, 0xb2, 0xa9, 0x68, 0x21, 0xde, 0xf1, 0x30, 0xe2, 0x7b, 0xe1, 0xd7,
562 0x00000000, 0x8f820000, 0xaf650178, 0x8f660178, 0x8f440180, 0x8f65004c, 562 0xa8, 0x62, 0xe1, 0x6e, 0x30, 0x16, 0xaa, 0xf6, 0x60, 0x1d, 0xb9, 0xa3,
563 0x8c430000, 0x0060f809, 0x30c600ff, 0x0a000c79, 0x8fbf0010, 0xaf650178, 563 0x2c, 0x8b, 0xc3, 0xe9, 0x5e, 0x0a, 0x99, 0x28, 0xff, 0x6c, 0xe2, 0x3e,
564 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafbf0010, 0x93630000, 564 0x1d, 0x73, 0x78, 0x09, 0xfc, 0x3c, 0xb2, 0xde, 0x4c, 0x0b, 0x76, 0xe1,
565 0x24020020, 0x10620005, 0x00000000, 0x93630000, 0x24020030, 0x1462004d, 565 0x60, 0x7f, 0x46, 0x84, 0x65, 0xf3, 0x67, 0xbd, 0xad, 0xf9, 0x33, 0x54,
566 0x8fbf0010, 0x93420148, 0x2444ffff, 0x2c830005, 0x10600047, 0x3c020800, 566 0x39, 0xd4, 0xed, 0xa2, 0x35, 0x0b, 0x71, 0x92, 0xf0, 0x2f, 0x75, 0x77,
567 0x24425800, 0x00041880, 0x00621821, 0x8c640000, 0x00800008, 0x00000000, 567 0xb4, 0x9b, 0x41, 0xf2, 0x4f, 0xc5, 0x7e, 0x82, 0x1f, 0xc9, 0xb9, 0xba,
568 0x8f430144, 0x8f62000c, 0x14620006, 0x24020001, 0xaf62000c, 0x0e000d59, 568 0x41, 0x98, 0x3b, 0x9b, 0xbe, 0x6f, 0x30, 0x57, 0xdb, 0xb1, 0x29, 0x37,
569 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x8f62000c, 0x0a000cca, 0x00000000, 569 0x9f, 0x2b, 0xc3, 0x33, 0x57, 0xd8, 0x8b, 0x9a, 0xcd, 0x95, 0xf2, 0x43,
570 0x97630010, 0x8f420144, 0x14430006, 0x24020001, 0xa7620010, 0x0e00137a, 570 0x2a, 0xdf, 0xdc, 0x51, 0xc8, 0x93, 0x45, 0xf7, 0x5c, 0xed, 0x8c, 0x7f,
571 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620010, 0x0a000cca, 0x00000000, 571 0x4e, 0xce, 0xd9, 0x4e, 0xfb, 0xe0, 0x1a, 0x8f, 0x43, 0x34, 0xd0, 0x76,
572 0x97630012, 0x8f420144, 0x14430006, 0x24020001, 0xa7620012, 0x0e001395, 572 0x12, 0x2c, 0x33, 0xfc, 0x6b, 0xeb, 0x86, 0x5c, 0x5b, 0xcc, 0x2b, 0x9e,
573 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620012, 0x0a000cca, 0x00000000, 573 0x6f, 0xb8, 0xb6, 0xb0, 0x0f, 0x5c, 0x70, 0xf6, 0x81, 0xd3, 0x3e, 0x7d,
574 0x97630014, 0x8f420144, 0x14430006, 0x24020001, 0xa7620014, 0x0e0013bb, 574 0x51, 0xd9, 0xbc, 0xff, 0xab, 0xed, 0x0d, 0xcf, 0x7d, 0x22, 0xce, 0xe9,
575 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620014, 0x0a000cca, 0x00000000, 575 0xc8, 0x91, 0xdc, 0x47, 0xce, 0x37, 0xe4, 0x61, 0x3d, 0xdb, 0x5c, 0xa7,
576 0x97630016, 0x8f420144, 0x14430006, 0x24020001, 0xa7620016, 0x0e0013be, 576 0x6a, 0xee, 0x91, 0x73, 0x01, 0x79, 0x99, 0xa5, 0xf3, 0xf9, 0xc7, 0x06,
577 0x00000000, 0x0a000cd1, 0x8fbf0010, 0x97620016, 0x14400006, 0x8fbf0010, 577 0x75, 0xf7, 0x53, 0xa4, 0x1a, 0xd3, 0x72, 0x40, 0xf0, 0x61, 0xb7, 0xbe,
578 0x3c030800, 0x8c620070, 0x24420001, 0xac620070, 0x8fbf0010, 0x03e00008, 578 0xbc, 0xec, 0xe4, 0x28, 0xe6, 0x5c, 0x63, 0xb0, 0x9c, 0xcf, 0x36, 0x89,
579 0x27bd0018, 0x27bdffe0, 0x3c029000, 0xafbf001c, 0xafb20018, 0xafb10014, 579 0xa7, 0x6f, 0x25, 0x9e, 0x63, 0xc0, 0x23, 0x37, 0xbd, 0x73, 0x35, 0xa1,
580 0xafb00010, 0x8f500140, 0x34420001, 0x3c038000, 0x02021025, 0xaf420020, 580 0x65, 0xf2, 0xa8, 0xb3, 0x87, 0xce, 0xea, 0x9f, 0xf0, 0x18, 0x3d, 0xb1,
581 0x8f420020, 0x00431024, 0x1440fffd, 0x24020012, 0x24030080, 0xa362003f, 581 0x23, 0xe2, 0x9c, 0x11, 0xe0, 0xd2, 0xb6, 0x97, 0xcd, 0x0e, 0x5a, 0x94,
582 0xa3630082, 0x93620023, 0x30420040, 0x10400007, 0x00008821, 0x93620023, 582 0x7e, 0x46, 0x9a, 0xfa, 0xf8, 0x12, 0x15, 0x85, 0x7f, 0x0b, 0xb9, 0x51,
583 0x24110001, 0x304200bf, 0xa3620023, 0x0a000cf0, 0x3c028000, 0x3c028000, 583 0xb0, 0x71, 0xc3, 0x47, 0x87, 0xe7, 0xf0, 0xf7, 0x1b, 0x13, 0x8e, 0xcc,
584 0x34420001, 0x3c039000, 0x34630001, 0x3c048000, 0x02021025, 0x02031825, 584 0xfd, 0x93, 0x31, 0x8c, 0x7a, 0x38, 0x0b, 0x01, 0xeb, 0x9d, 0x34, 0xc9,
585 0xaf420020, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 0x00000000, 585 0x31, 0xb9, 0x1d, 0x71, 0x4e, 0x80, 0x8c, 0xcd, 0xbb, 0x5d, 0xde, 0x8e,
586 0x9362007d, 0x3c038000, 0x34420020, 0xa362007d, 0x8f640074, 0x34630001, 586 0x4f, 0xa1, 0x55, 0xbd, 0xe4, 0xeb, 0x68, 0xd8, 0xfc, 0x72, 0xcf, 0xf6,
587 0x02031825, 0xaf430020, 0x04810006, 0x3c038000, 0x02002021, 0x0e000470, 587 0x7d, 0x0a, 0x2a, 0x77, 0x5f, 0x71, 0x58, 0x75, 0x2d, 0x73, 0x69, 0xc1,
588 0x24050a63, 0x0a000d13, 0x00000000, 0x8f4201f8, 0x00431024, 0x1440fffd, 588 0x99, 0xe7, 0xd7, 0x55, 0xde, 0x6d, 0x77, 0x40, 0xde, 0x6d, 0x88, 0xe6,
589 0x24020002, 0x3c031000, 0xaf5001c0, 0xa34201c4, 0xaf4301f8, 0x1220003f, 589 0x84, 0xaf, 0x2e, 0x44, 0x39, 0x47, 0x37, 0x93, 0x9c, 0x5a, 0xd9, 0x6a,
590 0x3c120800, 0x8e420020, 0x8f71004c, 0x1040003c, 0x8fbf001c, 0x0e00148e, 590 0x23, 0x4e, 0xfc, 0x29, 0xee, 0xdd, 0x39, 0xf9, 0x7c, 0x5f, 0x04, 0xcf,
591 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001, 0xac820004, 591 0x46, 0x4e, 0xb5, 0x2d, 0x62, 0xf1, 0x33, 0xa2, 0x5c, 0xa7, 0xa7, 0x1c,
592 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 592 0xdf, 0x17, 0xd5, 0x33, 0x3b, 0xb9, 0x7c, 0x8a, 0x64, 0x0e, 0x7d, 0x27,
593 0x8f820018, 0xac510014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 593 0xcd, 0x15, 0x9b, 0xf5, 0x6b, 0x1f, 0xe2, 0x81, 0xe3, 0xf0, 0x95, 0x0a,
594 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024010, 0x00621825, 594 0xbf, 0x95, 0xa1, 0xfa, 0x80, 0x3e, 0xb5, 0x57, 0xfb, 0x04, 0xf9, 0x14,
595 0x0e0014cc, 0xaca3001c, 0x8e420020, 0x1040001e, 0x8fbf001c, 0x0e00148e, 595 0x12, 0x7e, 0x05, 0xbe, 0x76, 0xda, 0x99, 0x23, 0x77, 0xbf, 0xc2, 0xdc,
596 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x3c02008d, 0xac820004, 596 0x2f, 0x3c, 0xa7, 0xd3, 0x55, 0xb6, 0xd3, 0x55, 0xb6, 0x36, 0x5e, 0x3a,
597 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 597 0xeb, 0x54, 0x0b, 0xe5, 0x1f, 0x59, 0x2f, 0xfd, 0x56, 0xd8, 0xe6, 0xe6,
598 0x8f840018, 0x24020a6a, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448, 598 0xb3, 0x06, 0x2d, 0xac, 0xf7, 0xf2, 0x27, 0xc6, 0x1f, 0x94, 0xdb, 0xcb,
599 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c024019, 599 0xff, 0xdd, 0x9c, 0xa2, 0x5f, 0xc4, 0x02, 0xb6, 0xce, 0x07, 0x83, 0xf1,
600 0x00621825, 0x0e0014cc, 0xaca3001c, 0x8fbf001c, 0x8fb20018, 0x8fb10014, 600 0x1f, 0xbc, 0x6e, 0x13, 0x01, 0xeb, 0xb6, 0xf9, 0xbe, 0x22, 0xf7, 0x93,
601 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0010, 0x93620081, 601 0xe4, 0x95, 0x8a, 0x23, 0xaf, 0x36, 0x69, 0xd0, 0x27, 0xa7, 0x82, 0xd6,
602 0x3c030800, 0x8c640048, 0x0044102b, 0x14400005, 0x00000000, 0x0e000cd3, 602 0x29, 0xfa, 0x78, 0xca, 0xe9, 0xe3, 0x9b, 0xa2, 0x3f, 0xe3, 0x54, 0xa8,
603 0x00000000, 0x0a000da4, 0x8fbf0010, 0x93620081, 0x24420001, 0x0e0013c4, 603 0xe6, 0x0d, 0x1f, 0xe1, 0xeb, 0x98, 0xb2, 0xd1, 0x35, 0x90, 0xab, 0xdf,
604 0xa3620081, 0x9763006a, 0x00032880, 0x14a00002, 0x00403821, 0x24050001, 604 0x6c, 0x43, 0xc6, 0x04, 0x71, 0xb2, 0x03, 0x01, 0xfa, 0x80, 0xee, 0xd2,
605 0x97630068, 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 605 0x07, 0xe2, 0x55, 0x7d, 0x60, 0x45, 0xe8, 0x09, 0xbb, 0x1c, 0x1d, 0x34,
606 0x00c5102b, 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 606 0xd8, 0x16, 0x97, 0xcb, 0xe3, 0xcc, 0x1b, 0xd8, 0xf8, 0xa4, 0x1d, 0x7d,
607 0x54600001, 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 607 0xda, 0xaa, 0x9e, 0x99, 0xc3, 0xba, 0x65, 0x8d, 0x4b, 0xfb, 0xe5, 0x09,
608 0xaf62000c, 0x10e00021, 0x3c029000, 0x8f450140, 0x34420001, 0x3c038000, 608 0xce, 0xac, 0xa8, 0xcc, 0x3e, 0x30, 0xa3, 0xa4, 0xa5, 0x93, 0xf1, 0xa9,
609 0x00a21025, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 609 0x50, 0x84, 0x16, 0xac, 0x28, 0x15, 0xac, 0x14, 0x73, 0x70, 0xf0, 0xe3,
610 0x9362007d, 0x3c038000, 0x34420004, 0xa362007d, 0x8f640074, 0x34630001, 610 0xd0, 0x80, 0x46, 0x11, 0x96, 0x35, 0x11, 0x2a, 0x95, 0x94, 0x4e, 0x76,
611 0x00a31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021, 0x0e000470, 611 0x86, 0xc8, 0x2c, 0xc6, 0xa4, 0x0d, 0x9b, 0x71, 0x9a, 0x1f, 0x33, 0xe6,
612 0x24050a92, 0x0a000da4, 0x8fbf0010, 0x8f4201f8, 0x00431024, 0x1440fffd, 612 0x49, 0x43, 0xcc, 0x8b, 0x93, 0xa3, 0x0e, 0x0c, 0x8a, 0x38, 0x4b, 0xfd,
613 0x24020002, 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 613 0xe5, 0x91, 0x28, 0xb5, 0xa7, 0xa5, 0xcd, 0x68, 0x86, 0xdb, 0xf8, 0xc2,
614 0x03e00008, 0x27bd0018, 0x27bdffd8, 0xafb3001c, 0x27530100, 0xafbf0024, 614 0x8a, 0xd1, 0x95, 0x7c, 0xd2, 0x38, 0xc1, 0xed, 0x64, 0xac, 0x64, 0x62,
615 0xafb40020, 0xafb20018, 0xafb10014, 0xafb00010, 0x96620008, 0x3c140800, 615 0x92, 0x9f, 0x5d, 0x2c, 0x45, 0x28, 0x67, 0x45, 0xa8, 0x50, 0x4a, 0x19,
616 0x8f520100, 0x30420001, 0x104000da, 0x00000000, 0x8e700018, 0x8f630054, 616 0x43, 0x6d, 0xa2, 0xcd, 0x18, 0xda, 0x7c, 0x49, 0x1f, 0x33, 0x4e, 0x92,
617 0x2602ffff, 0x00431023, 0x18400006, 0x00000000, 0x0000000d, 0x00000000, 617 0xbb, 0xcd, 0xaf, 0x9c, 0x36, 0xbd, 0x6d, 0xfd, 0x61, 0xe3, 0xfe, 0x44,
618 0x2400015c, 0x0a000dea, 0x00008821, 0x8f62004c, 0x02021023, 0x18400028, 618 0xa8, 0x32, 0x7b, 0x9f, 0xf1, 0x92, 0x5b, 0x9d, 0x60, 0xd9, 0x14, 0x13,
619 0x00008821, 0x93650120, 0x93640121, 0x3c030800, 0x8c62008c, 0x308400ff, 619 0x67, 0xdb, 0x68, 0xe9, 0x34, 0xcb, 0x1d, 0x9c, 0x6d, 0x61, 0xd0, 0x62,
620 0x24420001, 0x30a500ff, 0x00803821, 0x1485000b, 0xac62008c, 0x3c040800, 620 0x39, 0x4e, 0xef, 0x57, 0xed, 0x07, 0x12, 0x43, 0x39, 0x91, 0x43, 0x84,
621 0x8c830090, 0x24630001, 0xac830090, 0x93620122, 0x30420001, 0x00021023, 621 0x33, 0x17, 0x2a, 0xb3, 0xbf, 0x9b, 0x5e, 0x7f, 0x3f, 0xeb, 0x5b, 0x1f,
622 0x30420005, 0x0a000dea, 0x34510004, 0x27660100, 0x00041080, 0x00c21021, 622 0xc5, 0x28, 0x72, 0x15, 0x71, 0xdd, 0x36, 0x5d, 0x1b, 0x4f, 0x5e, 0xd9,
623 0x8c430000, 0x02031823, 0x04600004, 0x24820001, 0x30440007, 0x1485fff9, 623 0x14, 0x79, 0x68, 0x09, 0x5a, 0x33, 0xa5, 0x3c, 0xcd, 0x71, 0xf9, 0x15,
624 0x00041080, 0x10870007, 0x3c030800, 0xa3640121, 0x8c620094, 0x24110005, 624 0x94, 0x5b, 0x4b, 0xd0, 0x3d, 0x91, 0x8f, 0xd6, 0x4e, 0x77, 0xf4, 0x18,
625 0x24420001, 0x0a000dea, 0xac620094, 0x24110004, 0x32220001, 0x1040001e, 625 0x85, 0x6e, 0x9a, 0xc6, 0xbc, 0xf0, 0x0b, 0x57, 0x66, 0x87, 0x86, 0x0d,
626 0x8e820020, 0x1040001d, 0x32220004, 0x0e00148e, 0x00000000, 0x8f820018, 626 0xd2, 0xae, 0xa2, 0x1e, 0xff, 0xbf, 0x89, 0xfb, 0x28, 0x61, 0x7e, 0x66,
627 0xac520000, 0x8f840018, 0x24020001, 0xac820004, 0x8f830018, 0xac600008, 627 0xac, 0x31, 0x5e, 0x49, 0xc3, 0xf1, 0x12, 0x64, 0xf3, 0x41, 0x89, 0xa5,
628 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018, 0xac500014, 628 0x39, 0x23, 0x42, 0xd0, 0x5f, 0x61, 0x7b, 0xeb, 0x35, 0x27, 0x7b, 0xa4,
629 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 629 0xfe, 0xe4, 0x3b, 0x9b, 0x43, 0x9f, 0x19, 0x71, 0x9f, 0xcf, 0x51, 0x7b,
630 0x944358ce, 0x8f850018, 0x3c024010, 0x00621825, 0x0e0014cc, 0xaca3001c, 630 0x66, 0xc6, 0x92, 0xef, 0xb9, 0x52, 0xee, 0xa5, 0x25, 0x6e, 0x7b, 0x64,
631 0x32220004, 0x10400081, 0x00003821, 0x3c029000, 0x34420001, 0x3c038000, 631 0xf8, 0x8c, 0x73, 0xa6, 0x0f, 0xff, 0xd9, 0x8b, 0x7b, 0x85, 0xb7, 0x7d,
632 0x02421025, 0xa360007c, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 632 0x7d, 0x14, 0xc5, 0x3d, 0x0d, 0xe8, 0x3c, 0xc7, 0xb0, 0xe9, 0x87, 0xc5,
633 0x00000000, 0x93620023, 0x30420080, 0x10400011, 0x00000000, 0x8f65005c, 633 0xb8, 0xa7, 0xe2, 0x98, 0xcb, 0xb9, 0xb8, 0x3a, 0x97, 0x08, 0x65, 0xba,
634 0x8f63004c, 0x9764003c, 0x8f620064, 0x00a32823, 0x00852821, 0x00a2102b, 634 0xe9, 0x91, 0xd5, 0x45, 0x3f, 0x8b, 0xf3, 0x47, 0xf8, 0xba, 0x84, 0x9c,
635 0x54400006, 0x3c023fff, 0x93620023, 0x3042007f, 0xa3620023, 0xaf700064, 635 0xa3, 0x36, 0xca, 0x64, 0xbb, 0x69, 0xb3, 0x14, 0x66, 0x71, 0x05, 0xec,
636 0x3c023fff, 0x0a000e37, 0x3442ffff, 0x8f62005c, 0x02021023, 0x04400011, 636 0x44, 0xb9, 0x4c, 0x81, 0xa6, 0xd6, 0x5f, 0xeb, 0x83, 0x1f, 0x66, 0x52,
637 0x00000000, 0x8f65005c, 0x8f630064, 0x9764003c, 0x3c023fff, 0x3442ffff, 637 0xab, 0x61, 0xe9, 0x51, 0x00, 0x96, 0x7e, 0xa9, 0xc3, 0xd2, 0xd1, 0xbe,
638 0xaf700064, 0x00a32823, 0x00852821, 0x0045102b, 0x10400004, 0x02051021, 638 0xe6, 0x58, 0xea, 0x77, 0x62, 0xd6, 0xa3, 0x14, 0x71, 0x70, 0xf4, 0x39,
639 0x3c053fff, 0x34a5ffff, 0x02051021, 0xaf62005c, 0x24070001, 0xaf70004c, 639 0xe3, 0xe8, 0x3d, 0xc6, 0xd1, 0xf1, 0x06, 0x38, 0xd2, 0x3c, 0x38, 0x3a,
640 0x8f620054, 0x16020005, 0x00000000, 0x93620023, 0x30420040, 0x10400017, 640 0x51, 0x87, 0xa3, 0x6c, 0x5f, 0x33, 0x1c, 0x1d, 0x0f, 0xa1, 0xff, 0xcd,
641 0x24020001, 0x9762006a, 0x00022880, 0x50a00001, 0x24050001, 0x97630068, 641 0xd6, 0x32, 0xfa, 0xb0, 0x9f, 0x39, 0xbd, 0x49, 0xa5, 0xd5, 0xe4, 0xf8,
642 0x93640081, 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 642 0x24, 0x55, 0x90, 0x73, 0x92, 0x58, 0xa2, 0xb4, 0xe0, 0x76, 0x05, 0x81,
643 0x54400001, 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 643 0xbf, 0x2c, 0x8f, 0xc9, 0xae, 0x06, 0xe7, 0xaa, 0x24, 0x9c, 0x79, 0x93,
644 0x00c02021, 0x8f420074, 0x2403fffe, 0x00832824, 0x00a21021, 0xaf62000c, 644 0x73, 0x99, 0xc9, 0x57, 0x66, 0x1f, 0x32, 0x36, 0xee, 0x6d, 0xe8, 0x3a,
645 0x93620082, 0x30420080, 0x50400001, 0xa3600081, 0x3c028000, 0x34420001, 645 0x7e, 0x0b, 0xb1, 0x8c, 0xbc, 0xbb, 0x81, 0x73, 0x5b, 0xe2, 0x74, 0xdf,
646 0x02421025, 0xaf420020, 0x9363007e, 0x9362007a, 0x10620004, 0x00000000, 646 0x1a, 0xa0, 0x7b, 0xd6, 0x7e, 0xba, 0x6b, 0x0d, 0xd2, 0x03, 0x0b, 0x6d,
647 0x0e0013c4, 0x00000000, 0x00403821, 0x10e0001f, 0x3c029000, 0x34420001, 647 0x60, 0x0e, 0xf8, 0x5e, 0xcc, 0x81, 0x46, 0x33, 0x31, 0x2e, 0x53, 0xda,
648 0x02421025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 648 0x4f, 0x95, 0x92, 0xc2, 0x35, 0xb0, 0x03, 0x0c, 0x35, 0xc6, 0x4e, 0xa6,
649 0x00000000, 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001, 649 0x0e, 0x3b, 0xb2, 0x0e, 0x30, 0xb3, 0xe4, 0xb7, 0xad, 0xed, 0x32, 0xf8,
650 0x02431825, 0xaf430020, 0x04810006, 0x3c038000, 0x02402021, 0x0e000470, 650 0x5d, 0x0d, 0xc6, 0x56, 0x58, 0xc4, 0x91, 0x24, 0x47, 0x67, 0x42, 0x90,
651 0x24050b3d, 0x0a000e8d, 0x00000000, 0x8f4201f8, 0x00431024, 0x1440fffd, 651 0x59, 0xb7, 0x18, 0x53, 0x3c, 0x17, 0x3c, 0x7e, 0xda, 0xf5, 0x41, 0x96,
652 0x24020002, 0x3c031000, 0xaf5201c0, 0xa34201c4, 0xaf4301f8, 0x9342010b, 652 0x39, 0x4f, 0x09, 0x1b, 0xf4, 0x94, 0xa9, 0xc7, 0x33, 0x64, 0x5f, 0xd6,
653 0x9343010b, 0x8e820020, 0x27500100, 0x38630006, 0x10400029, 0x2c710001, 653 0xcc, 0x31, 0x91, 0xeb, 0xb6, 0x54, 0xf6, 0x9e, 0x31, 0x91, 0xe1, 0xb1,
654 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018, 654 0x57, 0x78, 0xf4, 0xca, 0xa1, 0x76, 0xaa, 0x38, 0x31, 0x4c, 0x85, 0x55,
655 0x96020008, 0xac820004, 0x8f830018, 0x8e020014, 0xac620008, 0x8f850018, 655 0xdb, 0x7e, 0xc8, 0xfc, 0x7f, 0xcd, 0x84, 0xcc, 0xfe, 0xdb, 0xae, 0xc4,
656 0x3c026000, 0x8c434448, 0xaca3000c, 0x8f840018, 0x96020012, 0xac820010, 656 0x74, 0x5a, 0x36, 0x55, 0xdf, 0xee, 0x08, 0x7c, 0x31, 0x47, 0xa4, 0x77,
657 0x8f850018, 0x8e030020, 0xaca30014, 0x9602000c, 0x9603000e, 0x8f840018, 657 0x37, 0xaa, 0xaf, 0xc4, 0xbf, 0xe3, 0xbb, 0xbf, 0x04, 0x97, 0x59, 0xab,
658 0x00021400, 0x00431025, 0xac820018, 0x12200005, 0x3c020800, 0x944358ce, 658 0x96, 0x85, 0xed, 0xf8, 0xd2, 0xd8, 0xc2, 0x2a, 0xce, 0x7e, 0x7b, 0xfc,
659 0x8f840018, 0x0a000eb8, 0x3c024013, 0x944358ce, 0x8f840018, 0x3c024014, 659 0xea, 0xf9, 0xd5, 0x5c, 0x1f, 0x4b, 0xd8, 0x94, 0x4e, 0x76, 0x68, 0x79,
660 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001, 0x8e700014, 0x8f620040, 660 0x3c, 0xf7, 0x5c, 0x98, 0x86, 0x19, 0x97, 0x38, 0x83, 0x6b, 0x6c, 0x34,
661 0x14500003, 0x00501023, 0x0a000ec3, 0x00001021, 0x28420001, 0x1040003a, 661 0x2c, 0xce, 0x38, 0xd9, 0xcd, 0x78, 0xc8, 0x0a, 0x3b, 0xfd, 0xd4, 0x91,
662 0x00000000, 0x0e000fae, 0x02002021, 0xaf700040, 0x9362003e, 0x30420001, 662 0x09, 0x9a, 0x2c, 0xa7, 0xf9, 0x53, 0x3f, 0x7e, 0xb5, 0xb9, 0xe3, 0xe1,
663 0x1440000b, 0x3c029000, 0x93620022, 0x24420001, 0xa3620022, 0x93630022, 663 0x48, 0xe3, 0x37, 0x37, 0xff, 0xa8, 0xd5, 0x9d, 0xe6, 0xba, 0x33, 0x5b,
664 0x3c020800, 0x8c440098, 0x0064182b, 0x14600025, 0x3c020800, 0x3c029000, 664 0xd6, 0x55, 0xe7, 0x12, 0xfd, 0x03, 0x69, 0xae, 0x1b, 0xa3, 0xbc, 0x57,
665 0x34420001, 0x02421025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 665 0x00, 0x00, 0x00 };
666 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x34420001, 0xa362007d,
667 0x8f640074, 0x34630001, 0x02431825, 0xaf430020, 0x04810006, 0x3c038000,
668 0x02402021, 0x0e000470, 0x24050273, 0x0a000ef6, 0x24020001, 0x8f4201f8,
669 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf5201c0, 0xa34201c4,
670 0xaf4301f8, 0x24020001, 0xa7620012, 0x0a000efe, 0xa3600022, 0x9743007a,
671 0x9444002a, 0x00641821, 0x3063fffe, 0xa7630012, 0x97420108, 0x8fbf0024,
672 0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x00021042,
673 0x30420001, 0x03e00008, 0x27bd0028, 0x27bdffe0, 0xafb20018, 0x3c120800,
674 0x8e420020, 0xafb00010, 0x27500100, 0xafbf001c, 0x10400046, 0xafb10014,
675 0x0e00148e, 0x00000000, 0x8f840018, 0x8e020000, 0xac820000, 0x936300b1,
676 0x936200c5, 0x8f850018, 0x00031e00, 0x00021400, 0x34420100, 0x00621825,
677 0xaca30004, 0x8f840018, 0x8e02001c, 0xac820008, 0x8f830018, 0x8f620048,
678 0xac62000c, 0x8f840018, 0x96020012, 0xac820010, 0x8f830018, 0x8f620040,
679 0x24040001, 0xac620014, 0x8f850018, 0x3c026000, 0x8c434448, 0x3c020800,
680 0x245158c0, 0xaca30018, 0x9623000e, 0x8f850018, 0x3c024016, 0x00621825,
681 0x0e0014cc, 0xaca3001c, 0x96030008, 0x30630010, 0x1060001c, 0x8e420020,
682 0x1040001a, 0x8e100000, 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000,
683 0x8f830018, 0xac600004, 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c,
684 0x8f820018, 0xac400010, 0x8f830018, 0xac600014, 0x8f850018, 0x3c036000,
685 0x8c634448, 0x24040001, 0xaca30018, 0x9622000e, 0x8f850018, 0x3c034015,
686 0x00431025, 0x0e0014cc, 0xaca2001c, 0x00001021, 0x8fbf001c, 0x8fb20018,
687 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe0, 0xafb20018,
688 0x3c120800, 0x8e420020, 0xafb00010, 0x27500100, 0xafbf001c, 0x10400041,
689 0xafb10014, 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000,
690 0x8f840018, 0x24020100, 0xac820004, 0x8f830018, 0x8e02001c, 0xac620008,
691 0x8f840018, 0x8e020018, 0xac82000c, 0x8f830018, 0x96020012, 0xac620010,
692 0x8f840018, 0x96020008, 0xac820014, 0x8f850018, 0x3c026000, 0x8c434448,
693 0x24040001, 0x3c020800, 0x245158c0, 0xaca30018, 0x9623000e, 0x8f850018,
694 0x3c024017, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x96030008, 0x30630010,
695 0x1060001c, 0x8e420020, 0x1040001a, 0x8e100000, 0x0e00148e, 0x00000000,
696 0x8f820018, 0xac500000, 0x8f830018, 0xac600004, 0x8f820018, 0xac400008,
697 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010, 0x8f830018, 0xac600014,
698 0x8f850018, 0x3c036000, 0x8c634448, 0x24040001, 0xaca30018, 0x9622000e,
699 0x8f850018, 0x3c034015, 0x00431025, 0x0e0014cc, 0xaca2001c, 0x00001021,
700 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
701 0x27bdfff0, 0x03e00008, 0x27bd0010, 0x27bdffd0, 0xafb10014, 0x00808821,
702 0xafb40020, 0x00c0a021, 0xafbf0028, 0xafb50024, 0xafb3001c, 0xafb20018,
703 0xafb00010, 0x93620023, 0x00e0a821, 0x30420040, 0x1040003e, 0x30b3ffff,
704 0x3c120800, 0x8e420020, 0x1040003a, 0x8f70004c, 0x0e00148e, 0x00000000,
705 0x8f820018, 0xac510000, 0x8f840018, 0x24020001, 0xac820004, 0x8f830018,
706 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018,
707 0x24040001, 0xac500014, 0x8f850018, 0x3c026000, 0x8c434448, 0x3c020800,
708 0x245058c0, 0xaca30018, 0x9603000e, 0x8f850018, 0x3c024010, 0x00621825,
709 0x0e0014cc, 0xaca3001c, 0x8e430020, 0x1060001b, 0x00000000, 0x0e00148e,
710 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 0x3c02008d, 0xac820004,
711 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
712 0x8f820018, 0xac550014, 0x8f850018, 0x3c036000, 0x8c634448, 0x24040001,
713 0xaca30018, 0x9602000e, 0x8f850018, 0x3c034019, 0x00431025, 0x0e0014cc,
714 0xaca2001c, 0x93620023, 0x30420020, 0x14400003, 0x3c120800, 0x1280003f,
715 0x3c029000, 0x8e420020, 0x8f70004c, 0x1040003b, 0x3c029000, 0x0e00148e,
716 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 0x24020001, 0xac820004,
717 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
718 0x8f820018, 0x24040001, 0xac500014, 0x8f850018, 0x3c026000, 0x8c434448,
719 0x3c020800, 0x245058c0, 0xaca30018, 0x9603000e, 0x8f850018, 0x3c024010,
720 0x00621825, 0x0e0014cc, 0xaca3001c, 0x8e430020, 0x1060001c, 0x3c029000,
721 0x0e00148e, 0x00000000, 0x8f820018, 0xac510000, 0x8f840018, 0x00131400,
722 0xac820004, 0x8f830018, 0xac750008, 0x8f820018, 0xac40000c, 0x8f830018,
723 0xac600010, 0x8f820018, 0xac400014, 0x8f850018, 0x3c036000, 0x8c634448,
724 0x24040001, 0xaca30018, 0x9602000e, 0x8f850018, 0x3c03401b, 0x00431025,
725 0x0e0014cc, 0xaca2001c, 0x3c029000, 0x34420001, 0x02221025, 0xaf420020,
726 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93630023,
727 0x3c028000, 0x34420001, 0x02221025, 0x8fbf0028, 0x8fb50024, 0x8fb40020,
728 0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x3063009f, 0xa3630023,
729 0xaf420020, 0x03e00008, 0x27bd0030, 0x27bdffe0, 0xafb10014, 0x27510100,
730 0x3c029000, 0x34420001, 0xafb00010, 0x00808021, 0x02021025, 0x3c038000,
731 0xafbf0018, 0xaf420020, 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000,
732 0xa7600008, 0x8f63005c, 0x3c028000, 0x34420001, 0xaf630148, 0x8f640050,
733 0x02021025, 0x3c039000, 0xaf64017c, 0xaf420020, 0x8f450100, 0x34630001,
734 0x3c048000, 0x00a31825, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd,
735 0x00000000, 0x9362007d, 0x3c038000, 0x34420001, 0xa362007d, 0x8f640074,
736 0x34630001, 0x00a31825, 0xaf430020, 0x04810006, 0x3c038000, 0x00a02021,
737 0x0e000470, 0x24050de5, 0x0a001093, 0x3c020800, 0x8f4201f8, 0x00431024,
738 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4501c0, 0xa34201c4, 0xaf4301f8,
739 0x3c020800, 0x8c430020, 0x1060001e, 0x8fbf0018, 0x0e00148e, 0x00000000,
740 0x8f830018, 0xac700000, 0x9622000c, 0x8f840018, 0x00021400, 0xac820004,
741 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010,
742 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001,
743 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c02401f, 0x00621825,
744 0x0e0014cc, 0xaca3001c, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x03e00008,
745 0x27bd0020, 0x3c020800, 0x24424c3c, 0xaf82000c, 0x03e00008, 0x00000000,
746 0x27bdffe8, 0xafb00010, 0x27500100, 0xafbf0014, 0x8e02001c, 0x14400003,
747 0x3c020800, 0x0000000d, 0x3c020800, 0x8c430020, 0x10600020, 0x00001021,
748 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018,
749 0x8e02001c, 0xac820004, 0x8f830018, 0xac600008, 0x8f840018, 0x8e020018,
750 0xac82000c, 0x8f850018, 0x96020012, 0xaca20010, 0x8f830018, 0x3c026000,
751 0xac600014, 0x8f840018, 0x8c434448, 0x3c020800, 0xac830018, 0x944358ce,
752 0x8f840018, 0x3c024012, 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001,
753 0x00001021, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800,
754 0x97430078, 0x9444002e, 0x00001021, 0x00641821, 0x3063fffe, 0x03e00008,
755 0xa7630010, 0x27bdfff0, 0x00001021, 0x03e00008, 0x27bd0010, 0x8f420100,
756 0x34420001, 0xaf4200a4, 0x03e00008, 0x00001021, 0x27bdffe0, 0xafbf0018,
757 0xafb10014, 0xafb00010, 0x9362007e, 0x30d000ff, 0x16020031, 0x00808821,
758 0x8f620178, 0x1602002e, 0x00000000, 0x9362007f, 0x1602002b, 0x00000000,
759 0x9362007a, 0x16020004, 0x00000000, 0x0000000d, 0x00000000, 0x240009d2,
760 0x0e0013e6, 0x00000000, 0x3c039000, 0x34630001, 0x3c048000, 0x02231825,
761 0xa370007a, 0xaf430020, 0x8f420020, 0x00441024, 0x1440fffd, 0x00000000,
762 0x9362007d, 0x3c038000, 0xa362007d, 0x8f640074, 0x34630001, 0x02231825,
763 0xaf430020, 0x04810006, 0x3c038000, 0x02202021, 0x0e000470, 0x240509dd,
764 0x0a001138, 0x8fbf0018, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002,
765 0x3c031000, 0xaf5101c0, 0xa34201c4, 0xaf4301f8, 0x0a001138, 0x8fbf0018,
766 0x0000000d, 0x00000000, 0x240009e2, 0x8fbf0018, 0x8fb10014, 0x8fb00010,
767 0x03e00008, 0x27bd0020, 0x27bdffe8, 0x30a500ff, 0x3c029000, 0x34420001,
768 0x00803821, 0x00e21025, 0x3c038000, 0xafbf0010, 0xaf420020, 0x8f420020,
769 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x00a21025,
770 0xa362007d, 0x8f640074, 0x34630001, 0x00e31825, 0xaf430020, 0x04810006,
771 0x3c038000, 0x00e02021, 0x0e000470, 0x00c02821, 0x0a001161, 0x8fbf0010,
772 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4701c0,
773 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800,
774 0x8c430020, 0x27bdffe8, 0xafb00010, 0x27500100, 0x10600024, 0xafbf0014,
775 0x0e00148e, 0x00000000, 0x8f830018, 0x8e020000, 0xac620000, 0x8f840018,
776 0x8e020004, 0xac820004, 0x8f830018, 0x8e020018, 0xac620008, 0x8f840018,
777 0x8e03001c, 0xac83000c, 0x9602000c, 0x9203000a, 0x8f840018, 0x00021400,
778 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018,
779 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x946458ce, 0x8f850018,
780 0x00021400, 0x00441025, 0x24040001, 0x0e0014cc, 0xaca2001c, 0x8fbf0014,
781 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8,
782 0xafb00010, 0x27500100, 0x10600020, 0xafbf0014, 0x0e00148e, 0x00000000,
783 0x8f820018, 0xac400000, 0x8f830018, 0xac600004, 0x8f820018, 0xac400008,
784 0x8f830018, 0xac60000c, 0x9602000c, 0x9603000e, 0x8f840018, 0x00021400,
785 0x00431025, 0xac820010, 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018,
786 0x8c434448, 0xac830018, 0x96020008, 0x3c030800, 0x946458ce, 0x8f850018,
787 0x00021400, 0x00441025, 0x24040001, 0x0e0014cc, 0xaca2001c, 0x8fbf0014,
788 0x8fb00010, 0x03e00008, 0x27bd0018, 0x27bdffe8, 0xafb00010, 0x27500100,
789 0xafbf0014, 0x9602000c, 0x10400024, 0x00802821, 0x3c020800, 0x8c430020,
790 0x1060003a, 0x8fbf0014, 0x0e00148e, 0x00000000, 0x8f840018, 0x8e030000,
791 0xac830000, 0x9602000c, 0x8f840018, 0x00021400, 0xac820004, 0x8f830018,
792 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018, 0xac600010, 0x8f820018,
793 0xac400014, 0x8f850018, 0x3c026000, 0x8c434448, 0x24040001, 0x3c020800,
794 0xaca30018, 0x944358ce, 0x8f850018, 0x3c02400b, 0x00621825, 0x0e0014cc,
795 0xaca3001c, 0x0a0011ff, 0x8fbf0014, 0x93620005, 0x30420010, 0x14400015,
796 0x3c029000, 0x34420001, 0x00a21025, 0xaf420020, 0x3c038000, 0x8f420020,
797 0x00431024, 0x1440fffd, 0x00000000, 0x3c038000, 0x93620005, 0x34630001,
798 0x00a02021, 0x00a31825, 0x24055852, 0x34420010, 0xa3620005, 0x0e000766,
799 0xaf430020, 0x0a0011ff, 0x8fbf0014, 0x0000000d, 0x8fbf0014, 0x8fb00010,
800 0x03e00008, 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe8, 0xafb00010,
801 0x27500100, 0x10600022, 0xafbf0014, 0x0e00148e, 0x00000000, 0x8f840018,
802 0x8e020004, 0xac820000, 0x9603000c, 0x9762002c, 0x8f840018, 0x00031c00,
803 0x00431025, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
804 0x8f830018, 0xac600010, 0x8f820018, 0xac400014, 0x8f850018, 0x3c026000,
805 0x8c434448, 0x24040001, 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018,
806 0x3c02400e, 0x00621825, 0x0e0014cc, 0xaca3001c, 0x0e00122e, 0x8e040000,
807 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x3c038000, 0x8f420278,
808 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf440240, 0xa3420244,
809 0x03e00008, 0xaf430278, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb10014,
810 0x00808821, 0xafb20018, 0x00c09021, 0xafb00010, 0x30b0ffff, 0x1060001c,
811 0xafbf001c, 0x0e00148e, 0x00000000, 0x8f820018, 0xac510000, 0x8f840018,
812 0x00101400, 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c,
813 0x8f830018, 0xac600010, 0x8f820018, 0xac520014, 0x8f840018, 0x3c026000,
814 0x8c434448, 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c024019,
815 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf001c, 0x8fb20018,
816 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0x27450100,
817 0xafbf0010, 0x94a3000c, 0x240200c1, 0x14620031, 0x00803021, 0x3c029000,
818 0x34420001, 0x00c21025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024,
819 0x1440fffd, 0x3c028000, 0x34420001, 0x3c049000, 0x34840001, 0x3c058000,
820 0x24030012, 0x00c21025, 0x00c42025, 0xa363003f, 0xaf420020, 0xaf440020,
821 0x8f420020, 0x00451024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000,
822 0x34420020, 0xa362007d, 0x8f640074, 0x34630001, 0x00c31825, 0xaf430020,
823 0x04810006, 0x3c038000, 0x00c02021, 0x0e000470, 0x24050906, 0x0a0012a1,
824 0x8fbf0010, 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000,
825 0xaf4601c0, 0xa34201c4, 0xaf4301f8, 0x0a0012a1, 0x8fbf0010, 0x00c02021,
826 0x94a5000c, 0x24060001, 0x0e000fb1, 0x2407090e, 0x8fbf0010, 0x03e00008,
827 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb00010, 0x00808021,
828 0xafb20018, 0x00a09021, 0xafb10014, 0x30d100ff, 0x1060001c, 0xafbf001c,
829 0x0e00148e, 0x00000000, 0x8f820018, 0xac500000, 0x8f840018, 0x24020001,
830 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
831 0xac600010, 0x8f820018, 0xac520014, 0x8f840018, 0x3c026000, 0x8c434448,
832 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c024010, 0x00621825,
833 0xac83001c, 0x0e0014cc, 0x02202021, 0x8fbf001c, 0x8fb20018, 0x8fb10014,
834 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0014, 0xafb00010,
835 0x93620005, 0x30420001, 0x10400036, 0x00808021, 0x3c029000, 0x34420001,
836 0x02021025, 0xaf420020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
837 0x00000000, 0x93620023, 0x34420004, 0xa3620023, 0x93630005, 0x3c048000,
838 0x3c020800, 0x306300fe, 0xa3630005, 0x8c430020, 0x34840001, 0x02042025,
839 0xaf440020, 0x10600020, 0x8fbf0014, 0x0e00148e, 0x00000000, 0x8f820018,
840 0xac500000, 0x93630082, 0x9362003f, 0x8f840018, 0x00031a00, 0x00431025,
841 0xac820004, 0x8f830018, 0xac600008, 0x8f820018, 0xac40000c, 0x8f830018,
842 0xac600010, 0x8f820018, 0xac400014, 0x8f840018, 0x3c026000, 0x8c434448,
843 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c02400a, 0x00621825,
844 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf0014, 0x8fb00010, 0x03e00008,
845 0x27bd0018, 0x3c020800, 0x8c430020, 0x27bdffe0, 0xafb10014, 0x00808821,
846 0xafb20018, 0x00a09021, 0xafb00010, 0x30d000ff, 0x1060002f, 0xafbf001c,
847 0x0e00148e, 0x00000000, 0x8f820018, 0xac510000, 0x8f830018, 0xac700004,
848 0x8f820018, 0xac520008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
849 0x9763006a, 0x00032880, 0x50a00001, 0x24050001, 0x97630068, 0x93640081,
850 0x3c020800, 0x8c46004c, 0x00652821, 0x00852804, 0x00c5102b, 0x54400001,
851 0x00a03021, 0x3c020800, 0x8c440050, 0x00c4182b, 0x54600001, 0x00c02021,
852 0x8f830018, 0x2402fffe, 0x00822824, 0x3c026000, 0xac650014, 0x8f840018,
853 0x8c434448, 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c024011,
854 0x00621825, 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf001c, 0x8fb20018,
855 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x27bdffe8, 0xafbf0014,
856 0xafb00010, 0x8f440100, 0x27500100, 0x8f650050, 0x0e0010fc, 0x9206001b,
857 0x3c020800, 0x8c430020, 0x1060001d, 0x8e100018, 0x0e00148e, 0x00000000,
858 0x8f840018, 0x8f420100, 0xac820000, 0x8f830018, 0xac700004, 0x8f840018,
859 0x8f620050, 0xac820008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
860 0x8f830018, 0x3c026000, 0xac600014, 0x8f850018, 0x8c434448, 0x24040001,
861 0x3c020800, 0xaca30018, 0x944358ce, 0x8f850018, 0x3c02401c, 0x00621825,
862 0x0e0014cc, 0xaca3001c, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018,
863 0x8f430238, 0x3c020800, 0x04610013, 0x8c44009c, 0x2406fffe, 0x3c050800,
864 0x3c038000, 0x2484ffff, 0x14800009, 0x00000000, 0x97420078, 0x8ca3007c,
865 0x24420001, 0x00461024, 0x24630001, 0xa7620010, 0x03e00008, 0xaca3007c,
866 0x8f420238, 0x00431024, 0x1440fff3, 0x2484ffff, 0x8f420140, 0x3c031000,
867 0xaf420200, 0x03e00008, 0xaf430238, 0x27bdffe8, 0x3c029000, 0xafbf0010,
868 0x8f450140, 0x34420001, 0x3c038000, 0x00a21025, 0xaf420020, 0x8f420020,
869 0x00431024, 0x1440fffd, 0x00000000, 0x9362007d, 0x3c038000, 0x34420001,
870 0xa362007d, 0x8f640074, 0x34630001, 0x00a31825, 0xaf430020, 0x04810006,
871 0x3c038000, 0x00a02021, 0x0e000470, 0x24050ac7, 0x0a0013b9, 0x8fbf0010,
872 0x8f4201f8, 0x00431024, 0x1440fffd, 0x24020002, 0x3c031000, 0xaf4501c0,
873 0xa34201c4, 0xaf4301f8, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x0000000d,
874 0x03e00008, 0x00000000, 0x0000000d, 0x03e00008, 0x00000000, 0x24020001,
875 0x03e00008, 0xa7620010, 0x9362003f, 0x304400ff, 0x3883000e, 0x2c630001,
876 0x38820010, 0x2c420001, 0x00621825, 0x14600003, 0x24020012, 0x14820003,
877 0x00000000, 0x03e00008, 0x00001021, 0x9363007e, 0x9362007a, 0x14620006,
878 0x00000000, 0x9363007e, 0x24020001, 0x24630001, 0x03e00008, 0xa363007e,
879 0x9362007e, 0x8f630178, 0x304200ff, 0x14430006, 0x00000000, 0x9363000b,
880 0x24020001, 0x24630001, 0x03e00008, 0xa363000b, 0x03e00008, 0x00001021,
881 0x9362000b, 0x10400023, 0x00001021, 0xa360000b, 0x9362003f, 0x304400ff,
882 0x3883000e, 0x2c630001, 0x38820010, 0x2c420001, 0x00621825, 0x14600017,
883 0x00001821, 0x24020012, 0x10820014, 0x00000000, 0x9363007e, 0x9362007a,
884 0x14620007, 0x00000000, 0x9362007e, 0x24030001, 0x24420001, 0xa362007e,
885 0x03e00008, 0x00601021, 0x9362007e, 0x8f630178, 0x304200ff, 0x14430005,
886 0x00001821, 0x9362000b, 0x24030001, 0x24420001, 0xa362000b, 0x03e00008,
887 0x00601021, 0x03e00008, 0x00000000, 0x24040001, 0xaf64000c, 0x8f6300dc,
888 0x8f6200cc, 0x50620001, 0xa7640010, 0xa7640012, 0xa7640014, 0x03e00008,
889 0xa7640016, 0x3c020800, 0x8c430020, 0x27bdffe8, 0x1060001b, 0xafbf0010,
890 0x0e00148e, 0x00000000, 0x8f820018, 0xac400000, 0x8f830018, 0xac600004,
891 0x8f820018, 0xac400008, 0x8f830018, 0xac60000c, 0x8f820018, 0xac400010,
892 0x8f830018, 0x3c026000, 0xac600014, 0x8f840018, 0x8c434448, 0x3c020800,
893 0xac830018, 0x944358ce, 0x8f840018, 0x3c024020, 0x00621825, 0xac83001c,
894 0x0e0014cc, 0x24040001, 0x8fbf0010, 0x03e00008, 0x27bd0018, 0x3c020800,
895 0x8c430020, 0x27bdffe0, 0xafb00010, 0x00a08021, 0xafb10014, 0x00c08821,
896 0xafb20018, 0x00e09021, 0x1060001e, 0xafbf001c, 0x0e00148e, 0x00000000,
897 0x8f840018, 0x8f420100, 0xac820000, 0x8f830018, 0xac700004, 0x8f820018,
898 0xac510008, 0x8f830018, 0xac72000c, 0x8f840018, 0x8fa20030, 0xac820010,
899 0x8f830018, 0x8fa20034, 0xac620014, 0x8f840018, 0x3c026000, 0x8c434448,
900 0x3c020800, 0xac830018, 0x944358ce, 0x8f840018, 0x3c0240c9, 0x00621825,
901 0xac83001c, 0x0e0014cc, 0x24040001, 0x8fbf001c, 0x8fb20018, 0x8fb10014,
902 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3c020800, 0x8c430020, 0x27bdffe8,
903 0xafb00010, 0x27500100, 0x1060001d, 0xafbf0014, 0x0e00148e, 0x00000000,
904 0x8f830018, 0x8e020004, 0xac620000, 0x8f840018, 0x8e020018, 0xac820004,
905 0x8f850018, 0x8e020000, 0xaca20008, 0x8f830018, 0xac60000c, 0x8f820018,
906 0xac400010, 0x8f830018, 0xac600014, 0x8f820018, 0xac400018, 0x96030008,
907 0x3c020800, 0x944458ce, 0x8f850018, 0x00031c00, 0x00641825, 0x24040001,
908 0x0e0014cc, 0xaca3001c, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018,
909 0x3c060800, 0x24c558c0, 0x3c02000a, 0x03421821, 0x94640006, 0x94a2000a,
910 0x00441023, 0x00021400, 0x00021c03, 0x04610006, 0xa4a40006, 0x0000000d,
911 0x00000000, 0x2400005a, 0x0a0014a3, 0x24020001, 0x8f820014, 0x0062102b,
912 0x14400002, 0x00001021, 0x24020001, 0x304200ff, 0x1040001c, 0x274a0400,
913 0x3c07000a, 0x3c020800, 0x244558c0, 0x94a9000a, 0x8f880014, 0x03471021,
914 0x94430006, 0x00402021, 0xa4a30006, 0x94820006, 0xa4a20006, 0x01221023,
915 0x00021400, 0x00021403, 0x04410006, 0x0048102b, 0x0000000d, 0x00000000,
916 0x2400005a, 0x0a0014be, 0x24020001, 0x14400002, 0x00001021, 0x24020001,
917 0x304200ff, 0x1440ffec, 0x03471021, 0x24c458c0, 0x8c820010, 0xaf420038,
918 0x8c830014, 0x3c020005, 0xaf43003c, 0xaf420030, 0xaf800010, 0xaf8a0018,
919 0x03e00008, 0x00000000, 0x27bdffe0, 0x8f820010, 0x8f850018, 0x3c070800,
920 0x24e858c0, 0xafbf001c, 0xafb20018, 0xafb10014, 0xafb00010, 0x9503000a,
921 0x8d060014, 0x00009021, 0x309000ff, 0x00e08821, 0x24420001, 0x24a50020,
922 0x24630001, 0xaf820010, 0xaf850018, 0xa503000a, 0x24c30020, 0x3c028000,
923 0x04c10007, 0xad030014, 0x00621024, 0x14400005, 0x262258c0, 0x8d020010,
924 0x24420001, 0xad020010, 0x262258c0, 0x9444000a, 0x94450018, 0x0010102b,
925 0x00a41826, 0x2c630001, 0x00621825, 0x1060001c, 0x3c030006, 0x8f820010,
926 0x24120001, 0x00021140, 0x00431025, 0xaf420030, 0x00000000, 0x00000000,
927 0x00000000, 0x27450400, 0x8f420000, 0x30420010, 0x1040fffd, 0x262258c0,
928 0x9444000a, 0x94430018, 0xaf800010, 0xaf850018, 0x14830012, 0x262758c0,
929 0x0e00155a, 0x00000000, 0x1600000e, 0x262758c0, 0x0e00148e, 0x00000000,
930 0x0a001517, 0x262758c0, 0x00041c00, 0x00031c03, 0x00051400, 0x00021403,
931 0x00621823, 0x18600002, 0x3c026000, 0xac400808, 0x262758c0, 0x94e2000e,
932 0x94e3000c, 0x24420001, 0xa4e2000e, 0x3042ffff, 0x50430001, 0xa4e0000e,
933 0x12000005, 0x3c02000a, 0x94e2000a, 0xa74200a2, 0x0a001554, 0x02401021,
934 0x03421821, 0x94640006, 0x94e2000a, 0x00441023, 0x00021400, 0x00021c03,
935 0x04610006, 0xa4e40006, 0x0000000d, 0x00000000, 0x2400005a, 0x0a001536,
936 0x24020001, 0x8f820014, 0x0062102b, 0x14400002, 0x00001021, 0x24020001,
937 0x304200ff, 0x1040001b, 0x3c020800, 0x3c06000a, 0x244558c0, 0x94a8000a,
938 0x8f870014, 0x03461021, 0x94430006, 0x00402021, 0xa4a30006, 0x94820006,
939 0xa4a20006, 0x01021023, 0x00021400, 0x00021403, 0x04410006, 0x0047102b,
940 0x0000000d, 0x00000000, 0x2400005a, 0x0a001550, 0x24020001, 0x14400002,
941 0x00001021, 0x24020001, 0x304200ff, 0x1440ffec, 0x03461021, 0x02401021,
942 0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020,
943 0x3c020800, 0x244558c0, 0x94a3001a, 0x8ca40024, 0x00403021, 0x000318c0,
944 0x00832021, 0xaf44003c, 0x8ca20020, 0xaf420038, 0x3c020050, 0x34420008,
945 0xaf420030, 0x00000000, 0x00000000, 0x00000000, 0x8f420000, 0x30420020,
946 0x1040fffd, 0x00000000, 0x8f430400, 0x24c658c0, 0xacc30010, 0x8f420404,
947 0x3c030020, 0xacc20014, 0xaf430030, 0x94c40018, 0x94c3001c, 0x94c2001a,
948 0x94c5001e, 0x00832021, 0x24420001, 0xa4c2001a, 0x3042ffff, 0x14450002,
949 0xa4c40018, 0xa4c0001a, 0x03e00008, 0x00000000, 0x8f820010, 0x3c030006,
950 0x00021140, 0x00431025, 0xaf420030, 0x00000000, 0x00000000, 0x00000000,
951 0x27430400, 0x8f420000, 0x30420010, 0x1040fffd, 0x00000000, 0xaf800010,
952 0xaf830018, 0x03e00008, 0x00000000, 0x27bdffe8, 0xafb00010, 0x3c100800,
953 0x261058c0, 0x3c05000a, 0x02002021, 0x03452821, 0xafbf0014, 0x0e0015b0,
954 0x2406000a, 0x96020002, 0x9603001e, 0x3042000f, 0x24420003, 0x00431804,
955 0x24027fff, 0x0043102b, 0xaf830014, 0x10400004, 0x00000000, 0x0000000d,
956 0x00000000, 0x24000043, 0x0e00155a, 0x00000000, 0x8fbf0014, 0x8fb00010,
957 0x03e00008, 0x27bd0018, 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff,
958 0x24a50004, 0xac820000, 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000,
959 0x0a0015c1, 0x00a01021, 0xac860000, 0x00000000, 0x00000000, 0x24840004,
960 0x00a01021, 0x1440fffa, 0x24a5ffff, 0x03e00008, 0x00000000, 0x3c036000,
961 0x8c642b7c, 0x3c036010, 0x8c6553fc, 0x00041582, 0x00042302, 0x308403ff,
962 0x00052d82, 0x00441026, 0x0002102b, 0x0005282b, 0x00451025, 0x1440000d,
963 0x3c020050, 0x34420004, 0xaf400038, 0xaf40003c, 0xaf420030, 0x00000000,
964 0x00000000, 0x8f420000, 0x30420020, 0x1040fffd, 0x3c020020, 0xaf420030,
965 0x0000000d, 0x03e00008, 0x00000000, 0x3c020050, 0x34420004, 0xaf440038,
966 0xaf45003c, 0xaf420030, 0x00000000, 0x00000000, 0x8f420000, 0x30420020,
967 0x1040fffd, 0x3c020020, 0xaf420030, 0x03e00008, 0x00000000, 0x00000000};
968 666
969static u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x0 }; 667static u32 bnx2_COM_b06FwData[(0x0/4) + 1] = { 0x0 };
970static u32 bnx2_COM_b06FwRodata[(0x58/4) + 1] = { 668static u32 bnx2_COM_b06FwRodata[(0x58/4) + 1] = {
@@ -989,952 +687,368 @@ static u32 bnx2_RXP_b06FwBssAddr = 0x08005900;
989static int bnx2_RXP_b06FwBssLen = 0x13a4; 687static int bnx2_RXP_b06FwBssLen = 0x13a4;
990static u32 bnx2_RXP_b06FwSbssAddr = 0x080058e0; 688static u32 bnx2_RXP_b06FwSbssAddr = 0x080058e0;
991static int bnx2_RXP_b06FwSbssLen = 0x1c; 689static int bnx2_RXP_b06FwSbssLen = 0x1c;
992static u32 bnx2_RXP_b06FwText[(0x588c/4) + 1] = { 690static u8 bnx2_RXP_b06FwText[] = {
993 0x0a000c61, 0x00000000, 0x00000000, 0x0000000d, 0x72787020, 0x322e362e, 691 0x1f, 0x8b, 0x08, 0x08, 0x07, 0x87, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
994 0x31000000, 0x02060103, 0x00000000, 0x0000000d, 0x00000000, 0x00000000, 692 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x5d, 0x6c,
995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 693 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x43, 0x71, 0x49, 0x91, 0xd4, 0x70, 0xb9,
996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 694 0x62, 0x57, 0x12, 0x65, 0xed, 0x8a, 0x43, 0x71, 0x6d, 0x31, 0xce, 0x50,
997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 695 0x58, 0xdb, 0x82, 0xb1, 0x48, 0xc7, 0xb3, 0xa4, 0xc8, 0x24, 0x02, 0x42,
998 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 696 0x1b, 0x42, 0xab, 0xa4, 0xa9, 0xc1, 0x90, 0x72, 0x91, 0x22, 0x2c, 0xa0,
999 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 697 0x1a, 0x79, 0xf0, 0x43, 0x10, 0x2f, 0x56, 0x3f, 0xa6, 0xd1, 0x8d, 0x96,
1000 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 698 0xb6, 0x1c, 0x53, 0x08, 0x82, 0x82, 0xe5, 0x52, 0x52, 0x0b, 0x2c, 0xb4,
1001 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 699 0x96, 0xed, 0x36, 0x7e, 0xa8, 0x23, 0x9a, 0x92, 0x8d, 0xa6, 0x68, 0x81,
1002 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 700 0x22, 0xad, 0xd1, 0xf4, 0x4d, 0x95, 0x9a, 0x4a, 0x75, 0x5f, 0xd4, 0xa2,
1003 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 701 0x48, 0xda, 0x46, 0xcd, 0xf4, 0xfb, 0xee, 0xcc, 0x88, 0xd4, 0x9a, 0xb2,
1004 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 702 0x2c, 0x3b, 0x0d, 0x62, 0x74, 0x0e, 0x30, 0xd8, 0xb9, 0x7f, 0xe7, 0xef,
1005 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 703 0x9e, 0x73, 0xee, 0x39, 0x77, 0x28, 0x7d, 0xa5, 0x43, 0xda, 0x25, 0x84,
1006 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 704 0x4e, 0x3c, 0x99, 0xc3, 0xcf, 0x3c, 0xfd, 0xe0, 0xc3, 0x0f, 0xee, 0xc1,
1007 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 705 0xeb, 0xb0, 0xa1, 0x6d, 0xd0, 0xa3, 0xfe, 0x18, 0x62, 0x88, 0x21, 0x86,
1008 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 706 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62,
1009 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 707 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21,
1010 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 708 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18,
1011 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 709 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88,
1012 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 710 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0xff, 0xef, 0x60, 0x88, 0x58,
1013 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 711 0xfc, 0xed, 0x0c, 0x1f, 0x49, 0xe8, 0x85, 0xcb, 0x07, 0x3d, 0x5b, 0x12,
1014 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 712 0x46, 0x61, 0x69, 0x66, 0xda, 0x16, 0x71, 0xeb, 0xbb, 0x33, 0x45, 0xf9,
1015 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 713 0x1f, 0xbf, 0x94, 0x32, 0x85, 0xfd, 0xdb, 0x0b, 0x37, 0x9f, 0x7d, 0xf3,
1016 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 714 0x91, 0xec, 0x8d, 0x05, 0x43, 0x12, 0x56, 0xe1, 0xe8, 0xb0, 0xb5, 0x4b,
1017 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 715 0x12, 0x7d, 0x58, 0xf3, 0xdd, 0xc1, 0xcf, 0x59, 0xd2, 0x15, 0xe1, 0xba,
1018 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 716 0xee, 0xbf, 0x39, 0x68, 0xc9, 0x2b, 0x8d, 0x94, 0x5c, 0x68, 0x6c, 0xdf,
1019 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 717 0x24, 0x5d, 0xd9, 0x52, 0x09, 0xfd, 0x6e, 0x8a, 0xe3, 0x96, 0x94, 0xab,
1020 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 718 0x2d, 0xe2, 0x2a, 0xba, 0x7d, 0x5a, 0x71, 0xfe, 0x3e, 0xcd, 0x9b, 0x7f,
1021 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 719 0x9e, 0xff, 0x1e, 0x24, 0xa5, 0xcb, 0x7d, 0x68, 0xf7, 0xa1, 0xcd, 0xf7,
1022 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 720 0x81, 0xf4, 0x94, 0x98, 0x72, 0xa4, 0x91, 0x90, 0xa3, 0xd5, 0x8c, 0xe8,
1023 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 721 0x05, 0x71, 0xbd, 0xbc, 0x9d, 0x2e, 0xa3, 0x6f, 0xea, 0x00, 0xdb, 0x29,
1024 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 722 0xe0, 0xf9, 0x0e, 0xd7, 0x59, 0x5e, 0x5e, 0x4a, 0xb7, 0xc6, 0x14, 0x0d,
1025 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 723 0x8e, 0xb1, 0x0f, 0xbf, 0x58, 0x5f, 0xae, 0x76, 0x00, 0x6f, 0xd6, 0x71,
1026 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 724 0x41, 0xdc, 0x73, 0x2c, 0xd0, 0xf6, 0xfd, 0xdf, 0x75, 0x32, 0xb2, 0xe2,
1027 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 725 0x74, 0x81, 0xa7, 0x16, 0x69, 0xb5, 0xc5, 0xd2, 0x0b, 0xb6, 0xb5, 0x22,
1028 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 726 0x6d, 0x1c, 0xeb, 0x34, 0x0a, 0xbe, 0x3f, 0x9d, 0x97, 0xae, 0xa0, 0x6f,
1029 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 727 0xb7, 0xe2, 0x63, 0x72, 0x42, 0xc3, 0xbc, 0x57, 0x49, 0x0f, 0x3a, 0xe2,
1030 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 728 0x3b, 0x7f, 0xf3, 0x52, 0xac, 0x6c, 0x97, 0xc9, 0x54, 0xf6, 0xa0, 0x1b,
1031 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 729 0xd0, 0x74, 0x3d, 0x67, 0x2b, 0x70, 0x6a, 0xe0, 0x4f, 0xdb, 0x81, 0xf5,
1032 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 730 0xee, 0x0a, 0x68, 0x1a, 0x85, 0xcd, 0x62, 0x6c, 0x66, 0x9f, 0xe8, 0x3b,
1033 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 731 0x87, 0x93, 0xe1, 0x78, 0x97, 0x36, 0x32, 0x6f, 0x88, 0x6e, 0xff, 0x81,
1034 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 732 0xe6, 0xd5, 0x7a, 0xe5, 0xd8, 0xbc, 0x8e, 0x77, 0x5d, 0xae, 0xe6, 0x4b,
1035 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 733 0x9a, 0xdb, 0xa8, 0x68, 0xde, 0xd9, 0x59, 0xad, 0x78, 0xd6, 0x94, 0xa3,
1036 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 734 0xb6, 0x7f, 0xe1, 0xb4, 0x73, 0x42, 0x1b, 0x39, 0x7b, 0x46, 0x1b, 0x3d,
1037 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 735 0xfb, 0x86, 0x36, 0xde, 0xd8, 0xb2, 0x49, 0xda, 0xb3, 0xd0, 0x1e, 0x71,
1038 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 736 0x90, 0xbf, 0x4f, 0x87, 0xba, 0xec, 0xa2, 0xde, 0x4a, 0xe4, 0x7d, 0x9f,
1039 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 737 0xf3, 0x86, 0xe6, 0x55, 0x6d, 0x8b, 0xfb, 0xe6, 0xa6, 0x22, 0x1a, 0xed,
1040 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 738 0x72, 0x74, 0xde, 0x94, 0x63, 0xd5, 0x94, 0x3c, 0x57, 0x2d, 0x29, 0x5a,
1041 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 739 0x86, 0x5d, 0xd2, 0xbc, 0x06, 0xc7, 0x2b, 0xa0, 0x75, 0x42, 0xdb, 0x07,
1042 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 740 0x9a, 0xde, 0x59, 0x29, 0x5d, 0x71, 0xe6, 0x40, 0xaf, 0x03, 0x78, 0xff,
1043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 741 0x58, 0x1b, 0x6d, 0xf4, 0x6a, 0xde, 0xc9, 0x9b, 0xe2, 0x39, 0x59, 0xeb,
1044 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 742 0x4b, 0x62, 0xba, 0xb0, 0x01, 0xc8, 0x0c, 0xfd, 0x38, 0xd0, 0x49, 0xca,
1045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 743 0xf7, 0xf5, 0x82, 0xff, 0x2c, 0x74, 0x6f, 0x5d, 0xa1, 0xfc, 0x8d, 0x5e,
1046 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 744 0x29, 0xcf, 0x53, 0xd7, 0xa6, 0x36, 0x52, 0xf5, 0x2f, 0x78, 0x8e, 0xf4,
1047 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 745 0x19, 0xe2, 0xfb, 0x47, 0x9d, 0x81, 0xf4, 0x21, 0x39, 0x03, 0xdc, 0x75,
1048 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 746 0xad, 0xd8, 0xa0, 0xae, 0xc1, 0xdf, 0x2d, 0x39, 0x02, 0xbd, 0x15, 0x9d,
1049 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 747 0x5e, 0x99, 0xb4, 0xb2, 0x2e, 0xf6, 0x68, 0x53, 0x20, 0x57, 0x32, 0xb4,
1050 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 748 0x17, 0xd2, 0xe7, 0xde, 0x67, 0xd3, 0x9e, 0xa1, 0xcb, 0x53, 0x2f, 0x3d,
1051 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 749 0xdf, 0xb3, 0x38, 0xb4, 0x91, 0x32, 0x43, 0xff, 0xf2, 0x45, 0xcf, 0xf6,
1052 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 750 0xb6, 0xb4, 0x48, 0x29, 0x6d, 0x48, 0x16, 0xfb, 0xb4, 0x43, 0x4e, 0x3b,
1053 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 751 0x22, 0x87, 0x2a, 0xd0, 0x8d, 0x6d, 0x5a, 0x8b, 0x62, 0x67, 0xca, 0x32,
1054 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 752 0x50, 0x32, 0x75, 0x74, 0x26, 0x49, 0x97, 0x3a, 0xd2, 0xe5, 0x7a, 0x9e,
1055 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 753 0x7a, 0xa2, 0x3d, 0x7f, 0x28, 0x5d, 0x69, 0xab, 0xba, 0x5a, 0xd5, 0xd3,
1056 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 754 0xf8, 0x2f, 0x5d, 0x4f, 0xd4, 0xc9, 0x72, 0x28, 0xb7, 0x03, 0xdc, 0x8f,
1057 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 755 0x40, 0x5f, 0xe2, 0xea, 0xc3, 0x0f, 0xb1, 0x6f, 0x93, 0x51, 0xb0, 0xd3,
1058 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 756 0x17, 0x61, 0x14, 0x7a, 0x61, 0x37, 0x64, 0x19, 0xa6, 0xee, 0xe0, 0xc3,
1059 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 757 0x1f, 0x49, 0x5e, 0xf9, 0xd5, 0x90, 0x97, 0xfc, 0xdb, 0x32, 0x55, 0x49,
1060 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 758 0x80, 0x06, 0x65, 0xd4, 0xe5, 0xbd, 0x7c, 0x64, 0x1b, 0x7b, 0x20, 0x5f,
1061 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 759 0x5e, 0xa6, 0xbe, 0x45, 0x7f, 0xa2, 0xfd, 0xf3, 0x9d, 0xb2, 0xfe, 0xcc,
1062 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 760 0xbf, 0xee, 0x7c, 0x92, 0xf6, 0x96, 0x7c, 0x27, 0xe4, 0x78, 0x35, 0xc9,
1063 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 761 0x3d, 0xd4, 0x56, 0x54, 0x6c, 0x8a, 0x64, 0x14, 0xdd, 0x28, 0x74, 0x48,
1064 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 762 0x51, 0xed, 0xf7, 0x5e, 0xd0, 0x43, 0x2c, 0xa8, 0xf2, 0xbd, 0xa0, 0x64,
1065 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 763 0x9b, 0xb6, 0xed, 0xcc, 0x11, 0xc9, 0xc2, 0xbe, 0x45, 0x8e, 0xcc, 0x99,
1066 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 764 0x32, 0x6d, 0xff, 0x63, 0xa7, 0xb4, 0x2f, 0xdf, 0x6f, 0xa8, 0xb8, 0xae,
1067 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 765 0xf7, 0x6e, 0x90, 0x4d, 0xe0, 0x77, 0xf9, 0x7e, 0x5d, 0xe4, 0xa6, 0x59,
1068 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 766 0xc8, 0x5a, 0x23, 0x08, 0xf6, 0x46, 0x81, 0xb1, 0x4c, 0x43, 0x2c, 0x93,
1069 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 767 0x44, 0x8b, 0x4d, 0x7d, 0xf9, 0xfe, 0xf8, 0xf0, 0xdd, 0xf5, 0x75, 0x64,
1070 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 768 0x9e, 0xb4, 0xa9, 0x2f, 0xc6, 0xa8, 0x12, 0xf4, 0xc1, 0xf8, 0x74, 0xbb,
1071 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 769 0xae, 0x8a, 0xa1, 0xae, 0x46, 0xfe, 0xef, 0xed, 0xc2, 0xf5, 0xaa, 0xa2,
1072 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 770 0x79, 0xce, 0xbb, 0xa1, 0x2f, 0xd8, 0x32, 0x02, 0x7f, 0x37, 0xec, 0x4f,
1073 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 771 0xcb, 0x91, 0x54, 0x76, 0xc2, 0x95, 0xc0, 0xe6, 0xaf, 0xad, 0xb1, 0xf9,
1074 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 772 0xd1, 0xbb, 0xc8, 0x75, 0x3c, 0x94, 0xcb, 0x0d, 0xe5, 0x1a, 0x85, 0x5c,
1075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 773 0x63, 0x90, 0x6b, 0xe5, 0x23, 0xc8, 0xb5, 0xf2, 0x91, 0xe5, 0xd2, 0xa4,
1076 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 774 0xec, 0x3c, 0x08, 0x5a, 0xa6, 0xfc, 0xab, 0x13, 0xd8, 0xf2, 0xbf, 0x38,
1077 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 775 0x9f, 0x14, 0x19, 0x7c, 0x7f, 0x70, 0xd8, 0x16, 0xef, 0x5b, 0xe0, 0xd5,
1078 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 776 0x71, 0x40, 0x8b, 0xef, 0xef, 0x97, 0xe1, 0x6e, 0xfe, 0x38, 0x8b, 0x7d,
1079 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 777 0x5d, 0xcf, 0x1f, 0x29, 0x87, 0x3e, 0x7c, 0xef, 0xfe, 0xa8, 0x6b, 0x1f,
1080 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 778 0x55, 0x0e, 0xc6, 0x9c, 0x4f, 0x35, 0x9d, 0xab, 0x1f, 0x56, 0x86, 0xf5,
1081 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 779 0x63, 0xca, 0x2f, 0x4f, 0x86, 0xc7, 0x64, 0x72, 0x33, 0xed, 0xa9, 0xa4,
1082 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 780 0x8d, 0x0c, 0x92, 0xef, 0xb5, 0xfc, 0x4a, 0x26, 0xe0, 0x0d, 0x39, 0xd1,
1083 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 781 0xd2, 0x46, 0x39, 0xb2, 0x60, 0x49, 0x69, 0xe9, 0x4e, 0x71, 0x57, 0x03,
1084 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 782 0x6f, 0xb4, 0x47, 0xf6, 0x7d, 0xd2, 0x7c, 0x2a, 0xc8, 0x2b, 0x2e, 0x54,
1085 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 783 0x91, 0x83, 0x56, 0x13, 0x72, 0xd9, 0x48, 0xcb, 0x9b, 0x83, 0x87, 0xe5,
1086 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 784 0xf3, 0xd5, 0x24, 0xe8, 0x31, 0x9f, 0x2c, 0xe7, 0x10, 0x17, 0xb5, 0xb2,
1087 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 785 0x63, 0x08, 0x79, 0xaf, 0xd9, 0x9c, 0x13, 0xc4, 0x96, 0x72, 0x10, 0x83,
1088 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 786 0x5d, 0x6f, 0x50, 0xe5, 0x14, 0x90, 0x4f, 0x64, 0x0c, 0xb1, 0xb7, 0x66,
1089 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 787 0xb3, 0xcd, 0xfe, 0xa0, 0xef, 0xb3, 0x95, 0x5e, 0xad, 0xc8, 0xbc, 0x64,
1090 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 788 0xf0, 0xa6, 0x4c, 0x3b, 0x41, 0xdf, 0xe7, 0x2a, 0xa3, 0x9b, 0x98, 0x1f,
1091 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 789 0x1a, 0x05, 0xc9, 0x94, 0x9d, 0xf7, 0x7c, 0xd7, 0xba, 0x7d, 0xcd, 0xfa,
1092 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 790 0x78, 0xb2, 0x13, 0x81, 0xce, 0x45, 0xfb, 0xaa, 0xad, 0xf7, 0xb6, 0x4a,
1093 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 791 0x09, 0x27, 0x5d, 0xd6, 0x1a, 0x47, 0xe7, 0xbe, 0x4a, 0x79, 0x5b, 0xab,
1094 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 792 0xdc, 0x34, 0x80, 0x3f, 0x6d, 0x68, 0x62, 0x1e, 0xaa, 0x94, 0xbb, 0xd9,
1095 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 793 0xa6, 0xbe, 0x74, 0x4d, 0x12, 0xa3, 0x15, 0x5f, 0xae, 0x3a, 0x41, 0xee,
1096 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 794 0x63, 0x68, 0x7a, 0x6f, 0x5b, 0xb8, 0x56, 0xd7, 0x76, 0x39, 0x97, 0x44,
1097 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 795 0x3a, 0x0e, 0x55, 0xc4, 0x2a, 0x56, 0x76, 0x39, 0x6f, 0x4b, 0xb9, 0xa7,
1098 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 796 0x6d, 0x75, 0x5d, 0x8a, 0xeb, 0x76, 0x0e, 0xaf, 0x9d, 0xbb, 0xcb, 0xb9,
1099 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 797 0x28, 0xe5, 0x2d, 0x6d, 0xab, 0xb4, 0xd2, 0x58, 0xdb, 0x17, 0xac, 0xe5,
1100 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 798 0xf8, 0x66, 0x71, 0xbb, 0x39, 0x47, 0xef, 0x6d, 0xbf, 0x45, 0x43, 0x32,
1101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 799 0xc5, 0x4a, 0xb9, 0xa7, 0x7d, 0x15, 0xaf, 0x4d, 0xbc, 0xde, 0x1a, 0xbc,
1102 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 800 0xc4, 0xd9, 0xbe, 0x8a, 0x33, 0x07, 0x9c, 0x43, 0xab, 0x38, 0x39, 0x7e,
1103 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 801 0x58, 0x8a, 0x38, 0xd3, 0x5a, 0x0a, 0x32, 0xbc, 0x54, 0xc9, 0x48, 0x79,
1104 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 802 0x28, 0x01, 0xdd, 0xf7, 0x1f, 0xfc, 0x9a, 0xaa, 0x43, 0xcc, 0x61, 0x0f,
1105 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 803 0xba, 0x32, 0x55, 0x5e, 0x87, 0xd8, 0x08, 0xdb, 0xf8, 0x5a, 0x5d, 0x86,
1106 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 804 0x17, 0xeb, 0xa6, 0x1c, 0x6f, 0x70, 0xbf, 0x98, 0xe3, 0x05, 0x75, 0xc6,
1107 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 805 0x85, 0x46, 0x4e, 0xdb, 0x87, 0xbd, 0x66, 0x9d, 0xb0, 0xaf, 0x61, 0x6a,
1108 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 806 0xa3, 0x3c, 0x1f, 0x80, 0x97, 0x76, 0x7e, 0xac, 0x41, 0xdb, 0x79, 0x03,
1109 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 807 0xb6, 0x41, 0xce, 0xa3, 0x9c, 0xbd, 0x95, 0xb9, 0x53, 0x66, 0xd1, 0x51,
1110 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 808 0x75, 0x88, 0x56, 0xcb, 0x77, 0x20, 0x07, 0x4d, 0xa0, 0xd6, 0x80, 0xcd,
1111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 809 0xdb, 0x78, 0x6f, 0x70, 0xde, 0x32, 0xe6, 0x6d, 0xe0, 0x3c, 0xec, 0xcd,
1112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 810 0x25, 0xe5, 0x0f, 0xa6, 0xcd, 0xf1, 0x77, 0xb1, 0xc7, 0x68, 0xd7, 0x59,
1113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 811 0x57, 0x58, 0x02, 0x5f, 0xc1, 0x3e, 0xa2, 0x6e, 0x48, 0xed, 0x60, 0x7e,
1114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 812 0x8f, 0xb9, 0x19, 0xcc, 0xcd, 0x66, 0x18, 0xcf, 0x3d, 0xfb, 0x99, 0x0e,
1115 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 813 0xe9, 0x42, 0xbb, 0xce, 0x35, 0xd9, 0x0c, 0x72, 0x5b, 0xdf, 0xcb, 0xb7,
1116 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 814 0xc9, 0x4a, 0xca, 0xbf, 0x60, 0xd8, 0xd1, 0xdc, 0x08, 0x6f, 0xf3, 0x5c,
1117 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 815 0xe6, 0xc5, 0xc4, 0xbd, 0x21, 0xcc, 0x83, 0xc7, 0xc5, 0x6d, 0xfc, 0x49,
1118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 816 0xb7, 0x74, 0xb9, 0xf8, 0x8d, 0xe6, 0x4c, 0x6f, 0x0e, 0x6a, 0x2e, 0xbe,
1119 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 817 0xb7, 0x50, 0x3e, 0x17, 0xe7, 0xa1, 0x56, 0xac, 0x66, 0x26, 0x59, 0x1f,
1120 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 818 0x15, 0xeb, 0x6c, 0xef, 0x85, 0x3f, 0x04, 0x75, 0xd7, 0x85, 0x5b, 0xbe,
1121 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 819 0x70, 0x19, 0x7a, 0x4b, 0x43, 0x6f, 0x29, 0x39, 0xdf, 0x60, 0x9d, 0xe6,
1122 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 820 0x42, 0x5f, 0x19, 0xf1, 0x1a, 0xe3, 0x58, 0x2b, 0x87, 0x81, 0x03, 0x3a,
1123 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 821 0x17, 0x47, 0x2f, 0x64, 0x65, 0xca, 0xda, 0x1d, 0xf1, 0x00, 0x5c, 0x88,
1124 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 822 0x1f, 0x85, 0x36, 0xf4, 0xf1, 0x1d, 0x9a, 0x53, 0xff, 0x86, 0x7f, 0x94,
1125 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 823 0xed, 0x09, 0xbd, 0x30, 0xd6, 0xd4, 0xbf, 0x6e, 0xfc, 0xa1, 0x1c, 0x68,
1126 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 824 0x33, 0x06, 0x31, 0xfe, 0xe8, 0xa8, 0xf3, 0x18, 0x8b, 0x48, 0xd7, 0x92,
1127 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 825 0x23, 0x4b, 0x23, 0xdc, 0x37, 0x8b, 0xf1, 0xa7, 0x5c, 0xe7, 0x9e, 0x29,
1128 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 826 0x5c, 0xc0, 0x19, 0xad, 0xf1, 0xfd, 0x11, 0x87, 0x6b, 0x7c, 0x99, 0x70,
1129 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 827 0x3a, 0xc4, 0x48, 0x96, 0xb4, 0xc7, 0x07, 0x11, 0x7b, 0x1e, 0xe0, 0x3e,
1130 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 828 0x32, 0x06, 0x6d, 0x17, 0xb0, 0xea, 0xb4, 0x3c, 0x3c, 0xc8, 0x75, 0xa0,
1131 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 829 0xdd, 0x2a, 0x7a, 0x92, 0x34, 0xf3, 0x21, 0x4f, 0x43, 0xdd, 0x81, 0xbe,
1132 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 830 0x06, 0xac, 0x40, 0x7f, 0x9f, 0xe9, 0x5e, 0xd5, 0x1f, 0xd7, 0x35, 0xf3,
1133 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 831 0xcb, 0x18, 0x96, 0x90, 0x81, 0x33, 0x1b, 0x65, 0xe7, 0xa2, 0x25, 0xf6,
1134 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 832 0x99, 0x55, 0xfe, 0x76, 0x9e, 0x5b, 0xcb, 0x5f, 0xf4, 0x7f, 0x15, 0x5c,
1135 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 833 0xd0, 0xc5, 0x8e, 0xfa, 0x1e, 0x4b, 0x05, 0xb8, 0xa3, 0xf6, 0x7b, 0xe1,
1136 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 834 0x5e, 0xf1, 0xfd, 0x99, 0x70, 0x4f, 0xb0, 0x07, 0x88, 0x95, 0xe7, 0x6f,
1137 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 835 0xc5, 0xa9, 0x0c, 0xf6, 0x06, 0xb6, 0xa7, 0xe2, 0x11, 0xe3, 0x18, 0xed,
1138 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 836 0xbb, 0x63, 0xd2, 0x2c, 0xb0, 0x8e, 0xe6, 0x3e, 0xc9, 0x44, 0xb9, 0x22,
1139 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 837 0xa5, 0xad, 0x85, 0x67, 0x7d, 0xd8, 0xcf, 0xa4, 0xa5, 0x6c, 0xaf, 0x63,
1140 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 838 0xaf, 0x97, 0x37, 0xa0, 0x1b, 0x8c, 0xc1, 0x26, 0xf5, 0x42, 0x42, 0x8a,
1141 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 839 0x8d, 0x44, 0xc2, 0x3c, 0x31, 0xf0, 0x23, 0xcf, 0x48, 0x24, 0xf4, 0x13,
1142 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 840 0x81, 0x9d, 0x4d, 0xd6, 0x6f, 0x20, 0x56, 0x6a, 0x72, 0x74, 0xe8, 0x86,
1143 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 841 0xcf, 0x1a, 0xd8, 0xdb, 0x0b, 0x9b, 0x1b, 0x82, 0xcf, 0x80, 0x8f, 0x72,
1144 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 842 0xa3, 0xa3, 0x37, 0xe0, 0xed, 0x2b, 0x11, 0x8f, 0xa6, 0x8e, 0xdc, 0xd3,
1145 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 843 0xcb, 0xfb, 0xbe, 0x51, 0xd8, 0x90, 0x98, 0xce, 0x8f, 0x6f, 0xd1, 0xcf,
1146 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 844 0xed, 0xdf, 0x62, 0x9c, 0x2b, 0x6d, 0x01, 0x3e, 0xdd, 0xcb, 0xe3, 0xf7,
1147 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 845 0x9c, 0xc8, 0x44, 0x15, 0x3a, 0xdf, 0x03, 0x3d, 0x59, 0xf0, 0xc5, 0x3d,
1148 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 846 0xa6, 0xca, 0xd1, 0xf5, 0x3d, 0x2f, 0x6e, 0x0a, 0x70, 0xf0, 0xfd, 0x27,
1149 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 847 0x7e, 0x70, 0x86, 0x5e, 0x0e, 0xfb, 0x7e, 0x3f, 0xdc, 0x87, 0x5f, 0x45,
1150 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 848 0xb9, 0x78, 0x5e, 0x44, 0xb2, 0xad, 0x3d, 0x37, 0xb2, 0xe3, 0x25, 0x9c,
1151 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 849 0x33, 0xa7, 0x1d, 0xdf, 0x7f, 0x07, 0xcf, 0x35, 0xa7, 0xd9, 0x46, 0xde,
1152 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 850 0x7f, 0xf6, 0x31, 0x07, 0xf8, 0x2c, 0xce, 0xbd, 0xd1, 0xa6, 0xb3, 0xff,
1153 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 851 0x5e, 0xcf, 0xbd, 0x7b, 0x3f, 0xfb, 0xc9, 0xf3, 0x1d, 0x7d, 0xef, 0x03,
1154 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 852 0xce, 0xfe, 0x0f, 0x5c, 0x77, 0x0f, 0x3e, 0x1b, 0xd8, 0x6d, 0xb1, 0xd1,
1155 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 853 0x1c, 0x5f, 0xee, 0xd5, 0x7f, 0x7f, 0xad, 0xfb, 0x76, 0xff, 0xb5, 0xbb,
1156 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 854 0x6f, 0xf7, 0xdf, 0xcd, 0xdd, 0xbf, 0x18, 0xff, 0xcd, 0x01, 0x0f, 0x7d,
1157 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 855 0x70, 0xad, 0xff, 0xae, 0xe7, 0x93, 0xd4, 0xf7, 0xf3, 0x3d, 0xe5, 0xa1,
1158 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 856 0xce, 0x30, 0x1f, 0x52, 0xe7, 0xf5, 0x17, 0xa7, 0x6d, 0xef, 0x7e, 0x53,
1159 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 857 0x4a, 0xb9, 0x16, 0xc9, 0xe6, 0x6a, 0xb2, 0x43, 0x8e, 0x3b, 0x22, 0x4b,
1160 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 858 0xaa, 0x16, 0x31, 0x51, 0x8b, 0x0f, 0xa0, 0x3e, 0x0b, 0xf4, 0xba, 0xa4,
1161 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 859 0xf4, 0xf2, 0x02, 0x78, 0x89, 0xf0, 0x74, 0xdd, 0x05, 0x0f, 0x71, 0x10,
1162 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 860 0x17, 0xf1, 0x0c, 0xe2, 0x7c, 0xb7, 0xd7, 0xc1, 0x85, 0x73, 0xea, 0x25,
1163 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 861 0xd4, 0x64, 0xb6, 0xde, 0xa3, 0x07, 0x67, 0xb2, 0x5b, 0x96, 0xdd, 0xe9,
1164 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 862 0xeb, 0xf2, 0x05, 0x9e, 0x59, 0x0a, 0xae, 0xce, 0x21, 0x56, 0x0f, 0x8d,
1165 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 863 0x85, 0x75, 0xd2, 0xdc, 0x41, 0xcf, 0x8e, 0xee, 0x49, 0x78, 0x47, 0x92,
1166 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 864 0x90, 0x92, 0x9a, 0xb5, 0x04, 0x1d, 0x68, 0x72, 0x0d, 0x67, 0xd0, 0xd5,
1167 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 865 0xb9, 0x76, 0xe0, 0x45, 0xee, 0x77, 0x20, 0xbb, 0x57, 0xb4, 0x7e, 0xab,
1168 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 866 0x55, 0x6b, 0x87, 0x2f, 0x65, 0xc4, 0x55, 0x6d, 0x9e, 0xd3, 0xa7, 0x66,
1169 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 867 0x16, 0x2b, 0xc8, 0x03, 0x6d, 0x9c, 0xaf, 0x79, 0xbc, 0xd7, 0x49, 0x43,
1170 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 868 0x93, 0x2b, 0x73, 0xba, 0xfc, 0xd3, 0x9c, 0x21, 0xff, 0x8c, 0x3a, 0xf4,
1171 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 869 0x9a, 0x7d, 0x6a, 0xe6, 0xb4, 0x2d, 0xf7, 0x81, 0xd5, 0xf0, 0x0e, 0x4f,
1172 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 870 0x76, 0x9a, 0x42, 0x5b, 0x1d, 0x48, 0xff, 0x8e, 0x20, 0xff, 0xc1, 0x9a,
1173 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 871 0x2b, 0x73, 0xa4, 0xb5, 0x76, 0x8d, 0xf4, 0x22, 0x1f, 0x83, 0x5d, 0x0f,
1174 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 872 0x30, 0x27, 0xe2, 0x7c, 0xd4, 0xab, 0x03, 0xd6, 0x3e, 0xc5, 0x5b, 0x42,
1175 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 873 0x16, 0xeb, 0x9c, 0x6f, 0x82, 0xb7, 0x2e, 0x9c, 0x31, 0x59, 0x6b, 0x52,
1176 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 874 0xfe, 0xb0, 0x5b, 0xe5, 0xaa, 0x1a, 0xfb, 0x0d, 0xb5, 0xc7, 0xef, 0xef,
1177 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 875 0xe7, 0xde, 0x1b, 0x32, 0x95, 0x62, 0x9b, 0x63, 0x59, 0xd4, 0x9c, 0xc4,
1178 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 876 0x97, 0xdd, 0xeb, 0x0a, 0x79, 0x0e, 0xde, 0xaf, 0x08, 0x65, 0xdb, 0x6d,
1179 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 877 0x5d, 0x97, 0xd7, 0x7d, 0xf7, 0x00, 0xe5, 0x89, 0x72, 0x8b, 0x39, 0x9f,
1180 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 878 0xb1, 0xd8, 0x28, 0xcc, 0xc0, 0x8e, 0xbf, 0x2a, 0xdf, 0x6f, 0x1c, 0x92,
1181 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 879 0xef, 0x35, 0x26, 0xe5, 0xcf, 0x1a, 0x5f, 0x96, 0x3f, 0x6d, 0x1c, 0x94,
1182 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 880 0xd7, 0x1b, 0x07, 0xe4, 0xb5, 0xc6, 0x84, 0xbc, 0xda, 0xd8, 0x0f, 0x1b,
1183 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 881 0x1f, 0x87, 0x8d, 0x9f, 0x9a, 0x99, 0xac, 0xf7, 0xcb, 0xd4, 0x49, 0xc4,
1184 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 882 0x20, 0xe7, 0x1b, 0xba, 0xba, 0xe3, 0xb3, 0xe9, 0xe7, 0x2d, 0x32, 0xad,
1185 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 883 0xee, 0xaf, 0x34, 0xe4, 0x89, 0x2d, 0xbc, 0x2b, 0x7c, 0xc5, 0x33, 0x2e,
1186 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 884 0x87, 0xf1, 0xe8, 0xe1, 0x94, 0xb4, 0x03, 0xbf, 0xca, 0x4b, 0x4d, 0x9e,
1187 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 885 0xdb, 0x62, 0x86, 0xf7, 0x9c, 0x87, 0x24, 0xc9, 0xfb, 0xb0, 0x9c, 0x67,
1188 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 886 0xa0, 0xde, 0x5e, 0xd7, 0x27, 0x73, 0xb4, 0x65, 0xe8, 0xc6, 0x95, 0x43,
1189 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 887 0xb0, 0x53, 0xc3, 0x7e, 0xcb, 0xa5, 0x1e, 0x16, 0x97, 0x28, 0xf7, 0x46,
1190 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 888 0x59, 0x5c, 0xa0, 0x6f, 0xff, 0x1b, 0x64, 0x6c, 0x97, 0xda, 0x82, 0x89,
1191 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 889 0xb9, 0x6e, 0x98, 0xab, 0x6c, 0xa7, 0x3d, 0x00, 0x1f, 0xf1, 0x7e, 0x10,
1192 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 890 0x4e, 0xab, 0x09, 0x27, 0xf1, 0x24, 0x54, 0x0c, 0x08, 0x70, 0x5b, 0x52,
1193 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 891 0x5b, 0x4a, 0xca, 0xc2, 0x42, 0x0f, 0x9e, 0x94, 0x2c, 0xd4, 0x6d, 0x3c,
1194 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 892 0x39, 0x3c, 0x43, 0x78, 0xd2, 0xb0, 0x53, 0xca, 0xc8, 0xd8, 0x12, 0xc9,
1195 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 893 0x88, 0x78, 0x5c, 0xed, 0x0d, 0x6b, 0x2a, 0xf2, 0xa3, 0x85, 0xfc, 0x74,
1196 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 894 0x87, 0x7d, 0x1d, 0x52, 0xab, 0x38, 0x32, 0x55, 0xfd, 0x94, 0x3e, 0xa5,
1197 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 895 0x74, 0x07, 0xfc, 0x95, 0x21, 0xb4, 0xef, 0x0f, 0xdb, 0x8f, 0xca, 0xf4,
1198 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 896 0xbc, 0xc8, 0xca, 0xcb, 0x03, 0x7a, 0x51, 0xb5, 0xf7, 0xa2, 0xad, 0xa3,
1199 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 897 0x9d, 0x0d, 0xdb, 0xcc, 0x8f, 0x0e, 0xe0, 0x71, 0xd5, 0xf3, 0xf5, 0xea,
1200 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 898 0xb8, 0x3c, 0x55, 0xed, 0x77, 0x5e, 0x87, 0xcd, 0xbd, 0x65, 0x46, 0xf7,
1201 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 899 0xd2, 0x04, 0x24, 0x79, 0xf6, 0x56, 0x75, 0xf7, 0xf1, 0x04, 0xe2, 0xad,
1202 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 900 0x9b, 0x34, 0xe5, 0x6f, 0x4f, 0x64, 0xad, 0xa7, 0xf5, 0x5c, 0x52, 0xda,
1203 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 901 0x7d, 0xff, 0x71, 0x3b, 0x3b, 0x3b, 0xa9, 0x77, 0xca, 0xdf, 0xbf, 0x98,
1204 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 902 0x91, 0x85, 0xb3, 0x5b, 0x65, 0xa1, 0x06, 0x99, 0x1a, 0xbf, 0x8e, 0x7d,
1205 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 903 0x35, 0xe5, 0xea, 0x9e, 0x47, 0xb1, 0x27, 0x8c, 0x5d, 0x49, 0xe4, 0x6c,
1206 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 904 0x1b, 0xc4, 0xec, 0x25, 0x5d, 0x49, 0x98, 0x85, 0x9c, 0x1c, 0x81, 0xdf,
1207 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 905 0x4f, 0xdb, 0xb9, 0x1e, 0x69, 0xc7, 0x7b, 0x7d, 0x04, 0x7c, 0x5b, 0x32,
1208 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 906 0xd5, 0x6b, 0xc9, 0x99, 0xc1, 0x68, 0xff, 0xb6, 0x62, 0x6e, 0x46, 0x16,
1209 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 907 0xcf, 0x66, 0xf0, 0x9b, 0x83, 0xfd, 0xec, 0x94, 0x57, 0x6a, 0xfd, 0xb2,
1210 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 908 0x54, 0xdb, 0x2a, 0x8b, 0xb5, 0xe6, 0x7d, 0xe8, 0xec, 0x09, 0xe2, 0x1d,
1211 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 909 0xf1, 0xf4, 0x5b, 0x53, 0xfa, 0x56, 0x71, 0xcd, 0x7e, 0xeb, 0x29, 0xfd,
1212 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 910 0x1f, 0xe4, 0x31, 0x33, 0xa0, 0xa9, 0x17, 0x7e, 0xa4, 0xee, 0x84, 0x26,
1213 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 911 0x79, 0xf6, 0x2a, 0xbc, 0x4f, 0x26, 0x49, 0xfb, 0xf5, 0xc6, 0x07, 0xd1,
1214 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 912 0x59, 0xcb, 0xcf, 0x9d, 0x68, 0x52, 0x06, 0xe2, 0xec, 0xbf, 0x71, 0x52,
1215 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 913 0xef, 0x95, 0xe5, 0x6d, 0x0f, 0x58, 0x4f, 0xea, 0xad, 0x88, 0x01, 0x3f,
1216 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 914 0x97, 0x9f, 0xee, 0xd9, 0x24, 0x3f, 0xfc, 0xcd, 0xec, 0xa9, 0x6f, 0x22,
1217 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 915 0xd9, 0xbf, 0xb2, 0xa7, 0x83, 0x71, 0x01, 0xef, 0xec, 0xcf, 0xde, 0x70,
1218 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 916 0x75, 0xea, 0xe1, 0x2f, 0xa0, 0x87, 0xec, 0x9c, 0xba, 0x9b, 0x56, 0x3c,
1219 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 917 0x90, 0x3e, 0xf5, 0x52, 0x06, 0x6f, 0x18, 0xab, 0xf7, 0x03, 0x57, 0x59,
1220 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 918 0xe9, 0xf9, 0x09, 0x27, 0x7b, 0x03, 0xe9, 0xb0, 0xbf, 0x68, 0xf7, 0xa7,
1221 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 919 0x77, 0xea, 0x3b, 0x64, 0x32, 0xfd, 0x80, 0xf5, 0xb4, 0x6c, 0x21, 0xce,
1222 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 920 0xd9, 0x05, 0xc1, 0xda, 0x79, 0xe2, 0xfb, 0x2b, 0xe0, 0x0b, 0x70, 0x28,
1223 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 921 0xff, 0x51, 0x38, 0x77, 0x59, 0x5f, 0xd7, 0x79, 0xc6, 0x63, 0x0c, 0x71,
1224 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 922 0xe1, 0xe2, 0x10, 0x65, 0x40, 0x82, 0x95, 0xca, 0xa6, 0x5d, 0xfd, 0xc3,
1225 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 923 0xc8, 0x47, 0xfc, 0xfd, 0x56, 0x51, 0x27, 0x0f, 0xe7, 0xc0, 0xcb, 0x4f,
1226 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 924 0xc0, 0x7f, 0x3f, 0x70, 0xa2, 0xf6, 0x48, 0x47, 0x74, 0xff, 0x4e, 0xd1,
1227 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 925 0x7d, 0xad, 0x21, 0xe6, 0x2a, 0x5d, 0xf4, 0xd5, 0x75, 0xc8, 0xdd, 0x07,
1228 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 926 0x7b, 0xb5, 0xf0, 0xcb, 0xbd, 0xe9, 0x0c, 0xf7, 0x98, 0xeb, 0x22, 0xba,
1229 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 927 0x11, 0xbf, 0x5c, 0x73, 0x27, 0x1e, 0xee, 0x75, 0x3e, 0xea, 0xd4, 0x03,
1230 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 928 0x09, 0x79, 0xf7, 0x44, 0xb4, 0x37, 0x07, 0x64, 0xba, 0x0a, 0xdd, 0xed,
1231 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 929 0xea, 0x0f, 0xfc, 0x27, 0x1d, 0xf1, 0x40, 0xde, 0xff, 0x06, 0xbc, 0x07,
1232 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 930 0xb8, 0x5b, 0x0b, 0xcd, 0xba, 0xc3, 0x58, 0x3d, 0xa0, 0x31, 0xb6, 0x0e,
1233 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 931 0x4f, 0x57, 0xf6, 0x44, 0xbe, 0x98, 0x84, 0x5f, 0xed, 0xb6, 0x9e, 0x10,
1234 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 932 0xd6, 0x63, 0xc4, 0x9b, 0x94, 0x1f, 0xbe, 0x0c, 0x1e, 0x92, 0xf4, 0x93,
1235 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 933 0x7f, 0x5f, 0xe3, 0x27, 0x1c, 0xdb, 0x2a, 0x35, 0xd4, 0xd4, 0x5e, 0xde,
1236 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 934 0x94, 0x69, 0x25, 0x03, 0xda, 0x35, 0xfa, 0x77, 0x29, 0xf4, 0xef, 0x47,
1237 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 935 0x80, 0xa3, 0x5d, 0x8c, 0x47, 0x1f, 0xc7, 0x59, 0x9d, 0xcd, 0x2c, 0xeb,
1238 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 936 0xcc, 0x03, 0x76, 0x4b, 0x51, 0xdd, 0x4f, 0xdf, 0x8b, 0xee, 0xa2, 0xd8,
1239 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 937 0x94, 0x96, 0x8b, 0x95, 0x28, 0x2e, 0xa5, 0x71, 0x9e, 0xb4, 0xcb, 0xa5,
1240 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 938 0xb9, 0x28, 0xe6, 0xb5, 0xcb, 0x12, 0xf2, 0x9a, 0x95, 0x97, 0x2c, 0x8c,
1241 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 939 0x25, 0xe5, 0xe2, 0x5c, 0x12, 0x31, 0xab, 0x47, 0x56, 0xe6, 0x7a, 0x30,
1242 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 940 0x96, 0xc2, 0xba, 0x14, 0xe6, 0xdb, 0xb2, 0x52, 0xb1, 0x81, 0x27, 0x87,
1243 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 941 0x76, 0x0e, 0xed, 0x21, 0xb9, 0xa4, 0xbe, 0x17, 0x30, 0x2f, 0x18, 0x42,
1244 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 942 0xdc, 0x62, 0x5e, 0x30, 0x82, 0x18, 0x32, 0x81, 0x27, 0x8a, 0x5d, 0xa7,
1245 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 943 0x66, 0xa6, 0x2a, 0xbc, 0x73, 0x84, 0x0e, 0xac, 0x53, 0x33, 0xd3, 0xb6,
1246 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 944 0x89, 0xba, 0xed, 0x1b, 0xda, 0x54, 0x83, 0x72, 0x41, 0xb7, 0x43, 0x1d,
1247 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 945 0xa2, 0x3f, 0x4a, 0x9b, 0xe4, 0x79, 0x67, 0x20, 0xc6, 0x77, 0x01, 0x9f,
1248 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 946 0x23, 0xfa, 0x6f, 0xd0, 0x17, 0xa0, 0xc3, 0x27, 0xba, 0xe4, 0xd2, 0xcb,
1249 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 947 0x8c, 0x35, 0xae, 0xbc, 0x7a, 0x96, 0x3a, 0x2c, 0xf6, 0xac, 0xea, 0x90,
1250 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 948 0x63, 0x0f, 0xe1, 0x8c, 0xd8, 0x0f, 0x7b, 0x32, 0x33, 0x87, 0x90, 0xcb,
1251 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 949 0x7c, 0x1b, 0xf6, 0x59, 0x66, 0xcd, 0x9d, 0x0e, 0x6a, 0x84, 0x20, 0x06,
1252 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 950 0xa0, 0xdd, 0x47, 0x5d, 0xb1, 0xdd, 0x07, 0xbb, 0xe3, 0x58, 0x9f, 0x1a,
1253 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 951 0x5b, 0x04, 0x8e, 0x60, 0x8c, 0xed, 0xcd, 0xb2, 0xa8, 0xc6, 0x0e, 0xaa,
1254 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 952 0xb1, 0xb2, 0xb2, 0x0f, 0x8e, 0x1d, 0x52, 0xb1, 0xe9, 0x7c, 0x23, 0xea,
1255 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 953 0xdf, 0x88, 0x58, 0xc2, 0x7e, 0xf6, 0xe5, 0x61, 0xeb, 0x7b, 0x71, 0xae,
1256 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 954 0x15, 0x64, 0xa9, 0x81, 0x3a, 0x30, 0xff, 0x7b, 0x98, 0xcb, 0x3d, 0xc8,
1257 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 955 0x9e, 0x2a, 0xe9, 0xe4, 0xf1, 0x20, 0xce, 0x83, 0xfd, 0x21, 0xad, 0xb6,
1258 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 956 0x90, 0xaf, 0x03, 0x61, 0xbb, 0x25, 0xa4, 0x4d, 0x3c, 0x36, 0x70, 0x1c,
1259 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 957 0xc3, 0x5a, 0x17, 0x38, 0x18, 0x63, 0x11, 0x23, 0x52, 0x29, 0xe8, 0x82,
1260 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 958 0x34, 0xdb, 0xa4, 0xac, 0xde, 0xf7, 0xc3, 0x76, 0xb9, 0x16, 0x3a, 0xb4,
1261 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 959 0xa2, 0x75, 0xa5, 0x70, 0xcf, 0x53, 0xea, 0x9c, 0xd1, 0x93, 0x9b, 0xc3,
1262 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 960 0x9c, 0x10, 0x7a, 0x45, 0x9c, 0xd5, 0x93, 0x8c, 0x37, 0xef, 0x84, 0x76,
1263 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 961 0xda, 0x8b, 0xbe, 0x87, 0x44, 0xef, 0x65, 0xdf, 0x51, 0xe0, 0x61, 0xed,
1264 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 962 0x3c, 0x0c, 0x99, 0xd9, 0xe6, 0xfa, 0x6c, 0xd3, 0xfa, 0xc4, 0x3a, 0xeb,
1265 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 963 0x3b, 0x9a, 0xfa, 0x32, 0x52, 0x9b, 0xef, 0x52, 0xf1, 0xf2, 0x7c, 0x18,
1266 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 964 0x2f, 0x17, 0x6b, 0x94, 0x05, 0x7e, 0x96, 0x7f, 0x5b, 0xe9, 0xa2, 0x76,
1267 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 965 0x36, 0xb0, 0xf5, 0xa5, 0x93, 0x3c, 0x17, 0x57, 0xe7, 0xd5, 0xd4, 0xbc,
1268 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 966 0xdf, 0x06, 0xff, 0xba, 0x1c, 0x55, 0x32, 0x70, 0x3e, 0xe6, 0xd5, 0x02,
1269 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 967 0xbf, 0x31, 0x6c, 0xce, 0xa1, 0x8f, 0x44, 0x6b, 0x38, 0xff, 0xe7, 0xa8,
1270 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 968 0x55, 0xbe, 0xac, 0xd6, 0xac, 0xfa, 0x0c, 0xf9, 0x71, 0x42, 0x9e, 0x7b,
1271 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 969 0xc0, 0x5f, 0x67, 0x28, 0x43, 0x7b, 0x28, 0x03, 0xf1, 0xfd, 0x27, 0x70,
1272 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 970 0xb7, 0x61, 0x1e, 0x79, 0xdd, 0x86, 0x3e, 0xbe, 0xff, 0x17, 0xfa, 0x76,
1273 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 971 0x23, 0xff, 0x23, 0x6f, 0x89, 0x26, 0xde, 0xfe, 0x03, 0x63, 0x3d, 0x4a,
1274 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 972 0xb7, 0x35, 0xd4, 0x26, 0x53, 0xbc, 0xef, 0x48, 0xe1, 0x1c, 0x38, 0xb9,
1275 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 973 0x4d, 0xd1, 0xad, 0x9d, 0xbd, 0x86, 0xf1, 0x5e, 0xac, 0x89, 0xda, 0xcd,
1276 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 974 0xb2, 0xe9, 0x58, 0xfb, 0x53, 0x25, 0xcf, 0x62, 0xed, 0x4e, 0xf2, 0x6f,
1277 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 975 0x5b, 0x23, 0x3b, 0xe5, 0x26, 0x4f, 0xe4, 0xa7, 0x1f, 0x4f, 0x2b, 0x72,
1278 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 976 0x21, 0xd8, 0x6d, 0xd2, 0x90, 0xd1, 0x7c, 0x9a, 0xdf, 0xf9, 0x12, 0xbc,
1279 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 977 0x17, 0x1d, 0x19, 0xe4, 0x9e, 0xa1, 0xdd, 0x60, 0x4e, 0x47, 0x7f, 0x4b,
1280 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 978 0xc8, 0x31, 0xd4, 0x24, 0xe5, 0x85, 0x8c, 0x56, 0x3c, 0x99, 0x45, 0x16,
1281 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 979 0xad, 0xbe, 0xd5, 0xc9, 0x8b, 0x4b, 0xb6, 0x7c, 0x1b, 0x7e, 0x7a, 0xb2,
1282 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 980 0x9e, 0x4d, 0x7f, 0x13, 0xf9, 0xc1, 0x91, 0x25, 0xe6, 0x13, 0x3d, 0x29,
1283 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 981 0x65, 0x9b, 0xf3, 0x9a, 0x6c, 0x60, 0x4c, 0x9b, 0x47, 0x7e, 0x6a, 0xdd,
1284 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 982 0x2d, 0x47, 0x82, 0x9f, 0x57, 0xd7, 0xc6, 0x0c, 0xca, 0xb1, 0x36, 0x66,
1285 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 983 0x10, 0x0f, 0x63, 0xc6, 0x4e, 0xec, 0x13, 0x63, 0x06, 0xf6, 0xff, 0x24,
1286 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 984 0x63, 0x86, 0x8d, 0x75, 0x8c, 0x19, 0x79, 0x59, 0xac, 0x32, 0x66, 0xec,
1287 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 985 0x45, 0x9b, 0x31, 0xa3, 0x80, 0x76, 0x10, 0x2f, 0x16, 0x55, 0xbc, 0xc8,
1288 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 986 0x5a, 0xcb, 0xc2, 0x38, 0x81, 0x3c, 0xb1, 0x8a, 0x3c, 0xb1, 0x8a, 0x3c,
1289 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 987 0xb1, 0x8a, 0x3c, 0xb1, 0x8a, 0x3c, 0x11, 0xb6, 0xfe, 0x5a, 0x15, 0x79,
1290 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 988 0x22, 0xfc, 0xe7, 0x3c, 0x72, 0x92, 0xa0, 0xa6, 0x38, 0x8c, 0x9a, 0xc2,
1291 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 989 0xd5, 0xc6, 0xaa, 0xe3, 0xda, 0xbe, 0x2a, 0x6a, 0x43, 0xf5, 0x9d, 0x58,
1292 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 990 0x1f, 0xda, 0x80, 0xba, 0xa8, 0xe6, 0x6c, 0x01, 0x5f, 0xd7, 0xe0, 0x1b,
1293 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 991 0xd4, 0xd3, 0x56, 0x99, 0xca, 0xed, 0x80, 0x7c, 0xd8, 0x7f, 0xfb, 0xfb,
1294 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 992 0xe8, 0x43, 0x3e, 0x9f, 0x63, 0x0d, 0xc2, 0x78, 0xb5, 0x0f, 0x6d, 0x1d,
1295 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 993 0x6d, 0xec, 0xe9, 0x04, 0x7c, 0xc4, 0x7e, 0x90, 0xf9, 0x62, 0x7a, 0x41,
1296 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 994 0x9e, 0xdc, 0x1c, 0xd8, 0xf4, 0x6f, 0x31, 0x27, 0x5e, 0xd3, 0xde, 0x88,
1297 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 995 0x39, 0xf0, 0x17, 0xd8, 0x97, 0x5a, 0x03, 0x5c, 0xba, 0xfd, 0xe7, 0xc4,
1298 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 996 0xd1, 0xb7, 0xe1, 0xd6, 0x1c, 0xda, 0xd5, 0xf7, 0x9a, 0xfa, 0xb2, 0x98,
1299 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 997 0xcf, 0xef, 0xe2, 0x3b, 0xf0, 0xfb, 0x16, 0x7e, 0x61, 0x77, 0xf6, 0x05,
1300 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 998 0xcc, 0xe9, 0xc3, 0xef, 0x77, 0x9a, 0xe6, 0x42, 0x0a, 0xfb, 0x2f, 0xd1,
1301 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 999 0x77, 0x31, 0xa4, 0xc1, 0x6f, 0x89, 0x5f, 0x6a, 0xe2, 0xe3, 0x07, 0xe8,
1302 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1000 0xfb, 0x6b, 0xf4, 0xf9, 0xfe, 0xdb, 0x4e, 0xd4, 0x27, 0xa5, 0x96, 0x70,
1303 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1001 0xef, 0x46, 0xd5, 0xde, 0x69, 0xca, 0xe6, 0x8f, 0x2c, 0xe9, 0xaa, 0x0e,
1304 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1002 0x7a, 0xae, 0x8e, 0xea, 0x08, 0x71, 0xbe, 0xbc, 0x10, 0xd4, 0xad, 0xc7,
1305 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1003 0x51, 0x73, 0x16, 0xab, 0xb4, 0x91, 0x1c, 0xfa, 0x6d, 0x9c, 0x69, 0x32,
1306 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1004 0x69, 0xdc, 0xaa, 0x63, 0x13, 0x89, 0xc9, 0x7a, 0x9b, 0x48, 0x37, 0x69,
1307 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1005 0x32, 0x4f, 0x22, 0x8e, 0xd9, 0x99, 0xe2, 0xc2, 0xec, 0x8c, 0x07, 0x9c,
1308 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1006 0x63, 0x75, 0xae, 0xe5, 0x3c, 0x93, 0xf7, 0x63, 0x4d, 0x74, 0x69, 0x13,
1309 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1007 0x60, 0x06, 0xf4, 0x9e, 0xab, 0x93, 0x7e, 0x40, 0xb3, 0xac, 0x68, 0xda,
1310 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1008 0xe8, 0x8f, 0xea, 0xc7, 0x1c, 0x6a, 0x5d, 0x99, 0x64, 0xed, 0x5c, 0x0c,
1311 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1009 0x69, 0xba, 0x75, 0x49, 0x24, 0x0a, 0xcd, 0xf8, 0x82, 0x8c, 0xf3, 0xb9,
1312 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1010 0xfa, 0xec, 0x8c, 0xfe, 0x42, 0x36, 0xc7, 0x3b, 0x11, 0xd7, 0x9a, 0x9d,
1313 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1011 0x69, 0x1d, 0x48, 0xc8, 0x8f, 0x91, 0xbb, 0x1d, 0x53, 0x34, 0x66, 0x67,
1314 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1012 0x8c, 0x17, 0x02, 0x5b, 0x0c, 0xe8, 0xe0, 0x3c, 0xc9, 0xb7, 0x43, 0x4e,
1315 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1013 0xd2, 0x62, 0x4d, 0x1d, 0x8c, 0x4f, 0xaa, 0x7a, 0xd1, 0x94, 0x2b, 0x15,
1316 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1014 0x45, 0x3b, 0xac, 0xdb, 0xc9, 0xc3, 0xec, 0x8c, 0xfc, 0xd1, 0x2d, 0x1e,
1317 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1015 0xd6, 0x91, 0x87, 0x78, 0x49, 0x27, 0xd0, 0x5b, 0xc0, 0x7f, 0x12, 0xf5,
1318 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1016 0x7b, 0x54, 0xab, 0xfb, 0xfe, 0x8a, 0x93, 0x43, 0x5c, 0xe0, 0x3e, 0xb6,
1319 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1017 0xa8, 0x3c, 0xd7, 0x73, 0x32, 0xbc, 0xef, 0x9b, 0xe3, 0xdf, 0x39, 0x78,
1320 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1018 0xf9, 0x01, 0xd4, 0x4d, 0xbc, 0x1b, 0xa4, 0x7f, 0xe1, 0xf7, 0x36, 0xff,
1321 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1019 0xe2, 0x7c, 0xf6, 0x93, 0xe7, 0x81, 0xf4, 0x55, 0xf0, 0xe7, 0xe5, 0xd1,
1322 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1020 0x87, 0x58, 0x51, 0x6c, 0x44, 0xb8, 0x78, 0xc7, 0xce, 0x39, 0x2a, 0xff,
1323 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1021 0x6e, 0xf2, 0xd1, 0x96, 0xf0, 0xdc, 0xa5, 0x8e, 0xc8, 0x27, 0xf9, 0xe9,
1324 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1022 0x84, 0x4d, 0x90, 0x17, 0xce, 0x8f, 0xee, 0x25, 0xd8, 0xfe, 0xb8, 0x36,
1325 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1023 0x12, 0xdd, 0xa9, 0x7d, 0x9c, 0x3d, 0x8f, 0x74, 0x76, 0x37, 0x7e, 0x88,
1326 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1024 0x83, 0xb4, 0x23, 0xbe, 0x22, 0x9e, 0x88, 0x8f, 0xfc, 0x44, 0xbc, 0x28,
1327 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1025 0x1b, 0x5d, 0x97, 0x9f, 0x60, 0x5d, 0xc0, 0x4f, 0x69, 0x21, 0x0d, 0x9d,
1328 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1026 0x90, 0xa7, 0x11, 0x6d, 0xa4, 0xba, 0xde, 0x1d, 0xc7, 0x0f, 0x5c, 0xc6,
1329 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1027 0xd5, 0xb1, 0x06, 0xef, 0xa1, 0x48, 0x97, 0x7f, 0x3b, 0xb2, 0xa4, 0x8d,
1330 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1028 0x34, 0xf8, 0x9d, 0xa9, 0xae, 0xb9, 0x8d, 0x88, 0xde, 0x5a, 0x9d, 0x46,
1331 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1029 0xbf, 0xbc, 0x2b, 0xff, 0x0c, 0xf6, 0xa9, 0x3b, 0xf8, 0xbb, 0x14, 0x55,
1332 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1030 0x47, 0xb1, 0x6f, 0xb9, 0xd5, 0x73, 0xa2, 0xbf, 0xd3, 0xd9, 0x1f, 0xe6,
1333 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1031 0x43, 0x51, 0x6d, 0x1c, 0xd5, 0x59, 0xea, 0x9e, 0x7d, 0xaf, 0xe7, 0x68,
1334 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1032 0xc8, 0x4f, 0x99, 0x33, 0x05, 0x3a, 0x08, 0xf1, 0xde, 0x91, 0xcf, 0x91,
1335 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1033 0x26, 0x3e, 0x47, 0xc1, 0xe7, 0x3e, 0xf0, 0x39, 0x76, 0x8b, 0xcf, 0x5b,
1336 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1034 0xb6, 0x97, 0x29, 0xc3, 0xf6, 0x46, 0xd6, 0xb5, 0xbd, 0x55, 0x3a, 0xab,
1337 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1035 0x73, 0x83, 0xfb, 0x9a, 0x91, 0x86, 0x2f, 0xc7, 0x9d, 0x8f, 0x53, 0x37,
1338 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1036 0xb7, 0xcb, 0x99, 0x85, 0xbb, 0xd5, 0xb7, 0x11, 0xaf, 0x2a, 0x77, 0x94,
1339 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1037 0x4b, 0xf5, 0x80, 0x9f, 0x1f, 0x2f, 0xb1, 0x3d, 0x12, 0xea, 0x8a, 0x3a,
1340 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1038 0xcb, 0x3a, 0x25, 0xb9, 0x1b, 0x2f, 0xbf, 0xf8, 0x9c, 0x76, 0xa5, 0x12,
1341 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1039 0x9d, 0x4f, 0x5a, 0x78, 0xc6, 0xae, 0xe5, 0x29, 0xfa, 0x6e, 0x32, 0x66,
1342 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1040 0x45, 0xf7, 0x67, 0x22, 0xfc, 0xfe, 0xc0, 0xef, 0x75, 0x6b, 0xbf, 0x13,
1343 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1041 0xf0, 0x7c, 0x8a, 0x78, 0xd7, 0x53, 0x3c, 0x9f, 0xc6, 0x9c, 0x66, 0x19,
1344 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1042 0x5c, 0xd8, 0xa4, 0x9e, 0xe4, 0x98, 0xe7, 0xd0, 0x2f, 0x4c, 0xd0, 0x0c,
1345 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1043 0xee, 0xdd, 0x6a, 0x4b, 0xbe, 0x5c, 0x74, 0x36, 0x06, 0xe7, 0x28, 0x64,
1346 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1044 0xba, 0x6c, 0xf1, 0xfe, 0x0a, 0x31, 0x8c, 0x67, 0x83, 0xb2, 0xb5, 0x16,
1347 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1045 0xf5, 0x5c, 0x39, 0xd0, 0x0e, 0x1d, 0xb3, 0xdd, 0xd6, 0xcb, 0xfb, 0x0a,
1348 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1046 0xca, 0xbc, 0xa0, 0xf6, 0x21, 0xd2, 0x71, 0xf4, 0x7d, 0xae, 0x55, 0x96,
1349 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1047 0xc3, 0xbb, 0xad, 0xc5, 0x8a, 0xef, 0xbf, 0x83, 0x3c, 0xfc, 0x34, 0x74,
1350 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1048 0x5f, 0xae, 0xff, 0xcc, 0x5f, 0x4e, 0xf1, 0x6f, 0xa5, 0x22, 0x9b, 0xd8,
1351 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1049 0xd1, 0xcb, 0x7b, 0x20, 0xf8, 0x96, 0x1c, 0xaf, 0x87, 0x65, 0xbf, 0x70,
1352 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1050 0x9c, 0x7d, 0xff, 0x0d, 0xbe, 0x7d, 0xff, 0xf4, 0xaa, 0x9d, 0x02, 0xfe,
1353 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1051 0x17, 0x33, 0xe1, 0x9b, 0xdd, 0x90, 0x58, 0x00, 0x00, 0x00 };
1354 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1355 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1356 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1357 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1358 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1359 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1360 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1361 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1362 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1363 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1364 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1365 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1366 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1367 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1368 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1369 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1370 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1371 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1372 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1373 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1374 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1375 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1376 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1377 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1378 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1379 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1380 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1381 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1382 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1383 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1384 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1385 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1386 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1387 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1388 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1389 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1390 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1391 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1392 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1393 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1394 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1395 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1396 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1397 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1398 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1399 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1400 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1401 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1402 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1403 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1404 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1405 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1406 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1407 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1408 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1409 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1410 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1411 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1412 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1413 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1414 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1415 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1416 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1417 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1418 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1419 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1420 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1421 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1422 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1423 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1424 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1425 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1426 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1427 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1428 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1429 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1430 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1431 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1432 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1433 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1434 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1435 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1436 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1437 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1438 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1439 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1440 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1441 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1442 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1443 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1444 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1445 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1446 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1447 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1448 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1449 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1450 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1451 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1452 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1453 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1454 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1455 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1456 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1457 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1458 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1459 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1460 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1461 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1462 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1463 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1464 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1465 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1466 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1467 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1468 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1469 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1470 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1471 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1472 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1473 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1474 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1475 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1476 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1477 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1478 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1479 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1480 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1481 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1482 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1483 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1484 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1485 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1486 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1487 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1488 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1489 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1490 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1491 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1492 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1493 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1494 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1495 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1496 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1497 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1498 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1499 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1500 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1501 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1502 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1503 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1504 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1505 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1506 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1507 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1508 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1509 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1510 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1511 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1512 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1513 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1514 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1515 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1516 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1517 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1518 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1519 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1520 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1521 0x00000000, 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d,
1522 0x3c020800, 0x244258e0, 0x3c030800, 0x24636ca4, 0xac400000, 0x0043202b,
1523 0x1480fffd, 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800,
1524 0x26103184, 0x3c1c0800, 0x279c58e0, 0x0e00104a, 0x00000000, 0x0000000d,
1525 0x27bdffe8, 0xafb00010, 0xafbf0014, 0x0e000f1d, 0x00808021, 0x1440000d,
1526 0x00000000, 0x8f820010, 0x10400005, 0x00000000, 0x9743011c, 0x9742011e,
1527 0x0a000c89, 0x00021400, 0x9743011e, 0x9742011c, 0x00021400, 0x00621825,
1528 0xaf830004, 0x8f840008, 0x3c020020, 0x34424000, 0x00821824, 0x54620004,
1529 0x3c020020, 0x8f820014, 0x0a000c9a, 0x34421000, 0x34428000, 0x00821824,
1530 0x14620004, 0x00000000, 0x8f820014, 0x34428000, 0xaf820014, 0x8f820008,
1531 0x9743010c, 0x00403021, 0x30421000, 0x10400010, 0x3069ffff, 0x30c20020,
1532 0x1440000e, 0x24070005, 0x3c021000, 0x00c21024, 0x10400009, 0x3c030dff,
1533 0x3463ffff, 0x3c020e00, 0x00c21024, 0x0062182b, 0x50600004, 0x24070001,
1534 0x0a000cb2, 0x3c020800, 0x24070001, 0x3c020800, 0x8c430034, 0x1460001d,
1535 0x00405821, 0x8f820014, 0x30424000, 0x1440001a, 0x3c020001, 0x3c021f01,
1536 0x00c24024, 0x3c031000, 0x15030015, 0x3c020001, 0x31220200, 0x14400012,
1537 0x3c020001, 0x9744010e, 0x24020003, 0xa342018b, 0x97850016, 0x24020002,
1538 0x34e30002, 0xaf400180, 0xa742018c, 0xa7430188, 0x24840004, 0x30a5bfff,
1539 0xa744018e, 0xa74501a6, 0xaf4801b8, 0x0a000f19, 0x00001021, 0x3c020001,
1540 0x00c21024, 0x1040002f, 0x00000000, 0x9742010e, 0x3c038000, 0x3046ffff,
1541 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9784000a,
1542 0x8f850004, 0x8f870014, 0x24020080, 0x24030002, 0xaf420180, 0x24020003,
1543 0xa743018c, 0xa746018e, 0xa7420188, 0x30e28000, 0xa7440190, 0x1040000c,
1544 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000,
1545 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00e21024, 0xaf820014,
1546 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff,
1547 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x0a000f19,
1548 0x00001021, 0x8f820014, 0x30434000, 0x10600016, 0x00404021, 0x3c020f00,
1549 0x00c21024, 0x14400012, 0x00000000, 0x93420116, 0x34424000, 0x03421821,
1550 0x94650002, 0x2ca21389, 0x1040000b, 0x3c020800, 0x24425900, 0x00051942,
1551 0x00031880, 0x00621821, 0x30a5001f, 0x8c640000, 0x24020001, 0x00a21004,
1552 0x00822024, 0x02048025, 0x12000030, 0x3c021000, 0x9742010e, 0x34e80002,
1553 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1554 0x24020003, 0xa342018b, 0x9784000a, 0x8f850004, 0x8f870014, 0x24020180,
1555 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0xa7480188, 0x30e28000,
1556 0xa7440190, 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021,
1557 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
1558 0x00e21024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff,
1559 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
1560 0xaf4201b8, 0x0a000f19, 0x00001021, 0x00c21024, 0x104000c0, 0x3c020800,
1561 0x8c430030, 0x10600037, 0x31024000, 0x10400035, 0x3c030f00, 0x00c31824,
1562 0x3c020100, 0x0043102b, 0x14400031, 0x3c030800, 0x9742010e, 0x34e80002,
1563 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1564 0x24020003, 0xa342018b, 0x9784000a, 0x8f850004, 0x8f870014, 0x24020080,
1565 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0xa7480188, 0x30e28000,
1566 0xa7440190, 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021,
1567 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
1568 0x00e21024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff,
1569 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
1570 0xaf4201b8, 0x0a000f19, 0x00001021, 0x3c030800, 0x8c620024, 0x30420008,
1571 0x10400035, 0x34ea0002, 0x3c020f00, 0x00c21024, 0x14400032, 0x8d620034,
1572 0x31220200, 0x1040002f, 0x8d620034, 0x9742010e, 0x30e8fffb, 0x3c038000,
1573 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1574 0xa342018b, 0x9784000a, 0x8f850004, 0x8f870014, 0x24020180, 0x24030002,
1575 0xaf420180, 0xa743018c, 0xa746018e, 0xa7480188, 0x30e28000, 0xa7440190,
1576 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1577 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00e21024,
1578 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1579 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1580 0x8d620034, 0x8f860008, 0x10400012, 0x30c20100, 0x10400010, 0x3c020f00,
1581 0x00c21024, 0x3c030200, 0x1043000c, 0x3c020800, 0x8c430038, 0x8f840004,
1582 0x3c020800, 0x2442003c, 0x2463ffff, 0x00832024, 0x00822021, 0x90830000,
1583 0x24630004, 0x0a000de1, 0x000329c0, 0x00000000, 0x00061602, 0x3042000f,
1584 0x000229c0, 0x3c04fc00, 0x00441021, 0x3c030300, 0x0062182b, 0x50600001,
1585 0x24050800, 0x9742010e, 0x3148ffff, 0x3c038000, 0x24420004, 0x3046ffff,
1586 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9783000a,
1587 0x8f840004, 0x8f870014, 0x24020002, 0xaf450180, 0xa742018c, 0xa746018e,
1588 0xa7480188, 0x30e28000, 0xa7430190, 0x1040000c, 0xaf4401a8, 0x93420116,
1589 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004,
1590 0x3c02ffff, 0x34427fff, 0x00e21024, 0xaf820014, 0x97820016, 0x9743010c,
1591 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
1592 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x0a000f19, 0x00001021, 0x8f424000,
1593 0x30420100, 0x104000d5, 0x3c020800, 0x8c440024, 0x24030001, 0x1483002f,
1594 0x00405021, 0x9742010e, 0x34e70002, 0x3c038000, 0x24420004, 0x3045ffff,
1595 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9783000a,
1596 0x8f840004, 0x8f860014, 0x24020002, 0xaf400180, 0xa742018c, 0xa745018e,
1597 0xa7470188, 0x30c28000, 0xa7430190, 0x1040000c, 0xaf4401a8, 0x93420116,
1598 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004,
1599 0x3c02ffff, 0x34427fff, 0x00c21024, 0xaf820014, 0x97820016, 0x9743010c,
1600 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6,
1601 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x0a000f19, 0x00001021, 0x30820001,
1602 0x1040002e, 0x30eb0004, 0x9742010e, 0x30e9fffb, 0x3c038000, 0x24420004,
1603 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b,
1604 0x9783000a, 0x8f840004, 0x8f860014, 0x24020002, 0xaf400180, 0xa742018c,
1605 0xa745018e, 0xa7470188, 0x30c28000, 0xa7430190, 0x1040000c, 0xaf4401a8,
1606 0x93420116, 0x304200fc, 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff,
1607 0x14600004, 0x3c02ffff, 0x34427fff, 0x00c21024, 0xaf820014, 0x97820016,
1608 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825,
1609 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8, 0x3127ffff, 0x8d420024,
1610 0x30420004, 0x10400030, 0x8d420024, 0x9742010e, 0x30e9fffb, 0x3c038000,
1611 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003,
1612 0xa342018b, 0x9784000a, 0x8f850004, 0x8f880014, 0x24020100, 0x24030002,
1613 0xaf420180, 0xa743018c, 0xa746018e, 0xa7470188, 0x31028000, 0xa7440190,
1614 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1615 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x01021024,
1616 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1617 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1618 0x3127ffff, 0x8d420024, 0x30420008, 0x1040002d, 0x00000000, 0x9742010e,
1619 0x3c038000, 0x24420004, 0x3046ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1620 0x24020003, 0xa342018b, 0x9784000a, 0x8f850004, 0x8f880014, 0x24020180,
1621 0x24030002, 0xaf420180, 0xa743018c, 0xa746018e, 0xa7470188, 0x31028000,
1622 0xa7440190, 0x1040000c, 0xaf4501a8, 0x93420116, 0x304200fc, 0x005a1021,
1623 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff,
1624 0x01021024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff,
1625 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000,
1626 0xaf4201b8, 0x15600041, 0x00001021, 0x27440180, 0x3c038000, 0x8f4201b8,
1627 0x00431024, 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008, 0xa083000b,
1628 0xa4800010, 0x3c021000, 0xaf4201b8, 0x0a000f19, 0x00001021, 0x3c030800,
1629 0x8c620024, 0x30420001, 0x1040002e, 0x00001021, 0x9742010e, 0x34e70002,
1630 0x3c038000, 0x24420004, 0x3045ffff, 0x8f4201b8, 0x00431024, 0x1440fffd,
1631 0x24020003, 0xa342018b, 0x9783000a, 0x8f840004, 0x8f860014, 0x24020002,
1632 0xaf400180, 0xa742018c, 0xa745018e, 0xa7470188, 0x30c28000, 0xa7430190,
1633 0x1040000c, 0xaf4401a8, 0x93420116, 0x304200fc, 0x005a1021, 0x24424004,
1634 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff, 0x34427fff, 0x00c21024,
1635 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104, 0x3042bfff, 0x00031c00,
1636 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac, 0x3c021000, 0xaf4201b8,
1637 0x00001021, 0x8fbf0014, 0x8fb00010, 0x03e00008, 0x27bd0018, 0x8f4b0070,
1638 0x93420112, 0x8f840008, 0x00022882, 0x30820100, 0x14400003, 0x24a30003,
1639 0x03e00008, 0x00001021, 0x30824000, 0x10400010, 0x27424000, 0x00031880,
1640 0x00431021, 0x8c470000, 0x24a30004, 0x00031880, 0x27424000, 0x00431021,
1641 0x8c490000, 0x93430116, 0x27424000, 0x306300fc, 0x00431021, 0x8c4a0000,
1642 0x0a000f45, 0x3c030800, 0x30822000, 0x1040ffea, 0x00031880, 0x27424000,
1643 0x00431021, 0x8c470000, 0x24a30004, 0x00031880, 0x27424000, 0x00431021,
1644 0x8c490000, 0x00005021, 0x3c030800, 0x24680100, 0x00071602, 0x00021080,
1645 0x00481021, 0x8c460000, 0x00071b82, 0x306303fc, 0x01031821, 0x8c640400,
1646 0x00071182, 0x304203fc, 0x01021021, 0x8c450800, 0x30e300ff, 0x00031880,
1647 0x01031821, 0x00091602, 0x00021080, 0x01021021, 0x00c43026, 0x8c640c00,
1648 0x8c431000, 0x00c53026, 0x00091382, 0x304203fc, 0x01021021, 0x8c451400,
1649 0x312200ff, 0x00021080, 0x01021021, 0x00c43026, 0x00c33026, 0x00091982,
1650 0x306303fc, 0x01031821, 0x8c641800, 0x8c431c00, 0x00c53026, 0x00c43026,
1651 0x11400015, 0x00c33026, 0x000a1602, 0x00021080, 0x01021021, 0x8c432000,
1652 0x000a1382, 0x304203fc, 0x01021021, 0x8c452400, 0x314200ff, 0x00021080,
1653 0x01021021, 0x00c33026, 0x000a1982, 0x306303fc, 0x01031821, 0x8c642800,
1654 0x8c432c00, 0x00c53026, 0x00c43026, 0x00c33026, 0x8f430070, 0x3c050800,
1655 0x8ca43100, 0x2c820020, 0x10400008, 0x006b5823, 0x3c020800, 0x24423104,
1656 0x00041880, 0x00621821, 0x24820001, 0xac6b0000, 0xaca23100, 0xaf860004,
1657 0x03e00008, 0x24020001, 0x27bdffe8, 0xafbf0010, 0x8f460128, 0x8f840010,
1658 0xaf460020, 0x8f450104, 0x8f420100, 0x24030800, 0xaf850008, 0xaf820014,
1659 0xaf4301b8, 0x1080000a, 0x3c020800, 0x8c430034, 0x10600007, 0x30a22000,
1660 0x10400005, 0x34a30100, 0x8f82000c, 0xaf830008, 0x24420001, 0xaf82000c,
1661 0x3c020800, 0x8c4300c0, 0x10600006, 0x3c030800, 0x8c6200c4, 0x24040001,
1662 0x24420001, 0x0a000fd5, 0xac6200c4, 0x8f820008, 0x3c030010, 0x00431024,
1663 0x14400009, 0x3c02001f, 0x3c030800, 0x8c620020, 0x00002021, 0x24420001,
1664 0x0e000c78, 0xac620020, 0x0a000fd5, 0x00402021, 0x3442ff00, 0x14c20009,
1665 0x2403bfff, 0x3c030800, 0x8c620020, 0x24040001, 0x24420001, 0x0e000c78,
1666 0xac620020, 0x0a000fd5, 0x00402021, 0x8f820014, 0x00431024, 0x14400006,
1667 0x00000000, 0xaf400048, 0x0e0011a9, 0xaf400040, 0x0a000fd5, 0x00402021,
1668 0x0e001563, 0x00000000, 0x00402021, 0x10800005, 0x3c024000, 0x8f430124,
1669 0x3c026020, 0xac430014, 0x3c024000, 0xaf420138, 0x00000000, 0x8fbf0010,
1670 0x03e00008, 0x27bd0018, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0xafb00010,
1671 0x8f420140, 0xaf420020, 0x8f430148, 0x3c027000, 0x00621824, 0x3c023000,
1672 0x10620021, 0x0043102b, 0x14400006, 0x3c024000, 0x3c022000, 0x10620009,
1673 0x3c024000, 0x0a001040, 0x00000000, 0x10620045, 0x3c025000, 0x10620047,
1674 0x3c024000, 0x0a001040, 0x00000000, 0x27440180, 0x3c038000, 0x8f4201b8,
1675 0x00431024, 0x1440fffd, 0x00000000, 0x8f420148, 0x24030002, 0xa083000b,
1676 0x00021402, 0xa4820008, 0x8f430148, 0xa4830010, 0x8f420144, 0x3c031000,
1677 0xac820024, 0xaf4301b8, 0x0a001040, 0x3c024000, 0x8f420148, 0x24030002,
1678 0x3044ffff, 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003,
1679 0x10400005, 0x24020003, 0x0600001d, 0x36053000, 0x0a001027, 0x3c038000,
1680 0x12020007, 0x00000000, 0x0a001034, 0x00000000, 0x0e00112c, 0x00000000,
1681 0x0a001025, 0x00402021, 0x0e00113e, 0x00000000, 0x00402021, 0x36053000,
1682 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008,
1683 0xa222000b, 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8,
1684 0x0a001040, 0x3c024000, 0x0000000d, 0x00000000, 0x240002bf, 0x0a001040,
1685 0x3c024000, 0x0e001441, 0x00000000, 0x0a001040, 0x3c024000, 0x0e0015ea,
1686 0x00000000, 0x3c024000, 0xaf420178, 0x00000000, 0x8fbf0018, 0x8fb10014,
1687 0x8fb00010, 0x03e00008, 0x27bd0020, 0x24020800, 0x03e00008, 0xaf4201b8,
1688 0x27bdffe8, 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000,
1689 0x2403ff7f, 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000,
1690 0x3c020008, 0xaf430008, 0x8e040808, 0x0342d825, 0x8e020808, 0x3c030800,
1691 0xac600020, 0x3084fff0, 0x2c840001, 0x3042fff0, 0x38420010, 0x2c420001,
1692 0xaf840010, 0xaf820000, 0x0e00160c, 0x00000000, 0x0e001561, 0x00000000,
1693 0x3c020400, 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c,
1694 0x8e021980, 0x34420200, 0xae021980, 0x8f500000, 0x32020003, 0x1040fffd,
1695 0x32020001, 0x10400004, 0x32020002, 0x0e000f92, 0x00000000, 0x32020002,
1696 0x1040fff6, 0x00000000, 0x0e000fe0, 0x00000000, 0x0a001071, 0x00000000,
1697 0x27bdffe8, 0x3c04600c, 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000,
1698 0x2403ff7f, 0x3c106000, 0x00431024, 0x3442380c, 0x24030003, 0xac825000,
1699 0x3c020008, 0xaf430008, 0x8e040808, 0x0342d825, 0x8e020808, 0x3c030800,
1700 0xac600020, 0x3084fff0, 0x2c840001, 0x3042fff0, 0x38420010, 0x2c420001,
1701 0xaf840010, 0xaf820000, 0x0e00160c, 0x00000000, 0x0e001561, 0x00000000,
1702 0x3c020400, 0x3442000c, 0x3c03ffff, 0x34630806, 0xae021948, 0xae03194c,
1703 0x8e021980, 0x8fbf0014, 0x34420200, 0xae021980, 0x8fb00010, 0x03e00008,
1704 0x27bd0018, 0x00804821, 0x30a5ffff, 0x30c6ffff, 0x30e7ffff, 0x3c038000,
1705 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020003, 0xa342018b, 0x9783000a,
1706 0x8f840004, 0x8f880014, 0xaf490180, 0xa745018c, 0xa746018e, 0xa7470188,
1707 0x31028000, 0xa7430190, 0x1040000c, 0xaf4401a8, 0x93420116, 0x304200fc,
1708 0x005a1021, 0x24424004, 0x8c430000, 0x3063ffff, 0x14600004, 0x3c02ffff,
1709 0x34427fff, 0x01021024, 0xaf820014, 0x97820016, 0x9743010c, 0x8f440104,
1710 0x3042bfff, 0x00031c00, 0x3084ffff, 0x00641825, 0xa74201a6, 0xaf4301ac,
1711 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00000000, 0x27440180, 0x3c038000,
1712 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24022000, 0x24030002, 0xa4820008,
1713 0xa083000b, 0xa4800010, 0x3c021000, 0xaf4201b8, 0x03e00008, 0x00000000,
1714 0x27440180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1715 0x8f420148, 0x24030002, 0xa083000b, 0x00021402, 0xa4820008, 0x8f430148,
1716 0xa4830010, 0x8f420144, 0x3c031000, 0xac820024, 0x03e00008, 0xaf4301b8,
1717 0x27bdffe0, 0xafbf0018, 0xafb10014, 0xafb00010, 0x8f420148, 0x24030002,
1718 0x3044ffff, 0x00021402, 0x305000ff, 0x1203000c, 0x27510180, 0x2a020003,
1719 0x10400005, 0x24020003, 0x0600001d, 0x36053000, 0x0a001117, 0x3c038000,
1720 0x12020007, 0x00000000, 0x0a001124, 0x00000000, 0x0e00112c, 0x00000000,
1721 0x0a001115, 0x00402021, 0x0e00113e, 0x00000000, 0x00402021, 0x36053000,
1722 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002, 0xa6250008,
1723 0xa222000b, 0xa6240010, 0x8f420144, 0x3c031000, 0xae220024, 0xaf4301b8,
1724 0x0a001128, 0x8fbf0018, 0x0000000d, 0x00000000, 0x240002bf, 0x8fbf0018,
1725 0x8fb10014, 0x8fb00010, 0x03e00008, 0x27bd0020, 0x3084ffff, 0x2c821389,
1726 0x1040000d, 0x00001021, 0x3c030800, 0x24635900, 0x00042942, 0x00052880,
1727 0x00a32821, 0x3086001f, 0x8ca40000, 0x24030001, 0x00c31804, 0x00832025,
1728 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x3084ffff, 0x2c821389,
1729 0x1040000e, 0x00001021, 0x3c030800, 0x24635900, 0x00042942, 0x00052880,
1730 0x00a32821, 0x3086001f, 0x24030001, 0x8ca40000, 0x00c31804, 0x00031827,
1731 0x00832024, 0x03e00008, 0xaca40000, 0x03e00008, 0x24020091, 0x9482000c,
1732 0x24870014, 0x00021302, 0x00021080, 0x00824021, 0x00e8182b, 0x1060004f,
1733 0x00000000, 0x90e30000, 0x2c620009, 0x10400047, 0x3c020800, 0x24425890,
1734 0x00031880, 0x00621821, 0x8c640000, 0x00800008, 0x00000000, 0x0a0011a4,
1735 0x24e70001, 0x90e30001, 0x2402000a, 0x54620024, 0x01003821, 0x01071023,
1736 0x2c42000a, 0x54400020, 0x01003821, 0x3c050800, 0x8ca26c98, 0x24e70002,
1737 0x34420100, 0xaca26c98, 0x90e30000, 0x90e20001, 0x90e40002, 0x90e60003,
1738 0x24e70004, 0x24a56c98, 0x00031e00, 0x00021400, 0x00621825, 0x00042200,
1739 0x00641825, 0x00661825, 0xaca30004, 0x90e20000, 0x90e30001, 0x90e40002,
1740 0x90e60003, 0x24e70004, 0x00021600, 0x00031c00, 0x00431025, 0x00042200,
1741 0x00441025, 0x00461025, 0x0a0011a4, 0xaca20008, 0x90e30001, 0x24020004,
1742 0x1062000e, 0x00601021, 0x0a00119e, 0x01001021, 0x90e30001, 0x24020003,
1743 0x10620008, 0x00601021, 0x0a00119e, 0x01001021, 0x90e30001, 0x24020002,
1744 0x14620003, 0x01001021, 0x00601021, 0x00e21021, 0x0a0011a4, 0x00403821,
1745 0x90e20001, 0x0a0011a4, 0x00e23821, 0x01003821, 0x00e8102b, 0x5440ffb4,
1746 0x90e30000, 0x03e00008, 0x24020001, 0x27bdff90, 0x3c030800, 0xafbf006c,
1747 0xafbe0068, 0xafb70064, 0xafb60060, 0xafb5005c, 0xafb40058, 0xafb30054,
1748 0xafb20050, 0xafb1004c, 0xafb00048, 0xac606c98, 0x93620023, 0x30420010,
1749 0x1440027c, 0x24020001, 0x93420116, 0x93630005, 0x34424000, 0x30630001,
1750 0x14600005, 0x0342b021, 0x0e0015e0, 0x00000000, 0x0a001436, 0x8fbf006c,
1751 0x93420112, 0x8f430104, 0x3c040020, 0x34424000, 0x00641824, 0x10600012,
1752 0x03422821, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1753 0x00000000, 0x8f420128, 0xaca20000, 0x8f640040, 0x24030008, 0x240240c1,
1754 0xa4a20008, 0x24020002, 0xa0a2000b, 0x3c021000, 0x0a0011f1, 0xa0a3000a,
1755 0x8f420104, 0x3c030040, 0x00431024, 0x1040001d, 0x3c038000, 0x27450180,
1756 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000,
1757 0x8f640040, 0x24030010, 0x240240c1, 0xa4a20008, 0x24020002, 0xa0a3000a,
1758 0x24030008, 0xa0a2000b, 0x3c021000, 0xa4a30010, 0xa0a00012, 0xa0a00013,
1759 0xaca00014, 0xaca00024, 0xaca00028, 0xaca0002c, 0xaca40018, 0x0e0015e0,
1760 0xaf4201b8, 0x0a001436, 0x8fbf006c, 0x8f820000, 0x10400016, 0x00000000,
1761 0x8f420104, 0x3c030001, 0x00431024, 0x10400011, 0x00000000, 0x8ca3000c,
1762 0x8f620030, 0x1462022d, 0x24020001, 0x8ca30010, 0x8f62002c, 0x14620229,
1763 0x24020001, 0x9763003a, 0x96c20000, 0x14430225, 0x24020001, 0x97630038,
1764 0x96c20002, 0x14430221, 0x24020001, 0xaf400048, 0xaf400054, 0xaf400040,
1765 0x8f740040, 0x8f650048, 0x00b43023, 0x04c10004, 0x00000000, 0x0000000d,
1766 0x00000000, 0x240001af, 0x9742011a, 0x3052ffff, 0x12400004, 0x8ed30004,
1767 0x02721021, 0x0a001228, 0x2451ffff, 0x02608821, 0x92d7000d, 0xa7a00020,
1768 0xa3a0001a, 0xafa00028, 0x9362003f, 0x32e30004, 0x1060003a, 0x305000ff,
1769 0x24040012, 0x16040006, 0x24020001, 0x3c040800, 0x8c830028, 0x24630001,
1770 0x0a001328, 0xac830028, 0x8f620044, 0x16620010, 0x27a60010, 0x27450180,
1771 0x3c038000, 0x2402001a, 0xa7a20020, 0x24020020, 0xafb40028, 0xa3b00022,
1772 0xa3a40023, 0xa3a2001a, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000,
1773 0x0a00130d, 0x00000000, 0x8f620044, 0x02621023, 0x0440001a, 0x02651023,
1774 0x044100d9, 0x24020001, 0x3c020800, 0x8c4300d8, 0x10600004, 0x24020001,
1775 0xa7a20020, 0x0a00125e, 0xafb40028, 0x2402001a, 0xa7a20020, 0x24020020,
1776 0xafb40028, 0xa3b00022, 0xa3a40023, 0xa3a2001a, 0x27a60010, 0x27450180,
1777 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a00130d,
1778 0x00000000, 0x0a001328, 0x24020001, 0x0293f023, 0x1bc00016, 0x025e102a,
1779 0x54400007, 0x32f700fe, 0x57d2000f, 0x027e9821, 0x32e20001, 0x5440000c,
1780 0x027e9821, 0x32f700fe, 0x0240f021, 0x3c040800, 0x8c8300c8, 0x00009021,
1781 0x24020001, 0xa7a20020, 0xafb40028, 0x24630001, 0x0a001282, 0xac8300c8,
1782 0x025e1023, 0x0a001282, 0x3052ffff, 0x0000f021, 0x24a2ffff, 0x02221823,
1783 0x1860001f, 0x0072102a, 0x54400019, 0x00a08821, 0x97a20020, 0x3c040800,
1784 0x8c8300cc, 0xafb40028, 0x34420001, 0x24630001, 0xa7a20020, 0x02741026,
1785 0x2c420001, 0xac8300cc, 0x2cc30001, 0x00431024, 0x1440000a, 0x02401821,
1786 0x27a60010, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd,
1787 0x00000000, 0x0a00130d, 0x00000000, 0x00a08821, 0x02431023, 0x3052ffff,
1788 0x0a0012ae, 0x32f700f6, 0x02741023, 0x18400008, 0x97a20020, 0x3c040800,
1789 0x8c8300d4, 0xafb30028, 0x34420400, 0x24630001, 0xa7a20020, 0xac8300d4,
1790 0x32e20002, 0x1040001c, 0x32e20010, 0x8f620044, 0x1662000d, 0x27a60010,
1791 0x97a20020, 0x27450180, 0x3c038000, 0xafb40028, 0x34420001, 0xa7a20020,
1792 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a00130d, 0x00000000,
1793 0x97a20020, 0x27450180, 0x3c038000, 0xafb40028, 0x34420001, 0xa7a20020,
1794 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x0a00130d, 0x00000000,
1795 0x54400003, 0x8ed50008, 0x0a001328, 0x24020001, 0x8f630054, 0x26a2ffff,
1796 0x00431023, 0x18400011, 0x27a60010, 0x97a20020, 0x3c040800, 0x8c8300d0,
1797 0x27450180, 0x3c078000, 0xafb40028, 0x34420001, 0x24630001, 0xa7a20020,
1798 0xac8300d0, 0x8f4201b8, 0x00471024, 0x1440fffd, 0x00000000, 0x0a00130d,
1799 0x00000000, 0x32e20020, 0x10400011, 0x00000000, 0x96c20012, 0x0052102b,
1800 0x10400008, 0x97a20020, 0x96d20012, 0x12400003, 0x02721021, 0x0a0012f2,
1801 0x2451ffff, 0x02608821, 0x97a20020, 0x93a3001a, 0x34420008, 0x34630004,
1802 0xa7a20020, 0xa3a3001a, 0x8f420104, 0x3c030080, 0x00431024, 0x10400037,
1803 0x3a03000a, 0x0e001151, 0x02c02021, 0x24030002, 0x1443002b, 0x3c030800,
1804 0x27a60010, 0x97a20020, 0x27450180, 0x3c038000, 0xafb40028, 0x34420001,
1805 0xa7a20020, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128,
1806 0xaca20000, 0x8cc30018, 0x240240c1, 0xa4a20008, 0xaca30018, 0x90c4000a,
1807 0x24020002, 0xa0a2000b, 0xa0a4000a, 0x94c20010, 0xa4a20010, 0x90c30012,
1808 0xa0a30012, 0x90c20013, 0xa0a20013, 0x8cc30014, 0xaca30014, 0x8cc20024,
1809 0xaca20024, 0x8cc30028, 0xaca30028, 0x8cc4002c, 0x24020001, 0x3c031000,
1810 0xaca4002c, 0xaf4301b8, 0xaf400044, 0xaf400050, 0x0a001436, 0x8fbf006c,
1811 0x8c626c98, 0x30420100, 0x10400003, 0x24636c98, 0x8c620004, 0xaf62017c,
1812 0x3a03000a, 0x2c630001, 0x3a02000c, 0x2c420001, 0x00621825, 0x14600003,
1813 0x2402000e, 0x56020030, 0x00009021, 0x52400008, 0x96c4000e, 0x12400004,
1814 0xa7b20040, 0x02721021, 0x0a001343, 0x2451ffff, 0x02608821, 0x96c4000e,
1815 0x93630035, 0x8f62004c, 0x00642004, 0x00952021, 0x00821023, 0x18400015,
1816 0x00000000, 0x8f620018, 0x02621023, 0x1c400015, 0x97a20020, 0x8f620018,
1817 0x1662001c, 0x00000000, 0x8f62001c, 0x02a21023, 0x1c40000e, 0x97a20020,
1818 0x8f62001c, 0x16a20015, 0x00000000, 0x8f620058, 0x00821023, 0x18400011,
1819 0x97a20020, 0x0a001364, 0xafb10028, 0x8f620058, 0x00821023, 0x0441000b,
1820 0x97a20020, 0xafb10028, 0xafb30034, 0xafb50038, 0xafa4003c, 0x34420020,
1821 0x0a00136d, 0xa7a20020, 0x02809821, 0x02608821, 0x8f640058, 0x8f62004c,
1822 0x02a21023, 0x18400009, 0x00000000, 0x8f620054, 0x02a21023, 0x1c400005,
1823 0x97a20020, 0xafb10028, 0xafb50024, 0x0a001385, 0x34420040, 0x9742011a,
1824 0x1440000c, 0x24020014, 0x8f620058, 0x14820009, 0x24020014, 0x8f63004c,
1825 0x8f620054, 0x10620004, 0x97a20020, 0xafb10028, 0x34420080, 0xa7a20020,
1826 0x24020014, 0x1202000a, 0x2a020015, 0x10400005, 0x2402000c, 0x12020006,
1827 0x32e20001, 0x0a0013c6, 0x00000000, 0x24020016, 0x16020035, 0x32e20001,
1828 0x8f620084, 0x24420001, 0x16a20031, 0x32e20001, 0x24020014, 0x12020021,
1829 0x2a020015, 0x10400005, 0x2402000c, 0x12020008, 0x32e20001, 0x0a0013c6,
1830 0x00000000, 0x24020016, 0x1202000c, 0x32e20001, 0x0a0013c6, 0x00000000,
1831 0x97a30020, 0x2402000e, 0xafb10028, 0xa3b00022, 0xa3a20023, 0xafb50024,
1832 0x34630054, 0x0a0013c5, 0xa7a30020, 0x97a20020, 0x93a4001a, 0x24030010,
1833 0xafb10028, 0xa3b00022, 0xa3a30023, 0xafb50024, 0x3442005d, 0x34840002,
1834 0xa7a20020, 0x0a0013c5, 0xa3a4001a, 0x97a20020, 0x24030012, 0xa3a30023,
1835 0x93a3001a, 0xafb10028, 0xa3b00022, 0xafb50024, 0x3042fffe, 0x3442005c,
1836 0x34630002, 0xa7a20020, 0xa3a3001a, 0x32e20001, 0x10400030, 0x2402000c,
1837 0x12020013, 0x2a02000d, 0x10400005, 0x2402000a, 0x12020008, 0x97a20020,
1838 0x0a0013f8, 0x32e20009, 0x2402000e, 0x1202001b, 0x32e20009, 0x0a0013f9,
1839 0x0002102b, 0x93a4001a, 0x24030008, 0xafb10028, 0xa3b00022, 0xa3a30023,
1840 0x0a0013f4, 0x34420013, 0x97a30020, 0x30620004, 0x14400005, 0x93a2001a,
1841 0x3463001b, 0xa7a30020, 0x0a0013e7, 0x24030016, 0x3463001b, 0xa7a30020,
1842 0x24030010, 0xafb10028, 0xa3b00022, 0xa3a30023, 0x34420002, 0x0a0013f7,
1843 0xa3a2001a, 0x97a20020, 0x93a4001a, 0x24030010, 0xafb10028, 0xa3b00022,
1844 0xa3a30023, 0x3442001b, 0x34840002, 0xa7a20020, 0xa3a4001a, 0x32e20009,
1845 0x0002102b, 0x00021023, 0x30420007, 0x12400015, 0x34450003, 0x8f820018,
1846 0x24030800, 0x27440180, 0x24420001, 0xaf820018, 0x24020004, 0xaf4301b8,
1847 0xa4850008, 0xa082000b, 0x93430120, 0x00003021, 0x3c021000, 0xa492000e,
1848 0xac950024, 0xac930028, 0x007e1821, 0xa483000c, 0xaf4201b8, 0x0a001413,
1849 0x97a20020, 0x24060001, 0x97a20020, 0x10400020, 0x27450180, 0x3c038000,
1850 0x8f4201b8, 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000,
1851 0x8fa30028, 0x240240c1, 0xa4a20008, 0xaca30018, 0x93a4001a, 0x24020002,
1852 0xa0a2000b, 0xa0a4000a, 0x97a20020, 0xa4a20010, 0x93a30022, 0xa0a30012,
1853 0x93a20023, 0xa0a20013, 0x8fa30024, 0xaca30014, 0x8fa20034, 0xaca20024,
1854 0x8fa30038, 0xaca30028, 0x8fa2003c, 0x3c031000, 0xaca2002c, 0xaf4301b8,
1855 0x00c01021, 0x8fbf006c, 0x8fbe0068, 0x8fb70064, 0x8fb60060, 0x8fb5005c,
1856 0x8fb40058, 0x8fb30054, 0x8fb20050, 0x8fb1004c, 0x8fb00048, 0x03e00008,
1857 0x27bd0070, 0x8f470140, 0x8f460148, 0x3c028000, 0x00c24024, 0x00062c02,
1858 0x30a300ff, 0x24020019, 0x106200e7, 0x27440180, 0x2862001a, 0x1040001f,
1859 0x24020008, 0x106200be, 0x28620009, 0x1040000d, 0x24020001, 0x10620046,
1860 0x28620002, 0x50400005, 0x24020006, 0x1060002e, 0x00a01821, 0x0a00155e,
1861 0x00000000, 0x1062005b, 0x00a01821, 0x0a00155e, 0x00000000, 0x2402000b,
1862 0x10620084, 0x2862000c, 0x10400005, 0x24020009, 0x106200bc, 0x00061c02,
1863 0x0a00155e, 0x00000000, 0x2402000e, 0x106200b7, 0x00061c02, 0x0a00155e,
1864 0x00000000, 0x28620021, 0x10400009, 0x2862001f, 0x104000c1, 0x2402001b,
1865 0x106200bf, 0x2402001c, 0x1062009a, 0x00061c02, 0x0a00155e, 0x00000000,
1866 0x240200c2, 0x106200ca, 0x286200c3, 0x10400005, 0x24020080, 0x1062005a,
1867 0x00a01821, 0x0a00155e, 0x00000000, 0x240200c9, 0x106200cd, 0x30c5ffff,
1868 0x0a00155e, 0x00000000, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd,
1869 0x24020001, 0xa4830008, 0x24030002, 0xac870000, 0xac800004, 0xa082000a,
1870 0xa083000b, 0xa4860010, 0x8f430144, 0x3c021000, 0xac800028, 0xac830024,
1871 0x3c036000, 0xaf4201b8, 0x03e00008, 0xac600808, 0x11000009, 0x00a01821,
1872 0x3c020800, 0x24030002, 0xa0436c88, 0x24426c88, 0xac470008, 0x8f430144,
1873 0x03e00008, 0xac430004, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd,
1874 0x24020002, 0xac800000, 0xac870004, 0xa4830008, 0xa082000a, 0xa082000b,
1875 0xa4860010, 0xac800024, 0x8f420144, 0x3c031000, 0xac820028, 0x3c026000,
1876 0xaf4301b8, 0x03e00008, 0xac400808, 0x3c080800, 0x3c058000, 0x8f4201b8,
1877 0x00451024, 0x1440fffd, 0x00000000, 0xac870000, 0x91026c88, 0x00002821,
1878 0x10400002, 0x25076c88, 0x8ce50008, 0xac850004, 0xa4830008, 0x91036c88,
1879 0x24020002, 0xa082000b, 0xa4860010, 0x34630001, 0xa083000a, 0x8f420144,
1880 0xac820024, 0x91036c88, 0x10600002, 0x00001021, 0x8ce20004, 0xac820028,
1881 0x3c021000, 0xaf4201b8, 0x3c026000, 0xa1006c88, 0x03e00008, 0xac400808,
1882 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002, 0xa082000b,
1883 0xa4830008, 0xa4860010, 0x8f420144, 0x3c031000, 0xa4820012, 0x03e00008,
1884 0xaf4301b8, 0x30c2ffff, 0x14400028, 0x00061c02, 0x93620005, 0x30420004,
1885 0x14400020, 0x3c029000, 0x34420001, 0x00e21025, 0xaf420020, 0x3c038000,
1886 0x8f420020, 0x00431024, 0x1440fffd, 0x00000000, 0x93620005, 0x3c038000,
1887 0x34630001, 0x00e31825, 0x34420004, 0xa3620005, 0xaf430020, 0x93620005,
1888 0x30420004, 0x14400003, 0x3c038000, 0x0000000d, 0x3c038000, 0x8f4201b8,
1889 0x00431024, 0x1440fffd, 0x24020005, 0x3c031000, 0xac870000, 0xa082000b,
1890 0xaf4301b8, 0x0a00150d, 0x00061c02, 0x0000000d, 0x03e00008, 0x00000000,
1891 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001,
1892 0xa4830008, 0x24030002, 0xac870000, 0xac800004, 0xa082000a, 0xa083000b,
1893 0xa4860010, 0x8f430144, 0x3c021000, 0xac800028, 0xac830024, 0x03e00008,
1894 0xaf4201b8, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002,
1895 0xac800000, 0xac870004, 0xa4830008, 0xa082000a, 0xa082000b, 0xa4860010,
1896 0xac800024, 0x8f420144, 0x3c031000, 0xac820028, 0x03e00008, 0xaf4301b8,
1897 0x00061c02, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020001,
1898 0xa4830008, 0x24030002, 0xa082000a, 0x3c021000, 0xac870000, 0xac800004,
1899 0xa083000b, 0xa4860010, 0xac800024, 0xac800028, 0x03e00008, 0xaf4201b8,
1900 0x00a01821, 0x3c058000, 0x8f4201b8, 0x00451024, 0x1440fffd, 0x24020002,
1901 0xac870000, 0xac800004, 0xa4830008, 0xa080000a, 0x0a001518, 0xa082000b,
1902 0x8f440144, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002,
1903 0x240340c9, 0xaf470180, 0xa342018b, 0x3c021000, 0xa7430188, 0xaf4401a4,
1904 0xaf4501a8, 0xaf4001ac, 0x03e00008, 0xaf4201b8, 0x0000000d, 0x03e00008,
1905 0x00000000, 0x03e00008, 0x00000000, 0x8f420100, 0x3042003e, 0x14400011,
1906 0x24020001, 0xaf400048, 0x8f420100, 0x304207c0, 0x10400005, 0x00000000,
1907 0xaf40004c, 0xaf400050, 0x03e00008, 0x24020001, 0xaf400054, 0xaf400040,
1908 0x8f420100, 0x30423800, 0x54400001, 0xaf400044, 0x24020001, 0x03e00008,
1909 0x00000000, 0x3c038000, 0x8f4201b8, 0x00431024, 0x1440fffd, 0x24020002,
1910 0x240340c9, 0xaf440180, 0xa342018b, 0x3c021000, 0xa7430188, 0xaf4501a4,
1911 0xaf4601a8, 0xaf4701ac, 0x03e00008, 0xaf4201b8, 0x3c029000, 0x34420001,
1912 0x00822025, 0xaf440020, 0x3c038000, 0x8f420020, 0x00431024, 0x1440fffd,
1913 0x00000000, 0x03e00008, 0x00000000, 0x3c028000, 0x34420001, 0x00822025,
1914 0x03e00008, 0xaf440020, 0x308600ff, 0x27450180, 0x3c038000, 0x8f4201b8,
1915 0x00431024, 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8f640040,
1916 0x24030008, 0x240240c1, 0xa4a20008, 0x24020002, 0xa0a2000b, 0x3c021000,
1917 0xa0a6000a, 0xa4a30010, 0xa0a00012, 0xa0a00013, 0xaca00014, 0xaca00024,
1918 0xaca00028, 0xaca0002c, 0xaca40018, 0x03e00008, 0xaf4201b8, 0x24020001,
1919 0xacc40000, 0x03e00008, 0xa4e50000, 0x24020001, 0xaf400044, 0x03e00008,
1920 0xaf400050, 0x00803021, 0x27450180, 0x3c038000, 0x8f4201b8, 0x00431024,
1921 0x1440fffd, 0x00000000, 0x8f420128, 0xaca20000, 0x8cc30018, 0x240240c1,
1922 0xa4a20008, 0xaca30018, 0x90c4000a, 0x24020002, 0xa0a2000b, 0xa0a4000a,
1923 0x94c20010, 0xa4a20010, 0x90c30012, 0xa0a30012, 0x90c20013, 0xa0a20013,
1924 0x8cc30014, 0xaca30014, 0x8cc20024, 0xaca20024, 0x8cc30028, 0xaca30028,
1925 0x8cc2002c, 0x3c031000, 0xaca2002c, 0x24020001, 0xaf4301b8, 0xaf400044,
1926 0x03e00008, 0xaf400050, 0x27bdffe8, 0xafbf0010, 0x0e001047, 0x00000000,
1927 0x00002021, 0x0e000c78, 0xaf400180, 0x8fbf0010, 0x03e00008, 0x27bd0018,
1928 0x8f460148, 0x27450180, 0x3c038000, 0x00061402, 0x304700ff, 0x8f4201b8,
1929 0x00431024, 0x1440fffd, 0x00000000, 0x8f440140, 0x00061202, 0x304200ff,
1930 0x00061c02, 0xaca20004, 0x24020002, 0xa4a30008, 0x30c300ff, 0xa0a2000b,
1931 0xaca30024, 0x10e0000a, 0xaca40000, 0x28e20004, 0x14400005, 0x24020001,
1932 0x24020005, 0x54e20005, 0xa0a0000a, 0x24020001, 0x0a001609, 0xa0a2000a,
1933 0xa0a0000a, 0x3c021000, 0x03e00008, 0xaf4201b8, 0x03e00008, 0x00001021,
1934 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000,
1935 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a00161f, 0x00a01021,
1936 0xac860000, 0x00000000, 0x00000000, 0x24840004, 0x00a01021, 0x1440fffa,
1937 0x24a5ffff, 0x03e00008, 0x00000000, 0x00000000 };
1938 1052
1939static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 }; 1053static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1940static u32 bnx2_RXP_b06FwRodata[(0x28/4) + 1] = { 1054static u32 bnx2_RXP_b06FwRodata[(0x28/4) + 1] = {
@@ -1943,387 +1057,264 @@ static u32 bnx2_RXP_b06FwRodata[(0x28/4) + 1] = {
1943static u32 bnx2_RXP_b06FwBss[(0x13a4/4) + 1] = { 0x0 }; 1057static u32 bnx2_RXP_b06FwBss[(0x13a4/4) + 1] = { 0x0 };
1944static u32 bnx2_RXP_b06FwSbss[(0x1c/4) + 1] = { 0x0 }; 1058static u32 bnx2_RXP_b06FwSbss[(0x1c/4) + 1] = { 0x0 };
1945 1059
1946static u32 bnx2_rv2p_proc1[] = { 1060static u8 bnx2_rv2p_proc1[] = {
1947 0x00000008, 0xac000001, 0x0000000c, 0x2f800001, 0x00000010, 0x213f0004, 1061 0x1f, 0x8b, 0x08, 0x08, 0x5e, 0xd0, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
1948 0x00000010, 0x20bf002c, 0x00000010, 0x203f0143, 0x00000018, 0x8000fffd, 1062 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x56, 0xcf, 0x6b,
1949 0x00000010, 0xb1b8b017, 0x0000000b, 0x2fdf0002, 0x00000000, 0x03d80000, 1063 0x13, 0x51, 0x10, 0x9e, 0xec, 0x6e, 0xb2, 0xdb, 0x74, 0xbb, 0x1b, 0x2b,
1950 0x00000000, 0x2c380000, 0x00000008, 0x2c800000, 0x00000008, 0x2d000000, 1064 0xda, 0xa0, 0xb1, 0x8d, 0x51, 0x6a, 0x7f, 0xa4, 0xb4, 0x11, 0x0f, 0x82,
1951 0x00000010, 0x91d40000, 0x00000008, 0x2d800108, 0x00000008, 0x02000002, 1065 0x42, 0x25, 0x3d, 0x04, 0x54, 0x44, 0x7a, 0x28, 0x22, 0x82, 0x36, 0x8a,
1952 0x00000010, 0x91de0000, 0x0000000f, 0x42e0001c, 0x00000010, 0x91840a08, 1066 0xfe, 0x1b, 0xa1, 0x3f, 0xd2, 0x4b, 0x10, 0x7a, 0xb0, 0x58, 0xf1, 0x50,
1953 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008, 0x00000008, 0x2d800150, 1067 0x10, 0x2a, 0x68, 0x0f, 0xc9, 0xa1, 0x20, 0x52, 0x11, 0xda, 0x8b, 0x07,
1954 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 0x00000010, 0x2c620002, 1068 0x2f, 0x42, 0x0f, 0x7a, 0x69, 0xbd, 0xa8, 0xff, 0x82, 0x08, 0x4d, 0x7c,
1955 0x00000018, 0x80000012, 0x0000000b, 0x2fdf0002, 0x0000000c, 0x1f800002, 1069 0x6f, 0x66, 0x9e, 0xee, 0x6e, 0xb2, 0x4d, 0x15, 0xc1, 0x85, 0xf6, 0xe3,
1956 0x00000000, 0x2c070000, 0x00000018, 0x8000ffe6, 0x00000008, 0x02000002, 1070 0xbd, 0x9d, 0x79, 0x33, 0xf3, 0xcd, 0x37, 0xfb, 0x62, 0x01, 0x40, 0x04,
1957 0x0000000f, 0x42e0001c, 0x00000010, 0x91840a08, 0x00000008, 0x2c8000b0, 1071 0x60, 0xcd, 0x46, 0x2c, 0x8d, 0x26, 0x04, 0x1a, 0x30, 0x7e, 0x52, 0x62,
1958 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800108, 1072 0x16, 0xde, 0xa6, 0x25, 0x4e, 0x44, 0xc6, 0xd3, 0x49, 0x81, 0x7b, 0x0d,
1959 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 0x00000018, 0x80000004, 1073 0x28, 0xc9, 0x75, 0x4f, 0xf5, 0x55, 0xad, 0x53, 0xa0, 0x06, 0xbb, 0xa3,
1960 0x0000000c, 0x1f800002, 0x00000000, 0x00000000, 0x00000018, 0x8000ffd9, 1074 0x80, 0xcf, 0x47, 0x9d, 0xf0, 0x7c, 0xd6, 0x42, 0x2c, 0x31, 0xc2, 0x48,
1961 0x0000000c, 0x29800002, 0x0000000c, 0x1f800002, 0x00000000, 0x2adf0000, 1075 0x02, 0x61, 0x7b, 0x51, 0xae, 0xad, 0x48, 0x69, 0xc4, 0x42, 0x3f, 0xd0,
1962 0x00000008, 0x2a000005, 0x00000018, 0x8000ffd4, 0x00000008, 0x02240030, 1076 0x68, 0x7f, 0x67, 0xd1, 0x15, 0xff, 0x53, 0xf0, 0x39, 0x2f, 0xd7, 0x56,
1963 0x00000018, 0x00040000, 0x00000018, 0x80000015, 0x00000018, 0x80000017, 1077 0x7c, 0x0e, 0xed, 0xaa, 0xec, 0x2f, 0xfe, 0xd0, 0xfe, 0xba, 0xf0, 0x03,
1964 0x00000018, 0x8000001b, 0x00000018, 0x8000004c, 0x00000018, 0x8000008c, 1078 0x7e, 0x94, 0x5f, 0x02, 0xcf, 0x29, 0x66, 0x65, 0x5e, 0xdd, 0x22, 0xa0,
1965 0x00000018, 0x8000000f, 0x00000018, 0x8000000e, 0x00000018, 0x8000000d, 1079 0xca, 0xc7, 0x46, 0x2c, 0xf5, 0x91, 0xb5, 0x89, 0xef, 0xbf, 0x8a, 0xbc,
1966 0x00000018, 0x8000000c, 0x00000018, 0x800000c2, 0x00000018, 0x8000000a, 1080 0x55, 0xdc, 0x76, 0xf1, 0x82, 0xf9, 0x06, 0xe3, 0x26, 0x91, 0x1f, 0x28,
1967 0x00000018, 0x80000009, 0x00000018, 0x80000008, 0x00000018, 0x800000fd, 1081 0xf9, 0xe3, 0x00, 0xc8, 0xfd, 0x4f, 0x8d, 0x5f, 0xfb, 0x83, 0xfe, 0xf7,
1968 0x00000018, 0x80000006, 0x00000018, 0x80000005, 0x00000018, 0x800000ff, 1082 0xbb, 0x43, 0xf2, 0xbc, 0x28, 0xc0, 0x90, 0xb4, 0xdb, 0xe6, 0x7c, 0xc6,
1969 0x00000018, 0x80000104, 0x00000018, 0x80000002, 0x00000018, 0x80000098, 1083 0xe0, 0xb4, 0x96, 0xc4, 0xf7, 0x06, 0xfa, 0x1f, 0x11, 0xe7, 0x4a, 0xec,
1970 0x00000018, 0x80000000, 0x0000000c, 0x1f800001, 0x00000000, 0x00000000, 1084 0x61, 0x3c, 0xce, 0x78, 0x95, 0xb1, 0xc2, 0xe8, 0x32, 0x3a, 0x8c, 0x5d,
1971 0x00000018, 0x8000ffba, 0x00000010, 0x91d40000, 0x0000000c, 0x29800001, 1085 0x8c, 0x36, 0xe3, 0x26, 0x63, 0x9c, 0xb1, 0x83, 0xd1, 0x62, 0xdc, 0x63,
1972 0x0000000c, 0x1f800001, 0x00000008, 0x2a000002, 0x00000018, 0x8000ffb5, 1086 0x8c, 0x31, 0x46, 0x19, 0x1b, 0x8c, 0x46, 0x84, 0x50, 0xe3, 0xf5, 0x63,
1973 0x00000010, 0xb1a0b012, 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c200000, 1087 0x46, 0xe0, 0xba, 0x23, 0x81, 0xba, 0x5f, 0xb3, 0x2e, 0x24, 0x6f, 0xfc,
1974 0x00000008, 0x2c800000, 0x00000008, 0x2d000000, 0x00000010, 0x91d40000, 1088 0x7e, 0x50, 0xd9, 0x31, 0xef, 0x58, 0xf7, 0x3a, 0xdb, 0x75, 0x57, 0x57,
1975 0x00000008, 0x2d80011c, 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 1089 0x02, 0xfa, 0x49, 0xef, 0xab, 0x9b, 0x54, 0x8b, 0x3e, 0xb8, 0x58, 0xcf,
1976 0x0000000f, 0x47600008, 0x0000000f, 0x060e0001, 0x00000010, 0x001f0000, 1090 0x9d, 0x82, 0x8b, 0x71, 0x9c, 0x18, 0xed, 0xab, 0xb4, 0x6e, 0xb8, 0x84,
1977 0x00000000, 0x0f580000, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000, 1091 0xf7, 0xe2, 0x84, 0x5f, 0x18, 0xef, 0x77, 0x12, 0x4e, 0x77, 0xc9, 0x7c,
1978 0x00000000, 0x0b660000, 0x00000000, 0x0d610000, 0x00000018, 0x80000013, 1092 0x0e, 0x8b, 0x80, 0xea, 0x1c, 0x95, 0x4f, 0xbb, 0x3c, 0xc2, 0xe2, 0xa9,
1979 0x0000000f, 0x47600008, 0x0000000b, 0x2fdf0002, 0x00000008, 0x2c800000, 1093 0xbc, 0xda, 0xc5, 0x25, 0x2c, 0x6a, 0xfe, 0xfa, 0x9f, 0x8c, 0x11, 0x1a,
1980 0x00000008, 0x2d000000, 0x00000010, 0x91d40000, 0x00000008, 0x2d80011c, 1094 0x39, 0x22, 0x75, 0xc9, 0x16, 0x3d, 0x83, 0x46, 0x63, 0xd9, 0x36, 0xe4,
1981 0x0000000f, 0x060e0001, 0x00000010, 0x001f0000, 0x00000000, 0x0f580000, 1095 0xfa, 0xdc, 0xf2, 0x7b, 0xd4, 0xfb, 0xd9, 0xa5, 0x1a, 0xe7, 0xe7, 0x2a,
1982 0x00000010, 0x91de0000, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000, 1096 0x9e, 0x69, 0x0e, 0x32, 0x40, 0xeb, 0x49, 0xe4, 0x1d, 0x04, 0x5a, 0xb8,
1983 0x00000000, 0x0b660000, 0x00000000, 0x0d610000, 0x00000000, 0x02620000, 1097 0x86, 0x8c, 0xbf, 0x5f, 0xa4, 0x43, 0x9d, 0xfb, 0x31, 0xcb, 0xfd, 0x38,
1984 0x0000000b, 0x2fdf0002, 0x00000000, 0x309a0000, 0x00000000, 0x31040000, 1098 0x11, 0xd2, 0x8f, 0xb0, 0xb9, 0x68, 0x9e, 0xc7, 0xdb, 0xe9, 0x20, 0x6f,
1985 0x00000000, 0x0c961800, 0x00000009, 0x0c99ffff, 0x00000004, 0xcc993400, 1099 0x61, 0xf3, 0xa3, 0xf8, 0xa6, 0xdd, 0x3f, 0xe5, 0xf1, 0x01, 0xf3, 0x58,
1986 0x00000010, 0xb1963202, 0x00000008, 0x0f800000, 0x0000000c, 0x29800001, 1100 0x24, 0x1e, 0x93, 0xdf, 0x5a, 0xf2, 0x94, 0xf6, 0xf0, 0x24, 0xeb, 0xec,
1987 0x00000010, 0x00220002, 0x0000000c, 0x29520001, 0x0000000c, 0x29520000, 1101 0x0d, 0xe9, 0x73, 0x58, 0x7d, 0xd9, 0xbf, 0xee, 0x73, 0x20, 0x3f, 0xb8,
1988 0x00000008, 0x22000001, 0x0000000c, 0x1f800001, 0x00000000, 0x2adf0000, 1102 0x8b, 0xdf, 0x9b, 0x04, 0x14, 0x0b, 0x2a, 0x5f, 0x3f, 0xcf, 0xc7, 0xa8,
1989 0x00000008, 0x2a000003, 0x00000018, 0x8000ff83, 0x00000010, 0xb1a0b01d, 1103 0xdf, 0x30, 0x97, 0x93, 0xfb, 0x62, 0xfe, 0x36, 0x35, 0x5c, 0x1b, 0xf9,
1990 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c200000, 0x00000008, 0x2c8000b0, 1104 0x88, 0x04, 0xab, 0x98, 0x23, 0x7f, 0x47, 0xd3, 0x78, 0x7d, 0x50, 0x5d,
1991 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800150, 1105 0xa8, 0xbe, 0x4b, 0x8c, 0x41, 0x7e, 0x9a, 0xeb, 0xcc, 0x50, 0x3c, 0xd2,
1992 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000008, 0x2c800000, 1106 0x81, 0xc1, 0x3a, 0xc8, 0xf3, 0xf7, 0x28, 0xc8, 0x87, 0x55, 0x5d, 0x59,
1993 0x00000008, 0x2d000000, 0x00000008, 0x2d800108, 0x00000000, 0x00000000, 1107 0xf4, 0xce, 0x75, 0x12, 0x8a, 0x39, 0xd2, 0x55, 0x73, 0x5f, 0x59, 0x6f,
1994 0x00000010, 0x91de0000, 0x0000000f, 0x47600008, 0x00000000, 0x060e0000, 1108 0x6b, 0xea, 0xbb, 0x84, 0xdb, 0xd5, 0x92, 0xee, 0xab, 0xf7, 0x12, 0x64,
1995 0x00000010, 0x001f0000, 0x00000000, 0x0f580000, 0x00000010, 0x91de0000, 1109 0xbd, 0x3c, 0x47, 0x5a, 0xe8, 0xa3, 0x5d, 0x1c, 0xdf, 0x79, 0x0e, 0x64,
1996 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000, 0x00000000, 0x0b670000, 1110 0x5b, 0x7d, 0x6f, 0x4c, 0xae, 0xeb, 0x0c, 0xeb, 0xfb, 0x68, 0x93, 0xbe,
1997 0x00000000, 0x0d620000, 0x00000000, 0x0ce71800, 0x00000009, 0x0c99ffff, 1111 0xd5, 0x7d, 0xf5, 0xef, 0x74, 0xce, 0xf5, 0x9b, 0x68, 0x97, 0xda, 0x59,
1998 0x00000004, 0xcc993400, 0x00000010, 0xb1963220, 0x00000008, 0x0f800000, 1112 0xf7, 0xde, 0x4f, 0x71, 0xcf, 0xfd, 0x44, 0x6e, 0xa6, 0xca, 0xbb, 0xcf,
1999 0x00000018, 0x8000001e, 0x0000000f, 0x47600008, 0x0000000b, 0x2fdf0002, 1113 0x7b, 0xaf, 0x1c, 0x0a, 0xe9, 0x83, 0xf7, 0x3e, 0x0a, 0xd6, 0xeb, 0xd7,
2000 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 1114 0x23, 0xf5, 0x35, 0xce, 0xf5, 0x9b, 0x0d, 0xee, 0xc3, 0x54, 0xff, 0x0c,
2001 0x00000008, 0x2d80012c, 0x0000000f, 0x060e0001, 0x00000010, 0x001f0000, 1115 0xe9, 0x3f, 0x53, 0x90, 0xfa, 0x71, 0xc1, 0x31, 0xe9, 0x7c, 0x42, 0x71,
2002 0x00000000, 0x0f580000, 0x00000010, 0x91de0000, 0x00000000, 0x0a640000, 1116 0x8e, 0x66, 0x62, 0xde, 0xf3, 0x1a, 0xad, 0xe7, 0x67, 0xd0, 0x2f, 0x3e,
2003 0x00000000, 0x0ae50000, 0x00000000, 0x0b670000, 0x00000000, 0x0d620000, 1117 0xa7, 0xf6, 0xf3, 0x48, 0xd8, 0xe4, 0x8b, 0x2d, 0xe2, 0xbd, 0xa6, 0xab,
2004 0x00000000, 0x02630000, 0x0000000f, 0x47620010, 0x00000000, 0x0ce71800, 1118 0xb9, 0x70, 0x91, 0xef, 0x01, 0x97, 0xec, 0xcc, 0x2b, 0x8a, 0x2f, 0xb9,
2005 0x0000000b, 0x2fdf0002, 0x00000000, 0x311a0000, 0x00000000, 0x31840000, 1119 0xaf, 0xc3, 0x12, 0xcd, 0xc5, 0xad, 0x47, 0x84, 0x37, 0xe1, 0x32, 0x9d,
2006 0x0000000b, 0xc20000ff, 0x00000002, 0x42040000, 0x00000001, 0x31620800, 1120 0xfb, 0xfb, 0xfb, 0x66, 0x21, 0x42, 0x97, 0x57, 0xc7, 0x51, 0xa1, 0x63,
2007 0x0000000f, 0x020e0010, 0x00000002, 0x31620800, 0x00000009, 0x0c99ffff, 1121 0x9c, 0x63, 0x25, 0x57, 0x78, 0xae, 0x11, 0x9f, 0xf3, 0xa4, 0x73, 0x8d,
2008 0x00000004, 0xcc993400, 0x00000010, 0xb1963202, 0x00000008, 0x0f800000, 1122 0xf3, 0xc3, 0xab, 0x45, 0x3e, 0xab, 0xba, 0xac, 0xf7, 0x9a, 0xd2, 0x1d,
2009 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x0000000c, 0x61420006, 1123 0x0c, 0x9b, 0x38, 0x3f, 0xa9, 0xca, 0x02, 0x2e, 0x7b, 0x1d, 0x46, 0xbb,
2010 0x00000008, 0x22000008, 0x00000000, 0x2adf0000, 0x00000008, 0x2a000004, 1124 0x4c, 0x18, 0xc3, 0xfc, 0x75, 0x78, 0x58, 0x93, 0x7e, 0x05, 0xbe, 0xdf,
2011 0x00000018, 0x8000ff42, 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008, 1125 0x7e, 0xb0, 0x5e, 0x74, 0xa8, 0xf0, 0xef, 0x8b, 0x05, 0x7c, 0x3f, 0x01,
2012 0x00000010, 0x91a0b008, 0x00000010, 0x91d40000, 0x0000000c, 0x31620018, 1126 0xcd, 0xf7, 0x1b, 0xc5, 0x29, 0x0f, 0x11, 0xda, 0xa7, 0xb8, 0xaf, 0xc3,
2013 0x00000008, 0x2d800001, 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 1127 0xd2, 0xce, 0x11, 0x7e, 0xdc, 0x3f, 0xec, 0xc3, 0x05, 0x8f, 0x3f, 0x42,
2014 0x00000008, 0xac000001, 0x00000018, 0x8000000e, 0x00000000, 0x0380b000, 1128 0xe5, 0xc3, 0x40, 0x98, 0xbf, 0xb4, 0xff, 0xde, 0xe2, 0x3e, 0xa5, 0xf7,
2015 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c004000, 0x00000010, 0x91d40000, 1129 0x2f, 0xc9, 0x7e, 0xaa, 0xff, 0x19, 0xd7, 0x3f, 0xec, 0xd5, 0xbd, 0x8a,
2016 0x00000008, 0x2d800101, 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 1130 0xf7, 0xae, 0xbe, 0xff, 0x7d, 0xdc, 0xc1, 0x76, 0x5b, 0xfb, 0xd8, 0xd1,
2017 0x0000000c, 0x31620018, 0x00000008, 0x2d800001, 0x00000000, 0x00000000, 1131 0xf1, 0xf9, 0x41, 0xef, 0xfd, 0xfd, 0xa6, 0x4e, 0x3c, 0x6d, 0xd4, 0xd5,
2018 0x00000010, 0x91de0000, 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c000e00, 1132 0x5c, 0x6d, 0x84, 0xcc, 0xd5, 0xc5, 0xff, 0x3a, 0x57, 0x10, 0x98, 0xab,
2019 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x00000008, 0x2a000007, 1133 0xd5, 0xfa, 0xc1, 0xe6, 0x0a, 0xb8, 0x7e, 0x08, 0x99, 0xab, 0x18, 0xf3,
2020 0x00000018, 0x8000ff27, 0x00000010, 0xb1a0b016, 0x0000000b, 0x2fdf0002, 1134 0xf0, 0x94, 0xcf, 0x33, 0x20, 0xaa, 0xc7, 0xb0, 0x7d, 0xc6, 0x2c, 0xeb,
2021 0x00000000, 0x03d80000, 0x00000000, 0x2c200000, 0x00000008, 0x2c8000b0, 1135 0x92, 0xf4, 0x68, 0x47, 0xcb, 0xa8, 0x3f, 0xc7, 0x2e, 0x93, 0x9d, 0x41,
2022 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800150, 1136 0xfb, 0x49, 0x85, 0x0b, 0xb3, 0xf4, 0x7b, 0x4a, 0x83, 0x9f, 0x94, 0x15,
2023 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000008, 0x2c800000, 1137 0x12, 0x3d, 0x80, 0x0b, 0x00, 0x00, 0x00 };
2024 0x00000008, 0x2d000000, 0x00000008, 0x2d800108, 0x00000008, 0x07000001,
2025 0x00000010, 0xb5de1c00, 0x00000010, 0x2c620002, 0x00000018, 0x8000000a,
2026 0x0000000b, 0x2fdf0002, 0x00000000, 0x2c070000, 0x0000000c, 0x1f800001,
2027 0x00000010, 0x91de0000, 0x00000018, 0x8000ff11, 0x00000008, 0x2c8000b0,
2028 0x00000008, 0x2d000008, 0x00000010, 0x91d40000, 0x00000008, 0x2d800108,
2029 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x00000010, 0x91de0000,
2030 0x00000000, 0x2adf0000, 0x00000008, 0x2a00000a, 0x00000018, 0x8000ff07,
2031 0x00000000, 0x82265600, 0x0000000f, 0x47220008, 0x00000009, 0x070e000f,
2032 0x00000008, 0x070e0008, 0x00000008, 0x02800001, 0x00000007, 0x02851c00,
2033 0x00000008, 0x82850001, 0x00000000, 0x02840a00, 0x00000007, 0x42851c00,
2034 0x00000003, 0xc3aa5200, 0x00000000, 0x03b10e00, 0x00000010, 0x001f0000,
2035 0x0000000f, 0x0f280007, 0x00000007, 0x4b071c00, 0x00000000, 0x00000000,
2036 0x0000000f, 0x0a960003, 0x00000000, 0x0a955c00, 0x00000000, 0x4a005a00,
2037 0x00000000, 0x0c960a00, 0x00000009, 0x0c99ffff, 0x00000008, 0x0d00ffff,
2038 0x00000010, 0xb1963202, 0x00000008, 0x0f800005, 0x00000010, 0x00220020,
2039 0x00000000, 0x02a70000, 0x00000010, 0xb1850002, 0x00000008, 0x82850200,
2040 0x00000000, 0x02000000, 0x00000000, 0x03a60000, 0x00000018, 0x8000004e,
2041 0x00000000, 0x072b0000, 0x00000001, 0x878c1c00, 0x00000000, 0x870e1e00,
2042 0x00000000, 0x860c1e00, 0x00000000, 0x03061e00, 0x00000010, 0xb18e0003,
2043 0x00000018, 0x80000047, 0x00000018, 0x8000fffa, 0x00000010, 0x918c0003,
2044 0x00000010, 0xb1870002, 0x00000018, 0x80000043, 0x00000010, 0x91d40000,
2045 0x0000000c, 0x29800001, 0x00000000, 0x2a860000, 0x00000000, 0x230c0000,
2046 0x00000000, 0x2b070000, 0x00000010, 0xb187000e, 0x00000008, 0x2a000008,
2047 0x00000018, 0x8000003b, 0x00000010, 0x91d40000, 0x00000000, 0x28d18c00,
2048 0x00000000, 0x2a860000, 0x00000000, 0x230c0000, 0x00000000, 0x2b070000,
2049 0x00000018, 0x8000fff8, 0x00000010, 0x91d40000, 0x0000000c, 0x29800001,
2050 0x00000000, 0x2aab0000, 0x00000000, 0xa3265600, 0x00000000, 0x2b000000,
2051 0x0000000c, 0x1f800001, 0x00000008, 0x2a000008, 0x00000018, 0x8000fec8,
2052 0x00000010, 0x91d40000, 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001,
2053 0x00000008, 0x2a000009, 0x00000018, 0x8000fec3, 0x00000010, 0x91d40000,
2054 0x0000000c, 0x29800001, 0x0000000c, 0x1f800001, 0x00000000, 0x29420000,
2055 0x00000008, 0x2a000002, 0x00000018, 0x8000febd, 0x00000018, 0x8000febc,
2056 0x00000010, 0xb1bcb016, 0x0000000b, 0x2fdf0002, 0x00000000, 0x03d80000,
2057 0x00000000, 0x2c3c0000, 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008,
2058 0x00000010, 0x91d40000, 0x00000008, 0x2d800150, 0x00000000, 0x00000000,
2059 0x00000010, 0x205f0000, 0x00000008, 0x2c800000, 0x00000008, 0x2d000000,
2060 0x00000008, 0x2d800108, 0x00000008, 0x07000001, 0x00000010, 0xb5de1c00,
2061 0x00000010, 0x2c620002, 0x00000018, 0x8000000a, 0x0000000b, 0x2fdf0002,
2062 0x00000000, 0x2c070000, 0x0000000c, 0x1f800000, 0x00000010, 0x91de0000,
2063 0x00000018, 0x8000fea6, 0x00000008, 0x2c8000b0, 0x00000008, 0x2d000008,
2064 0x00000010, 0x91d40000, 0x00000008, 0x2d800108, 0x0000000c, 0x29800000,
2065 0x0000000c, 0x1f800000, 0x00000010, 0x91de0000, 0x00000000, 0x2adf0000,
2066 0x00000008, 0x2a000006, 0x00000018, 0x8000fe9c, 0x00000008, 0x03050004,
2067 0x00000006, 0x83040c00, 0x00000008, 0x02850200, 0x00000000, 0x86050c00,
2068 0x00000001, 0x860c0e00, 0x00000008, 0x02040004, 0x00000000, 0x02041800,
2069 0x00000000, 0x83871800, 0x00000018, 0x00020000 };
2070 1138
2071static u32 bnx2_rv2p_proc2[] = { 1139static u8 bnx2_rv2p_proc2[] = {
2072 0x00000000, 0x2a000000, 0x00000010, 0xb1d40000, 0x00000008, 0x02540003, 1140 0x1f, 0x8b, 0x08, 0x08, 0x7e, 0xd1, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
2073 0x00000018, 0x00040000, 0x00000018, 0x8000000a, 0x00000018, 0x8000000a, 1141 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xcd, 0x58, 0x5b, 0x6c,
2074 0x00000018, 0x8000000e, 0x00000018, 0x80000056, 0x00000018, 0x800001b9, 1142 0x54, 0x55, 0x14, 0x3d, 0xf3, 0xe8, 0xcc, 0x9d, 0xe9, 0xed, 0x9d, 0xf2,
2075 0x00000018, 0x800001e1, 0x00000018, 0x8000019b, 0x00000018, 0x800001f9, 1143 0xb2, 0x03, 0xad, 0x08, 0xe5, 0xd1, 0x56, 0x29, 0xe8, 0x54, 0xab, 0x18,
2076 0x00000018, 0x8000019f, 0x00000018, 0x800001a6, 0x00000018, 0x80000000, 1144 0x15, 0x2c, 0x5a, 0x8c, 0x26, 0x68, 0xf0, 0xf9, 0x63, 0x14, 0x04, 0xda,
2077 0x0000000c, 0x29800001, 0x00000000, 0x2a000000, 0x0000000c, 0x29800000, 1145 0x9a, 0x56, 0x9b, 0x16, 0xfb, 0x81, 0xaf, 0x09, 0x14, 0x6a, 0x4c, 0x25,
2078 0x00000010, 0x20530000, 0x00000018, 0x8000ffee, 0x0000000c, 0x29800001, 1146 0xd6, 0x08, 0xc5, 0x47, 0xa0, 0x11, 0x1f, 0x84, 0xf0, 0xd3, 0x1f, 0x3b,
2079 0x00000010, 0x91de0000, 0x00000010, 0x001f0000, 0x00000000, 0x2f80aa00, 1147 0x8d, 0x7f, 0x0a, 0x24, 0x6a, 0x88, 0xc4, 0xa8, 0x9f, 0x24, 0x68, 0xa0,
2080 0x00000000, 0x2a000000, 0x00000000, 0x0d610000, 0x00000000, 0x03620000, 1148 0x21, 0x0a, 0x58, 0x8b, 0x63, 0x4c, 0xb4, 0xf5, 0xec, 0xbd, 0xf6, 0xb9,
2081 0x00000000, 0x2c400000, 0x00000000, 0x02638c00, 0x00000000, 0x26460000, 1149 0x73, 0xef, 0x6d, 0x8b, 0x1a, 0xf9, 0x70, 0x3e, 0xba, 0x7b, 0xce, 0xd9,
2082 0x00000010, 0x00420002, 0x00000008, 0x02040012, 0x00000010, 0xb9060836, 1150 0x67, 0x3f, 0xd6, 0xde, 0x67, 0x9f, 0x7d, 0xae, 0x52, 0xfc, 0xbb, 0xb6,
2083 0x00000000, 0x0f580000, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000, 1151 0x94, 0xc9, 0x37, 0x83, 0x96, 0xfe, 0x1b, 0x51, 0x0f, 0x85, 0xd3, 0x3c,
2084 0x00000000, 0x0b660000, 0x00000000, 0x0c000000, 0x00000000, 0x0b800000, 1152 0x8e, 0x2a, 0xa2, 0x49, 0xa5, 0xb2, 0x5e, 0xea, 0x08, 0x7d, 0x44, 0xe8,
2085 0x00000010, 0x00420009, 0x00000008, 0x0cc60012, 0x00000008, 0x0f800003, 1153 0x70, 0x08, 0xf4, 0xb4, 0xd0, 0x77, 0x84, 0xfe, 0x2e, 0xf4, 0x80, 0xd0,
2086 0x00000000, 0x00000000, 0x00000010, 0x009f0000, 0x00000008, 0x27110012, 1154 0x0f, 0x85, 0xea, 0x5f, 0xd6, 0xd6, 0x7f, 0xf4, 0xb0, 0x46, 0x89, 0x7e,
2087 0x00000000, 0x66900000, 0x00000008, 0xa31b0012, 0x00000018, 0x80000008, 1155 0x1b, 0xd3, 0x35, 0xb0, 0xe3, 0xc1, 0x05, 0xc4, 0x77, 0x61, 0xa2, 0xc0,
2088 0x00000000, 0x0cc60000, 0x00000008, 0x0f800003, 0x00000000, 0x00000000, 1156 0x87, 0xf9, 0x53, 0x7d, 0xa0, 0xd7, 0x60, 0xd7, 0xe1, 0xec, 0x0a, 0xb3,
2089 0x00000010, 0x009f0000, 0x00000000, 0x27110000, 0x00000000, 0x66900000, 1157 0x1f, 0x64, 0x43, 0x09, 0xe8, 0xc6, 0x08, 0xe8, 0xea, 0x65, 0x4c, 0x7a,
2090 0x00000000, 0x231b0000, 0x00000010, 0xb197320e, 0x00000000, 0x25960000, 1158 0x9f, 0x0a, 0x63, 0xdc, 0xb8, 0x94, 0xf6, 0x87, 0x55, 0x83, 0x22, 0x3f,
2091 0x00000000, 0x021b0000, 0x00000010, 0x001f0000, 0x00000008, 0x0f800003, 1159 0x67, 0xaa, 0x68, 0x98, 0xc6, 0xf5, 0x56, 0x6c, 0x18, 0xeb, 0x8f, 0xa5,
2092 0x0000000c, 0x29800000, 0x00000010, 0x20530000, 0x00000000, 0x22c50800, 1160 0x40, 0x37, 0x25, 0x41, 0xcf, 0x08, 0xdd, 0x52, 0x2c, 0x7a, 0x6c, 0x31,
2093 0x00000010, 0x009f0000, 0x00000000, 0x27002200, 0x00000000, 0x26802000, 1161 0xbf, 0x98, 0xf6, 0x25, 0x5c, 0x39, 0xc7, 0x6d, 0xe0, 0x96, 0x95, 0xfd,
2094 0x00000000, 0x231b0000, 0x0000000c, 0x69520001, 0x00000018, 0x8000fff3, 1162 0x4a, 0xc1, 0xce, 0x03, 0xb2, 0x3e, 0xa3, 0x0a, 0xb3, 0xaf, 0x6f, 0xc1,
2095 0x00000010, 0x01130002, 0x00000010, 0xb1980003, 0x00000010, 0x001f0000, 1163 0xb8, 0xfc, 0x20, 0xf9, 0xa7, 0xff, 0xcf, 0x62, 0x7e, 0xfa, 0xfd, 0xf8,
2096 0x00000008, 0x0f800004, 0x00000008, 0x22000003, 0x00000008, 0x2c80000c, 1164 0x15, 0xf6, 0x83, 0x96, 0x2f, 0xa2, 0x75, 0x27, 0xd3, 0x3f, 0x88, 0xf1,
2097 0x00000008, 0x2d00000c, 0x00000010, 0x009f0000, 0x00000000, 0x25960000, 1165 0xde, 0x25, 0x32, 0x1f, 0x36, 0xf8, 0x18, 0x79, 0x41, 0x5c, 0x99, 0x58,
2098 0x0000000c, 0x29800000, 0x00000000, 0x32140000, 0x00000000, 0x32950000, 1166 0xc7, 0x2a, 0x7d, 0xf2, 0x2b, 0x15, 0xe4, 0x2f, 0xc8, 0x2e, 0x35, 0xf2,
2099 0x00000000, 0x33160000, 0x00000000, 0x31e32e00, 0x00000008, 0x2d800010, 1167 0x81, 0xfb, 0xfa, 0x16, 0xb2, 0x73, 0x4c, 0xc7, 0x01, 0xb8, 0xcd, 0x0a,
2100 0x00000010, 0x20530000, 0x00000018, 0x8000ffac, 0x00000000, 0x23000000, 1168 0x95, 0xb2, 0xdc, 0x7d, 0x83, 0x5e, 0x3d, 0x51, 0xad, 0x07, 0xfa, 0x54,
2101 0x00000000, 0x25e60000, 0x00000008, 0x2200000b, 0x0000000c, 0x69520000, 1169 0xa5, 0xc5, 0x20, 0x65, 0x97, 0x81, 0xaa, 0x5a, 0xbf, 0x1f, 0x7b, 0x97,
2102 0x0000000c, 0x29800000, 0x00000010, 0x20530000, 0x00000018, 0x8000ffa5, 1170 0x18, 0x7b, 0x30, 0x9e, 0x9d, 0x01, 0xdd, 0x23, 0xf4, 0xaa, 0x3a, 0x26,
2103 0x0000000c, 0x29800001, 0x00000010, 0x91de0000, 0x00000000, 0x2fd50000, 1171 0xcb, 0x7f, 0xb8, 0xc1, 0x62, 0x0c, 0xb2, 0xb5, 0xde, 0x7c, 0x38, 0x32,
2104 0x00000010, 0x001f0000, 0x00000000, 0x02700000, 0x00000000, 0x0d620000, 1172 0x61, 0xf0, 0x52, 0x8b, 0x40, 0xce, 0x2e, 0x21, 0x3e, 0x1d, 0x9c, 0x4a,
2105 0x00000000, 0xbb630800, 0x00000000, 0x2a000000, 0x00000009, 0x076000ff, 1173 0xc8, 0x5d, 0xdf, 0x32, 0x55, 0x1e, 0x7d, 0x30, 0x45, 0x1e, 0x61, 0xff,
2106 0x0000000f, 0x2c0e0007, 0x00000008, 0x2c800000, 0x00000008, 0x2d000064, 1174 0xb7, 0x2b, 0x7c, 0xf9, 0xa4, 0xda, 0x25, 0x4f, 0x36, 0x22, 0x8f, 0xac,
2107 0x00000008, 0x2d80011c, 0x00000009, 0x06420002, 0x0000000c, 0x61420001, 1175 0xa7, 0x3e, 0x91, 0x85, 0x6b, 0x13, 0xfa, 0xcf, 0x84, 0x7a, 0x32, 0x4e,
2108 0x00000000, 0x0f400000, 0x00000000, 0x02d08c00, 0x00000000, 0x23000000, 1176 0x01, 0x8a, 0x2b, 0x87, 0xfd, 0x53, 0xe2, 0xe7, 0x26, 0xed, 0x27, 0xd1,
2109 0x00000004, 0x826da000, 0x00000000, 0x8304a000, 0x00000000, 0x22c50c00, 1177 0x8a, 0x50, 0xb6, 0x36, 0xc1, 0x38, 0x35, 0xc4, 0xa0, 0xaf, 0x61, 0x03,
2110 0x00000000, 0x03760000, 0x00000004, 0x83860a00, 0x00000000, 0x83870c00, 1178 0xb6, 0xaf, 0x46, 0x5c, 0x7b, 0x4f, 0x86, 0x8d, 0xfd, 0x51, 0xfa, 0x3b,
2111 0x00000010, 0x91de0000, 0x00000000, 0x037c0000, 0x00000000, 0x837b0c00, 1179 0xd0, 0xb6, 0x9d, 0x47, 0x03, 0xd1, 0x1d, 0x4c, 0xed, 0x63, 0x95, 0x58,
2112 0x00000001, 0x83060e00, 0x00000000, 0x83870c00, 0x00000000, 0x82850e00, 1180 0xee, 0x8a, 0xf0, 0x7a, 0x72, 0x97, 0xcc, 0xf7, 0xec, 0xf0, 0xdb, 0xfd,
2113 0x00000010, 0xb1860016, 0x0000000f, 0x47610018, 0x00000000, 0x068e0000, 1181 0x02, 0xf2, 0xdb, 0x7e, 0x7e, 0x47, 0x88, 0xa8, 0x13, 0x73, 0xf9, 0x98,
2114 0x0000000f, 0x47670010, 0x0000000f, 0x47e20010, 0x00000000, 0x870e1e00, 1182 0x3a, 0x3b, 0xb7, 0x13, 0xff, 0x55, 0x6a, 0xd7, 0x20, 0x29, 0x4e, 0xab,
2115 0x00000010, 0xb70e1a10, 0x00000010, 0x0ce7000e, 0x00000008, 0x22000009, 1183 0x0d, 0x6b, 0xb1, 0x6f, 0x77, 0x2c, 0xc5, 0xb8, 0x36, 0xad, 0x05, 0xfd,
2116 0x00000000, 0x286d0000, 0x0000000f, 0x65680010, 0x00000003, 0xf66c9400, 1184 0x1e, 0xf3, 0xf3, 0x9d, 0x1e, 0xe2, 0x2f, 0x9d, 0xe7, 0x0c, 0x71, 0x5e,
2117 0x00000010, 0xb972a003, 0x0000000c, 0x73e70019, 0x0000000c, 0x21420004, 1185 0xa9, 0x11, 0xce, 0xc7, 0x04, 0x65, 0x06, 0xff, 0xda, 0xaa, 0xc1, 0xdf,
2118 0x00000018, 0x8000023f, 0x00000000, 0x37ed0000, 0x0000000c, 0x73e7001a, 1186 0xbc, 0x99, 0x15, 0xbf, 0xd9, 0x9a, 0xe7, 0x3c, 0x18, 0xe8, 0x18, 0x26,
2119 0x00000010, 0x20530000, 0x00000008, 0x22000008, 0x0000000c, 0x61420004, 1187 0x3f, 0xe7, 0xaa, 0x91, 0x4e, 0xa2, 0x51, 0xd5, 0xb0, 0x90, 0xf0, 0x5e,
2120 0x00000000, 0x02f60000, 0x00000004, 0x82840a00, 0x00000010, 0xb1840a2b, 1188 0x15, 0x36, 0x71, 0x3a, 0x7f, 0x33, 0xcd, 0xcf, 0xd3, 0xeb, 0x26, 0x1e,
2121 0x00000010, 0x2d67000a, 0x00000010, 0xb96d0804, 0x00000004, 0xb6ed0a00, 1189 0x24, 0xd7, 0x92, 0x78, 0x45, 0x5d, 0x7c, 0xf2, 0x61, 0xf8, 0xdb, 0xcd,
2122 0x00000000, 0x37ed0000, 0x00000018, 0x80000029, 0x0000000c, 0x61420000, 1190 0x76, 0x5f, 0x97, 0xec, 0xe6, 0xfc, 0x4a, 0xaa, 0x26, 0x8e, 0x7f, 0xd4,
2123 0x00000000, 0x37040000, 0x00000000, 0x37850000, 0x0000000c, 0x33e7001a, 1191 0x6a, 0x1b, 0xc6, 0xfa, 0xf9, 0x8f, 0x8d, 0x5c, 0xd2, 0x53, 0x23, 0x75,
2124 0x00000018, 0x80000024, 0x00000010, 0xb96d0809, 0x00000004, 0xb6ed0a00, 1192 0x44, 0xb9, 0x72, 0xa2, 0x37, 0x83, 0xee, 0x34, 0x7a, 0xeb, 0x88, 0x6f,
2125 0x00000000, 0x036d0000, 0x00000004, 0xb76e0c00, 0x00000010, 0x91ee0c1f, 1193 0xb1, 0x42, 0xfe, 0x26, 0x26, 0xc9, 0x69, 0x03, 0xce, 0xf6, 0x33, 0xec,
2126 0x0000000c, 0x73e7001a, 0x00000004, 0xb6ef0c00, 0x00000000, 0x37ed0000, 1194 0xf7, 0x35, 0xf6, 0x85, 0x3e, 0x63, 0x2f, 0xe6, 0x2f, 0xfa, 0xf4, 0x95,
2127 0x00000018, 0x8000001b, 0x0000000c, 0x61420000, 0x00000010, 0xb7ee0a05, 1195 0x7b, 0xf4, 0x11, 0x7f, 0x51, 0xf2, 0x02, 0xef, 0x9b, 0x63, 0x3d, 0x3b,
2128 0x00000010, 0xb96f0815, 0x00000003, 0xb76e0800, 0x00000004, 0xb7ef0a00, 1196 0xcc, 0xb8, 0x58, 0xcf, 0x0c, 0x41, 0xfe, 0xc5, 0x21, 0xe2, 0x9f, 0x23,
2129 0x00000018, 0x80000015, 0x00000010, 0x0ce7000c, 0x00000008, 0x22000009, 1197 0x7a, 0xed, 0xff, 0x88, 0xe7, 0x9c, 0x30, 0xe4, 0x4c, 0x8f, 0x5f, 0xc1,
2130 0x00000000, 0x286d0000, 0x0000000f, 0x65680010, 0x00000003, 0xf66c9400, 1198 0x6f, 0xe3, 0x17, 0xcb, 0xb5, 0x47, 0x73, 0x69, 0xe6, 0x33, 0xf1, 0xe8,
2131 0x00000010, 0xb972a003, 0x0000000c, 0x73e70019, 0x0000000c, 0x21420004, 1199 0x0e, 0x73, 0x02, 0xa6, 0x1b, 0x16, 0xfa, 0x71, 0x33, 0xf6, 0x9c, 0xdf,
2132 0x00000018, 0x80000215, 0x00000010, 0x20530000, 0x00000008, 0x22000008, 1200 0xcc, 0x79, 0x3e, 0xd1, 0x26, 0x75, 0x40, 0x71, 0x9d, 0xb9, 0x5d, 0xe2,
2133 0x0000000c, 0x61420004, 0x00000000, 0x37040000, 0x00000000, 0x37850000, 1201 0xa1, 0xf3, 0x3a, 0x04, 0xff, 0x46, 0x73, 0x2c, 0x3f, 0xd9, 0xc5, 0x79,
2134 0x00000000, 0x036d0000, 0x00000003, 0xb8f10c00, 0x00000018, 0x80000004, 1202 0xb9, 0xd2, 0x8e, 0xe6, 0x38, 0x5e, 0xd6, 0xd9, 0x21, 0x6c, 0x2b, 0xd4,
2135 0x00000000, 0x02840000, 0x00000002, 0x21421800, 0x0000000c, 0x61420000, 1203 0x4f, 0xc8, 0x6b, 0xb6, 0x41, 0x9b, 0xa4, 0x8e, 0x9e, 0x15, 0xda, 0x6d,
2136 0x00000000, 0x286d0000, 0x0000000f, 0x65ed0010, 0x00000009, 0x266dffff, 1204 0x33, 0x3e, 0xba, 0x8e, 0x59, 0x2c, 0x3f, 0x9b, 0x32, 0xf7, 0x0c, 0xd6,
2137 0x00000000, 0x23000000, 0x00000010, 0xb1840a3d, 0x00000010, 0x01420002, 1205 0x9f, 0x16, 0x39, 0x3f, 0x0a, 0x55, 0x22, 0xa7, 0x55, 0xf6, 0x9f, 0xf3,
2138 0x00000004, 0xb8f10a00, 0x00000003, 0x83760a00, 0x00000010, 0xb8040c39, 1206 0xc9, 0x89, 0x04, 0xe4, 0x84, 0x94, 0xc1, 0xcd, 0x9c, 0xef, 0x5d, 0x52,
2139 0x00000010, 0xb7e6080a, 0x00000000, 0x0a640000, 0x00000000, 0x0ae50000, 1207 0xbf, 0xf7, 0xc5, 0xa6, 0xab, 0xb7, 0x7c, 0x0e, 0xdc, 0xba, 0x5a, 0x8e,
2140 0x00000009, 0x0c68ffff, 0x00000009, 0x0b67ffff, 0x00000000, 0x0be60000, 1208 0x3a, 0x53, 0x1f, 0x0d, 0xb3, 0xbf, 0x03, 0xdd, 0x3b, 0x80, 0x53, 0x8f,
2141 0x00000000, 0x0c840000, 0x00000010, 0xb197320c, 0x00000008, 0x0f800002, 1209 0xe0, 0x14, 0x07, 0x4e, 0xf3, 0x0a, 0xf5, 0x59, 0x14, 0xd4, 0x90, 0xfe,
2142 0x00000018, 0x8000000a, 0x00000000, 0x0a6a0000, 0x00000000, 0x0aeb0000, 1210 0x53, 0x21, 0xe3, 0xc7, 0xbe, 0x98, 0xaf, 0xfe, 0xf6, 0x9a, 0xfa, 0x5b,
2143 0x00000000, 0x0c000000, 0x00000009, 0x0b6cffff, 0x00000000, 0x0be90000, 1211 0xa8, 0xd3, 0xc4, 0xff, 0xb3, 0xa9, 0x6f, 0x5a, 0x9f, 0xd1, 0xff, 0x6f,
2144 0x00000000, 0x0c840000, 0x00000010, 0xb1973203, 0x00000008, 0x0f800002, 1212 0xf5, 0x72, 0x9c, 0x92, 0xdd, 0x7d, 0x26, 0xce, 0x98, 0x2e, 0xd4, 0xd9,
2145 0x00000018, 0x80000001, 0x00000010, 0x001f0000, 0x00000000, 0x0c860000, 1213 0x22, 0x22, 0xcb, 0x46, 0x3a, 0x99, 0x5e, 0xdf, 0xbc, 0x15, 0xf3, 0x65,
2146 0x00000000, 0x06980000, 0x00000008, 0x0f800003, 0x00000000, 0x00000000, 1214 0x7c, 0x4e, 0x6e, 0x09, 0x01, 0xaf, 0xa8, 0x3a, 0xde, 0x87, 0xba, 0xae,
2147 0x00000010, 0x009f0000, 0x00000010, 0xb1973210, 0x00000000, 0x231b0000, 1215 0xe2, 0x2c, 0xaf, 0xe2, 0x28, 0xc7, 0x3f, 0xaa, 0xe5, 0x12, 0xdf, 0x67,
2148 0x00000000, 0x02043600, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010, 1216 0xa1, 0x42, 0x3e, 0x7a, 0xfd, 0xd9, 0xad, 0xf3, 0x84, 0xec, 0x88, 0xe9,
2149 0x00000009, 0x2607ffff, 0x00000000, 0x27111a00, 0x00000000, 0x66900000, 1217 0xbc, 0xa5, 0xb1, 0x3e, 0x47, 0xb6, 0xe4, 0xf9, 0x1a, 0xe6, 0xb3, 0xc7,
2150 0x0000000c, 0x29000000, 0x00000018, 0x800001de, 0x00000000, 0x06980000, 1218 0x22, 0x34, 0xff, 0x80, 0xd5, 0xd3, 0x87, 0xf9, 0x9f, 0x1a, 0x69, 0xbc,
2151 0x00000010, 0x20530000, 0x00000000, 0x22c58c00, 0x00000010, 0x001f0000, 1219 0xce, 0x7e, 0x0d, 0xe7, 0xcc, 0x7e, 0x0d, 0xf5, 0xcb, 0x2a, 0x3a, 0x88,
2152 0x00000008, 0x0f800003, 0x00000018, 0x8000fff0, 0x00000000, 0x02043600, 1220 0xba, 0xd6, 0x78, 0x10, 0xf2, 0x71, 0x4f, 0x7b, 0xfd, 0xf2, 0xe2, 0x47,
2153 0x00000000, 0x231b0000, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010, 1221 0xe7, 0xe1, 0xb2, 0x38, 0xd9, 0xcf, 0x09, 0x4e, 0x97, 0x7c, 0xf1, 0x39,
2154 0x00000009, 0x2607ffff, 0x00000000, 0x27111a00, 0x00000000, 0x66900000, 1222 0x6c, 0xe2, 0xd3, 0x1b, 0x93, 0xf3, 0xd2, 0x7c, 0x29, 0xe8, 0x17, 0xf1,
2155 0x0000000c, 0x29000000, 0x00000010, 0x91840a02, 0x00000002, 0x21421800, 1223 0x9d, 0x71, 0xef, 0x9d, 0xae, 0x95, 0xa0, 0xdd, 0x2b, 0xe5, 0x9c, 0xd6,
2156 0x00000000, 0x32140000, 0x00000000, 0x32950000, 0x00000005, 0x73e72c00, 1224 0xf9, 0xf3, 0x6b, 0x3e, 0xea, 0xf2, 0xb8, 0x7b, 0x4f, 0x20, 0xbf, 0xac,
2157 0x00000005, 0x74683000, 0x00000000, 0x33170000, 0x00000018, 0x80000138, 1225 0x9d, 0xf0, 0x4b, 0xbd, 0x28, 0x79, 0x3c, 0x2e, 0xf4, 0x65, 0xc9, 0xdf,
2158 0x00000010, 0x91c60004, 0x00000008, 0x07000004, 0x00000010, 0xb1c41c02, 1226 0x6d, 0xd2, 0xb7, 0x98, 0xfe, 0xe2, 0x0f, 0xcc, 0x3b, 0xfd, 0x6e, 0x5f,
2159 0x00000010, 0x91840a04, 0x00000018, 0x800001c3, 0x00000010, 0x20530000, 1227 0x60, 0xea, 0x36, 0x8d, 0x43, 0xca, 0x89, 0x13, 0x83, 0x36, 0xeb, 0x33,
2160 0x00000000, 0x22c58c00, 0x00000010, 0xb1840a8e, 0x0000000c, 0x21420006, 1228 0x24, 0x4a, 0xcf, 0x1a, 0xe0, 0x35, 0x52, 0x07, 0xbe, 0xdd, 0x91, 0xb0,
2161 0x00000010, 0x0ce7001a, 0x0000000f, 0x43680010, 0x00000000, 0x03f30c00, 1229 0x8c, 0x21, 0x6f, 0xac, 0xda, 0x77, 0x0f, 0xd7, 0x4f, 0xc6, 0x93, 0xe4,
2162 0x00000010, 0x91870850, 0x0000000f, 0x46ec0010, 0x00000010, 0xb68d0c4e, 1230 0xc6, 0xdc, 0xfa, 0x24, 0x79, 0xaf, 0x26, 0x84, 0x96, 0x2f, 0xbe, 0x2c,
2163 0x00000000, 0x838d0c00, 0x00000000, 0xa3050800, 0x00000001, 0xa3460e00, 1231 0xbe, 0x85, 0xfe, 0x64, 0xa9, 0x17, 0xdf, 0x97, 0x34, 0xbe, 0xbc, 0xaf,
2164 0x00000000, 0x02048c00, 0x00000010, 0x91840a02, 0x00000002, 0x21421800, 1232 0xbe, 0xf9, 0x12, 0xa6, 0x4b, 0x6f, 0x05, 0xed, 0xbb, 0x95, 0xe7, 0x17,
2165 0x00000010, 0x001f0000, 0x00000008, 0x22000008, 0x00000003, 0x8384a000, 1233 0xa3, 0xee, 0x11, 0x7e, 0x9c, 0x5f, 0xf5, 0x6f, 0x0c, 0x9a, 0x7e, 0x42,
2166 0x0000000f, 0x65870010, 0x00000009, 0x2607ffff, 0x00000000, 0x27750c00, 1234 0xf0, 0x08, 0xf4, 0x41, 0x65, 0x77, 0x80, 0xbe, 0x29, 0x74, 0xce, 0x2a,
2167 0x00000000, 0x66f40000, 0x0000000c, 0x29000000, 0x00000018, 0x800001aa, 1235 0xd0, 0xbd, 0xab, 0xfc, 0x71, 0x88, 0xa5, 0x7c, 0x71, 0xac, 0x47, 0x1c,
2168 0x00000000, 0x03068c00, 0x00000003, 0xf4680c00, 0x00000010, 0x20530000, 1236 0x8f, 0x4c, 0x04, 0xeb, 0x81, 0xc4, 0x4b, 0xc7, 0x27, 0x70, 0xbf, 0x1b,
2169 0x00000000, 0x22c58c00, 0x00000018, 0x8000ffe5, 0x00000000, 0x39760000, 1237 0xfd, 0xe2, 0xce, 0xdf, 0xc5, 0xed, 0x4a, 0xc7, 0xab, 0x7b, 0x25, 0xee,
2170 0x00000000, 0x39840000, 0x0000000c, 0x33e70019, 0x00000010, 0x001f0000, 1238 0x93, 0x0e, 0xe9, 0x4b, 0xc7, 0xdc, 0xfb, 0xe2, 0x9f, 0xc4, 0x31, 0x7e,
2171 0x00000000, 0x031e0000, 0x00000000, 0x0760fe00, 0x0000000f, 0x0f0e0007, 1239 0x85, 0xe3, 0x78, 0xf7, 0xff, 0x2c, 0x8e, 0x9d, 0x12, 0xc7, 0x22, 0xb9,
2172 0x00000000, 0x83850800, 0x00000000, 0x0a7d0000, 0x00000000, 0x0afe0000, 1240 0x57, 0x4d, 0xbf, 0xd9, 0x2e, 0x7d, 0x18, 0xf5, 0x8d, 0x7e, 0xbd, 0x4f,
2173 0x00000000, 0x0b7f0000, 0x00000000, 0x0d7a0000, 0x00000000, 0x0c000000, 1241 0x70, 0x1f, 0x78, 0xb5, 0x5b, 0x8f, 0xe7, 0x33, 0x7f, 0x4e, 0xf6, 0x95,
2174 0x00000000, 0x0bfc0000, 0x00000000, 0x0c970e00, 0x00000008, 0x0f800003, 1242 0xca, 0xbe, 0x7b, 0x26, 0xed, 0x3b, 0xc5, 0xf5, 0xee, 0xf1, 0xf1, 0xc9,
2175 0x0000000f, 0x47670010, 0x00000008, 0x070e0001, 0x0000000b, 0xc38000ff, 1243 0xef, 0x15, 0x9f, 0x9d, 0x59, 0x95, 0x02, 0xee, 0xa8, 0xe3, 0xb1, 0x29,
2176 0x00000002, 0x43870000, 0x00000001, 0x33e70e00, 0x0000000f, 0x038e0010, 1244 0xde, 0x37, 0x86, 0x1f, 0xf9, 0xb5, 0x36, 0x85, 0xba, 0x05, 0xfe, 0xb9,
2177 0x00000002, 0x33e70e00, 0x00000000, 0x28f30000, 0x00000010, 0x009f0000, 1245 0x9e, 0x7a, 0x4a, 0xe3, 0xfb, 0xc7, 0xa7, 0xef, 0x57, 0x8d, 0x3c, 0xc4,
2178 0x00000000, 0x02043600, 0x00000010, 0x91840a02, 0x00000002, 0x21421800, 1246 0x6d, 0x43, 0xb8, 0x84, 0xf9, 0x4e, 0xb7, 0xf3, 0x7d, 0xe7, 0xfa, 0xb7,
2179 0x00000008, 0x22000006, 0x00000000, 0x231b0000, 0x00000000, 0x23ff0000, 1247 0x9a, 0xfd, 0x3a, 0x2a, 0xfe, 0x55, 0x88, 0x7f, 0x7a, 0xb9, 0x96, 0xeb,
2180 0x00000000, 0x241b0000, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010, 1248 0xbe, 0x75, 0xba, 0xdd, 0xeb, 0xdf, 0x9d, 0x97, 0xd1, 0xf7, 0x4f, 0xfb,
2181 0x00000009, 0x2607ffff, 0x00000000, 0x27110000, 0x00000000, 0x26900000, 1249 0x63, 0xd1, 0x9b, 0x32, 0xfa, 0x49, 0x5e, 0xb9, 0xf4, 0x7d, 0xd4, 0x4f,
2182 0x0000000c, 0x29000000, 0x00000018, 0x8000017e, 0x00000003, 0xf4683600, 1250 0x62, 0x7e, 0x72, 0x9f, 0x41, 0xfa, 0x5b, 0x34, 0x5e, 0x72, 0xdf, 0x70,
2183 0x00000000, 0x3a100000, 0x00000000, 0x3a910000, 0x00000003, 0xf66c2400, 1251 0x3e, 0x47, 0xac, 0xa3, 0x6c, 0x57, 0x5e, 0xf9, 0x71, 0x39, 0x23, 0x7c,
2184 0x00000010, 0x001f0000, 0x00000010, 0xb1923604, 0x00000008, 0x0f800004, 1252 0x53, 0xc5, 0x8d, 0xd6, 0x8b, 0x64, 0x7d, 0x2a, 0xbf, 0xc5, 0x4e, 0x37,
2185 0x00000000, 0x00000000, 0x00000010, 0x009f0000, 0x00000000, 0x3e170000, 1253 0x1f, 0x64, 0x1f, 0xf3, 0x35, 0x0b, 0x5f, 0x34, 0x34, 0x39, 0xfe, 0x18,
2186 0x00000000, 0x3e940000, 0x00000000, 0x3f150000, 0x00000000, 0x3f960000, 1254 0xe5, 0xab, 0x38, 0xaf, 0xf7, 0x6f, 0xcb, 0x11, 0x9f, 0x76, 0x9e, 0xf3,
2187 0x00000010, 0x001f0000, 0x00000000, 0x0f060000, 0x00000010, 0x20530000, 1255 0xf0, 0xfb, 0x80, 0x7d, 0xe9, 0x2b, 0x80, 0x23, 0xf1, 0xcd, 0x50, 0x4d,
2188 0x00000000, 0x22c53600, 0x00000018, 0x8000ffac, 0x00000010, 0x001f0000, 1256 0xce, 0x74, 0x78, 0xe1, 0xdd, 0x30, 0x9a, 0x33, 0x78, 0xdb, 0xec, 0xe7,
2189 0x00000000, 0x031e0000, 0x00000000, 0x83850800, 0x00000009, 0x076000ff, 1257 0x48, 0x27, 0xe9, 0x5f, 0x1d, 0xc0, 0x31, 0x2c, 0x38, 0x9e, 0x50, 0x7f,
2190 0x0000000f, 0x0f0e0007, 0x00000000, 0x0c000000, 0x00000000, 0x0a7d0000, 1258 0x9f, 0xf7, 0xc6, 0x0f, 0x6f, 0x5e, 0x8c, 0xff, 0x19, 0xcc, 0xe3, 0x87,
2191 0x00000000, 0x0afe0000, 0x00000000, 0x0b7f0000, 0x00000000, 0x0d7a0000, 1259 0xe5, 0x5d, 0xdd, 0x18, 0x03, 0xfd, 0x2e, 0x62, 0xec, 0x46, 0x5e, 0xdf,
2192 0x00000000, 0x0bfc0000, 0x00000000, 0x0c970e00, 0x00000008, 0x0f800003, 1260 0xc3, 0xe7, 0xb5, 0x4a, 0xf5, 0xf2, 0xbb, 0xc3, 0x52, 0x0d, 0x6b, 0xc9,
2193 0x0000000f, 0x47670010, 0x00000008, 0x070e0001, 0x0000000b, 0xc38000ff, 1261 0xee, 0x94, 0xae, 0x7f, 0xc8, 0x77, 0x27, 0xee, 0xbd, 0xb7, 0x75, 0x0d,
2194 0x00000002, 0x43870000, 0x00000001, 0x33e70e00, 0x0000000f, 0x038e0010, 1262 0x4c, 0xc4, 0x69, 0x58, 0x31, 0x33, 0xc1, 0x82, 0xde, 0xf8, 0xe2, 0x4b,
2195 0x00000002, 0x33e70e00, 0x00000000, 0x39840000, 0x00000003, 0xb9720800, 1263 0x5e, 0x7e, 0xaf, 0xbf, 0x18, 0xf3, 0x65, 0xf7, 0x91, 0x9c, 0x88, 0xda,
2196 0x00000000, 0x28f30000, 0x0000000f, 0x65680010, 0x00000010, 0x009f0000, 1264 0x8b, 0xba, 0xfb, 0xee, 0x1e, 0xd0, 0xb7, 0xd5, 0xbd, 0xd8, 0x3f, 0x73,
2197 0x00000000, 0x02043600, 0x00000010, 0x91840a02, 0x00000002, 0x21421800, 1265 0x3b, 0xd7, 0x51, 0xab, 0x4c, 0xf2, 0x2b, 0x0d, 0x5c, 0xd3, 0xa8, 0xc3,
2198 0x00000008, 0x22000007, 0x00000000, 0x231b0000, 0x00000000, 0x23ff0000, 1266 0x13, 0x13, 0xaa, 0x04, 0xf7, 0x9a, 0x79, 0x07, 0xab, 0x1a, 0xd1, 0x8b,
2199 0x00000000, 0x241b0000, 0x00000003, 0x8384a000, 0x0000000f, 0x65870010, 1267 0xfa, 0x68, 0x17, 0xde, 0xc1, 0x44, 0x8b, 0x83, 0x7d, 0x9f, 0x55, 0xe8,
2200 0x00000009, 0x2607ffff, 0x00000000, 0x27110000, 0x00000000, 0x26900000, 1268 0xaf, 0x08, 0x8f, 0xf7, 0x5d, 0x1c, 0xd3, 0xe1, 0x60, 0x5d, 0xf2, 0xfa,
2201 0x0000000c, 0x29000000, 0x00000018, 0x80000145, 0x00000003, 0xf4683600, 1269 0x15, 0x93, 0x73, 0xfd, 0xab, 0xfb, 0x6e, 0xee, 0xe1, 0x7e, 0x2a, 0x19,
2202 0x00000000, 0x3a100000, 0x00000000, 0x3a910000, 0x00000003, 0xf66c2400, 1270 0xac, 0xcb, 0x01, 0xf9, 0xfb, 0x24, 0x7e, 0x49, 0x89, 0x5f, 0x54, 0xc7,
2203 0x00000010, 0x001f0000, 0x00000010, 0xb1923604, 0x00000008, 0x0f800004, 1271 0x0f, 0xef, 0xed, 0x4f, 0x7d, 0xef, 0x7a, 0xaa, 0x1b, 0xde, 0xbc, 0xfb,
2204 0x00000000, 0x00000000, 0x00000010, 0x009f0000, 0x00000000, 0x3e170000, 1272 0xfc, 0x4f, 0x63, 0xd7, 0xf6, 0x98, 0xb7, 0x0e, 0x57, 0xbb, 0xe7, 0xae,
2205 0x00000000, 0x3e940000, 0x00000000, 0x3f150000, 0x00000000, 0x3f960000, 1273 0x43, 0xde, 0x8b, 0x5d, 0x87, 0x30, 0xce, 0x73, 0xbf, 0xbc, 0x38, 0xd3,
2206 0x00000010, 0x001f0000, 0x00000000, 0x0f060000, 0x00000010, 0x20530000, 1274 0x21, 0x79, 0x74, 0x57, 0x44, 0xf2, 0x41, 0xec, 0xfb, 0x22, 0x62, 0xee,
2207 0x00000000, 0x22c53600, 0x00000018, 0x8000ff73, 0x00000010, 0x0ce70005, 1275 0x1b, 0x8c, 0xbf, 0x92, 0xfb, 0xee, 0x97, 0x2a, 0xf4, 0xd9, 0x17, 0x87,
2208 0x00000008, 0x2c80000c, 0x00000008, 0x2d000070, 0x00000008, 0x2d800010, 1276 0xcc, 0xfb, 0xc4, 0xbc, 0x57, 0xb0, 0xbe, 0x3e, 0xae, 0x04, 0x67, 0xbe,
2209 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000018, 0x8000011d, 1277 0xff, 0xb5, 0x3f, 0x9c, 0xaf, 0x99, 0x8e, 0x61, 0x1f, 0x5e, 0x2a, 0x16,
2210 0x00000000, 0x2c1e0000, 0x00000008, 0x2c8000b8, 0x00000008, 0x2d000010, 1278 0x78, 0xbf, 0xc4, 0xe5, 0xfb, 0x45, 0xbf, 0xe0, 0xe1, 0xf0, 0xf9, 0x29,
2211 0x00000008, 0x2d800048, 0x00000000, 0x00000000, 0x00000010, 0x91de0000, 1279 0xd5, 0xf6, 0x13, 0x4d, 0x65, 0x3a, 0x73, 0xb0, 0xa7, 0xd5, 0xed, 0x23,
2212 0x00000018, 0x8000fe5d, 0x0000000c, 0x29800001, 0x00000000, 0x2a000000, 1280 0xc1, 0x27, 0xd4, 0x79, 0x4b, 0xde, 0xc1, 0xf2, 0x5e, 0xd6, 0xef, 0x61,
2213 0x00000010, 0x001f0000, 0x00000000, 0x0f008000, 0x00000008, 0x0f800007, 1281 0xf4, 0x73, 0xad, 0x79, 0x8c, 0xc7, 0xd0, 0xb7, 0x39, 0xbf, 0xca, 0xbd,
2214 0x00000018, 0x80000006, 0x0000000c, 0x29800001, 0x00000000, 0x2a000000, 1282 0xb5, 0x75, 0x9b, 0xe9, 0x4b, 0xa7, 0xde, 0x67, 0xee, 0xb9, 0xb6, 0x6a,
2215 0x00000010, 0x001f0000, 0x0000000f, 0x0f470007, 0x00000008, 0x0f800008, 1283 0xd0, 0x16, 0xee, 0x5b, 0x1f, 0xb2, 0xf3, 0x92, 0x1f, 0x85, 0x77, 0x89,
2216 0x00000018, 0x80000119, 0x00000010, 0x20530000, 0x00000018, 0x8000fe4f, 1284 0xff, 0x3d, 0x62, 0xfa, 0x85, 0x73, 0xc5, 0xb8, 0x67, 0xf3, 0xbd, 0x34,
2217 0x0000000c, 0x29800001, 0x00000010, 0x91de0000, 0x00000000, 0x2fd50000, 1285 0xa1, 0xdf, 0x23, 0x09, 0x6f, 0x9e, 0x25, 0x32, 0x65, 0x82, 0xfb, 0xec,
2218 0x00000000, 0x2a000000, 0x00000009, 0x0261ffff, 0x0000000d, 0x70e10001, 1286 0x9b, 0x40, 0xf7, 0xdc, 0x84, 0xbe, 0xbc, 0xb5, 0x4b, 0x70, 0xb8, 0x91,
2219 0x00000018, 0x80000101, 0x00000000, 0x2c400000, 0x00000008, 0x2c8000c4, 1287 0x71, 0x5b, 0x3e, 0x9a, 0x0b, 0x7e, 0x67, 0x21, 0x5c, 0x7f, 0x73, 0xfb,
2220 0x00000008, 0x2d00001c, 0x00000008, 0x2d800001, 0x00000005, 0x70e10800, 1288 0xd1, 0x73, 0x6c, 0xd7, 0xbc, 0x81, 0x3c, 0xf3, 0xcd, 0x55, 0xb3, 0xf8,
2221 0x00000010, 0x91de0000, 0x00000018, 0x8000fe41, 0x0000000c, 0x29800001, 1289 0xfc, 0xa6, 0x9d, 0x51, 0xd8, 0x99, 0xe9, 0x17, 0xbf, 0xda, 0x6f, 0x01,
2222 0x00000010, 0x91de0000, 0x00000000, 0x2fd50000, 0x00000010, 0x001f0000, 1290 0xed, 0x92, 0x3a, 0x73, 0xd2, 0x7d, 0x97, 0xc3, 0x4e, 0x53, 0x4f, 0x26,
2223 0x00000000, 0x02700000, 0x00000000, 0x0d620000, 0x00000000, 0xbb630800, 1291 0xbf, 0x13, 0x30, 0x9e, 0x5b, 0xc7, 0x63, 0xd5, 0xbc, 0x95, 0xe4, 0x97,
2224 0x00000000, 0x2a000000, 0x00000000, 0x0f400000, 0x00000000, 0x2c400000, 1292 0x4c, 0x7a, 0xcf, 0x16, 0xe2, 0x6e, 0xf2, 0xc1, 0xe4, 0x8f, 0xf7, 0x1d,
2225 0x0000000c, 0x73e7001b, 0x00000010, 0x0ce7000e, 0x00000000, 0x286d0000, 1293 0x7b, 0x9b, 0xa7, 0x5e, 0xfa, 0xe3, 0xef, 0x70, 0xbe, 0x84, 0x65, 0x3d,
2226 0x0000000f, 0x65ed0010, 0x00000009, 0x266dffff, 0x00000018, 0x80000069, 1294 0x96, 0xe9, 0xef, 0xbb, 0x3c, 0x3e, 0x6f, 0x01, 0x9f, 0x8c, 0xd8, 0x6d,
2227 0x00000008, 0x02000004, 0x00000010, 0x91c40803, 0x00000018, 0x800000f6, 1295 0xb7, 0xf0, 0x3b, 0x74, 0x96, 0xda, 0x25, 0xf1, 0x39, 0x57, 0x2d, 0x75,
2228 0x00000010, 0x20530000, 0x00000018, 0x800000e5, 0x00000008, 0x2c8000b8, 1296 0x50, 0xec, 0xfb, 0x49, 0xfa, 0x1f, 0xc4, 0x31, 0x6e, 0x6f, 0xc9, 0x49,
2229 0x00000008, 0x2d000010, 0x00000008, 0x2d800048, 0x00000018, 0x80000005, 1297 0xdc, 0x24, 0x8f, 0x9e, 0x16, 0xbf, 0x7f, 0x84, 0xdf, 0xb6, 0xf1, 0xbb,
2230 0x00000008, 0x2c8000c4, 0x00000008, 0x2d00001c, 0x00000008, 0x2d800001, 1298 0xc5, 0xf5, 0xdb, 0xd4, 0x59, 0xaf, 0x9c, 0x99, 0x3a, 0x1f, 0xb8, 0x5e,
2231 0x00000000, 0x00000000, 0x00000010, 0x205f0000, 0x00000008, 0x2c800048, 1299 0xdb, 0x27, 0xf9, 0xdd, 0x53, 0x24, 0xe7, 0xa1, 0x42, 0xbe, 0x3b, 0x38,
2232 0x00000008, 0x2d000068, 0x00000008, 0x2d800104, 0x00000000, 0x00000000, 1300 0xe2, 0x4f, 0x89, 0x6a, 0x5a, 0xee, 0xdd, 0x57, 0x2c, 0xfb, 0x92, 0x7a,
2233 0x00000010, 0x91de0000, 0x00000000, 0x27f60000, 0x00000010, 0xb87a9e04, 1301 0x1f, 0xe6, 0x71, 0xfe, 0xec, 0x29, 0xf0, 0x34, 0xdf, 0x11, 0x8c, 0xdc,
2234 0x00000008, 0x2200000d, 0x00000018, 0x800000e2, 0x00000010, 0x20530000, 1302 0xe0, 0x39, 0xf2, 0xe2, 0xc7, 0x37, 0x13, 0xff, 0x50, 0x07, 0x74, 0x9c,
2235 0x00000018, 0x8000fe18, 0x0000000c, 0x29800001, 0x00000010, 0x91de0000, 1303 0x6a, 0xcd, 0xf7, 0x07, 0xcc, 0xe3, 0xfc, 0x26, 0xf7, 0xb7, 0xa1, 0xaf,
2236 0x00000000, 0x2fd50000, 0x00000010, 0x001f0000, 0x00000000, 0x02700000, 1304 0xdc, 0xdf, 0x76, 0x48, 0xfa, 0x08, 0xc1, 0xe5, 0x81, 0x21, 0xb2, 0x43,
2237 0x00000000, 0x0d620000, 0x00000000, 0xbb630800, 0x00000000, 0x2a000000, 1305 0xc7, 0xae, 0xd2, 0x7f, 0xfe, 0x61, 0x47, 0x54, 0xec, 0x28, 0xf7, 0xd8,
2238 0x00000010, 0x0e670011, 0x00000000, 0x286d0000, 0x0000000f, 0x65ed0010, 1306 0x11, 0xd0, 0x7b, 0x1d, 0xcd, 0xaf, 0x50, 0x5f, 0x73, 0x1e, 0x2e, 0x57,
2239 0x00000009, 0x266dffff, 0x00000004, 0xb8f1a000, 0x00000000, 0x0f400000, 1307 0xeb, 0x29, 0x47, 0xf4, 0xbd, 0xb0, 0xae, 0x88, 0xc6, 0xcb, 0xd4, 0xab,
2240 0x0000000c, 0x73e7001c, 0x00000018, 0x80000040, 0x00000008, 0x02000004, 1308 0xf0, 0xb7, 0x37, 0x59, 0x84, 0x3a, 0x96, 0xdc, 0x49, 0xf3, 0x35, 0xea,
2241 0x00000010, 0x91c40802, 0x00000018, 0x800000cd, 0x00000000, 0x2c1e0000, 1309 0xd5, 0x3e, 0x0e, 0xc4, 0x2b, 0xea, 0x18, 0xea, 0x73, 0xe3, 0x41, 0xb6,
2242 0x00000008, 0x2c8000b8, 0x00000008, 0x2d000010, 0x00000008, 0x2d800048, 1310 0x47, 0x1d, 0x1f, 0x34, 0xf5, 0x7a, 0xca, 0xef, 0x98, 0xbd, 0xeb, 0xa4,
2243 0x00000010, 0x20530000, 0x00000010, 0x91de0000, 0x00000018, 0x8000fdfe, 1311 0x5e, 0x9c, 0xc0, 0x77, 0x51, 0xfd, 0x5e, 0x23, 0xfe, 0xd9, 0xe6, 0x3d,
2244 0x0000000c, 0x29800001, 0x00000000, 0x03550000, 0x00000000, 0x06460000, 1312 0xb8, 0xfb, 0x98, 0xa1, 0x8b, 0x7c, 0xe3, 0xfd, 0x27, 0x96, 0x0a, 0xad,
2245 0x00000000, 0x03d60000, 0x00000000, 0x2a000000, 0x0000000f, 0x0f480007, 1313 0xf2, 0x8d, 0x07, 0xd6, 0x55, 0x09, 0xad, 0x36, 0xe3, 0xe9, 0xbe, 0x2b,
2246 0x00000010, 0xb18c0027, 0x0000000f, 0x47420008, 0x00000009, 0x070e000f, 1314 0x5e, 0x29, 0xf9, 0x62, 0xf7, 0x7b, 0xe2, 0xcf, 0x47, 0xe2, 0xcf, 0x59,
2247 0x00000008, 0x070e0008, 0x00000010, 0x001f0000, 0x00000008, 0x09000001, 1315 0xe0, 0x9f, 0xdc, 0x28, 0x78, 0x2c, 0x0a, 0xea, 0x17, 0xbb, 0xdc, 0x73,
2248 0x00000007, 0x09121c00, 0x00000003, 0xcbca9200, 0x00000000, 0x0b97a200, 1316 0x63, 0xd6, 0x11, 0x8f, 0x47, 0xd5, 0x5f, 0x3f, 0x97, 0x8f, 0x31, 0xd8,
2249 0x00000007, 0x4b171c00, 0x0000000f, 0x0a960003, 0x00000000, 0x0a959c00, 1317 0x17, 0x00, 0x00, 0x00 };
2250 0x00000000, 0x4a009a00, 0x00000008, 0x82120001, 0x00000001, 0x0c170800,
2251 0x00000000, 0x02180000, 0x00000000, 0x0c971800, 0x00000008, 0x0d00ffff,
2252 0x00000008, 0x0f800006, 0x0000000c, 0x29000000, 0x00000008, 0x22000001,
2253 0x00000000, 0x22c50c00, 0x00000010, 0x009f0000, 0x00000010, 0xb197320b,
2254 0x00000000, 0x231b0000, 0x00000000, 0x27110800, 0x00000000, 0x66900000,
2255 0x00000018, 0x800000a4, 0x00000000, 0x02180000, 0x00000010, 0x20530000,
2256 0x00000000, 0x22c53600, 0x00000010, 0x001f0000, 0x00000008, 0x0f800006,
2257 0x00000018, 0x8000fff5, 0x00000010, 0x91870002, 0x00000008, 0x2200000a,
2258 0x00000000, 0x231b0000, 0x00000000, 0x27110800, 0x00000000, 0x66900000,
2259 0x00000018, 0x80000098, 0x00000008, 0x0200000a, 0x00000010, 0x91c40804,
2260 0x00000010, 0x02c20003, 0x00000010, 0x001f0000, 0x00000008, 0x0f800008,
2261 0x00000010, 0x20530000, 0x00000018, 0x8000fdc9, 0x00000000, 0x06820000,
2262 0x00000010, 0x001f0000, 0x00000010, 0x0ce70028, 0x00000000, 0x03720000,
2263 0x00000000, 0xa8760c00, 0x00000000, 0x0cf60000, 0x00000010, 0xb8723224,
2264 0x00000000, 0x03440000, 0x00000008, 0x22000010, 0x00000000, 0x03ca0000,
2265 0x0000000f, 0x65680010, 0x00000000, 0x0bcf0000, 0x00000000, 0x27f20000,
2266 0x00000010, 0xb7ef3203, 0x0000000c, 0x21420004, 0x0000000c, 0x73e70019,
2267 0x00000000, 0x07520000, 0x00000000, 0x29000000, 0x00000018, 0x8000007e,
2268 0x00000004, 0xb9723200, 0x00000010, 0x20530000, 0x00000000, 0x22060000,
2269 0x0000000c, 0x61420004, 0x00000000, 0x25070000, 0x00000000, 0x27970000,
2270 0x00000000, 0x290e0000, 0x00000010, 0x0ce70010, 0x00000010, 0xb873320f,
2271 0x0000000f, 0x436c0010, 0x00000000, 0x03f30c00, 0x00000000, 0x03f30000,
2272 0x00000000, 0x83990e00, 0x00000001, 0x83860e00, 0x00000000, 0x83060e00,
2273 0x00000003, 0xf66c0c00, 0x00000000, 0x39f30e00, 0x00000000, 0x3af50e00,
2274 0x00000000, 0x7a740000, 0x0000000f, 0x43680010, 0x00000001, 0x83860e00,
2275 0x00000000, 0x83060e00, 0x00000003, 0xf4680c00, 0x00000000, 0x286d0000,
2276 0x00000000, 0x03690000, 0x00000010, 0xb1f60c54, 0x00000000, 0x0a6a0000,
2277 0x00000000, 0x0aeb0000, 0x00000009, 0x0b6cffff, 0x00000000, 0x0c000000,
2278 0x00000000, 0x0be90000, 0x00000003, 0x8cf6a000, 0x0000000c, 0x09800002,
2279 0x00000010, 0x009f0000, 0x00000010, 0xb8173209, 0x00000000, 0x35140000,
2280 0x00000000, 0x35950000, 0x00000005, 0x766c2c00, 0x00000000, 0x34970000,
2281 0x00000004, 0xb8f12e00, 0x00000010, 0x001f0000, 0x00000008, 0x0f800004,
2282 0x00000018, 0x8000fff7, 0x00000000, 0x03e90000, 0x00000010, 0xb8f6a01a,
2283 0x00000010, 0x20130019, 0x00000010, 0xb1f10e18, 0x00000000, 0x83973200,
2284 0x00000000, 0x38700e00, 0x00000000, 0xbb760e00, 0x00000000, 0x37d00000,
2285 0x0000000c, 0x73e7001a, 0x00000003, 0xb8f1a000, 0x00000000, 0x32140000,
2286 0x00000000, 0x32950000, 0x00000005, 0x73e72c00, 0x00000000, 0x33190000,
2287 0x00000005, 0x74680000, 0x00000010, 0x0ce7000d, 0x00000008, 0x22000009,
2288 0x00000000, 0x07520000, 0x00000000, 0x29000000, 0x0000000c, 0x73e70019,
2289 0x0000000f, 0x65680010, 0x0000000c, 0x21420004, 0x00000018, 0x8000003c,
2290 0x00000010, 0x20530000, 0x0000000c, 0x61420004, 0x00000000, 0x290e0000,
2291 0x00000018, 0x80000002, 0x00000010, 0x91973206, 0x00000000, 0x35140000,
2292 0x00000000, 0x35950000, 0x00000005, 0x766c2c00, 0x00000000, 0x34990000,
2293 0x00000004, 0xb8f13200, 0x00000000, 0x83690c00, 0x00000010, 0xb1860013,
2294 0x00000000, 0x28e90000, 0x00000008, 0x22000004, 0x00000000, 0x23ec0000,
2295 0x00000000, 0x03690000, 0x00000010, 0xb8660c07, 0x00000009, 0x036cffff,
2296 0x00000000, 0x326a0000, 0x00000000, 0x32eb0000, 0x00000005, 0x73e70c00,
2297 0x00000000, 0x33690000, 0x00000005, 0x74680000, 0x0000000c, 0x73e7001c,
2298 0x00000000, 0x03690000, 0x00000010, 0xb1f60c12, 0x00000010, 0xb1d00c11,
2299 0x0000000c, 0x21420005, 0x0000000c, 0x33e7001c, 0x00000018, 0x8000000e,
2300 0x00000010, 0x2e67000d, 0x00000000, 0x03690000, 0x00000010, 0xb1f60c0b,
2301 0x00000010, 0xb1d00c0a, 0x00000000, 0x03440000, 0x00000008, 0x2200000c,
2302 0x00000000, 0x07520000, 0x00000000, 0x29000000, 0x00000018, 0x80000015,
2303 0x0000000c, 0x33e7001c, 0x00000010, 0x20530000, 0x00000000, 0x22060000,
2304 0x00000000, 0x290e0000, 0x00000018, 0x000d0000, 0x00000000, 0x06820000,
2305 0x00000010, 0x2de7000d, 0x00000010, 0x0ce7000c, 0x00000000, 0x27f20000,
2306 0x00000010, 0xb96d9e0a, 0x00000000, 0xa86d9e00, 0x00000009, 0x0361ffff,
2307 0x00000010, 0xb7500c07, 0x00000008, 0x2200000f, 0x0000000f, 0x65680010,
2308 0x00000000, 0x29000000, 0x00000018, 0x80000004, 0x0000000c, 0x33e7001b,
2309 0x00000010, 0x20530000, 0x00000018, 0x000d0000, 0x00000000, 0x2b820000,
2310 0x00000010, 0x20d2002f, 0x00000010, 0x0052002e, 0x00000009, 0x054e0007,
2311 0x00000010, 0xb18a002c, 0x00000000, 0x050a8c00, 0x00000008, 0x850a0008,
2312 0x00000010, 0x918a0029, 0x00000003, 0xc5008800, 0x00000008, 0xa3460001,
2313 0x00000010, 0xb1c60007, 0x00000008, 0x22000001, 0x0000000c, 0x29800000,
2314 0x00000010, 0x20530000, 0x00000000, 0x274e8c00, 0x00000000, 0x66cd0000,
2315 0x00000000, 0x22c58c00, 0x00000008, 0x22000014, 0x00000003, 0x22c58e00,
2316 0x00000003, 0x23c58e00, 0x00000003, 0x22c58e00, 0x00000003, 0x26cd9e00,
2317 0x00000003, 0x27cd9e00, 0x00000003, 0x26cd9e00, 0x00000003, 0x274ea000,
2318 0x00000003, 0x284ea000, 0x00000003, 0x274ea000, 0x0000000c, 0x69520000,
2319 0x0000000c, 0x29800000, 0x00000010, 0x20530000, 0x00000003, 0x22c58e00,
2320 0x00000003, 0x23c58e00, 0x00000003, 0x22c58e00, 0x00000003, 0x26cd9e00,
2321 0x00000003, 0x27cd9e00, 0x00000003, 0x26cd9e00, 0x00000003, 0x274ea000,
2322 0x00000003, 0x284ea000, 0x00000003, 0x274ea000, 0x00000000, 0xa2c58c00,
2323 0x00000000, 0xa74e8c00, 0x00000000, 0xe6cd0000, 0x0000000f, 0x620a0010,
2324 0x00000008, 0x23460001, 0x0000000c, 0x29800000, 0x00000010, 0x20530000,
2325 0x0000000c, 0x29520000, 0x00000018, 0x80000002, 0x0000000c, 0x29800000,
2326 0x00000018, 0x00570000 };
2327 1318
2328static const int bnx2_TPAT_b06FwReleaseMajor = 0x1; 1319static const int bnx2_TPAT_b06FwReleaseMajor = 0x1;
2329static const int bnx2_TPAT_b06FwReleaseMinor = 0x0; 1320static const int bnx2_TPAT_b06FwReleaseMinor = 0x0;
@@ -2339,201 +1330,199 @@ static const u32 bnx2_TPAT_b06FwBssAddr = 0x08001aa0;
2339static const int bnx2_TPAT_b06FwBssLen = 0x250; 1330static const int bnx2_TPAT_b06FwBssLen = 0x250;
2340static const u32 bnx2_TPAT_b06FwSbssAddr = 0x08001a60; 1331static const u32 bnx2_TPAT_b06FwSbssAddr = 0x08001a60;
2341static const int bnx2_TPAT_b06FwSbssLen = 0x34; 1332static const int bnx2_TPAT_b06FwSbssLen = 0x34;
2342static u32 bnx2_TPAT_b06FwText[(0x122c/4) + 1] = { 1333static u8 bnx2_TPAT_b06FwText[] = {
2343 0x0a000218, 0x00000000, 0x00000000, 0x0000000d, 0x74706174, 0x20322e35, 1334 0x1f, 0x8b, 0x08, 0x08, 0x47, 0xd2, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
2344 0x2e313100, 0x02050b01, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1335 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x57, 0x4d, 0x68,
2345 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1336 0x1c, 0xe7, 0x19, 0x7e, 0xe7, 0x77, 0x47, 0x62, 0x25, 0x8d, 0x93, 0x3d,
2346 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1337 0xac, 0x5d, 0xa5, 0x99, 0x91, 0x46, 0x3f, 0x54, 0x26, 0x9e, 0x84, 0xa5,
2347 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800, 1338 0x56, 0x61, 0x20, 0xe3, 0x99, 0x95, 0x2c, 0x0c, 0x05, 0x07, 0x42, 0x08,
2348 0x24421a60, 0x3c030800, 0x24631cf0, 0xac400000, 0x0043202b, 0x1480fffd, 1339 0xe4, 0xb2, 0x1d, 0x49, 0x36, 0x85, 0x1e, 0x5a, 0x9a, 0x43, 0xa0, 0x05,
2349 0x24420004, 0x3c1d0800, 0x37bd2ffc, 0x03a0f021, 0x3c100800, 0x26100860, 1340 0x0f, 0x33, 0xeb, 0x34, 0x87, 0xc5, 0xdb, 0xaa, 0xc5, 0xbe, 0x94, 0xd6,
2350 0x3c1c0800, 0x279c1a60, 0x0e000546, 0x00000000, 0x0000000d, 0x8f820010, 1341 0x95, 0xea, 0xe8, 0xb2, 0x68, 0xe2, 0x53, 0x0f, 0xc5, 0xd8, 0xb4, 0x54,
2351 0x8c450008, 0x24030800, 0xaf430178, 0x97430104, 0x3c020008, 0xaf420140, 1342 0xd0, 0x53, 0x7b, 0x0a, 0x85, 0x5c, 0x4c, 0x69, 0x20, 0x85, 0x12, 0x44,
2352 0x8f820024, 0x30420001, 0x10400007, 0x3069ffff, 0x24020002, 0x2523fffe, 1343 0x0f, 0x21, 0xd4, 0xad, 0xa7, 0xcf, 0xfb, 0xcd, 0x8c, 0xbc, 0xbb, 0x95,
2353 0xa7420146, 0xa7430148, 0x0a000242, 0x3c020800, 0xa7400146, 0x3c020800, 1344 0x5b, 0x1f, 0x02, 0x15, 0xac, 0x66, 0xe6, 0xfb, 0xde, 0xf7, 0xfb, 0x79,
2354 0x8c43083c, 0x1460000e, 0x24020f00, 0x8f820024, 0x30430020, 0x0003182b, 1345 0x9f, 0xe7, 0x79, 0xbf, 0xf7, 0x6b, 0xca, 0x34, 0x49, 0xe5, 0xdf, 0x14,
2355 0x00031823, 0x30650009, 0x30420c00, 0x24030400, 0x14430002, 0x34a40001, 1346 0x7e, 0x6f, 0x7f, 0xe3, 0xdb, 0x6f, 0x7f, 0xf5, 0xa5, 0x57, 0x2c, 0xa2,
2356 0x34a40005, 0xa744014a, 0x0a000264, 0x3c020800, 0x8f830014, 0x14620008, 1347 0x57, 0x5e, 0x92, 0x64, 0x5d, 0xa6, 0x2f, 0xe0, 0x4f, 0x21, 0x32, 0xab,
2357 0x00000000, 0x8f820024, 0x30420020, 0x0002102b, 0x00021023, 0x3042000d, 1348 0xf1, 0xf9, 0x47, 0x86, 0xec, 0x75, 0xce, 0x04, 0x0e, 0x19, 0x8a, 0x77,
2358 0x0a000262, 0x34420005, 0x8f820024, 0x30420020, 0x0002102b, 0x00021023, 1349 0x34, 0xbb, 0xe9, 0x10, 0xf9, 0x83, 0x15, 0x2b, 0xa4, 0x7f, 0xe5, 0x71,
2359 0x30420009, 0x34420001, 0xa742014a, 0x3c020800, 0x8c430820, 0x8f840024, 1350 0x43, 0x25, 0x6e, 0x7f, 0xc1, 0xfb, 0xe7, 0xb9, 0x7b, 0xe7, 0xed, 0xa3,
2360 0x3c020048, 0x00621825, 0x30840006, 0x24020002, 0x1082000d, 0x2c820003, 1351 0xdb, 0x0a, 0x19, 0xa6, 0xd7, 0x31, 0xcc, 0x45, 0x32, 0x66, 0xe1, 0xf3,
2361 0x50400005, 0x24020004, 0x10800012, 0x3c020001, 0x0a000284, 0x00000000, 1352 0xd3, 0xa5, 0x75, 0x8d, 0xa6, 0xab, 0xb1, 0x4c, 0x4a, 0xfa, 0x06, 0xad,
2362 0x10820007, 0x24020006, 0x1482000f, 0x3c020111, 0x0a00027c, 0x00621025, 1353 0xf5, 0x30, 0x8e, 0xf3, 0x8e, 0x14, 0x66, 0xaa, 0x14, 0xde, 0x32, 0x48,
2363 0x0a00027b, 0x3c020101, 0x3c020011, 0x00621025, 0x24030001, 0xaf421000, 1354 0xf6, 0x7c, 0x29, 0xc8, 0x1c, 0xf4, 0x49, 0x14, 0xb8, 0x35, 0xf2, 0xcd,
2364 0xaf830020, 0x0a000284, 0x00000000, 0x00621025, 0xaf421000, 0xaf800020, 1355 0x3c, 0xff, 0xa6, 0x2b, 0x93, 0xec, 0x3c, 0xce, 0xe7, 0x17, 0xd6, 0xa5,
2365 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8f830020, 0x1060003f, 1356 0x60, 0x7f, 0x43, 0x0a, 0xf7, 0x03, 0xde, 0x37, 0xd6, 0xb1, 0x2e, 0xf9,
2366 0x3c048000, 0x8f421000, 0x00441024, 0x1040fffd, 0x00000000, 0x10600039, 1357 0xfb, 0xfc, 0xf4, 0x8c, 0xb0, 0x37, 0x4d, 0x9d, 0x06, 0xcd, 0xc8, 0x0e,
2367 0x00000000, 0x8f421000, 0x3c030020, 0x00431024, 0x10400034, 0x00000000, 1358 0xfb, 0x5a, 0x14, 0xba, 0x2b, 0x4d, 0x85, 0xe6, 0xf1, 0x9b, 0xa0, 0x6d,
2368 0x97421014, 0x14400031, 0x00000000, 0x97421008, 0x8f840010, 0x24420006, 1359 0x97, 0xea, 0x81, 0x4b, 0xaa, 0xe2, 0xc8, 0x14, 0x36, 0x24, 0xfa, 0x65,
2369 0x00024082, 0x00081880, 0x00643821, 0x8ce50000, 0x30430003, 0x30420001, 1360 0x4b, 0xc3, 0xef, 0x92, 0xd4, 0xde, 0xdf, 0x2a, 0xc7, 0x69, 0x50, 0x8a,
2370 0x10400004, 0x00000000, 0x0000000d, 0x0a0002c3, 0x00081080, 0x5460000f, 1361 0xb5, 0x44, 0x0d, 0x5e, 0x5b, 0xe1, 0x1f, 0xb8, 0x2b, 0xa6, 0x4c, 0xf3,
2371 0x30a5ffff, 0x3c06ffff, 0x00a62824, 0x0005182b, 0x00a61026, 0x0002102b, 1362 0xf8, 0x4d, 0xe1, 0x3d, 0x82, 0x9d, 0x46, 0x41, 0x6b, 0xbc, 0x6f, 0x02,
2372 0x00621824, 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x240001fb, 1363 0xef, 0x58, 0x27, 0xc6, 0x0a, 0xc4, 0x3a, 0x2c, 0xac, 0xc3, 0xa1, 0x6e,
2373 0x8ce20000, 0x0a0002c2, 0x00462825, 0x0005182b, 0x38a2ffff, 0x0002102b, 1364 0x7f, 0x03, 0xfb, 0x58, 0x68, 0x46, 0xa4, 0x53, 0x57, 0xac, 0x7d, 0x8a,
2374 0x00621824, 0x10600004, 0x00000000, 0x0000000d, 0x00000000, 0x24000205, 1365 0x12, 0x53, 0xa1, 0xe4, 0xac, 0x46, 0xfe, 0x65, 0x15, 0xdf, 0xcf, 0x51,
2375 0x8ce20000, 0x3445ffff, 0x00081080, 0x00441021, 0x3c030800, 0xac450000, 1366 0x6c, 0x4a, 0xb0, 0xe9, 0x96, 0xf8, 0xd5, 0xd0, 0xaf, 0xa3, 0x7d, 0x86,
2376 0x8c620830, 0x24420001, 0xac620830, 0x8f840018, 0x01202821, 0x24820008, 1367 0x92, 0xc6, 0x29, 0x49, 0xf6, 0xbe, 0x8f, 0xf6, 0x05, 0x33, 0xa2, 0xef,
2377 0x30421fff, 0x24434000, 0x0343d821, 0x30a30007, 0xaf84000c, 0xaf820018, 1368 0xe1, 0x29, 0xe1, 0xfb, 0x14, 0x8f, 0x87, 0x6f, 0x89, 0x14, 0x87, 0xcc,
2378 0xaf420084, 0x10600002, 0x24a20007, 0x3045fff8, 0x8f820030, 0x8f840000, 1369 0x20, 0xb3, 0x28, 0xcd, 0x2a, 0x5f, 0x6e, 0x2f, 0xda, 0xe2, 0x6c, 0x1c,
2379 0x00451821, 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023, 1370 0x3b, 0xd8, 0xf5, 0x5f, 0xa5, 0x8e, 0x49, 0xb1, 0xea, 0xc1, 0xa6, 0xef,
2380 0xaf820030, 0x8f840030, 0x34028000, 0x00821021, 0x03421821, 0x3c021000, 1371 0x98, 0x6d, 0xe0, 0xe4, 0x0b, 0x3c, 0xbf, 0xc6, 0xed, 0xfc, 0x87, 0x76,
2381 0xaf830010, 0xaf440080, 0x03e00008, 0xaf420178, 0x8f830024, 0x27bdffe0, 1372 0x8b, 0x14, 0xcf, 0x31, 0x43, 0x6a, 0x51, 0xd1, 0xd7, 0x30, 0x83, 0x5b,
2382 0xafbf0018, 0xafb10014, 0x30620200, 0x14400004, 0xafb00010, 0x0000000d, 1373 0x2f, 0x93, 0x2f, 0xe2, 0x61, 0xe0, 0xdd, 0xc4, 0x9e, 0x74, 0x60, 0x9b,
2383 0x00000000, 0x24000242, 0x00031a82, 0x30630003, 0x000310c0, 0x00431021, 1374 0xf8, 0x32, 0xc5, 0x4d, 0x83, 0xec, 0xd5, 0x2d, 0xf4, 0x7c, 0xdc, 0x53,
2384 0x00021080, 0x00431021, 0x00021080, 0x3c030800, 0x24631aa0, 0x00438821, 1375 0x10, 0x67, 0xc6, 0x49, 0x2d, 0xfd, 0x18, 0xd7, 0xdf, 0x62, 0x5d, 0xb1,
2385 0x8e240000, 0x10800004, 0x00000000, 0x0000000d, 0x00000000, 0x2400024d, 1376 0x69, 0xd0, 0x0c, 0x75, 0x5e, 0xcf, 0xf3, 0x3b, 0x6e, 0x9e, 0xeb, 0x9e,
2386 0x8f850010, 0x24020001, 0xae220000, 0x8ca70008, 0xa2200007, 0x8f620004, 1377 0xb3, 0xfc, 0x3e, 0xad, 0x34, 0x35, 0x5a, 0x34, 0xf1, 0x44, 0xdc, 0x1c,
2387 0x26300014, 0x02002021, 0x00021402, 0xa2220004, 0x304600ff, 0x24c60005, 1378 0xc4, 0x46, 0x2d, 0xe7, 0x9f, 0x2a, 0xd7, 0xfa, 0x48, 0x42, 0xe8, 0xe9,
2388 0x0e000673, 0x00063082, 0x8f620004, 0xa6220008, 0x8f430108, 0x3c021000, 1379 0xcf, 0xbd, 0xdf, 0xf0, 0xde, 0x97, 0xd7, 0x85, 0x7d, 0x9e, 0xef, 0xae,
2389 0x00621824, 0x10600008, 0x00000000, 0x97420104, 0x92230007, 0x2442ffec, 1380 0x3e, 0xcd, 0x5e, 0x93, 0x0b, 0xfb, 0x3c, 0x5f, 0x6b, 0xf1, 0x7c, 0x36,
2390 0x3045ffff, 0x34630002, 0x0a000321, 0xa2230007, 0x97420104, 0x2442fff0, 1381 0xf6, 0xc6, 0x9c, 0x24, 0x5a, 0x1b, 0xb8, 0x46, 0xd4, 0xc3, 0xba, 0x1c,
2391 0x3045ffff, 0x8f620004, 0x3042ffff, 0x2c420013, 0x54400005, 0x92230007, 1382 0x3c, 0x07, 0x4d, 0xac, 0xdd, 0x5e, 0xb6, 0x24, 0x83, 0x12, 0x27, 0x7f,
2392 0x92220007, 0x34420001, 0xa2220007, 0x92230007, 0x24020001, 0x10620009, 1383 0x11, 0x3c, 0xf0, 0x43, 0xc7, 0xfe, 0x53, 0xa8, 0xd4, 0x68, 0xcf, 0xad,
2393 0x28620002, 0x14400014, 0x24020002, 0x10620012, 0x24020003, 0x1062000a, 1384 0x53, 0x37, 0x6b, 0x52, 0x92, 0x75, 0x29, 0xc8, 0x64, 0x8c, 0x5f, 0xa3,
2394 0x00000000, 0x0a000342, 0x00000000, 0x8f820010, 0x8c43000c, 0x3c04ffff, 1385 0x5d, 0xe7, 0xf3, 0x7c, 0xcd, 0x75, 0x81, 0x33, 0xb1, 0x5f, 0x73, 0x8d,
2395 0x00641824, 0x00651825, 0x0a000342, 0xac43000c, 0x8f820010, 0x8c430010, 1386 0x66, 0xd1, 0xbf, 0x62, 0x6e, 0x91, 0x8b, 0x98, 0xcb, 0x88, 0xc9, 0xbc,
2396 0x3c04ffff, 0x00641824, 0x00651825, 0xac430010, 0x8f620004, 0x3042ffff, 1387 0x78, 0x4f, 0x32, 0x17, 0xfd, 0x14, 0xcb, 0x2d, 0xdb, 0x4c, 0xc8, 0x6e,
2397 0x24420002, 0x00021083, 0xa2220005, 0x304500ff, 0x8f820010, 0x3c04ffff, 1388 0x06, 0x0a, 0x99, 0xb2, 0x67, 0xc2, 0x26, 0xa6, 0x76, 0x66, 0xd0, 0x43,
2398 0x00052880, 0x00a22821, 0x8ca70000, 0x96220008, 0x97430104, 0x00e42024, 1389 0xe5, 0x1d, 0xc1, 0xe3, 0xb4, 0xff, 0x30, 0xbf, 0xb7, 0xd4, 0xa4, 0xfb,
2399 0x24420002, 0x00621823, 0x00833825, 0xaca70000, 0x92240005, 0x00041080, 1390 0x59, 0x83, 0xee, 0x66, 0x24, 0x47, 0x1c, 0xab, 0x86, 0x49, 0x1f, 0x64,
2400 0x02021021, 0x90430000, 0x3c05fff6, 0x34a5ffff, 0x3063000f, 0x00832021, 1391 0xd5, 0x3e, 0xc0, 0x65, 0x27, 0x39, 0xa3, 0x40, 0x67, 0x9b, 0xee, 0x03,
2401 0xa2240006, 0x308200ff, 0x24420003, 0x00021080, 0x02021021, 0x8c460000, 1392 0xb0, 0xc4, 0x06, 0x0e, 0x31, 0xf6, 0x5c, 0x3d, 0x79, 0x4f, 0xb7, 0xcf,
2402 0x308300ff, 0x8f820010, 0x3c04ff3f, 0x00031880, 0x00c53824, 0x00621821, 1393 0x6c, 0x3a, 0xf6, 0x7b, 0x21, 0xb3, 0xf3, 0x86, 0x8a, 0xd6, 0xe1, 0x38,
2403 0xae26000c, 0xac67000c, 0x8e22000c, 0x92230006, 0x3484ffff, 0x00441024, 1394 0x7c, 0x1d, 0xfe, 0x26, 0x5d, 0x87, 0x5e, 0x64, 0xc4, 0x63, 0xee, 0xc0,
2404 0x24630003, 0x00031880, 0x02031821, 0x00e42024, 0xae22000c, 0xac640000, 1395 0xa0, 0xfd, 0x5e, 0x8d, 0xac, 0x5d, 0x95, 0xa2, 0x7e, 0x83, 0xdc, 0x45,
2405 0x92220006, 0x24420004, 0x00021080, 0x02021021, 0x94470002, 0xac470000, 1396 0xdb, 0x22, 0x59, 0x6e, 0xc8, 0x88, 0xdf, 0xdc, 0x6e, 0x4e, 0xeb, 0xae,
2406 0x92230006, 0x8f820010, 0x00031880, 0x00621821, 0x24020010, 0xac670010, 1397 0x46, 0x87, 0xce, 0x77, 0x75, 0x9a, 0x4e, 0x5c, 0x9d, 0xd8, 0xc6, 0xa0,
2407 0x24030002, 0xa7420140, 0xa7400142, 0xa7400144, 0xa7430146, 0x97420104, 1398 0xb9, 0xf7, 0x0d, 0x29, 0xec, 0xf3, 0xfa, 0x39, 0xce, 0x46, 0x19, 0x67,
2408 0x24030001, 0x2442fffe, 0xa7420148, 0xa743014a, 0x8f820024, 0x24030002, 1399 0x55, 0x0a, 0x6e, 0xd5, 0x68, 0x7e, 0xe7, 0x6f, 0x79, 0xe0, 0x20, 0xc6,
2409 0x30440006, 0x1083000d, 0x2c820003, 0x10400005, 0x24020004, 0x10800011, 1400 0xe0, 0xf1, 0x66, 0xcb, 0x56, 0x68, 0x12, 0x6d, 0xbb, 0xdc, 0x77, 0x54,
2410 0x3c020009, 0x0a0003a5, 0x00000000, 0x10820007, 0x24020006, 0x1482000d, 1401 0xb6, 0xf3, 0x18, 0x79, 0x1e, 0xb8, 0xcf, 0x53, 0xc0, 0xfc, 0x7e, 0x9d,
2411 0x3c020119, 0x0a00039f, 0x24030001, 0x0a00039e, 0x3c020109, 0x3c020019, 1402 0x7d, 0x6a, 0x34, 0xb7, 0xc3, 0xba, 0xc0, 0x73, 0x97, 0xbf, 0x79, 0x6d,
2412 0x24030001, 0xaf421000, 0xaf830020, 0x0a0003a5, 0x00000000, 0xaf421000, 1403 0x13, 0x14, 0x61, 0x37, 0xd1, 0x72, 0x03, 0xfb, 0x97, 0x85, 0x06, 0x22,
2413 0xaf800020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x92220004, 1404 0xec, 0x56, 0x76, 0x26, 0xf1, 0x14, 0x71, 0x50, 0x0a, 0x3e, 0x73, 0x5e,
2414 0x24030008, 0x8f840020, 0x24420002, 0x30420007, 0x00621823, 0x30630007, 1405 0xa8, 0x53, 0x08, 0x5c, 0x55, 0xac, 0x67, 0x8b, 0x16, 0x9a, 0xdb, 0xa2,
2415 0x10800006, 0xae230010, 0x3c038000, 0x8f421000, 0x00431024, 0x1040fffd, 1406 0x0f, 0x6d, 0x03, 0xee, 0x33, 0xc7, 0xfa, 0xf0, 0x3d, 0xa8, 0xd6, 0x20,
2416 0x00000000, 0x8f820018, 0xaf82000c, 0x24420010, 0x30421fff, 0xaf820018, 1407 0x03, 0xf3, 0x14, 0xb3, 0x68, 0x62, 0xaf, 0x6b, 0x2e, 0xdb, 0xb3, 0x6d,
2417 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 0x3063ffff, 0x30620007, 1408 0xbc, 0xac, 0x91, 0xbd, 0xbc, 0x8b, 0xd1, 0xf7, 0x7b, 0xd8, 0xef, 0x4d,
2418 0x10400002, 0x24620007, 0x3043fff8, 0x8f820030, 0x8f840000, 0x00431821, 1409 0xce, 0x35, 0x8e, 0xf5, 0x17, 0x62, 0xfb, 0x79, 0xec, 0x79, 0x61, 0x35,
2419 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023, 0xaf820030, 1410 0xe5, 0xbe, 0x81, 0x46, 0xce, 0x4e, 0x6c, 0xaa, 0x88, 0xbd, 0x8c, 0xc0,
2420 0x8f840030, 0x34028000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x00821021, 1411 0x87, 0x3f, 0xfc, 0x2c, 0xd7, 0x3c, 0x70, 0xb8, 0x35, 0x03, 0x6c, 0x6c,
2421 0x03421821, 0x3c021000, 0xaf830010, 0xaf440080, 0xaf420178, 0x03e00008, 1412 0x2b, 0x85, 0x9e, 0x1d, 0x8c, 0x9b, 0xb8, 0x0a, 0xfc, 0x0a, 0x8c, 0xd8,
2422 0x27bd0020, 0x8f830024, 0x27bdffe0, 0xafbf0018, 0xafb10014, 0x30620200, 1413 0x6e, 0xbd, 0x97, 0x53, 0x2a, 0xe6, 0xba, 0xc6, 0x73, 0x21, 0xe7, 0x38,
2423 0x14400004, 0xafb00010, 0x0000000d, 0x00000000, 0x240002e4, 0x00031a82, 1414 0xab, 0xbf, 0x03, 0x27, 0x22, 0xaa, 0xd3, 0xe2, 0x41, 0x9d, 0xae, 0x0e,
2424 0x30630003, 0x000310c0, 0x00431021, 0x00021080, 0x00431021, 0x00021080, 1415 0xea, 0x34, 0x77, 0x43, 0x47, 0x1c, 0xf2, 0xbc, 0xdb, 0x62, 0x0d, 0x02,
2425 0x3c030800, 0x24631aa0, 0x00438021, 0x8e040000, 0x14800004, 0x00000000, 1416 0x6b, 0x87, 0xed, 0xec, 0xa6, 0x22, 0xf3, 0x3a, 0xd0, 0x7f, 0x40, 0xb4,
2426 0x0000000d, 0x00000000, 0x240002e9, 0x8f620004, 0x04410008, 0x26050014, 1417 0x35, 0xd0, 0x11, 0x37, 0x75, 0x68, 0x6c, 0x99, 0x2e, 0xfe, 0x84, 0xe8,
2427 0x92020006, 0x8e03000c, 0x24420003, 0x00021080, 0x00a21021, 0xac430000, 1418 0xe2, 0x80, 0x7d, 0x79, 0xfc, 0xc2, 0x27, 0xc2, 0x9e, 0x65, 0x60, 0x7e,
2428 0xae000000, 0x92020005, 0x24420001, 0x00021080, 0x00a21021, 0x8c430000, 1419 0x75, 0x20, 0x23, 0x1f, 0x20, 0x5f, 0xee, 0x07, 0xc8, 0x83, 0x6d, 0xfc,
2429 0x3c040001, 0x00641821, 0xac430000, 0x92060004, 0x27710008, 0x02202021, 1420 0xd6, 0x91, 0x1b, 0x19, 0x1b, 0xce, 0x13, 0x8f, 0x81, 0xcf, 0x06, 0xfa,
2430 0x24c60005, 0x0e000673, 0x00063082, 0x92040006, 0x3c057fff, 0x8f620004, 1421 0x2e, 0xa1, 0x8d, 0xf3, 0x16, 0xdb, 0xea, 0xd4, 0x76, 0xa7, 0x28, 0xad,
2431 0x00042080, 0x00912021, 0x8c830004, 0x34a5ffff, 0x00451024, 0x00621821, 1422 0x72, 0x91, 0xc9, 0xb9, 0xe8, 0x14, 0xf8, 0x34, 0x81, 0xfc, 0x72, 0x47,
2432 0xac830004, 0x92050005, 0x3c07ffff, 0x92040004, 0x00052880, 0x00b12821, 1423 0x19, 0xcd, 0x45, 0xc8, 0x59, 0x8d, 0xd3, 0xc8, 0x3d, 0x3f, 0x47, 0x3b,
2433 0x8ca30000, 0x97420104, 0x96060008, 0x00671824, 0x00441021, 0x00461023, 1424 0x8f, 0xf7, 0x33, 0x3c, 0x27, 0xf0, 0x7d, 0x1a, 0xb6, 0xc3, 0x79, 0xa8,
2434 0x3042ffff, 0x00621825, 0xaca30000, 0x92030007, 0x24020001, 0x1062000a, 1425 0xf2, 0x7b, 0x5a, 0x0e, 0x02, 0xef, 0x76, 0x0c, 0xd8, 0x5b, 0xd0, 0x0b,
2435 0x28620002, 0x1440001d, 0x2402000a, 0x24020002, 0x10620019, 0x24020003, 1426 0xc7, 0xbb, 0x86, 0x7c, 0xc1, 0x31, 0xaf, 0x21, 0xa6, 0x3a, 0xe6, 0x36,
2436 0x1062000e, 0x2402000a, 0x0a000447, 0x00000000, 0x92020004, 0x97430104, 1427 0x69, 0xfe, 0x80, 0x62, 0xa5, 0xcc, 0x4f, 0xe1, 0x71, 0x7e, 0x6a, 0x0a,
2437 0x8e24000c, 0x00621821, 0x2463fff2, 0x3063ffff, 0x00872024, 0x00832025, 1428 0x1e, 0x24, 0x99, 0x09, 0x1f, 0xd6, 0x6d, 0xa5, 0x53, 0xc6, 0x8e, 0xfc,
2438 0xae24000c, 0x0a000447, 0x2402000a, 0x92020004, 0x97430104, 0x8e240010, 1429 0x00, 0x1a, 0x0e, 0x94, 0x3c, 0xdf, 0xc4, 0x19, 0x11, 0x01, 0x77, 0x1f,
2439 0x00621821, 0x2463ffee, 0x3063ffff, 0x00872024, 0x00832025, 0xae240010, 1430 0xda, 0x8d, 0xa0, 0xdd, 0x70, 0x48, 0xbb, 0xe1, 0xff, 0xd4, 0x2e, 0x74,
2440 0x2402000a, 0xa7420140, 0x96030012, 0x8f840024, 0xa7430142, 0x92020004, 1431 0x09, 0x8d, 0xdc, 0x05, 0xa7, 0x3e, 0xe8, 0x9f, 0xa4, 0x63, 0xd6, 0x30,
2441 0xa7420144, 0xa7400146, 0x97430104, 0x30840006, 0x24020001, 0xa7430148, 1432 0x6b, 0xd9, 0xa2, 0x7b, 0x4b, 0xcf, 0xa2, 0xe5, 0xbf, 0x3e, 0xab, 0x96,
2442 0xa742014a, 0x24020002, 0x1082000d, 0x2c820003, 0x10400005, 0x24020004, 1433 0x63, 0xd6, 0xb2, 0xca, 0x5a, 0x6e, 0x0c, 0x6b, 0xf9, 0x53, 0xf8, 0x17,
2443 0x10800011, 0x3c020041, 0x0a00046c, 0x00000000, 0x10820007, 0x24020006, 1434 0x9a, 0xbc, 0xa0, 0x36, 0x48, 0x5b, 0x04, 0x0e, 0x3b, 0x75, 0x52, 0x6e,
2444 0x1482000d, 0x3c020151, 0x0a000466, 0x24030001, 0x0a000465, 0x3c020141, 1435 0x3c, 0xe1, 0x1b, 0x73, 0x38, 0x1c, 0xe0, 0xdf, 0x81, 0x86, 0x3e, 0x69,
2445 0x3c020051, 0x24030001, 0xaf421000, 0xaf830020, 0x0a00046c, 0x00000000, 1436 0xb4, 0x1d, 0x39, 0x4f, 0xf5, 0xec, 0xe6, 0x96, 0xb0, 0x51, 0x49, 0x47,
2446 0xaf421000, 0xaf800020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1437 0xdc, 0xbf, 0xb3, 0x64, 0x5b, 0x96, 0x3c, 0xac, 0x79, 0xa8, 0x7e, 0x27,
2447 0x8f820020, 0x8f840018, 0x10400006, 0x92030004, 0x3c058000, 0x8f421000, 1438 0xbf, 0xa6, 0x79, 0x3c, 0x4f, 0x6c, 0x81, 0xeb, 0xd6, 0x8f, 0x80, 0x51,
2448 0x00451024, 0x1040fffd, 0x00000000, 0x2463000a, 0x30620007, 0x10400002, 1439 0xda, 0x63, 0x9e, 0x3b, 0xe6, 0x9a, 0xe0, 0x17, 0xbe, 0xa1, 0x05, 0x0d,
2449 0x24620007, 0x304303f8, 0x00831021, 0x30421fff, 0xaf84000c, 0xaf820018, 1440 0x7c, 0xad, 0xc1, 0x4e, 0xdd, 0x29, 0xf4, 0x73, 0x17, 0xe3, 0xee, 0xf5,
2450 0xaf420084, 0x97430104, 0x24424000, 0x0342d821, 0x3063ffff, 0x30620007, 1441 0x98, 0x5f, 0x06, 0xe9, 0x37, 0x9d, 0xe6, 0x55, 0x91, 0x73, 0xe7, 0xcd,
2451 0x10400002, 0x24620007, 0x3043fff8, 0x8f820030, 0x8f840000, 0x00431821, 1442 0x75, 0x62, 0xed, 0xf1, 0x79, 0x87, 0xfe, 0x41, 0x8d, 0x14, 0xa1, 0xf7,
2452 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023, 0xaf820030, 1443 0xc9, 0x52, 0xef, 0x2f, 0x20, 0x46, 0x93, 0xf8, 0x66, 0xcd, 0x9f, 0x2e,
2453 0x8f840030, 0x34028000, 0x8fbf0018, 0x8fb10014, 0x8fb00010, 0x00821021, 1444 0x35, 0x3f, 0x8d, 0x27, 0xb7, 0x5d, 0x54, 0x0b, 0xee, 0x80, 0x87, 0x3b,
2454 0x03421821, 0x3c021000, 0xaf830010, 0xaf440080, 0xaf420178, 0x03e00008, 1445 0x8c, 0x6b, 0x1d, 0xf9, 0x8d, 0xe7, 0xff, 0x7b, 0xbe, 0xe9, 0x30, 0xb6,
2455 0x27bd0020, 0x8f620000, 0x97430104, 0x3c048000, 0x3045ffff, 0x3066ffff, 1446 0x8e, 0xf5, 0x03, 0x5a, 0x80, 0xee, 0xd0, 0x7e, 0xc0, 0xb6, 0xec, 0x53,
2456 0x8f420178, 0x00441024, 0x1440fffd, 0x2402000a, 0x30a30007, 0xa7420140, 1447 0xd9, 0x9a, 0xa5, 0xed, 0xa7, 0x63, 0xb6, 0x68, 0x3f, 0x60, 0x3b, 0xd6,
2457 0x24020008, 0x00431023, 0x30420007, 0x24a3fffe, 0xa7420142, 0xa7430144, 1448 0xc5, 0x73, 0xa4, 0xdc, 0xe4, 0xf3, 0x38, 0x60, 0x5d, 0xc0, 0xaf, 0x8d,
2458 0xa7400146, 0xa7460148, 0x8f420108, 0x8f830024, 0x30420020, 0x0002102b, 1449 0x36, 0xae, 0x19, 0xd8, 0x9f, 0xcf, 0x66, 0x5e, 0x27, 0xd7, 0x13, 0x7c,
2459 0x00021023, 0x30420009, 0x34420001, 0x30630006, 0xa742014a, 0x24020002, 1450 0x7e, 0x8f, 0x9d, 0xd3, 0xc7, 0xda, 0xb8, 0x00, 0xbe, 0x7f, 0x4b, 0xfd,
2460 0x1062000d, 0x2c620003, 0x10400005, 0x24020004, 0x10600011, 0x3c020041, 1451 0x4f, 0x6d, 0xbc, 0x06, 0x2d, 0x5c, 0x51, 0x0b, 0x6d, 0x6c, 0xe3, 0x79,
2461 0x0a0004d6, 0x00000000, 0x10620007, 0x24020006, 0x1462000d, 0x3c020151, 1452 0x01, 0xdf, 0xaf, 0x8d, 0x69, 0xa3, 0xf2, 0x7b, 0xfa, 0xf9, 0x9c, 0xf4,
2462 0x0a0004d0, 0x24030001, 0x0a0004cf, 0x3c020141, 0x3c020051, 0x24030001, 1453 0x9b, 0xe2, 0x6c, 0xe5, 0xf9, 0x94, 0x1d, 0x8a, 0xb5, 0x52, 0x07, 0x6b,
2463 0xaf421000, 0xaf830020, 0x0a0004d6, 0x00000000, 0xaf421000, 0xaf800020, 1454 0xc7, 0x3a, 0x98, 0x44, 0xae, 0x18, 0xe1, 0xb8, 0x12, 0xba, 0xb6, 0x99,
2464 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8f820020, 0x24a30008, 1455 0x12, 0x6b, 0x62, 0xf8, 0xfc, 0xfa, 0x7f, 0xe9, 0x82, 0xc0, 0x23, 0x31,
2465 0x8f850018, 0x10400006, 0x30c6ffff, 0x3c048000, 0x8f421000, 0x00441024, 1456 0x37, 0x6a, 0x0c, 0x3e, 0x0f, 0xf2, 0xfc, 0x8a, 0x8b, 0xfe, 0xaa, 0xd6,
2466 0x1040fffd, 0x00000000, 0x3063ffff, 0x30620007, 0x10400002, 0x24620007, 1457 0x10, 0xd8, 0xf3, 0x59, 0xcb, 0x78, 0xa0, 0xbe, 0x73, 0xe6, 0xa1, 0x05,
2467 0x3043fff8, 0x00a31021, 0x30421fff, 0x24434000, 0x0343d821, 0x00c02021, 1458 0xce, 0x01, 0x8f, 0xf3, 0x3d, 0x27, 0x40, 0x5b, 0x1b, 0xf1, 0x67, 0x4c,
2468 0x30830007, 0xaf85000c, 0xaf820018, 0xaf420084, 0x10600002, 0x24820007, 1459 0x36, 0xa4, 0xf5, 0x7d, 0x83, 0xfd, 0xa0, 0xb3, 0x93, 0x6a, 0x2c, 0x1d,
2469 0x3044fff8, 0x8f820030, 0x8f850000, 0x00441821, 0xaf82001c, 0x0065102b, 1460 0x9a, 0x7a, 0x82, 0x13, 0xf3, 0x28, 0x1a, 0xc2, 0xa9, 0x23, 0x70, 0xfa,
2470 0xaf830030, 0x14400002, 0x00651023, 0xaf820030, 0x8f840030, 0x34028000, 1461 0xf0, 0x18, 0xa7, 0xa8, 0xc4, 0x29, 0x12, 0x38, 0xfd, 0xb1, 0xc4, 0xe9,
2471 0x3c030800, 0x8c650834, 0x00821021, 0x03421821, 0xaf830010, 0xaf440080, 1462 0x0f, 0x4f, 0xc1, 0xe9, 0xc3, 0x67, 0xc0, 0xc9, 0xa0, 0x3d, 0xa7, 0x89,
2472 0x10a00006, 0x2402000e, 0x9383002f, 0x14620004, 0x3c021000, 0x2402043f, 1463 0x73, 0x56, 0x17, 0x35, 0xe9, 0xa1, 0x7b, 0x52, 0x4d, 0x75, 0x52, 0xdc,
2473 0xa7420148, 0x3c021000, 0x03e00008, 0xaf420178, 0x8f820024, 0x30424000, 1464 0x6d, 0x73, 0x8f, 0x86, 0xeb, 0x0e, 0xdb, 0x7a, 0x80, 0xf5, 0xa5, 0xc0,
2474 0x10400005, 0x24020800, 0x0000000d, 0x00000000, 0x2400040e, 0x24020800, 1465 0xee, 0xfa, 0x58, 0xed, 0x91, 0xc0, 0xbe, 0x5d, 0xe2, 0x74, 0x1d, 0x38,
2475 0xaf420178, 0x97440104, 0x3c030008, 0xaf430140, 0x8f820024, 0x30420001, 1466 0xb5, 0x4b, 0x9c, 0xb6, 0x87, 0x70, 0xda, 0x1e, 0xc1, 0x89, 0xf3, 0x49,
2476 0x10400006, 0x3085ffff, 0x24020002, 0x24a3fffe, 0xa7420146, 0x0a000526, 1467 0xcb, 0xd8, 0xee, 0x55, 0x18, 0x55, 0xf8, 0xe8, 0x74, 0xdb, 0x9c, 0xc6,
2477 0xa7430148, 0xa7400146, 0x8f840018, 0x2402000d, 0xa742014a, 0x24830008, 1468 0xfe, 0xcf, 0x51, 0xfa, 0x63, 0x95, 0xeb, 0x5a, 0x60, 0xf7, 0xaa, 0x2a,
2478 0x30631fff, 0x24624000, 0x0342d821, 0x30a20007, 0xaf84000c, 0xaf830018, 1469 0x8b, 0xf3, 0x80, 0xdf, 0x9f, 0xd4, 0x27, 0x98, 0xcb, 0x0f, 0x5c, 0x8e,
2479 0xaf430084, 0x10400002, 0x24a20007, 0x3045fff8, 0x8f820030, 0x8f840000, 1470 0x23, 0xea, 0x57, 0xa7, 0xca, 0x43, 0xcf, 0xab, 0xa8, 0xad, 0xf0, 0xcd,
2480 0x00451821, 0xaf82001c, 0x0064102b, 0xaf830030, 0x14400002, 0x00641023, 1471 0x36, 0xaa, 0xd4, 0x86, 0xde, 0x15, 0xd4, 0xe5, 0xe1, 0x71, 0x5d, 0x5e,
2481 0xaf820030, 0x8f840030, 0x34028000, 0x00821021, 0x03421821, 0x3c021000, 1472 0xc4, 0xe0, 0x7a, 0x59, 0x97, 0xef, 0x39, 0x5c, 0x97, 0x2f, 0x6a, 0x34,
2482 0xaf830010, 0xaf440080, 0x03e00008, 0xaf420178, 0x27bdffe8, 0x3c046008, 1473 0xb9, 0x51, 0x62, 0xc9, 0x9c, 0x9e, 0x42, 0xdf, 0x25, 0x81, 0x79, 0x8a,
2483 0xafbf0014, 0xafb00010, 0x8c825000, 0x3c1a8000, 0x2403ff7f, 0x375b4000, 1474 0xfc, 0xbd, 0x89, 0xfd, 0x47, 0x82, 0x9b, 0xa8, 0xb1, 0x4a, 0xde, 0xa2,
2484 0x00431024, 0x3442380c, 0xac825000, 0x8f430008, 0x3c100800, 0x37428000, 1475 0x86, 0xa5, 0x30, 0x2b, 0x62, 0xf5, 0xc5, 0xd6, 0x5d, 0x9f, 0x20, 0x4f,
2485 0x34630001, 0xaf430008, 0xaf820010, 0x3c02601c, 0xaf800018, 0xaf400080, 1476 0x1b, 0x1d, 0x15, 0x75, 0xfd, 0xfd, 0x8c, 0xf3, 0x33, 0x5d, 0x4e, 0x7a,
2486 0xaf400084, 0x8c450008, 0x3c036000, 0x8c620808, 0x3c040800, 0x3c030080, 1477 0x14, 0x9f, 0xf1, 0xae, 0xe5, 0xc0, 0xdc, 0x7f, 0xeb, 0x3c, 0x9f, 0x33,
2487 0xac830820, 0x3042fff0, 0x38420010, 0x2c420001, 0xaf850000, 0xaf820004, 1478 0xf5, 0xd5, 0xa0, 0x85, 0xf6, 0x81, 0x41, 0xa8, 0x7d, 0x70, 0x4f, 0xa1,
2488 0x0e000658, 0x00000000, 0x8f420000, 0x30420001, 0x1040fffb, 0x00000000, 1479 0x38, 0x38, 0x2f, 0xa1, 0xc6, 0xc1, 0x37, 0x7c, 0x92, 0x6c, 0xb6, 0x23,
2489 0x8f430108, 0x8f440100, 0x30622000, 0xaf830024, 0xaf840014, 0x10400004, 1480 0x7b, 0x4d, 0x70, 0x21, 0x26, 0x1f, 0xeb, 0xf4, 0x33, 0x71, 0x57, 0xe9,
2490 0x8e02082c, 0x24420001, 0x0a0005c6, 0xae02082c, 0x30620200, 0x14400003, 1481 0x28, 0x9e, 0x81, 0xda, 0x92, 0x0c, 0x9c, 0xf3, 0x88, 0x89, 0x65, 0xa4,
2491 0x24020f00, 0x14820027, 0x24020d00, 0x97420104, 0x1040001c, 0x30624000, 1482 0x03, 0xd4, 0x41, 0x38, 0xfb, 0x83, 0x55, 0xc4, 0xe5, 0x2c, 0x70, 0xcb,
2492 0x14400005, 0x00000000, 0x0e00022f, 0x00000000, 0x0a0005bb, 0x00000000, 1483 0x54, 0xf8, 0xbe, 0xa9, 0x17, 0xf7, 0x1c, 0x54, 0x35, 0x22, 0x5e, 0x8f,
2493 0x8f620008, 0x8f630000, 0x24020030, 0x00031e02, 0x306300f0, 0x10620007, 1484 0x4a, 0x7e, 0x88, 0x3a, 0x4b, 0x6a, 0xf7, 0xc9, 0x8a, 0x5c, 0xf0, 0x1c,
2494 0x28620031, 0x1440002f, 0x24020040, 0x10620007, 0x00000000, 0x0a0005bb, 1485 0xe7, 0x48, 0x37, 0xe3, 0xda, 0xf9, 0xac, 0x21, 0xdf, 0xe0, 0x5c, 0x7e,
2495 0x00000000, 0x0e0002e8, 0x00000000, 0x0a0005bb, 0x00000000, 0x0e0003db, 1486 0x88, 0x18, 0xe2, 0xfd, 0x80, 0xcf, 0x16, 0x85, 0xeb, 0x6f, 0xdc, 0x67,
2496 0x00000000, 0x0a0005bb, 0x00000000, 0x30620040, 0x1440002b, 0x00000000, 1487 0x96, 0x90, 0x6b, 0x68, 0x0a, 0x79, 0x0f, 0x79, 0x77, 0x96, 0x71, 0xf2,
2497 0x0000000d, 0x00000000, 0x240004b2, 0x0a0005c6, 0x00000000, 0x1482000f, 1488 0x23, 0xc6, 0x4b, 0x9c, 0x1b, 0xe7, 0xe4, 0x62, 0x9e, 0x5f, 0x6b, 0x05,
2498 0x30620006, 0x97420104, 0x10400005, 0x30620040, 0x0e000510, 0x00000000, 1489 0x7f, 0x71, 0x87, 0x41, 0xfc, 0x36, 0xfb, 0x2e, 0xe7, 0xdb, 0x2f, 0x2b,
2499 0x0a0005bb, 0x00000000, 0x1440001b, 0x00000000, 0x0000000d, 0x00000000, 1490 0x74, 0x44, 0x82, 0x8f, 0xe6, 0xcb, 0xc8, 0xc3, 0xe7, 0xe0, 0xe3, 0x0b,
2500 0x240004c4, 0x0a0005c6, 0x00000000, 0x1040000e, 0x30621000, 0x10400005, 1491 0x2d, 0x16, 0xf5, 0x56, 0xe5, 0xf3, 0xc9, 0xd8, 0x18, 0x1f, 0x29, 0xa3,
2501 0x00000000, 0x0e000688, 0x00000000, 0x0a0005bb, 0x00000000, 0x0e0004a1, 1492 0xdf, 0x3e, 0xf8, 0xbc, 0x52, 0xce, 0x57, 0xf1, 0xe3, 0x57, 0xe0, 0xc7,
2502 0x00000000, 0x8f82002c, 0x24420001, 0xaf82002c, 0x0a0005c6, 0x00000000, 1493 0x61, 0xd9, 0xcf, 0x77, 0x16, 0x1d, 0x36, 0xbc, 0x3e, 0xe6, 0x11, 0xdb,
2503 0x30620040, 0x14400004, 0x00000000, 0x0000000d, 0x00000000, 0x240004db, 1494 0x9b, 0xda, 0xe8, 0x18, 0x5f, 0x1a, 0xf3, 0xff, 0xfd, 0x90, 0xff, 0x34,
2504 0x8f420138, 0x3c034000, 0x00431025, 0xaf420138, 0x0a000566, 0x00000000, 1495 0xef, 0xc9, 0x8c, 0x0a, 0x0e, 0xe2, 0xef, 0x3d, 0x7d, 0xd4, 0xf7, 0x17,
2505 0x3c046008, 0x8c835000, 0x3c1a8000, 0x2402ff7f, 0x375b4000, 0x00621824, 1496 0x6a, 0xf1, 0x7d, 0xb6, 0xe0, 0x9e, 0x83, 0x67, 0x76, 0x38, 0xb4, 0x36,
2506 0x3463380c, 0xac835000, 0x8f420008, 0x3c056000, 0x3c03601c, 0x34420001, 1497 0x75, 0x6c, 0xec, 0x87, 0x18, 0x7b, 0x15, 0x79, 0x84, 0x7c, 0x05, 0x77,
2507 0xaf420008, 0x37428000, 0xaf800018, 0xaf820010, 0xaf400080, 0xaf400084, 1498 0xa6, 0x90, 0xf0, 0x9e, 0x5d, 0xa9, 0xe2, 0x03, 0x4e, 0xd0, 0xe5, 0xb4,
2508 0x8c660008, 0x8ca20808, 0x3c040800, 0x3c030080, 0xac830820, 0x3042fff0, 1499 0xe4, 0x82, 0x5c, 0x70, 0x81, 0xeb, 0xb4, 0xd5, 0x4d, 0x70, 0x21, 0x05,
2509 0x38420010, 0x2c420001, 0xaf860000, 0xaf820004, 0x03e00008, 0x00000000, 1500 0x17, 0xe0, 0xd7, 0xd1, 0xbc, 0x59, 0xe0, 0xcc, 0x39, 0x07, 0xdf, 0x19,
2510 0x3084ffff, 0x30820007, 0x10400002, 0x24820007, 0x3044fff8, 0x8f820018, 1501 0xf3, 0x82, 0x79, 0xc0, 0x9c, 0x78, 0xc2, 0x85, 0x2b, 0x3d, 0xc3, 0xd8,
2511 0x00441821, 0x30631fff, 0x24644000, 0x0344d821, 0xaf82000c, 0xaf830018, 1502 0xfd, 0x2f, 0x3c, 0x78, 0x57, 0xf0, 0x80, 0xf9, 0x58, 0xe4, 0x85, 0x2e,
2512 0x03e00008, 0xaf430084, 0x3084ffff, 0x30820007, 0x10400002, 0x24820007, 1503 0x70, 0x48, 0xca, 0xbc, 0x50, 0xe8, 0x9c, 0xeb, 0x1b, 0xd6, 0x78, 0xa1,
2513 0x3044fff8, 0x8f820030, 0x8f830000, 0x00442021, 0xaf82001c, 0x0083102b, 1504 0x8d, 0x2d, 0x68, 0xa3, 0xad, 0x70, 0xbd, 0xc3, 0xba, 0x60, 0x3f, 0xd6,
2514 0xaf840030, 0x14400002, 0x00831023, 0xaf820030, 0x8f820030, 0x34038000, 1505 0xc6, 0x49, 0x7e, 0x85, 0x46, 0xd2, 0xbe, 0x6d, 0x55, 0xf9, 0x21, 0x85,
2515 0x00431821, 0x03432021, 0xaf840010, 0x03e00008, 0xaf420080, 0x8f830024, 1506 0x2e, 0xba, 0xa5, 0x46, 0xd2, 0x52, 0x23, 0xb0, 0x89, 0x95, 0x16, 0xe7,
2516 0x24020002, 0x30630006, 0x1062000d, 0x2c620003, 0x50400005, 0x24020004, 1507 0x7a, 0xdb, 0x0a, 0x91, 0x17, 0xba, 0x62, 0xcc, 0x98, 0x8a, 0x3b, 0x09,
2517 0x10600012, 0x3c020001, 0x0a00062a, 0x00000000, 0x10620007, 0x24020006, 1508 0xeb, 0x96, 0xf3, 0xe9, 0x50, 0x1e, 0x2d, 0xef, 0xa5, 0x1d, 0x71, 0x2f,
2518 0x1462000f, 0x3c020111, 0x0a000622, 0x00821025, 0x0a000621, 0x3c020101, 1509 0xfd, 0x8a, 0x3e, 0x9a, 0x47, 0x67, 0x90, 0x43, 0xf8, 0x5e, 0x3a, 0xa7,
2519 0x3c020011, 0x00821025, 0x24030001, 0xaf421000, 0xaf830020, 0x0a00062a, 1510 0xf3, 0xbd, 0x14, 0xba, 0xd3, 0x87, 0xef, 0xa5, 0xc9, 0xc8, 0xbd, 0xb4,
2520 0x00000000, 0x00821025, 0xaf421000, 0xaf800020, 0x00000000, 0x00000000, 1511 0xf2, 0xe5, 0xf6, 0x93, 0xf2, 0x69, 0x15, 0x13, 0xce, 0xa9, 0x02, 0xf3,
2521 0x00000000, 0x03e00008, 0x00000000, 0x8f820020, 0x10400005, 0x3c038000, 1512 0x13, 0x6a, 0xbf, 0xca, 0x86, 0xf3, 0x0d, 0x6b, 0xb9, 0xcc, 0x51, 0xa8,
2522 0x8f421000, 0x00431024, 0x1040fffd, 0x00000000, 0x03e00008, 0x00000000, 1513 0xb5, 0xee, 0x67, 0x15, 0xe7, 0xdf, 0xc0, 0x3c, 0xf8, 0xee, 0x9f, 0xc4,
2523 0x8f820024, 0x27bdffe8, 0x30424000, 0x14400005, 0xafbf0010, 0x0e00022f, 1514 0x79, 0xa3, 0xe4, 0xfc, 0x54, 0xe1, 0xd3, 0x1f, 0xe6, 0xfd, 0x1b, 0xfa,
2524 0x00000000, 0x0a000656, 0x8fbf0010, 0x8f620008, 0x8f630000, 0x24020030, 1515 0x28, 0xef, 0xab, 0x71, 0x2a, 0xde, 0x17, 0x63, 0x3e, 0x54, 0x9a, 0x38,
2525 0x00031e02, 0x306300f0, 0x10620008, 0x28620031, 0x1440000d, 0x8fbf0010, 1516 0xdb, 0x96, 0x91, 0x6b, 0x66, 0xf8, 0xbe, 0x85, 0x5c, 0xe0, 0xd5, 0x71,
2526 0x24020040, 0x10620007, 0x00000000, 0x0a000656, 0x00000000, 0x0e0002e8, 1517 0xef, 0x98, 0xe1, 0xb1, 0xd3, 0x0c, 0xe7, 0x4d, 0x03, 0xbc, 0x17, 0x9c,
2527 0x00000000, 0x0a000656, 0x8fbf0010, 0x0e0003db, 0x00000000, 0x8fbf0010, 1518 0x3d, 0x12, 0xf7, 0x01, 0xac, 0x7b, 0x86, 0xab, 0xab, 0x51, 0x2e, 0xbe,
2528 0x03e00008, 0x27bd0018, 0x8f840028, 0x1080000f, 0x3c026000, 0x8c430c3c, 1519 0x88, 0x0b, 0x45, 0xb5, 0x97, 0xaa, 0xcd, 0x19, 0x6a, 0x5b, 0x2e, 0xb1,
2529 0x30630fff, 0xaf830008, 0x14600011, 0x3082000f, 0x10400005, 0x308200f0, 1520 0x2e, 0x62, 0xfd, 0xa0, 0xb8, 0x8f, 0xd3, 0x2e, 0x6a, 0xb1, 0x43, 0xd4,
2530 0x10400003, 0x30820f00, 0x14400006, 0x00000000, 0x0000000d, 0x00000000, 1521 0x39, 0x77, 0x70, 0x9f, 0x4b, 0x06, 0x8f, 0xf2, 0x07, 0x0d, 0x95, 0xba,
2531 0x2400051a, 0x03e00008, 0x00000000, 0x0000000d, 0x00000000, 0x2400051f, 1522 0xc7, 0x3e, 0x5d, 0xac, 0xd7, 0x36, 0x6f, 0xe3, 0xed, 0xdd, 0x41, 0x15,
2532 0x03e00008, 0x00000000, 0xaf830028, 0x03e00008, 0x00000000, 0x10c00007, 1523 0x53, 0xee, 0xe7, 0xb6, 0x7f, 0xe0, 0xbc, 0x45, 0x1d, 0x37, 0x32, 0x67,
2533 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004, 0xac820000, 0x14c0fffb, 1524 0xf5, 0xce, 0x7f, 0xff, 0x06, 0x63, 0xe1, 0x4b, 0x7b, 0x30, 0x12, 0x00,
2534 0x24840004, 0x03e00008, 0x00000000, 0x0a000684, 0x00a01021, 0xac860000, 1525 0x00, 0x00 };
2535 0x00000000, 0x00000000, 0x24840004, 0x00a01021, 0x1440fffa, 0x24a5ffff,
2536 0x03e00008, 0x00000000, 0x0000000d, 0x03e00008, 0x00000000, 0x00000000};
2537 1526
2538static u32 bnx2_TPAT_b06FwData[(0x0/4) + 1] = { 0x0 }; 1527static u32 bnx2_TPAT_b06FwData[(0x0/4) + 1] = { 0x0 };
2539static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x0 }; 1528static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x0 };
@@ -2554,939 +1543,422 @@ static const u32 bnx2_TXP_b06FwBssAddr = 0x080057a0;
2554static const int bnx2_TXP_b06FwBssLen = 0x1c4; 1543static const int bnx2_TXP_b06FwBssLen = 0x1c4;
2555static const u32 bnx2_TXP_b06FwSbssAddr = 0x08005760; 1544static const u32 bnx2_TXP_b06FwSbssAddr = 0x08005760;
2556static const int bnx2_TXP_b06FwSbssLen = 0x38; 1545static const int bnx2_TXP_b06FwSbssLen = 0x38;
2557static u32 bnx2_TXP_b06FwText[(0x5748/4) + 1] = { 1546static u8 bnx2_TXP_b06FwText[] = {
2558 0x0a000d2c, 0x00000000, 0x00000000, 0x0000000d, 0x74787020, 0x322e352e, 1547 0x1f, 0x8b, 0x08, 0x08, 0x21, 0xd3, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
2559 0x38000000, 0x02050800, 0x0000000a, 0x000003e8, 0x0000ea60, 0x00000000, 1548 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x6d, 0x6c,
2560 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1549 0x1b, 0xf7, 0x79, 0x7f, 0xee, 0x85, 0xd2, 0x51, 0x96, 0xe9, 0x93, 0xc2,
2561 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1550 0x78, 0x6c, 0xc0, 0xa6, 0x77, 0xd6, 0x51, 0x66, 0x20, 0xb5, 0xa0, 0x05,
2562 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1551 0x36, 0x55, 0x87, 0x43, 0x73, 0x3e, 0x52, 0x2f, 0x4e, 0x5c, 0x57, 0x71,
2563 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1552 0x94, 0x86, 0x6e, 0x0d, 0x8c, 0xa0, 0xec, 0xd8, 0xeb, 0x5a, 0x2c, 0x1f,
2564 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1553 0x8c, 0xd5, 0x68, 0xd1, 0x99, 0xa1, 0x68, 0xc7, 0xc9, 0x68, 0x51, 0xa9,
2565 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1554 0xe5, 0xa8, 0x43, 0x57, 0x80, 0x95, 0x64, 0xcb, 0x29, 0x4e, 0x3a, 0x65,
2566 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1555 0xcb, 0x16, 0x0c, 0x58, 0x16, 0xcd, 0x2f, 0x5d, 0x3f, 0x74, 0x80, 0x3f,
2567 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1556 0xec, 0x43, 0x3a, 0xec, 0x83, 0x91, 0x14, 0xad, 0x11, 0x6c, 0x59, 0xb0,
2568 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1557 0x2f, 0x33, 0xd6, 0x26, 0xb7, 0xdf, 0x73, 0x77, 0x94, 0x95, 0xc4, 0x4e,
2569 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1558 0xab, 0x7d, 0xbe, 0x07, 0x20, 0xee, 0x7f, 0xff, 0xd7, 0xe7, 0xfd, 0xe5,
2570 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1559 0x7f, 0x90, 0x06, 0xb7, 0x53, 0x17, 0x85, 0xb0, 0x1d, 0x3f, 0xed, 0x99,
2571 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1560 0x93, 0x27, 0x3e, 0xf7, 0xf9, 0xcf, 0x0d, 0xa1, 0x39, 0x4c, 0x4a, 0x4c,
2572 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1561 0xe4, 0xc1, 0x5b, 0x12, 0x51, 0xf9, 0x1d, 0x8a, 0x20, 0x82, 0x08, 0x22,
2573 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1562 0x88, 0x20, 0x82, 0x08, 0x22, 0x88, 0x20, 0x82, 0x08, 0x22, 0x88, 0x20,
2574 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1563 0x82, 0x08, 0x22, 0x88, 0x20, 0x82, 0x08, 0x22, 0x88, 0x20, 0x82, 0x08,
2575 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1564 0x22, 0x88, 0x20, 0x82, 0x08, 0x22, 0x88, 0x20, 0x82, 0x08, 0x22, 0x88,
2576 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1565 0x20, 0x82, 0x08, 0x22, 0x88, 0x20, 0x82, 0x08, 0x22, 0x88, 0x20, 0x82,
2577 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1566 0x08, 0x22, 0x88, 0x20, 0x82, 0x08, 0x22, 0x88, 0x20, 0x82, 0x08, 0x22,
2578 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1567 0xf8, 0x9d, 0x20, 0x11, 0xa9, 0xfc, 0xdc, 0x1e, 0xfe, 0x48, 0x11, 0xcd,
2579 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1568 0xf2, 0x53, 0xb6, 0x41, 0x8a, 0x64, 0x1e, 0x39, 0x34, 0x65, 0x10, 0x59,
2580 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1569 0xce, 0x80, 0x56, 0xa0, 0xf7, 0xbd, 0x6a, 0x52, 0x26, 0xee, 0xff, 0xb4,
2581 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1570 0xf9, 0xdb, 0x53, 0xaf, 0x7f, 0x41, 0x7f, 0xaf, 0x25, 0x91, 0xa2, 0x9a,
2582 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1571 0x6b, 0x79, 0xb5, 0x9f, 0x94, 0x34, 0xd6, 0xfc, 0xd5, 0xee, 0xaf, 0xef,
2583 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1572 0xa0, 0x44, 0x7b, 0xaf, 0x24, 0xd5, 0x9b, 0xb7, 0xbc, 0xd7, 0x77, 0x27,
2584 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1573 0xe9, 0x15, 0x57, 0xa5, 0x35, 0x57, 0x16, 0x46, 0x9b, 0x0a, 0x4d, 0x37,
2585 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1574 0x1d, 0x3a, 0xdd, 0xa8, 0x52, 0xc1, 0xbd, 0x4c, 0xb5, 0x39, 0x35, 0x61,
2586 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1575 0x2f, 0xff, 0x84, 0xa6, 0xe7, 0x7a, 0x13, 0x85, 0x65, 0x87, 0x6a, 0x8d,
2587 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1576 0x54, 0xc2, 0x76, 0xd5, 0x44, 0x61, 0x3e, 0x89, 0xf7, 0xde, 0x84, 0x3d,
2588 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1577 0xaf, 0x57, 0x89, 0x76, 0x62, 0x4e, 0x2a, 0x51, 0x68, 0xea, 0x65, 0xa2,
2589 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1578 0xbe, 0xdc, 0x75, 0x4a, 0x27, 0x0a, 0xee, 0x82, 0xb0, 0xae, 0x0a, 0x54,
2590 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1579 0xfb, 0x2c, 0xa9, 0x09, 0xf3, 0xb6, 0xf7, 0x29, 0x43, 0xa5, 0x1e, 0x83,
2591 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1580 0x76, 0xec, 0x30, 0xe8, 0xd9, 0x94, 0xa9, 0x50, 0xe5, 0x7c, 0x9c, 0x2c,
2592 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1581 0x9f, 0x26, 0x95, 0x2a, 0xf3, 0x03, 0xea, 0x15, 0x8a, 0x91, 0x95, 0x6c,
2593 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1582 0xbf, 0x7b, 0x9e, 0x9d, 0xfb, 0x16, 0xff, 0x9d, 0x16, 0xce, 0xa2, 0xc4,
2594 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1583 0xa8, 0x4b, 0x64, 0x03, 0x2f, 0x3b, 0xf7, 0xbe, 0x17, 0xac, 0x51, 0x70,
2595 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1584 0xae, 0x9c, 0x18, 0x69, 0x7a, 0x5e, 0x31, 0x87, 0x33, 0x72, 0xed, 0xb5,
2596 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1585 0x31, 0x6a, 0x25, 0xad, 0xd6, 0x74, 0x2e, 0xbf, 0x23, 0xf8, 0x1b, 0x2f,
2597 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1586 0xa6, 0x91, 0xdf, 0x2d, 0x12, 0x8d, 0xaf, 0x50, 0x25, 0x49, 0xad, 0x5a,
2598 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1587 0xee, 0x61, 0x7a, 0x21, 0xd7, 0x4d, 0x67, 0xb1, 0xdf, 0xf3, 0x39, 0xf0,
2599 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1588 0xd1, 0x38, 0x29, 0xd8, 0xae, 0x9e, 0x22, 0xe1, 0x05, 0xb2, 0xe7, 0xfb,
2600 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1589 0xd4, 0x02, 0xe1, 0x6c, 0xc3, 0xfb, 0x8c, 0x9d, 0xc3, 0x79, 0x83, 0xff,
2601 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1590 0xeb, 0x59, 0x49, 0xbd, 0xdc, 0xa2, 0x14, 0xd5, 0x9a, 0x7d, 0xb9, 0x9f,
2602 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1591 0x93, 0x40, 0x9d, 0x06, 0xf3, 0xc7, 0xa3, 0xc7, 0x70, 0xae, 0x6d, 0xa0,
2603 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1592 0xdf, 0x25, 0x4b, 0xcc, 0xc4, 0xe8, 0x4f, 0x55, 0x5d, 0xb3, 0xa5, 0x5e,
2604 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1593 0xaa, 0x9d, 0xef, 0x04, 0x9e, 0x56, 0xaf, 0x88, 0xb9, 0x63, 0x79, 0x4a,
2605 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1594 0x6e, 0x23, 0x12, 0x24, 0x33, 0x83, 0x7d, 0x89, 0x6a, 0x4e, 0x0a, 0x6b,
2606 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1595 0x33, 0xc3, 0xef, 0xd0, 0x0e, 0xd2, 0x7a, 0x64, 0x9a, 0x76, 0xba, 0xc0,
2607 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1596 0xc7, 0x6e, 0xc8, 0x20, 0x33, 0xfc, 0x2e, 0x84, 0x22, 0x1a, 0x99, 0xd4,
2608 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1597 0x49, 0x2a, 0x0b, 0x05, 0xb7, 0x83, 0xa6, 0x33, 0x0a, 0xd5, 0x81, 0x47,
2609 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1598 0x3d, 0xf7, 0x35, 0xc1, 0x5e, 0x2e, 0x09, 0x85, 0x65, 0xcc, 0x73, 0x5f,
2610 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1599 0x0b, 0xff, 0x76, 0xad, 0x1b, 0xfb, 0x88, 0x54, 0xcb, 0x94, 0x30, 0xa6,
2611 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1600 0xd0, 0x14, 0xe6, 0x4d, 0x81, 0xa6, 0x69, 0x77, 0x07, 0xad, 0x4f, 0x26,
2612 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1601 0x13, 0xcc, 0xab, 0x1a, 0xc6, 0xbf, 0x32, 0x21, 0x90, 0x6a, 0x58, 0xf4,
2613 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1602 0xeb, 0x3c, 0x64, 0x38, 0xdf, 0xcb, 0x32, 0xa3, 0xd3, 0x4d, 0x4a, 0x8a,
2614 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1603 0x94, 0x49, 0x55, 0xe8, 0x32, 0x2d, 0x3a, 0x2c, 0x7f, 0xc8, 0x13, 0xf2,
2615 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1604 0xae, 0x39, 0xbc, 0x0e, 0x72, 0x6b, 0x16, 0xc1, 0x8f, 0x71, 0xe0, 0x70,
2616 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1605 0x50, 0x78, 0x6c, 0x71, 0x52, 0x18, 0x73, 0x7f, 0x93, 0xa0, 0xae, 0x93,
2617 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1606 0xc2, 0x01, 0xf7, 0xa8, 0x10, 0xf2, 0x1e, 0xb2, 0x53, 0xc8, 0x9a, 0x50,
2618 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1607 0xe8, 0x92, 0x1b, 0xc8, 0x6e, 0x01, 0xfa, 0x69, 0xa9, 0x16, 0xe4, 0x70,
2619 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1608 0x78, 0x63, 0x0e, 0x8f, 0xd5, 0x97, 0x65, 0x3a, 0xed, 0xf2, 0xfc, 0x3f,
2620 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1609 0x82, 0x7c, 0x14, 0x72, 0x76, 0x77, 0x53, 0x19, 0xfd, 0xb5, 0x79, 0xb2,
2621 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1610 0xec, 0x9c, 0x88, 0x35, 0x09, 0x92, 0x8c, 0x9d, 0xf8, 0x75, 0xd1, 0xd4,
2622 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1611 0x62, 0xa7, 0x25, 0x19, 0x49, 0x9a, 0x72, 0x99, 0x87, 0x78, 0x36, 0xdb,
2623 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1612 0x7c, 0x64, 0x5c, 0xb9, 0x9f, 0xd7, 0x71, 0xbf, 0x8a, 0xfe, 0xcd, 0x7d,
2624 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1613 0xac, 0x17, 0x09, 0xe0, 0xa3, 0x67, 0x59, 0x9f, 0x2b, 0xcd, 0x8c, 0x7a,
2625 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1614 0x80, 0x9f, 0x2e, 0xf3, 0xb6, 0xcd, 0x53, 0x19, 0x73, 0x45, 0xaa, 0x2c,
2626 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1615 0xe2, 0x9c, 0xf3, 0xbf, 0xf5, 0x62, 0x79, 0xbc, 0x1b, 0x1d, 0xa0, 0x8b,
2627 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1616 0xcf, 0x95, 0x81, 0x93, 0x48, 0xe5, 0x45, 0xde, 0x8b, 0xc7, 0x09, 0xb2,
2628 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1617 0xaf, 0xf5, 0x88, 0x94, 0x85, 0x7c, 0x75, 0x9c, 0x13, 0xc7, 0x9c, 0x6e,
2629 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1618 0xf0, 0x0f, 0xb4, 0x2e, 0xa3, 0x0d, 0xda, 0x45, 0x43, 0xc4, 0xfa, 0x4e,
2630 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1619 0x9a, 0xca, 0xb1, 0xbe, 0x30, 0x9e, 0xdb, 0xb0, 0x77, 0x9c, 0x8e, 0x9c,
2631 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1620 0x67, 0x7e, 0xc8, 0xf4, 0x3c, 0x70, 0x9c, 0x9e, 0xd7, 0xd5, 0x22, 0xe9,
2632 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1621 0xe0, 0x8d, 0x85, 0x79, 0x9d, 0x54, 0x56, 0x3d, 0x6f, 0x24, 0x37, 0xa0,
2633 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1622 0xbe, 0xec, 0xeb, 0xf9, 0x80, 0x9a, 0x11, 0xa8, 0xda, 0x61, 0xfe, 0x21,
2634 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1623 0x70, 0xd0, 0x4b, 0x44, 0xfc, 0xfe, 0xcf, 0x64, 0x4d, 0xb2, 0xfd, 0x24,
2635 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1624 0xf9, 0x2c, 0xd8, 0xd3, 0x4e, 0xe0, 0xcf, 0x36, 0x97, 0x86, 0x5c, 0x52,
2636 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1625 0xbe, 0x1d, 0x8c, 0xdc, 0xd5, 0x0e, 0xf4, 0xf1, 0x16, 0x6c, 0xa6, 0xb6,
2637 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1626 0x2c, 0xb3, 0xfd, 0xe5, 0xa0, 0x6e, 0xb4, 0xcd, 0x80, 0x6e, 0xf9, 0xb2,
2638 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1627 0xd9, 0x8f, 0xfd, 0x3d, 0xef, 0xcb, 0xb9, 0x00, 0xa7, 0xda, 0xbc, 0x85,
2639 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1628 0xb5, 0x32, 0xf8, 0xae, 0x1f, 0xd7, 0xfc, 0xf3, 0xf7, 0x87, 0xe7, 0xab,
2640 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1629 0x34, 0x05, 0xbc, 0x6b, 0x4d, 0x89, 0x0a, 0x2a, 0xef, 0xf1, 0x2e, 0xf7,
2641 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1630 0x97, 0x83, 0xbd, 0xa0, 0xb7, 0xe7, 0xfa, 0xd4, 0x7d, 0xb0, 0x25, 0xb6,
2642 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1631 0xb1, 0xda, 0x0a, 0xf3, 0x18, 0xfb, 0xe4, 0x99, 0xc7, 0xaa, 0x8f, 0xa3,
2643 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1632 0x3d, 0xcf, 0x7a, 0x44, 0x69, 0x89, 0x58, 0xcf, 0x2f, 0xb3, 0x2e, 0x41,
2644 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1633 0x3f, 0x03, 0xbd, 0xaa, 0x38, 0x2c, 0xff, 0x2f, 0x85, 0xf6, 0x29, 0x52,
2645 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1634 0x7f, 0x86, 0xf5, 0xfd, 0x05, 0x2a, 0xc0, 0xc6, 0xa7, 0x70, 0xd2, 0x22,
2646 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1635 0x68, 0x5a, 0x68, 0xf6, 0x81, 0x57, 0x6d, 0xbb, 0x83, 0x7c, 0x07, 0xff,
2647 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1636 0xc7, 0x0b, 0xe6, 0x77, 0x03, 0x27, 0xb6, 0x99, 0x9a, 0x2a, 0x52, 0x15,
2648 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1637 0x3f, 0xe8, 0x8d, 0xa1, 0x67, 0x6d, 0x49, 0x9f, 0x28, 0x03, 0x37, 0xe8,
2649 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1638 0x3d, 0xd9, 0x7b, 0x58, 0x9f, 0x31, 0xc7, 0xa5, 0xa1, 0xb6, 0x9d, 0x2d,
2650 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1639 0x38, 0x2c, 0xa7, 0x2e, 0x9c, 0xdb, 0xc6, 0x49, 0x46, 0x1f, 0xef, 0xa3,
2651 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1640 0x40, 0xe7, 0xdb, 0x3a, 0xc3, 0xfa, 0xa7, 0x5b, 0xeb, 0xd4, 0x41, 0xd9,
2652 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1641 0x0c, 0x7c, 0xd9, 0xbc, 0x08, 0xf9, 0xa5, 0xe1, 0x53, 0x64, 0x7a, 0xba,
2653 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1642 0x99, 0xa4, 0x63, 0x4d, 0xc6, 0xaf, 0x08, 0xbb, 0x83, 0x6f, 0x9b, 0x1f,
2654 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1643 0x85, 0x9d, 0x8d, 0x0b, 0x23, 0xb0, 0x89, 0x47, 0x17, 0x19, 0x27, 0x8f,
2655 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1644 0xd8, 0x2e, 0x8b, 0xcb, 0x65, 0x61, 0xd4, 0x2d, 0x09, 0xe3, 0xcb, 0x6c,
2656 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1645 0x27, 0x6c, 0x23, 0xba, 0xfa, 0x38, 0x31, 0x0d, 0x98, 0xe3, 0xfe, 0x22,
2657 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1646 0xc1, 0xb6, 0x5a, 0x3b, 0x17, 0x07, 0x1e, 0xdb, 0x80, 0x4f, 0x37, 0x6c,
2658 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1647 0x0f, 0xfa, 0x65, 0xe8, 0x13, 0xac, 0x33, 0xc5, 0x8c, 0xa1, 0xfd, 0x25,
2659 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1648 0x7d, 0x9c, 0x0f, 0x23, 0x1b, 0x7c, 0x18, 0x00, 0x4f, 0x3e, 0xcc, 0x87,
2660 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1649 0xfa, 0xc7, 0xf9, 0x60, 0x55, 0xc1, 0x87, 0x3a, 0xfc, 0x50, 0xdd, 0x65,
2661 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1650 0x9a, 0x3d, 0x12, 0xf7, 0x10, 0xb4, 0x93, 0xf6, 0x8a, 0x26, 0xeb, 0x28,
2662 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1651 0xdb, 0x49, 0x46, 0x9b, 0xc6, 0x0e, 0x4b, 0x4e, 0xb7, 0x6f, 0x1b, 0xa3,
2663 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1652 0x3e, 0x2f, 0x7e, 0x17, 0xbd, 0x4c, 0xdf, 0x1d, 0x9a, 0xc7, 0x17, 0xd9,
2664 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1653 0xdf, 0x40, 0xcf, 0x33, 0x86, 0x7a, 0x88, 0xee, 0xd0, 0xbd, 0xef, 0x0e,
2665 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1654 0xdd, 0x38, 0xa7, 0xed, 0x83, 0x98, 0xe6, 0xb6, 0x3f, 0x66, 0x5d, 0x79,
2666 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1655 0xc3, 0x93, 0x0c, 0x03, 0x32, 0x60, 0x7d, 0x61, 0x1c, 0x74, 0xf5, 0xcb,
2667 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1656 0xa0, 0xa7, 0x02, 0xbf, 0xc0, 0xb6, 0x54, 0xf6, 0xe7, 0x75, 0x50, 0xb9,
2668 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1657 0x27, 0x98, 0x3f, 0xd5, 0xf4, 0xfe, 0x4b, 0x34, 0x3f, 0xf0, 0xec, 0xbc,
2669 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1658 0x11, 0xda, 0xb8, 0x42, 0x7f, 0xb2, 0xa8, 0x97, 0x35, 0xa1, 0x9b, 0xaa,
2670 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1659 0xf7, 0xc3, 0xaf, 0x34, 0xd9, 0x3e, 0x76, 0xde, 0xc3, 0x97, 0xa5, 0x43,
2671 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1660 0x5f, 0xf6, 0x3e, 0x78, 0xcf, 0xb1, 0xe7, 0xe8, 0x07, 0xeb, 0x49, 0x7e,
2672 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1661 0x66, 0xd4, 0x09, 0x2a, 0x71, 0xbc, 0xd9, 0x21, 0xfa, 0xfe, 0xbb, 0x8f,
2673 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1662 0x63, 0x41, 0x55, 0x36, 0xe3, 0x54, 0xed, 0xa1, 0xaa, 0x64, 0xb2, 0x1d,
2674 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1663 0xb1, 0x6d, 0xb4, 0xf1, 0xde, 0x1e, 0xc6, 0xdd, 0x41, 0x89, 0x0c, 0x1e,
2675 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1664 0x47, 0x8c, 0x68, 0x32, 0x0d, 0xef, 0x87, 0xf2, 0x60, 0x7f, 0x4a, 0xb1,
2676 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1665 0x40, 0xdf, 0xf6, 0xc3, 0x5f, 0x32, 0x3f, 0x37, 0xeb, 0x0a, 0xfb, 0x51,
2677 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1666 0xd2, 0x44, 0x83, 0xfd, 0x28, 0xa9, 0x92, 0x79, 0x50, 0xb0, 0x16, 0xbf,
2678 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1667 0x26, 0x58, 0xe0, 0x9b, 0x05, 0xbe, 0x59, 0xe0, 0x9b, 0x0d, 0xbe, 0x15,
2679 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1668 0x5c, 0xc6, 0x85, 0xf1, 0x08, 0xf6, 0x2f, 0x06, 0xfb, 0x03, 0xc7, 0x9d,
2680 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1669 0x54, 0xf1, 0xed, 0x9b, 0x69, 0x85, 0x3f, 0xf6, 0x7d, 0xc1, 0xa8, 0x10,
2681 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1670 0xf8, 0x02, 0xde, 0x6f, 0x1c, 0xeb, 0x1f, 0x47, 0x8c, 0xb3, 0x44, 0xd1,
2682 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1671 0xb8, 0xc3, 0x8f, 0xfa, 0x26, 0x7e, 0x4c, 0x3b, 0xcc, 0x1f, 0x9e, 0xcf,
2683 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1672 0x76, 0xec, 0x40, 0xe6, 0x6d, 0x9e, 0xec, 0x07, 0x0e, 0x9d, 0x4c, 0x77,
2684 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1673 0x48, 0x07, 0xef, 0xdf, 0x1b, 0xee, 0x7f, 0x00, 0x7b, 0xb2, 0xdd, 0xde,
2685 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1674 0xed, 0x5c, 0x3e, 0x93, 0xe3, 0xe8, 0x27, 0xd1, 0x83, 0x3c, 0x02, 0x7e,
2686 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1675 0x66, 0x0d, 0x76, 0x76, 0x53, 0x4a, 0xd1, 0xeb, 0xbb, 0x6f, 0x20, 0xb7,
2687 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1676 0xa0, 0xea, 0x03, 0xa6, 0xa7, 0xc9, 0xe6, 0xfb, 0x5e, 0x3d, 0x0f, 0xdf,
2688 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1677 0x69, 0xea, 0x29, 0x5b, 0x1a, 0xa4, 0x37, 0xdc, 0x2c, 0xfd, 0x9d, 0x6b,
2689 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1678 0xd0, 0xdf, 0xba, 0x1a, 0xbd, 0xea, 0xa6, 0xe9, 0x6f, 0xdc, 0x14, 0xfd,
2690 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1679 0xb5, 0xdb, 0xce, 0x43, 0x92, 0xac, 0x47, 0x89, 0xa2, 0x7b, 0xb7, 0x5c,
2691 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1680 0x08, 0x3a, 0x8e, 0xbd, 0xec, 0xbc, 0x5c, 0x96, 0x4d, 0x3f, 0x3f, 0x98,
2692 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1681 0x98, 0x6e, 0x90, 0xb2, 0xd3, 0xa0, 0xed, 0xf7, 0x23, 0xef, 0x49, 0x9a,
2693 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1682 0xb4, 0xe3, 0x3e, 0x3c, 0x7b, 0x4d, 0xb2, 0x7a, 0xcc, 0x53, 0x9e, 0x68,
2694 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1683 0xb0, 0x1e, 0x75, 0x0f, 0x4f, 0xe5, 0xe3, 0x8c, 0xfb, 0xc4, 0x34, 0xfc,
2695 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1684 0x91, 0x8d, 0xb3, 0xaa, 0xd0, 0xc5, 0xaa, 0x7b, 0xe8, 0xfe, 0x20, 0x17,
2696 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1685 0x7a, 0x2f, 0xcc, 0x89, 0x38, 0xaf, 0x5a, 0x7f, 0x6a, 0xc2, 0x60, 0x3f,
2697 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1686 0x2b, 0x6c, 0xf2, 0xb3, 0x24, 0x14, 0x41, 0x53, 0x1d, 0xb8, 0x16, 0x41,
2698 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1687 0xe7, 0x57, 0x5d, 0x45, 0x28, 0x9c, 0xef, 0xa5, 0xe9, 0x45, 0x8e, 0x55,
2699 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1688 0x3c, 0x4f, 0x09, 0x73, 0x19, 0x7e, 0xef, 0xc0, 0x3b, 0x21, 0x7e, 0x14,
2700 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1689 0xb6, 0x53, 0x42, 0x7f, 0x73, 0x82, 0x9c, 0x30, 0x17, 0x89, 0xd1, 0x05,
2701 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1690 0x5f, 0x77, 0xb8, 0xdf, 0x2a, 0xfd, 0xb0, 0xff, 0x4e, 0xff, 0xf9, 0x8d,
2702 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1691 0xfe, 0x72, 0xe9, 0xeb, 0x1b, 0xfd, 0xef, 0xa8, 0x01, 0x4e, 0xc3, 0xc2,
2703 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1692 0xe3, 0xee, 0xf3, 0x61, 0xdf, 0x6d, 0xf0, 0xd3, 0xf3, 0xea, 0x88, 0x27,
2704 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1693 0x35, 0xe3, 0x36, 0x72, 0x1f, 0xf6, 0x29, 0x5b, 0xf1, 0x21, 0x1f, 0xf2,
2705 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1694 0x1f, 0xaa, 0x2d, 0xb1, 0x9c, 0x14, 0x0a, 0xf6, 0xe4, 0xf1, 0x4e, 0xf8,
2706 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1695 0x92, 0xdb, 0x68, 0x73, 0xec, 0x6a, 0xfb, 0x31, 0x9e, 0xc3, 0xeb, 0x6f,
2707 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1696 0xdd, 0x43, 0x96, 0x2a, 0x64, 0xb9, 0x35, 0x79, 0xd5, 0x1a, 0xa7, 0x42,
2708 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1697 0x9f, 0xd0, 0x3d, 0x6c, 0x43, 0x2e, 0x12, 0xe4, 0x52, 0x83, 0x5c, 0x0a,
2709 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1698 0xf7, 0x94, 0x0b, 0xce, 0xd8, 0xd0, 0x29, 0xc6, 0xa3, 0x2b, 0x3c, 0x9b,
2710 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1699 0x14, 0xd9, 0xac, 0x96, 0xea, 0xc6, 0xa7, 0x28, 0x66, 0x30, 0x1e, 0x06,
2711 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1700 0xf0, 0x38, 0x8a, 0xb5, 0x1c, 0xc3, 0x48, 0x89, 0x99, 0x2c, 0xcf, 0xdc,
2712 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1701 0x13, 0xb6, 0x71, 0xab, 0xb4, 0xe0, 0xdc, 0x2a, 0x5d, 0x34, 0xf8, 0xfd,
2713 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1702 0xf6, 0x64, 0x90, 0x37, 0x77, 0x3f, 0x89, 0xbc, 0x19, 0xeb, 0xd9, 0x1f,
2714 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1703 0x72, 0xff, 0x30, 0xe6, 0x71, 0x7c, 0xa0, 0x43, 0x35, 0xfc, 0xea, 0xfe,
2715 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1704 0xdc, 0x6b, 0x4f, 0xf0, 0xdc, 0x4e, 0x53, 0x9e, 0xfc, 0x35, 0x9e, 0x1d,
2716 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1705 0xa6, 0xf6, 0xe4, 0x4f, 0x0d, 0xde, 0x77, 0x78, 0xf2, 0xa2, 0xbf, 0x07,
2717 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1706 0x62, 0xa6, 0xbf, 0x36, 0xfb, 0x24, 0xaf, 0x7d, 0x0e, 0x3e, 0xf6, 0x0c,
2718 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1707 0xe2, 0xcb, 0x69, 0x47, 0x3b, 0x54, 0xc1, 0x6f, 0x8a, 0x71, 0x6a, 0xf2,
2719 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1708 0xb8, 0x85, 0x71, 0x19, 0xb1, 0x90, 0xdb, 0x0a, 0x1d, 0xc3, 0xbc, 0xa7,
2720 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1709 0x31, 0xef, 0xa8, 0x33, 0x8e, 0xbc, 0xbd, 0x4d, 0xd7, 0xbf, 0xc5, 0x0b,
2721 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1710 0xf3, 0xec, 0xcf, 0x91, 0xed, 0xaf, 0xfc, 0x7b, 0xdc, 0x86, 0x5f, 0x16,
2722 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1711 0x57, 0x6e, 0xc6, 0x0b, 0xa0, 0x5b, 0x5a, 0xf9, 0x45, 0xbc, 0x08, 0x3d,
2723 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1712 0x13, 0x0d, 0x09, 0x7e, 0xf9, 0x33, 0x54, 0x53, 0x3d, 0x7a, 0x19, 0xf1,
2724 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1713 0xab, 0x96, 0x85, 0xbf, 0x82, 0x34, 0x45, 0x03, 0x7e, 0x4c, 0x25, 0xa5,
2725 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1714 0xcb, 0x3c, 0xa9, 0x52, 0x57, 0x3e, 0x6e, 0x23, 0xde, 0xd4, 0x54, 0x09,
2726 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1715 0xfd, 0xfd, 0x78, 0x6e, 0xee, 0xff, 0x65, 0x1c, 0x7e, 0x0b, 0x3e, 0x82,
2727 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1716 0x14, 0x3b, 0xdf, 0x8d, 0xfd, 0xbf, 0x8d, 0x7e, 0x4c, 0xc8, 0x6c, 0xf4,
2728 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1717 0x3f, 0x1b, 0xf4, 0xdf, 0x02, 0x2e, 0xbc, 0x8e, 0xe3, 0x27, 0x29, 0x53,
2729 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1718 0x79, 0x15, 0x38, 0xf0, 0xdc, 0xa4, 0x3f, 0xb7, 0x38, 0xcf, 0x3c, 0xa8,
2730 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1719 0x96, 0x16, 0x8c, 0x34, 0x15, 0xe6, 0x92, 0x34, 0x3a, 0xa7, 0xd2, 0xd8,
2731 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1720 0x9c, 0x3e, 0xd1, 0x62, 0xfb, 0x01, 0xcd, 0x84, 0x1c, 0x41, 0x5c, 0x21,
2732 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1721 0x50, 0xac, 0xa7, 0x9e, 0xa6, 0xbe, 0xd4, 0x31, 0xfa, 0x6f, 0x0f, 0xb1,
2733 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1722 0x08, 0x71, 0xa8, 0x9b, 0x64, 0x7f, 0x9f, 0x54, 0xfb, 0x4c, 0x96, 0xd1,
2734 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1723 0x87, 0xce, 0x2d, 0xce, 0xdf, 0x6b, 0x5f, 0x28, 0xf1, 0x4a, 0xea, 0x23,
2735 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1724 0xfb, 0xbe, 0x1b, 0xee, 0xab, 0x62, 0xdf, 0x34, 0xf6, 0x64, 0x1a, 0xf5,
2736 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1725 0xf8, 0xc8, 0x79, 0xb2, 0x3a, 0x81, 0x5f, 0x31, 0x83, 0x98, 0x8f, 0x7d,
2737 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1726 0xce, 0xcc, 0xb1, 0xde, 0xd3, 0x4e, 0xfc, 0x06, 0x63, 0x94, 0xc9, 0x2e,
2738 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1727 0x23, 0x27, 0x18, 0xf1, 0xf7, 0x08, 0xf2, 0x05, 0x71, 0x65, 0x10, 0xf9,
2739 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1728 0xda, 0x3b, 0xc0, 0x87, 0xe3, 0x18, 0xd3, 0x2c, 0x83, 0xde, 0x41, 0xe4,
2740 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1729 0x09, 0x9c, 0xe3, 0x7b, 0xa7, 0xec, 0x1c, 0xda, 0xcb, 0x5a, 0xbc, 0x00,
2741 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1730 0xdb, 0x16, 0x4d, 0x7a, 0x50, 0xf2, 0x7d, 0x2c, 0xcb, 0x65, 0x10, 0x72,
2742 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1731 0x62, 0xbc, 0x73, 0x90, 0x13, 0xf3, 0x68, 0x38, 0x5e, 0x6c, 0x32, 0x8f,
2743 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1732 0x08, 0xf8, 0x68, 0xb0, 0x27, 0xd9, 0xcf, 0xf3, 0xc5, 0x15, 0x0b, 0xf3,
2744 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1733 0x7e, 0xac, 0x72, 0x2e, 0x66, 0x1b, 0xdc, 0x86, 0xed, 0xac, 0x8c, 0x63,
2745 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1734 0x2e, 0xb7, 0x1f, 0xc6, 0xbe, 0x7d, 0xb9, 0x1a, 0x75, 0xe4, 0x9e, 0x86,
2746 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1735 0xdd, 0x8a, 0xf9, 0x01, 0xc4, 0x68, 0x01, 0xb9, 0xa0, 0xe7, 0x75, 0xe4,
2747 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1736 0xbf, 0x00, 0x7a, 0x98, 0x0e, 0xe8, 0xf5, 0x2c, 0xf3, 0x95, 0xfe, 0x40,
2748 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1737 0xe4, 0x5c, 0x2d, 0xdf, 0xce, 0x6b, 0x38, 0x9e, 0xf3, 0xf9, 0x88, 0x23,
2749 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1738 0x8d, 0x3d, 0x88, 0xa5, 0xfe, 0xd9, 0xd0, 0xb1, 0x71, 0x2a, 0x34, 0x3e,
2750 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1739 0x8b, 0x9c, 0x93, 0x6d, 0x67, 0x9b, 0x60, 0x9f, 0x67, 0x1a, 0x09, 0xb1,
2751 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1740 0x66, 0x8d, 0x2a, 0x0d, 0x39, 0x6c, 0xbf, 0x8a, 0xb6, 0x12, 0xb6, 0xd7,
2752 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1741 0xd1, 0xee, 0x0e, 0xdb, 0xd7, 0xd0, 0x56, 0xc3, 0xf6, 0xcf, 0xd0, 0x4e,
2753 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1742 0x86, 0xed, 0x9f, 0xa3, 0x9d, 0x0a, 0xdb, 0x37, 0xd1, 0x4e, 0x87, 0xed,
2754 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1743 0x5b, 0x68, 0x6b, 0x61, 0xfb, 0x3d, 0xb4, 0x13, 0xb0, 0x73, 0x03, 0xef,
2755 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1744 0x37, 0x50, 0x2b, 0x66, 0xf1, 0xfc, 0x57, 0xe0, 0x36, 0x08, 0xde, 0x64,
2756 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1745 0xc1, 0x8f, 0x5e, 0x8c, 0xe5, 0xd0, 0x87, 0x1c, 0xb1, 0x91, 0xc7, 0xd3,
2757 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1746 0xc1, 0x18, 0x95, 0x61, 0x7b, 0x18, 0x1f, 0x2f, 0x16, 0x1a, 0x26, 0x9e,
2758 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1747 0x6c, 0x0f, 0xba, 0x4a, 0xc2, 0x65, 0xd8, 0xb9, 0xef, 0x63, 0x72, 0xb6,
2759 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1748 0x34, 0x09, 0xdb, 0x9e, 0xa0, 0x7f, 0x74, 0xf7, 0xd3, 0x6b, 0xee, 0x38,
2760 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1749 0xe2, 0x46, 0x11, 0x71, 0xc3, 0x42, 0xdc, 0x30, 0x11, 0x37, 0x86, 0x11,
2761 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1750 0x37, 0xf2, 0x88, 0x1b, 0x39, 0xc4, 0x0d, 0xa2, 0x33, 0x7e, 0x8c, 0x4a,
2762 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1751 0x2a, 0xa8, 0x51, 0x15, 0xcb, 0x2d, 0x82, 0xbf, 0x13, 0x90, 0xcd, 0x24,
2763 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1752 0x78, 0x7d, 0x38, 0x3e, 0xd2, 0xcc, 0xc3, 0x9f, 0x69, 0xf0, 0x11, 0x69,
2764 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1753 0xf8, 0xf2, 0x1c, 0x6a, 0x13, 0xa2, 0x2b, 0xb3, 0x1a, 0xfc, 0x8f, 0x47,
2765 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1754 0x45, 0xc4, 0xfe, 0x69, 0x15, 0xb8, 0x19, 0xbb, 0x7c, 0x9b, 0x91, 0xcc,
2766 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1755 0x2f, 0xf6, 0x50, 0xd7, 0x20, 0xe8, 0x39, 0x8b, 0xbe, 0x14, 0xf6, 0x63,
2767 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1756 0xbe, 0xde, 0x2a, 0xd9, 0x86, 0x46, 0x0b, 0x6e, 0x1c, 0xfe, 0x9f, 0xdf,
2768 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1757 0xe3, 0xcc, 0xe3, 0x43, 0x4f, 0x19, 0x4c, 0x03, 0xea, 0x3c, 0x23, 0xad,
2769 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1758 0x14, 0x1c, 0x81, 0x24, 0x93, 0x9f, 0xed, 0x1c, 0xe2, 0xcf, 0x90, 0x43,
2770 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1759 0x74, 0x41, 0x06, 0x55, 0xc4, 0x05, 0x9d, 0xf3, 0x0b, 0xe8, 0xf2, 0x27,
2771 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1760 0xcd, 0xff, 0x1e, 0xe6, 0xef, 0xc5, 0xd9, 0x3c, 0x8f, 0xcf, 0x39, 0x85,
2772 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1761 0xfa, 0xc1, 0xea, 0x91, 0x68, 0x3d, 0x25, 0xa1, 0x9e, 0x28, 0xd0, 0x59,
2773 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1762 0x2a, 0x00, 0x9f, 0x82, 0xdb, 0xbe, 0x07, 0xb0, 0x0e, 0x05, 0xfe, 0x6c,
2774 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1763 0xe2, 0xd0, 0xb7, 0x0d, 0x0b, 0xeb, 0x18, 0x3f, 0xd6, 0x5b, 0xe0, 0xbe,
2775 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1764 0xb1, 0xe7, 0x05, 0xec, 0xf9, 0x4f, 0x49, 0xea, 0x9a, 0x0c, 0xfc, 0x91,
2776 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1765 0x5f, 0xf3, 0xca, 0xc2, 0x48, 0xf3, 0x2c, 0xf8, 0xd3, 0x87, 0x1a, 0x05,
2777 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1766 0x7e, 0xa4, 0xd4, 0x02, 0x9f, 0xda, 0xf3, 0x5f, 0xc1, 0x7c, 0x7e, 0xf7,
2778 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1767 0xef, 0x0e, 0x4a, 0xd2, 0xea, 0x12, 0xe6, 0x69, 0xac, 0x3f, 0x25, 0xb9,
2779 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1768 0xff, 0x86, 0xf7, 0xa2, 0x91, 0xa7, 0x5d, 0xab, 0xbc, 0x2e, 0x4b, 0x7d,
2780 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1769 0xab, 0x37, 0xbc, 0x9a, 0xa3, 0xd1, 0x62, 0x93, 0xc0, 0xab, 0xf8, 0x6d,
2781 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1770 0x8b, 0xf4, 0x35, 0x12, 0xf5, 0x59, 0x0b, 0x7a, 0x5a, 0x1c, 0x12, 0xc9,
2782 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1771 0x1e, 0xea, 0x84, 0x8f, 0x32, 0x68, 0x09, 0x7c, 0xdf, 0x35, 0x63, 0xd1,
2783 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1772 0x13, 0x43, 0xed, 0x7c, 0x10, 0x51, 0x0f, 0xb8, 0xee, 0x5a, 0xd5, 0x30,
2784 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1773 0x87, 0x73, 0x71, 0xa6, 0x45, 0x03, 0x2f, 0x85, 0x60, 0x8d, 0x1f, 0xb3,
2785 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1774 0xb8, 0x8e, 0x05, 0xdf, 0xdc, 0xb5, 0xd2, 0xd5, 0x19, 0xd4, 0x1a, 0x90,
2786 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1775 0xf3, 0xae, 0x19, 0xae, 0x85, 0xb6, 0x81, 0x2f, 0x31, 0xd8, 0x06, 0xe7,
2787 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1776 0xf1, 0x08, 0xf4, 0xf0, 0x87, 0x27, 0xe0, 0xf1, 0x6b, 0xcd, 0x13, 0xd0,
2788 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1777 0xfb, 0x2e, 0x2a, 0xcb, 0x3e, 0x11, 0x9f, 0xc0, 0xe3, 0xff, 0xe4, 0xbc,
2789 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1778 0x0e, 0xf3, 0xbf, 0x4b, 0xc5, 0xd9, 0x2e, 0xec, 0xb5, 0x9b, 0xa6, 0x93,
2790 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1779 0x8c, 0x9b, 0x3e, 0x8c, 0x41, 0x2d, 0x06, 0x7e, 0xc6, 0xcd, 0x8f, 0xe6,
2791 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1780 0x7d, 0x6b, 0xa5, 0x2b, 0x33, 0x6b, 0xa5, 0x6b, 0xa0, 0xbf, 0x6e, 0x70,
2792 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1781 0x8d, 0x0c, 0x5d, 0x6a, 0x70, 0x6d, 0xcf, 0x79, 0xd1, 0x18, 0x74, 0x64,
2793 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1782 0xbf, 0x5f, 0x33, 0xdb, 0x8b, 0x39, 0xea, 0x3b, 0x47, 0xaa, 0x68, 0x96,
2794 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1783 0x84, 0x31, 0xe4, 0x45, 0x23, 0xee, 0x49, 0x7f, 0xee, 0x99, 0x06, 0xd7,
2795 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1784 0x2b, 0x18, 0x5b, 0x61, 0x5d, 0x18, 0x03, 0x3e, 0x49, 0xba, 0xe8, 0xb2,
2796 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1785 0x4f, 0x0a, 0xec, 0x78, 0x0c, 0xfc, 0x5a, 0xf0, 0xe9, 0x4a, 0x71, 0x1c,
2797 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1786 0x47, 0xbe, 0xc1, 0xf2, 0xf9, 0x21, 0xc7, 0x41, 0xa1, 0xd3, 0x6c, 0xfb,
2798 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1787 0xdb, 0x89, 0x5e, 0xe6, 0x59, 0xa1, 0x01, 0xdf, 0x3f, 0x34, 0x11, 0xe6,
2799 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1788 0x1c, 0x7f, 0x8f, 0x39, 0x8c, 0x3b, 0xcd, 0x4a, 0x26, 0xce, 0xc8, 0x33,
2800 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1789 0xcf, 0x38, 0xa7, 0xe4, 0x7d, 0xc1, 0x5b, 0xf0, 0x7d, 0x53, 0x6e, 0xe9,
2801 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1790 0xc3, 0x74, 0x33, 0x46, 0x95, 0x59, 0xf0, 0x2e, 0x8f, 0x27, 0x9c, 0x6b,
2802 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1791 0x1d, 0x7c, 0x03, 0x2d, 0xd5, 0x20, 0x9f, 0x3d, 0xc1, 0x31, 0x0d, 0xfe,
2803 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1792 0x06, 0x36, 0xcd, 0x31, 0x6b, 0xe3, 0xde, 0xc9, 0xf7, 0x25, 0x32, 0x19,
2804 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1793 0x41, 0xce, 0x2a, 0xe2, 0x2c, 0x3b, 0xcf, 0x7e, 0x10, 0xf8, 0xb8, 0xdf,
2805 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1794 0xa5, 0xfa, 0x2c, 0xd3, 0x05, 0x1b, 0x4f, 0xb2, 0x2e, 0xfe, 0x7f, 0xf9,
2806 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1795 0x38, 0xba, 0x45, 0x3e, 0x8e, 0x6e, 0x99, 0x8f, 0x12, 0xf8, 0x58, 0xd9,
2807 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1796 0xe0, 0xa3, 0x82, 0x3d, 0xf8, 0x3e, 0xe1, 0xab, 0x64, 0x4d, 0x3c, 0x02,
2808 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1797 0x3f, 0x0c, 0xff, 0xd1, 0x3c, 0x05, 0x9f, 0x70, 0x52, 0xb8, 0xda, 0xf0,
2809 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1798 0x68, 0x1c, 0xb5, 0xb2, 0x74, 0xff, 0x66, 0xfa, 0x33, 0xa0, 0xff, 0xcf,
2810 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1799 0x31, 0x5e, 0xa5, 0x6b, 0xb3, 0x94, 0x56, 0xa8, 0x7d, 0x2e, 0xed, 0x92,
2811 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1800 0xe9, 0x3b, 0x74, 0x75, 0xb6, 0x8b, 0xae, 0xcf, 0x66, 0xc0, 0xeb, 0x2c,
2812 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1801 0xc5, 0x7a, 0x32, 0xc3, 0x15, 0x18, 0xf1, 0xcf, 0x5a, 0xba, 0xc5, 0xba,
2813 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1802 0xf8, 0xfb, 0xf3, 0x82, 0xf9, 0x70, 0xd0, 0xe7, 0xc3, 0xd8, 0x47, 0xf8,
2814 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1803 0x30, 0x7e, 0x4f, 0x3e, 0x1c, 0xfc, 0x18, 0x1f, 0xc6, 0x3f, 0xc6, 0x07,
2815 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1804 0xe6, 0x01, 0xf3, 0xe2, 0xd1, 0xde, 0xf0, 0xff, 0x1f, 0x7d, 0x82, 0x7d,
2816 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1805 0x7c, 0x09, 0x74, 0x22, 0xa7, 0xd8, 0x19, 0xe4, 0x50, 0x9c, 0x63, 0xd5,
2817 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1806 0x0c, 0xe6, 0x57, 0x60, 0xbf, 0x32, 0x72, 0xea, 0x23, 0xa1, 0xfd, 0x16,
2818 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1807 0x1c, 0xe8, 0x65, 0x23, 0xe6, 0xdb, 0xaf, 0x64, 0xe6, 0xe1, 0x03, 0xaa,
2819 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1808 0xa5, 0x96, 0xc3, 0xfe, 0x07, 0x6d, 0x87, 0x79, 0xda, 0x0b, 0x5a, 0x12,
2820 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1809 0x54, 0x99, 0x54, 0x10, 0x5f, 0x87, 0xa1, 0xb7, 0x71, 0xdf, 0x07, 0x4a,
2821 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1810 0x26, 0xeb, 0xe1, 0x7e, 0xcc, 0x3f, 0x1c, 0xe6, 0x45, 0x88, 0x73, 0x38,
2822 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1811 0xa3, 0xd6, 0x38, 0x0d, 0xfc, 0xf8, 0x9c, 0x6a, 0xa9, 0xec, 0xf0, 0x9a,
2823 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1812 0x34, 0x62, 0x21, 0x3f, 0x37, 0xeb, 0xb7, 0xaf, 0xef, 0xf7, 0xd2, 0x71,
2824 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1813 0xe8, 0x26, 0xeb, 0xb4, 0x82, 0xdc, 0x78, 0x02, 0xf1, 0xc5, 0xd7, 0xd3,
2825 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1814 0xec, 0x02, 0xb1, 0xdf, 0x7f, 0x06, 0x75, 0xd1, 0x61, 0xfc, 0x34, 0x1a,
2826 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1815 0x71, 0x03, 0x9b, 0x5a, 0xf2, 0xcf, 0xfc, 0xb0, 0x4f, 0xaa, 0x39, 0xeb,
2827 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1816 0xc8, 0xdf, 0x0d, 0xec, 0xcb, 0xe7, 0x56, 0xc1, 0x1b, 0x09, 0xe7, 0x72,
2828 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1817 0x5f, 0x37, 0xe2, 0x00, 0xf8, 0xe4, 0xfe, 0x07, 0xfa, 0x97, 0xe0, 0x1f,
2829 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1818 0x39, 0x2f, 0x68, 0xe3, 0x8e, 0x1c, 0xc2, 0xe1, 0x78, 0x9d, 0x07, 0xcd,
2830 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1819 0x9c, 0x63, 0x73, 0x2e, 0x81, 0xfc, 0x63, 0xe9, 0x4d, 0xf4, 0x0d, 0xd3,
2831 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1820 0xe9, 0xa1, 0x2c, 0xe4, 0xc3, 0x7d, 0x0f, 0x84, 0x7d, 0x3c, 0x8f, 0x94,
2832 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1821 0x07, 0x4d, 0xfd, 0x07, 0x55, 0xdf, 0xaf, 0x43, 0x0f, 0x51, 0xf7, 0xd5,
2833 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1822 0x96, 0x90, 0x63, 0x00, 0xa7, 0xca, 0x6a, 0x16, 0xb9, 0x3c, 0xdf, 0xab,
2834 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1823 0xe9, 0x97, 0x91, 0x07, 0x83, 0x27, 0x0a, 0xf5, 0x1a, 0xa5, 0xd0, 0x0f,
2835 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1824 0xe7, 0x40, 0x1f, 0xdf, 0x3d, 0xf5, 0x21, 0xf7, 0x91, 0xc0, 0x08, 0xd8,
2836 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1825 0xe9, 0xaa, 0x44, 0x7b, 0xe5, 0x01, 0xb5, 0x46, 0xff, 0x80, 0xb9, 0x32,
2837 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1826 0x95, 0x57, 0x39, 0x87, 0x90, 0xe9, 0xc8, 0x2a, 0xd1, 0x5b, 0x33, 0xec,
2838 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1827 0x97, 0x19, 0xd8, 0x2f, 0xb3, 0x7f, 0x7d, 0xd0, 0x1f, 0x7b, 0x6b, 0x06,
2839 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1828 0x35, 0xf8, 0xcc, 0x00, 0xc7, 0xb0, 0x75, 0x11, 0xbc, 0x44, 0xee, 0xc3,
2840 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1829 0xf9, 0xf9, 0x5d, 0xee, 0x98, 0xda, 0xf7, 0x4b, 0x0a, 0x55, 0x66, 0xf8,
2841 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1830 0x6e, 0x49, 0xc6, 0xf9, 0x5c, 0x5b, 0x6c, 0x03, 0x7e, 0x02, 0xa1, 0xee,
2842 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1831 0x12, 0x38, 0xa6, 0x09, 0xd0, 0xa1, 0x5d, 0x90, 0x3d, 0xf8, 0x1f, 0xb6,
2843 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1832 0xdb, 0xfa, 0xf4, 0x2f, 0xd0, 0x27, 0x9e, 0x27, 0x6f, 0xc2, 0x25, 0x33,
2844 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1833 0x6b, 0x8b, 0x1c, 0x1f, 0x3e, 0x0d, 0xdb, 0xb3, 0xe2, 0x63, 0xcd, 0x0e,
2845 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1834 0x6a, 0xf5, 0xb2, 0x3d, 0xb0, 0x5e, 0x5c, 0x66, 0x9d, 0xc0, 0x19, 0xd0,
2846 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1835 0xa1, 0x19, 0xae, 0xe7, 0x65, 0xcc, 0xbb, 0x2f, 0x9c, 0xc7, 0xfc, 0xfe,
2847 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1836 0x1e, 0x4d, 0x0f, 0xa9, 0x42, 0x59, 0x0d, 0xe2, 0x45, 0x6d, 0xa8, 0x03,
2848 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1837 0x63, 0x22, 0x1d, 0x7c, 0x38, 0x8f, 0xb5, 0x9c, 0x53, 0xc5, 0x85, 0xc0,
2849 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1838 0x6f, 0x71, 0x1f, 0xdf, 0xd7, 0xa9, 0x54, 0xbe, 0xd4, 0x4b, 0x95, 0x4b,
2850 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1839 0x0a, 0xf8, 0x02, 0x44, 0x17, 0x82, 0x7d, 0xd8, 0x17, 0x1c, 0x87, 0xdc,
2851 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1840 0xc4, 0x73, 0x0a, 0xc5, 0xce, 0x21, 0x87, 0xbc, 0xd0, 0x45, 0x1d, 0x17,
2852 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1841 0xfa, 0x49, 0xba, 0xa0, 0x73, 0x7e, 0xa8, 0x9d, 0x81, 0x0c, 0x8f, 0x50,
2853 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1842 0x9e, 0x9e, 0x73, 0x07, 0x39, 0xc7, 0xc3, 0x39, 0x5c, 0xe7, 0x25, 0x49,
2854 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1843 0x42, 0xf2, 0x2f, 0xbe, 0x68, 0xd1, 0x8b, 0x43, 0xc0, 0x2b, 0x8f, 0xf6,
2855 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1844 0x8f, 0x91, 0xc7, 0xbb, 0x23, 0xf7, 0x71, 0xcc, 0x96, 0xcd, 0x3e, 0xc8,
2856 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1845 0x16, 0x74, 0xe5, 0x1e, 0xf2, 0xef, 0x44, 0x5f, 0x1c, 0x62, 0x7a, 0x34,
2857 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1846 0xd0, 0x52, 0x87, 0xae, 0xf3, 0x3d, 0x57, 0x17, 0xd9, 0x32, 0xeb, 0x32,
2858 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1847 0xf2, 0xaa, 0x0b, 0x75, 0x9a, 0x6a, 0xe8, 0x90, 0x59, 0x1f, 0xf4, 0x02,
2859 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1848 0x32, 0x4b, 0x73, 0x3f, 0xef, 0x2d, 0x84, 0xfb, 0xde, 0xd1, 0xf7, 0x17,
2860 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1849 0xef, 0xad, 0xef, 0x3e, 0xd4, 0x9b, 0x8f, 0xc0, 0x67, 0xa3, 0x2e, 0x32,
2861 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1850 0xe0, 0xd3, 0x55, 0xe4, 0x72, 0x06, 0xbf, 0x07, 0x77, 0x95, 0x15, 0xe4,
2862 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1851 0x85, 0xfc, 0x5e, 0x6b, 0xdd, 0xcd, 0x77, 0x07, 0xf6, 0x7d, 0x06, 0x3c,
2863 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1852 0xba, 0x32, 0xf7, 0x00, 0x5d, 0x9d, 0x53, 0xe8, 0x5a, 0x43, 0xcf, 0x16,
2864 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1853 0xa8, 0x83, 0xaa, 0xc9, 0x34, 0x5d, 0x5f, 0x6a, 0xe7, 0x93, 0x22, 0xf4,
2865 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1854 0xc4, 0x22, 0xce, 0xcd, 0xaf, 0x2c, 0x55, 0x4b, 0x37, 0x76, 0xa7, 0x49,
2866 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1855 0x7e, 0x09, 0xb6, 0xfd, 0x92, 0xae, 0xd5, 0xc0, 0xe7, 0xba, 0xe1, 0xa2,
2867 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1856 0x56, 0xe3, 0x3a, 0x32, 0x05, 0xbb, 0xd3, 0x53, 0x2d, 0xca, 0x90, 0xb4,
2868 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1857 0xa0, 0xd0, 0xaf, 0x66, 0x74, 0x8d, 0x75, 0xee, 0xa2, 0x81, 0x7e, 0x37,
2869 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1858 0x7e, 0x7b, 0x3d, 0xd0, 0x43, 0xf4, 0xf5, 0xa3, 0xbe, 0xd5, 0xb3, 0x9a,
2870 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1859 0xd8, 0x4d, 0x6f, 0x43, 0x27, 0xca, 0x7e, 0xdf, 0x47, 0xf7, 0xbc, 0x1e,
2871 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1860 0xee, 0x59, 0x2d, 0x5d, 0xe1, 0x3a, 0x68, 0x86, 0x75, 0xbe, 0x17, 0xfe,
2872 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1861 0x03, 0xef, 0x6e, 0x07, 0x95, 0x27, 0x11, 0xa3, 0x66, 0x1e, 0xa5, 0xc2,
2873 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1862 0x90, 0x18, 0xd0, 0xed, 0xf3, 0x82, 0xfb, 0xf8, 0x7e, 0xb2, 0x76, 0x1f,
2874 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1863 0xdb, 0xb2, 0xb8, 0x0a, 0xbd, 0x3a, 0xc8, 0x7a, 0x80, 0xdc, 0x0e, 0x39,
2875 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1864 0x04, 0xfb, 0x4e, 0x09, 0x39, 0x44, 0xc1, 0x0d, 0x74, 0xa3, 0x75, 0x30,
2876 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1865 0x49, 0xc7, 0x5e, 0x62, 0x19, 0x61, 0x6c, 0x43, 0xef, 0x36, 0xee, 0xc4,
2877 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1866 0x31, 0x66, 0xd0, 0xf1, 0xef, 0xb7, 0x73, 0x4a, 0xb6, 0xbd, 0x34, 0xe4,
2878 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1867 0xa1, 0xa3, 0xf6, 0xe8, 0x53, 0x2b, 0xbe, 0x4f, 0x81, 0x4e, 0xa4, 0x02,
2879 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1868 0x19, 0xd4, 0x30, 0x36, 0xed, 0x4e, 0xc2, 0x27, 0xc6, 0xe8, 0xe6, 0xa4,
2880 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1869 0x05, 0x9d, 0x68, 0x01, 0x87, 0xc3, 0x71, 0xbe, 0x4b, 0xb8, 0x39, 0x59,
2881 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1870 0xc4, 0xfb, 0x61, 0x3f, 0xf7, 0x97, 0xf6, 0x40, 0x97, 0xdc, 0x07, 0xc2,
2882 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1871 0xfc, 0x9c, 0xcf, 0xd3, 0x84, 0xda, 0xac, 0x2e, 0x4c, 0xcf, 0x7a, 0x34,
2883 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1872 0x9a, 0xeb, 0x4b, 0x5d, 0xa5, 0x4e, 0xff, 0xce, 0xd8, 0xf7, 0x9b, 0xfe,
2884 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1873 0x9c, 0x5d, 0x18, 0xff, 0x00, 0x3a, 0x85, 0x27, 0xe2, 0xf5, 0xe9, 0x66,
2885 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1874 0x35, 0xd5, 0x41, 0xac, 0x53, 0x24, 0x2c, 0x18, 0xec, 0x3b, 0x04, 0xba,
2886 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1875 0xea, 0xdf, 0x47, 0x13, 0x15, 0x9d, 0xd7, 0x99, 0x6e, 0x61, 0xb1, 0xc5,
2887 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1876 0x6b, 0x58, 0xce, 0xbc, 0x46, 0xa2, 0x9b, 0x49, 0xd8, 0xe5, 0x9e, 0x3d,
2888 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1877 0x7e, 0xbd, 0xf8, 0xf8, 0x10, 0xe3, 0xda, 0x0d, 0x99, 0x42, 0xbf, 0x50,
2889 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1878 0xdb, 0x94, 0x83, 0xbe, 0x59, 0xae, 0x4d, 0xa7, 0xf9, 0xde, 0x23, 0xef,
2890 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1879 0xeb, 0x5a, 0xa8, 0x1f, 0x1f, 0xd7, 0xb5, 0xe7, 0xb0, 0xf6, 0x2d, 0xf6,
2891 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1880 0xab, 0x90, 0x75, 0xe0, 0x23, 0xbe, 0x41, 0x6f, 0xcd, 0x55, 0xb3, 0xfc,
2892 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1881 0xcd, 0xa3, 0x35, 0x21, 0xa0, 0x16, 0x3f, 0x4e, 0x6f, 0xcf, 0x3d, 0x4b,
2893 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1882 0xbf, 0x9c, 0x65, 0xdd, 0x31, 0x68, 0x14, 0xfa, 0x74, 0x94, 0xe4, 0xec,
2894 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1883 0x69, 0x1a, 0x50, 0xaf, 0xfb, 0xb5, 0x8d, 0x9e, 0xf3, 0x6b, 0x3a, 0x33,
2895 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1884 0x4b, 0xc5, 0xc6, 0x40, 0xea, 0x1a, 0xfa, 0xca, 0x93, 0xba, 0xb6, 0x8e,
2896 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1885 0xdc, 0xa3, 0xd0, 0xfc, 0x80, 0xef, 0x6c, 0xb2, 0x35, 0xd8, 0xde, 0x22,
2897 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1886 0x6a, 0x9b, 0xb7, 0x9d, 0xbb, 0xe9, 0x2c, 0xd7, 0x56, 0x81, 0xff, 0x5e,
2898 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1887 0x33, 0x50, 0x63, 0xac, 0xaa, 0xa1, 0x0e, 0x31, 0x70, 0x9d, 0xc1, 0xf1,
2899 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1888 0x07, 0x4f, 0x37, 0x06, 0x9f, 0xb2, 0x1f, 0x7c, 0x67, 0xd9, 0x42, 0xfe,
2900 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1889 0xab, 0xfc, 0x8d, 0x0a, 0xf2, 0x5f, 0x5d, 0xfe, 0x40, 0xeb, 0x65, 0x3f,
2901 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1890 0x6b, 0x80, 0x96, 0x41, 0x3a, 0x33, 0xcf, 0xf2, 0x47, 0xec, 0xf5, 0xed,
2902 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1891 0x34, 0x0d, 0xfe, 0x72, 0x7c, 0x19, 0xa4, 0x5f, 0x2d, 0x15, 0xfd, 0xfb,
2903 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1892 0x6b, 0x1b, 0xb9, 0xd6, 0x11, 0x67, 0x12, 0xf5, 0xfa, 0x77, 0x40, 0x2f,
2904 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1893 0xce, 0x1e, 0xda, 0x8d, 0xa7, 0x0a, 0x9b, 0xdc, 0x72, 0x9e, 0x23, 0x07,
2905 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1894 0x79, 0xce, 0xde, 0x2d, 0xe6, 0x39, 0x7b, 0xb7, 0x92, 0xe7, 0xc8, 0x9d,
2906 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1895 0xe0, 0xab, 0xd6, 0xbb, 0x65, 0xdc, 0xa4, 0x00, 0xb7, 0x03, 0x5b, 0xc4,
2907 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1896 0xed, 0xc0, 0x56, 0x70, 0x93, 0x3a, 0xcd, 0xbf, 0x40, 0x8c, 0x35, 0x10,
2908 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1897 0xdb, 0xe0, 0xd7, 0x86, 0xfa, 0x59, 0x7f, 0x80, 0xa3, 0x8f, 0xeb, 0xef,
2909 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1898 0x8b, 0xa7, 0x18, 0xe0, 0xf9, 0xd8, 0x16, 0xf1, 0x7c, 0x6c, 0x2b, 0x78,
2910 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1899 0x8a, 0x9d, 0x26, 0xe3, 0x28, 0xc3, 0xd7, 0x70, 0x6d, 0x83, 0xd8, 0x3c,
2911 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1900 0x24, 0x87, 0xba, 0x2e, 0x87, 0x75, 0x0e, 0x03, 0x7c, 0x50, 0xaf, 0x46,
2912 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1901 0x4b, 0x4c, 0xcb, 0x46, 0xdf, 0x9d, 0x3a, 0x4b, 0x32, 0x5b, 0xa5, 0x4a,
2913 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1902 0x83, 0xef, 0x95, 0xfb, 0xb0, 0x0f, 0xf7, 0xf1, 0x37, 0x2a, 0x8b, 0x64,
2914 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1903 0xc4, 0xf7, 0xe7, 0x9a, 0x77, 0xa7, 0xf5, 0x2a, 0x68, 0x9d, 0x0a, 0x69,
2915 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1904 0xad, 0xf8, 0xb9, 0xe0, 0xbe, 0x4d, 0xb9, 0x60, 0x40, 0xe3, 0x08, 0x68,
2916 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1905 0x2c, 0x86, 0x34, 0x3e, 0xdd, 0x60, 0xda, 0xf6, 0xf9, 0xb4, 0x2d, 0x6d,
2917 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1906 0xa2, 0x6d, 0xe4, 0x9e, 0xf9, 0x1f, 0xe3, 0x81, 0x5a, 0x1a, 0xb9, 0xd7,
2918 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1907 0x6b, 0x4d, 0xd4, 0xd2, 0x4d, 0xd4, 0xd2, 0xd0, 0xf7, 0x57, 0x9b, 0xa8,
2919 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1908 0xa5, 0x9b, 0xa8, 0xa5, 0x61, 0x07, 0xaf, 0xc0, 0x56, 0x82, 0x3b, 0xdc,
2920 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1909 0x12, 0x71, 0x0d, 0xee, 0xd7, 0xe3, 0x14, 0xe4, 0x39, 0x05, 0xc4, 0xf0,
2921 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1910 0xa3, 0xc8, 0xf1, 0xd8, 0x6e, 0x4f, 0x13, 0xc7, 0x04, 0x3d, 0x87, 0x9a,
2922 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1911 0x2f, 0x5b, 0x25, 0x33, 0x5e, 0x9c, 0x1f, 0x50, 0x97, 0x02, 0xfb, 0xd6,
2923 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1912 0x5a, 0xc4, 0x71, 0x70, 0x20, 0x85, 0x08, 0xa9, 0xb2, 0x5f, 0xb0, 0x73,
2924 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1913 0x4c, 0xe7, 0x76, 0xf0, 0x10, 0xbe, 0xdb, 0x60, 0x1f, 0xc6, 0xbe, 0xb4,
2925 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1914 0x4e, 0x0b, 0x8d, 0xf0, 0x1b, 0x9a, 0xcc, 0xfd, 0xfc, 0xce, 0x31, 0xb7,
2926 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1915 0xcf, 0xf7, 0x69, 0x76, 0xb6, 0x0f, 0x71, 0x80, 0xfb, 0x15, 0xf8, 0x35,
2927 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1916 0xe8, 0xca, 0x52, 0x1b, 0x17, 0x19, 0xeb, 0x55, 0xaa, 0xcf, 0x07, 0x31,
2928 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1917 0x7c, 0xca, 0xe0, 0x38, 0x87, 0xf8, 0xbe, 0xc4, 0xdf, 0xb0, 0x10, 0xeb,
2929 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1918 0x97, 0xae, 0x68, 0x32, 0x6a, 0xc7, 0x3a, 0x7f, 0xa3, 0x1d, 0xec, 0xc3,
2930 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1919 0xf9, 0x1d, 0xfe, 0x1d, 0xed, 0x51, 0xff, 0xae, 0xcd, 0xa0, 0x23, 0xad,
2931 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1920 0x80, 0x16, 0xdb, 0xc8, 0xd0, 0xc8, 0x2c, 0xdf, 0x35, 0x51, 0x8f, 0x68,
2932 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1921 0xca, 0x54, 0x75, 0xf8, 0x7e, 0x68, 0xe3, 0xbb, 0x49, 0x76, 0x91, 0xeb,
2933 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1922 0x4f, 0x23, 0xb8, 0xff, 0x3c, 0xed, 0xbc, 0xc9, 0xf7, 0x9f, 0xe1, 0x3a,
2934 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1923 0x8d, 0xde, 0x70, 0x33, 0x34, 0x8e, 0xf8, 0x5a, 0x6c, 0x68, 0xf0, 0x6f,
2935 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1924 0xbe, 0x3c, 0x39, 0xa7, 0xad, 0xc6, 0x42, 0x99, 0x8e, 0x84, 0x32, 0xad,
2936 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1925 0x34, 0xd6, 0x80, 0xdf, 0x0d, 0xef, 0x8f, 0x43, 0x99, 0xee, 0x3a, 0x47,
2937 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1926 0xda, 0xd5, 0x1c, 0xcb, 0x95, 0x65, 0x19, 0xc8, 0x75, 0x7c, 0xb1, 0x24,
2938 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1927 0x14, 0x21, 0xd3, 0x51, 0x5f, 0xa6, 0x32, 0xc7, 0x05, 0xec, 0x95, 0x83,
2939 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1928 0xfc, 0xd9, 0x8f, 0xe1, 0xe9, 0xb0, 0x8c, 0xb9, 0xde, 0xe0, 0x58, 0x98,
2940 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1929 0xa4, 0x4b, 0x9b, 0xe4, 0x5c, 0xbc, 0xa7, 0x0e, 0xe7, 0xa9, 0xff, 0x9c,
2941 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1930 0x16, 0xde, 0x9b, 0x66, 0x21, 0xc7, 0x76, 0x2e, 0xf6, 0x23, 0x81, 0x8c,
2942 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1931 0xf6, 0x9d, 0x6e, 0xbb, 0xef, 0xe5, 0x4d, 0x7d, 0xed, 0x67, 0x9b, 0x56,
2943 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1932 0xc4, 0xb7, 0x0d, 0xde, 0xf3, 0x1d, 0xe4, 0x9d, 0x7e, 0xc9, 0x1f, 0x53,
2944 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1933 0x31, 0xd6, 0x4b, 0x85, 0x25, 0x83, 0xac, 0x16, 0xcf, 0x91, 0x49, 0x34,
2945 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1934 0xda, 0x72, 0xea, 0xa4, 0xf5, 0x30, 0xc6, 0x2d, 0x34, 0x3c, 0xef, 0xa7,
2946 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1935 0xd0, 0x9d, 0x8b, 0x5c, 0x77, 0x3b, 0xbf, 0xf1, 0xd6, 0x93, 0xc8, 0x21,
2947 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1936 0x37, 0xce, 0xfc, 0xe6, 0xfd, 0xd4, 0xa5, 0xab, 0x88, 0x09, 0x74, 0xc6,
2948 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1937 0x09, 0x51, 0x22, 0x1e, 0xe7, 0x3e, 0xfe, 0x06, 0xef, 0x79, 0x17, 0x8d,
2949 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1938 0x3b, 0x78, 0x75, 0x99, 0xc7, 0x69, 0xdf, 0x39, 0xf6, 0xff, 0x3f, 0xd0,
2950 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1939 0x2e, 0x1a, 0xd6, 0x9e, 0x38, 0xf2, 0xe7, 0xeb, 0xc4, 0xb1, 0x4f, 0x4e,
2951 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1940 0x14, 0x9b, 0xba, 0x7a, 0x09, 0x6b, 0x8b, 0x8e, 0xc2, 0xdf, 0xd6, 0xf9,
2952 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1941 0xfb, 0xa8, 0x76, 0x89, 0xda, 0xf7, 0x65, 0x90, 0xa7, 0xa3, 0xf2, 0x77,
2953 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1942 0x52, 0xb5, 0x8a, 0xd8, 0x52, 0x70, 0x92, 0x98, 0xaf, 0x62, 0x2e, 0xc7,
2954 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1943 0x05, 0x8f, 0x14, 0xd8, 0x50, 0xc1, 0x49, 0x27, 0xc6, 0x9a, 0x9e, 0xa7,
2955 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1944 0x7c, 0x5e, 0xa0, 0x87, 0x32, 0x29, 0x1a, 0x73, 0xf8, 0xfe, 0xf7, 0x9b,
2956 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1945 0xf4, 0x36, 0xec, 0xac, 0x78, 0x9e, 0x6b, 0x26, 0xf6, 0x29, 0x78, 0x77,
2957 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1946 0xf8, 0xbe, 0xea, 0x14, 0x3d, 0xb4, 0x47, 0xcf, 0x5e, 0x22, 0xe0, 0xb3,
2958 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1947 0x42, 0xfd, 0x48, 0x72, 0x53, 0xc7, 0xfd, 0xef, 0x6d, 0x8c, 0x6b, 0x9a,
2959 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1948 0x96, 0xc0, 0x1b, 0xa7, 0x99, 0xa4, 0x95, 0x66, 0x8a, 0x56, 0xa1, 0x1f,
2960 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1949 0xdb, 0xcc, 0x32, 0x7d, 0x03, 0x78, 0x2b, 0x66, 0x95, 0x94, 0x8c, 0xb5,
2961 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1950 0xaf, 0x0b, 0x78, 0x67, 0x05, 0x3d, 0x15, 0x17, 0x18, 0x77, 0x5d, 0x2d,
2962 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1951 0x03, 0x6f, 0xd6, 0xd1, 0x51, 0xa7, 0x9b, 0x8e, 0x61, 0xed, 0x7e, 0xe4,
2963 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1952 0x1f, 0xdf, 0x72, 0xa8, 0x2c, 0x99, 0x29, 0x3a, 0x80, 0xf3, 0x8e, 0x36,
2964 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1953 0x38, 0x57, 0x3b, 0x02, 0x5f, 0x23, 0xd0, 0xa3, 0x19, 0x8f, 0x1e, 0xdd,
2965 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1954 0xa3, 0x5b, 0x71, 0x01, 0x7b, 0xae, 0xb0, 0x9e, 0xa0, 0xdf, 0x09, 0xce,
2966 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1955 0x8d, 0xad, 0xf8, 0xba, 0x08, 0x7f, 0xfa, 0x0c, 0x65, 0xce, 0xad, 0xe5,
2967 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1956 0xa6, 0x90, 0x9f, 0x8f, 0x36, 0xe9, 0x8b, 0x31, 0x9c, 0xf7, 0x36, 0xf8,
2968 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1957 0x34, 0xea, 0xc8, 0x02, 0xf3, 0xe9, 0x58, 0xc0, 0x27, 0x8c, 0xf1, 0xb7,
2969 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1958 0x23, 0xce, 0xd1, 0xf8, 0xec, 0x13, 0x74, 0xb6, 0xc1, 0x77, 0xdd, 0x27,
2970 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1959 0xe8, 0x4a, 0xe3, 0x11, 0xba, 0x98, 0xe3, 0x5c, 0x07, 0xfb, 0xf8, 0x67,
2971 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1960 0xa0, 0xcf, 0x3f, 0xa3, 0x9b, 0x8e, 0xfb, 0x72, 0xfa, 0x3f, 0xc3, 0x06,
2972 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 1961 0xd0, 0x70, 0x4c, 0x57, 0x00, 0x00, 0x00 };
2973 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2974 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2975 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2976 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2977 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2978 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2979 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2980 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2981 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2982 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2983 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2984 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2985 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2986 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2987 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2988 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2989 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2990 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2991 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2992 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2993 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2994 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2995 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2996 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2997 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2998 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2999 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3000 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3001 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3002 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3003 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3004 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3005 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3006 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3007 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3008 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3009 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3010 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3011 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3012 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3013 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3014 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3015 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3016 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3017 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3018 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3019 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3020 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3021 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3022 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3023 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3024 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3025 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3026 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3027 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3028 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3029 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3030 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3031 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3032 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3033 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3034 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3035 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3036 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3037 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3038 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3039 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3040 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3041 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3042 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3044 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3046 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3047 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3048 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3049 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3050 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3051 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3052 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3053 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3054 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3055 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3056 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3057 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3058 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3059 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3060 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3061 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3062 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3063 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3064 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3065 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3066 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3067 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3068 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3069 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3070 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3071 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3072 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3073 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3074 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3075 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3076 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3077 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3078 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3079 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3080 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3081 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3082 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3083 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3084 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3085 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3086 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3087 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3088 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3089 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3090 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3091 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3092 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3093 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3094 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3095 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3096 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3097 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3098 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3099 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3100 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3101 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3102 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3103 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3104 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3105 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3106 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3107 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3108 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3109 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3110 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3111 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3112 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3113 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3114 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3115 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3116 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3117 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3118 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3119 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3120 0x00000000, 0x10000003, 0x00000000, 0x0000000d, 0x0000000d, 0x3c020800,
3121 0x24425760, 0x3c030800, 0x24635964, 0xac400000, 0x0043202b, 0x1480fffd,
3122 0x24420004, 0x3c1d0800, 0x37bd7ffc, 0x03a0f021, 0x3c100800, 0x261034b0,
3123 0x3c1c0800, 0x279c5760, 0x0e000f5b, 0x00000000, 0x0000000d, 0x8f840014,
3124 0x27bdffe8, 0xafb10014, 0xafb00010, 0x8f460104, 0x8f830008, 0x8c8500ac,
3125 0xaf430080, 0x948200a8, 0xa7420e10, 0x948300aa, 0xa7430e12, 0x8c8200ac,
3126 0xaf420e18, 0x97430e10, 0xa7430e14, 0x97420e12, 0x00008021, 0xa7420e16,
3127 0x8f430e18, 0x00006021, 0x00c53023, 0xaf430e1c, 0x10c001a2, 0x2d820001,
3128 0x3c0e1000, 0x2419fff8, 0x24110010, 0x240f0f00, 0x3c188100, 0x93620008,
3129 0x10400009, 0x00000000, 0x97620010, 0x00c2102b, 0x14400005, 0x00000000,
3130 0x97620010, 0x3042ffff, 0x0a000d6d, 0xaf420e00, 0xaf460e00, 0x8f420000,
3131 0x30420008, 0x1040fffd, 0x00000000, 0x97420e08, 0x8f450e04, 0x3044ffff,
3132 0x30820001, 0x14400005, 0x00000000, 0x14a00005, 0x3083a040, 0x0a000f34,
3133 0x00000000, 0x0000000d, 0x3083a040, 0x24020040, 0x1462004f, 0x3082a000,
3134 0x308a0036, 0x8f88000c, 0x30890008, 0x24020800, 0xaf420178, 0x01001821,
3135 0x9742008a, 0x00431023, 0x2442ffff, 0x30421fff, 0x2c420008, 0x1440fffa,
3136 0x00a06021, 0x8f820018, 0x00cc3023, 0x24070001, 0x8f830008, 0x304b00ff,
3137 0x24420001, 0xaf820018, 0x25024000, 0x106f0005, 0x03422021, 0x93820012,
3138 0x30420007, 0x00021240, 0x34470001, 0x000b1400, 0x3c030100, 0x00431025,
3139 0xac820000, 0x8f830018, 0x00ea3825, 0x1120000f, 0xac830004, 0x97430e0a,
3140 0x8f84000c, 0x00ee3825, 0x2402000e, 0x00781825, 0xaf430160, 0x25830006,
3141 0x24840008, 0x30841fff, 0xa742015a, 0xa7430158, 0xaf84000c, 0x0a000db7,
3142 0x00000000, 0x8f83000c, 0x25820002, 0xa7420158, 0x24630008, 0x30631fff,
3143 0xaf83000c, 0x54c0000f, 0x8f420e14, 0x8f820008, 0x504f0002, 0x24100001,
3144 0x34e70040, 0x97420e10, 0x97430e12, 0x8f850014, 0x00021400, 0x00621825,
3145 0xaca300a8, 0x8f840014, 0x8f420e18, 0xac8200ac, 0x8f420e14, 0x8f430e1c,
3146 0xaf420144, 0xaf430148, 0xa34b0152, 0xaf470154, 0x0a000efb, 0xaf4e0178,
3147 0x10400165, 0x00000000, 0x93620008, 0x50400008, 0xafa60008, 0x97620010,
3148 0x00a2102b, 0x10400003, 0x30820040, 0x1040015c, 0x00000000, 0xafa60008,
3149 0xa7840010, 0xaf850004, 0x93620008, 0x1440005f, 0x27ac0008, 0xaf60000c,
3150 0x97820010, 0x30424000, 0x10400002, 0x2403000e, 0x24030016, 0xa363000a,
3151 0x24034007, 0xaf630014, 0x93820012, 0x8f630014, 0x30420007, 0x00021240,
3152 0x00621825, 0xaf630014, 0x97820010, 0x8f630014, 0x30420010, 0x00621825,
3153 0xaf630014, 0x97820010, 0x30420008, 0x5040000e, 0x00002821, 0x8f620014,
3154 0x004e1025, 0xaf620014, 0x97430e0a, 0x2402000e, 0x00781825, 0xaf630004,
3155 0xa3620002, 0x9363000a, 0x3405fffc, 0x24630004, 0x0a000e06, 0xa363000a,
3156 0xaf600004, 0xa3600002, 0x97820010, 0x9363000a, 0x30421f00, 0x00021182,
3157 0x24420028, 0x00621821, 0xa3630009, 0x97420e0c, 0xa7620010, 0x93630009,
3158 0x24020008, 0x24630002, 0x30630007, 0x00431023, 0x30420007, 0xa362000b,
3159 0x93640009, 0x97620010, 0x8f890004, 0x97830010, 0x00441021, 0x00a21021,
3160 0x30630040, 0x10600007, 0x3045ffff, 0x00a9102b, 0x14400005, 0x0125102b,
3161 0x3c068000, 0x0a000e3a, 0x00005821, 0x0125102b, 0x544000c7, 0x00006021,
3162 0x97420e14, 0xa7420e10, 0x97430e16, 0xa7430e12, 0x8f420e1c, 0xaf420e18,
3163 0xaf450e00, 0x8f420000, 0x30420008, 0x1040fffd, 0x00000000, 0x97420e08,
3164 0x00a04821, 0xa7820010, 0x8f430e04, 0x00003021, 0x240b0001, 0xaf830004,
3165 0x97620010, 0x0a000e4c, 0x304dffff, 0x8f890004, 0x97820010, 0x30420040,
3166 0x10400004, 0x01206821, 0x3c068000, 0x0a000e4c, 0x00005821, 0x97630010,
3167 0x8f820004, 0x10430003, 0x00003021, 0x0a000eee, 0x00006021, 0x240b0001,
3168 0x8d820000, 0x00491023, 0x1440000d, 0xad820000, 0x8f620014, 0x34420040,
3169 0xaf620014, 0x97430e10, 0x97420e12, 0x8f840014, 0x00031c00, 0x00431025,
3170 0xac8200a8, 0x8f830014, 0x8f420e18, 0xac6200ac, 0x93620008, 0x1440003e,
3171 0x00000000, 0x25260002, 0x8f84000c, 0x9743008a, 0x3063ffff, 0xafa30000,
3172 0x8fa20000, 0x00441023, 0x2442ffff, 0x30421fff, 0x2c420010, 0x1440fff7,
3173 0x00000000, 0x8f82000c, 0x8f830018, 0x00021082, 0x00021080, 0x24424000,
3174 0x03422821, 0x00605021, 0x24630001, 0x314200ff, 0x00021400, 0xaf830018,
3175 0x3c033200, 0x00431025, 0xaca20000, 0x93630009, 0x9362000a, 0x00031c00,
3176 0x00431025, 0xaca20004, 0x8f830018, 0xaca30008, 0x97820010, 0x30420008,
3177 0x10400002, 0x00c04021, 0x25280006, 0x97430e14, 0x93640002, 0x8f450e1c,
3178 0x8f660004, 0x8f670014, 0x3063ffff, 0xa7430144, 0x97420e16, 0xa7420146,
3179 0xaf450148, 0xa34a0152, 0x8f82000c, 0x308400ff, 0xa744015a, 0xaf460160,
3180 0xa7480158, 0xaf470154, 0xaf4e0178, 0x00511021, 0x30421fff, 0xaf82000c,
3181 0x0a000ed9, 0x8d820000, 0x93620009, 0x9363000b, 0x8f85000c, 0x2463000a,
3182 0x00435021, 0x25440007, 0x00992024, 0x9743008a, 0x3063ffff, 0xafa30000,
3183 0x8fa20000, 0x00451023, 0x2442ffff, 0x30421fff, 0x0044102b, 0x1440fff7,
3184 0x00000000, 0x8f82000c, 0x8f840018, 0x00021082, 0x00021080, 0x24424000,
3185 0x03422821, 0x00804021, 0x24840001, 0xaf840018, 0x93630009, 0x310200ff,
3186 0x00022400, 0x3c024100, 0x24630002, 0x00621825, 0x00832025, 0xaca40000,
3187 0x8f62000c, 0x00461025, 0xaca20004, 0x97430e14, 0x93640002, 0x8f450e1c,
3188 0x8f660004, 0x8f670014, 0x3063ffff, 0xa7430144, 0x97420e16, 0x308400ff,
3189 0xa7420146, 0xaf450148, 0xa3480152, 0x8f83000c, 0x25420007, 0x00591024,
3190 0xa744015a, 0xaf460160, 0xa7490158, 0xaf470154, 0xaf4e0178, 0x00621821,
3191 0x30631fff, 0xaf83000c, 0x8d820000, 0x14400005, 0x00000000, 0x8f620014,
3192 0x2403ffbf, 0x00431024, 0xaf620014, 0x8f62000c, 0x004d1021, 0xaf62000c,
3193 0x93630008, 0x14600008, 0x00000000, 0x11600006, 0x00000000, 0x8f630014,
3194 0x3c02efff, 0x3442fffe, 0x00621824, 0xaf630014, 0xa36b0008, 0x01206021,
3195 0x1580000c, 0x8fa60008, 0x97420e14, 0x97430e16, 0x8f850014, 0x00021400,
3196 0x00621825, 0xaca300a8, 0x8f840014, 0x8f420e1c, 0xac8200ac, 0x0a000efd,
3197 0x2d820001, 0x14c0fe65, 0x2d820001, 0x00501025, 0x10400058, 0x24020f00,
3198 0x8f830008, 0x14620023, 0x3c048000, 0x11800009, 0x3c038000, 0x97420e08,
3199 0x30420040, 0x14400005, 0x00000000, 0x0000000d, 0x00000000, 0x2400032c,
3200 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x00000000, 0x97420e10,
3201 0x3c030500, 0x00431025, 0xaf42014c, 0x97430e14, 0xa7430144, 0x97420e16,
3202 0xa7420146, 0x8f430e1c, 0x24022000, 0xaf430148, 0x3c031000, 0xa3400152,
3203 0xa740015a, 0xaf400160, 0xa7400158, 0xaf420154, 0xaf430178, 0x8f830008,
3204 0x3c048000, 0x8f420178, 0x00441024, 0x1440fffd, 0x24020f00, 0x10620016,
3205 0x00000000, 0x97420e14, 0xa7420144, 0x97430e16, 0xa7430146, 0x8f420e1c,
3206 0x3c031000, 0xaf420148, 0x0a000f51, 0x24020240, 0x97420e14, 0x97430e16,
3207 0x8f840014, 0x00021400, 0x00621825, 0xac8300a8, 0x8f850014, 0x8f420e1c,
3208 0x00006021, 0xaca200ac, 0x0a000efd, 0x2d820001, 0xaf40014c, 0x11800007,
3209 0x00000000, 0x97420e10, 0xa7420144, 0x97430e12, 0xa7430146, 0x0a000f4e,
3210 0x8f420e18, 0x97420e14, 0xa7420144, 0x97430e16, 0xa7430146, 0x8f420e1c,
3211 0xaf420148, 0x24020040, 0x3c031000, 0xa3400152, 0xa740015a, 0xaf400160,
3212 0xa7400158, 0xaf420154, 0xaf430178, 0x8fb10014, 0x8fb00010, 0x03e00008,
3213 0x27bd0018, 0x27bdffd0, 0x3c1a8000, 0x3c0420ff, 0x3484fffd, 0x3c020008,
3214 0x03421821, 0xafbf002c, 0xafb60028, 0xafb50024, 0xafb40020, 0xafb3001c,
3215 0xafb20018, 0xafb10014, 0xafb00010, 0xaf830014, 0xaf440e00, 0x00000000,
3216 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3c0200ff, 0x3442fffd,
3217 0x3c046004, 0xaf420e00, 0x8c835000, 0x24160800, 0x24150d00, 0x3c140800,
3218 0x24130f00, 0x3c120800, 0x3c114000, 0x2402ff7f, 0x00621824, 0x3463380c,
3219 0x24020009, 0xac835000, 0xaf420008, 0xaf800018, 0xaf80000c, 0x0e001559,
3220 0x00000000, 0x0e000ff0, 0x00000000, 0x3c020800, 0x245057c0, 0x8f420000,
3221 0x30420001, 0x1040fffd, 0x00000000, 0x8f440100, 0xaf840008, 0xaf440020,
3222 0xaf560178, 0x93430108, 0xa3830012, 0x93820012, 0x30420001, 0x10400008,
3223 0x00000000, 0x93820012, 0x30420006, 0x00021100, 0x0e000d43, 0x0050d821,
3224 0x0a000fac, 0x00000000, 0x14950005, 0x00000000, 0x0e000d43, 0x269b5840,
3225 0x0a000fac, 0x00000000, 0x14930005, 0x00000000, 0x0e000d43, 0x265b5860,
3226 0x0a000fac, 0x00000000, 0x0e0010ea, 0x00000000, 0xaf510138, 0x0a000f89,
3227 0x00000000, 0x27bdfff8, 0x3084ffff, 0x24820007, 0x3044fff8, 0x8f85000c,
3228 0x9743008a, 0x3063ffff, 0xafa30000, 0x8fa20000, 0x00451023, 0x2442ffff,
3229 0x30421fff, 0x0044102b, 0x1440fff7, 0x00000000, 0x8f82000c, 0x00021082,
3230 0x00021080, 0x24424000, 0x03421021, 0x03e00008, 0x27bd0008, 0x3084ffff,
3231 0x8f82000c, 0x24840007, 0x3084fff8, 0x00441021, 0x30421fff, 0xaf82000c,
3232 0x03e00008, 0x00000000, 0x27bdffe8, 0x3c1a8000, 0x3c0420ff, 0x3484fffd,
3233 0x3c020008, 0x03421821, 0xafbf0010, 0xaf830014, 0xaf440e00, 0x00000000,
3234 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x3c0200ff, 0x3442fffd,
3235 0x3c046004, 0xaf420e00, 0x8c825000, 0x2403ff7f, 0x00431024, 0x3442380c,
3236 0x24030009, 0xac825000, 0xaf430008, 0xaf800018, 0xaf80000c, 0x0e001559,
3237 0x00000000, 0x0e000ff0, 0x00000000, 0x8fbf0010, 0x03e00008, 0x27bd0018,
3238 0x27bdffe8, 0x3c02000a, 0x03421821, 0x3c040800, 0x24845880, 0x24050019,
3239 0xafbf0010, 0xaf830024, 0x0e001565, 0x00003021, 0x3c050800, 0x3c020800,
3240 0x24425330, 0xaca258e8, 0x24a558e8, 0x3c020800, 0x244254f8, 0x3c030800,
3241 0x2463550c, 0x3c040800, 0xaca20004, 0x3c020800, 0x24425338, 0xaca30008,
3242 0xac825900, 0x24845900, 0x3c020800, 0x244253c4, 0x3c070800, 0x24e75404,
3243 0x3c060800, 0x24c65520, 0x3c050800, 0x24a55438, 0x3c030800, 0xac820004,
3244 0x3c020800, 0x24425528, 0xac870008, 0xac86000c, 0xac850010, 0xac625920,
3245 0x24635920, 0x8fbf0010, 0x3c020800, 0x24425540, 0xac620004, 0x3c020800,
3246 0xac670008, 0xac66000c, 0xac650010, 0xac400048, 0x03e00008, 0x27bd0018,
3247 0x974309da, 0x00804021, 0xad030000, 0x8f4209dc, 0xad020004, 0x8f4309e0,
3248 0xad030008, 0x934409d9, 0x24020001, 0x30840003, 0x1082001f, 0x30a900ff,
3249 0x28820002, 0x10400005, 0x24020002, 0x10800009, 0x3c0a0800, 0x0a001078,
3250 0x93420934, 0x1082000b, 0x24020003, 0x10820026, 0x3c0a0800, 0x0a001078,
3251 0x93420934, 0x974209e4, 0x00021400, 0x34420800, 0xad02000c, 0x0a001077,
3252 0x25080010, 0x974209e4, 0x00021400, 0x34428100, 0xad02000c, 0x974309e8,
3253 0x3c0a0800, 0x00031c00, 0x34630800, 0xad030010, 0x0a001077, 0x25080014,
3254 0x974409e4, 0x3c050800, 0x24a25880, 0x9443001c, 0x94460014, 0x94470010,
3255 0x00a05021, 0x24020800, 0xad000010, 0xad020014, 0x00042400, 0x00661821,
3256 0x00671823, 0x2463fff2, 0x00832025, 0xad04000c, 0x0a001077, 0x25080018,
3257 0x974209e4, 0x3c050800, 0x00021400, 0x34428100, 0xad02000c, 0x974409e8,
3258 0x24a25880, 0x9443001c, 0x94460014, 0x94470010, 0x00a05021, 0x24020800,
3259 0xad000014, 0xad020018, 0x00042400, 0x00661821, 0x00671823, 0x2463ffee,
3260 0x00832025, 0xad040010, 0x2508001c, 0x93420934, 0x93450921, 0x3c074000,
3261 0x25445880, 0x94830018, 0x94860014, 0x00021082, 0x00021600, 0x00052c00,
3262 0x00a72825, 0x00451025, 0x00661821, 0x00431025, 0xad020000, 0x9783002c,
3263 0x974209ea, 0x00621821, 0x00031c00, 0xad030004, 0x9782002c, 0x24420001,
3264 0x30427fff, 0xa782002c, 0x93430920, 0x3c020006, 0x00031e00, 0x00621825,
3265 0xad030008, 0x8f42092c, 0xad02000c, 0x8f430930, 0xad030010, 0x8f440938,
3266 0x25080014, 0xad040000, 0x8f820020, 0x11200004, 0xad020004, 0x8f420940,
3267 0x0a0010a1, 0x2442ffff, 0x8f420940, 0xad020008, 0x8f440948, 0x8f420940,
3268 0x93430936, 0x00823023, 0x00663006, 0x3402ffff, 0x0046102b, 0x54400001,
3269 0x3406ffff, 0x93420937, 0x25445880, 0x90830024, 0xad000010, 0x00021700,
3270 0x34630010, 0x00031c00, 0x00431025, 0x00461025, 0xad02000c, 0x8c830008,
3271 0x14600031, 0x25080014, 0x3c020800, 0x8c430048, 0x1060002d, 0x00000000,
3272 0x9342010b, 0xad020000, 0x8f830000, 0x8c6200b0, 0xad020004, 0x8f830000,
3273 0x8c6200b4, 0xad020008, 0x8f830000, 0x8c6200c0, 0xad02000c, 0x8f830000,
3274 0x8c6200c4, 0xad020010, 0x8f830000, 0x8c6200c8, 0xad020014, 0x8f830000,
3275 0x8c6200cc, 0xad020018, 0x8f830000, 0x8c6200e0, 0xad02001c, 0x8f830000,
3276 0x8c6200e8, 0xad020020, 0x8f830000, 0x8c6200f0, 0x3c04600e, 0xad020024,
3277 0x8c8200d0, 0xad020028, 0x8c8300d4, 0xad03002c, 0x8f820028, 0x3c046012,
3278 0xad020030, 0x8c8200a8, 0xad020034, 0x8c8300ac, 0x3c026000, 0xad030038,
3279 0x8c434448, 0xad03003c, 0x03e00008, 0x01001021, 0x27bdffa8, 0x3c020008,
3280 0x03423021, 0xafbf0054, 0xafbe0050, 0xafb7004c, 0xafb60048, 0xafb50044,
3281 0xafb40040, 0xafb3003c, 0xafb20038, 0xafb10034, 0xafb00030, 0xaf860000,
3282 0x24020040, 0xaf420814, 0xaf400810, 0x8f420944, 0x8f430950, 0x8f440954,
3283 0x8f45095c, 0xaf820034, 0xaf830020, 0xaf84001c, 0xaf850030, 0x90c20000,
3284 0x24030020, 0x304400ff, 0x10830005, 0x24020030, 0x10820022, 0x3c030800,
3285 0x0a001139, 0x8c62002c, 0x24020088, 0xaf420818, 0x3c020800, 0x244258e8,
3286 0xafa20020, 0x93430109, 0x3c020800, 0x10600009, 0x24575900, 0x3c026000,
3287 0x24030100, 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000,
3288 0x24000376, 0x9342010a, 0x30420080, 0x14400021, 0x24020800, 0x3c026000,
3289 0x24030100, 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000,
3290 0x2400037d, 0x0a001141, 0x24020800, 0x93430109, 0x3063007f, 0x00031140,
3291 0x000318c0, 0x00431021, 0x24430088, 0xaf430818, 0x0000000d, 0x3c020800,
3292 0x24425940, 0x3c030800, 0x24775950, 0x0a001140, 0xafa20020, 0x24420001,
3293 0xac62002c, 0x0000000d, 0x00000000, 0x24000395, 0x0a0014c1, 0x8fbf0054,
3294 0x24020800, 0xaf420178, 0x8f450104, 0x8f420988, 0x00a21023, 0x58400005,
3295 0x8f4309a0, 0x0000000d, 0x00000000, 0x240003b1, 0x8f4309a0, 0x3c100800,
3296 0xae0358b0, 0x8f4209a4, 0x8f830020, 0x260458b0, 0x2491ffd0, 0xae220034,
3297 0x00a21023, 0xae230028, 0xac82ffd0, 0x8fa30020, 0x8c620000, 0x0040f809,
3298 0x0200b021, 0x00409021, 0x32440010, 0x32420002, 0x10400007, 0xafa40024,
3299 0x8e220020, 0x32530040, 0x2403ffbf, 0x00431024, 0x0a001493, 0xae220020,
3300 0x32420020, 0x10400002, 0x3c020800, 0x24575920, 0x32420001, 0x14400007,
3301 0x00000000, 0x8f820008, 0xaf420080, 0x8ec358b0, 0xaf430e10, 0x8e220034,
3302 0xaf420e18, 0x9343010b, 0x93420905, 0x30420008, 0x1040003c, 0x307400ff,
3303 0x8f820000, 0x8c430074, 0x0460000a, 0x00000000, 0x3c026000, 0x24030100,
3304 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d, 0x00000000, 0x240003ed,
3305 0x8f820000, 0x9044007b, 0x9343010a, 0x14830027, 0x32530040, 0x00003821,
3306 0x24052000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd,
3307 0x8ec258b0, 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034, 0x3c030100,
3308 0xaf420148, 0x24020047, 0xaf43014c, 0xa3420152, 0x8d230030, 0x3c021000,
3309 0xa7470158, 0xaf450154, 0xaf420178, 0x8c860034, 0x24630001, 0xad230030,
3310 0x9342010a, 0x3c030047, 0xafa50014, 0x00021600, 0x00431025, 0x00471025,
3311 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b,
3312 0x3c070100, 0x3c050800, 0x24a25880, 0x0a001250, 0x8c430020, 0x32820002,
3313 0x10400050, 0x00000000, 0x0e0015b9, 0x32530040, 0x3c039000, 0x34630001,
3314 0x8f820008, 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020, 0x00441024,
3315 0x1440fffd, 0x00000000, 0x8f830000, 0x90620005, 0x34420008, 0xa0620005,
3316 0x8f840000, 0x8c820074, 0x3c038000, 0x00431025, 0xac820074, 0x90830000,
3317 0x24020020, 0x10620004, 0x00000000, 0x0000000d, 0x00000000, 0x2400040b,
3318 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 0x9084007b,
3319 0x9342010a, 0x14820028, 0x3c030800, 0x00003821, 0x24052000, 0x3c090800,
3320 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec258b0, 0x26c458b0,
3321 0x2484ffd0, 0xaf420144, 0x8c820034, 0x3c030100, 0xaf420148, 0x24020046,
3322 0xaf43014c, 0xa3420152, 0x8d230030, 0x3c021000, 0xa7470158, 0xaf450154,
3323 0xaf420178, 0x8c860034, 0x24630001, 0xad230030, 0x9342010a, 0x3c030046,
3324 0xafa50014, 0x00021600, 0x00431025, 0x00471025, 0xafa20010, 0x9343010b,
3325 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b, 0x3c070100, 0x3c030800,
3326 0x24625880, 0x0a001250, 0x8c430020, 0x93420108, 0x30420010, 0x50400056,
3327 0x9343093f, 0x8f860000, 0x90c2007f, 0x8cc30178, 0x304800ff, 0x15030004,
3328 0x00000000, 0x0000000d, 0x00000000, 0x24000425, 0x90c2007e, 0x90c40080,
3329 0x00081c00, 0x00021600, 0x00431025, 0x00042200, 0x90c3007a, 0x90c5000a,
3330 0x00441025, 0x11050028, 0x00623825, 0xa0c8000a, 0x00004021, 0x24056000,
3331 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec258b0,
3332 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034, 0xaf420148, 0x24020052,
3333 0xaf47014c, 0xa3420152, 0x8d230030, 0x3c021000, 0xa7480158, 0xaf450154,
3334 0xaf420178, 0x8c860034, 0x24630001, 0xad230030, 0x9342010a, 0x3c030052,
3335 0xafa50014, 0x00021600, 0x00431025, 0x00481025, 0xafa20010, 0x9343010b,
3336 0xafa30018, 0x8f440100, 0x0e00159b, 0x8f450104, 0x0a00124a, 0x00000000,
3337 0x3c026000, 0x24030100, 0xac43081c, 0x3c030001, 0xac43081c, 0x0000000d,
3338 0x00000000, 0x2400043e, 0x16800009, 0x3c050800, 0x3c040800, 0x24825880,
3339 0x8c430020, 0x32530040, 0x2404ffbf, 0x00641824, 0x0a001493, 0xac430020,
3340 0x8ca25880, 0x10400005, 0x3c030800, 0x8c620034, 0xaca05880, 0x24420001,
3341 0xac620034, 0x9343093f, 0x24020012, 0x5462000e, 0x97420908, 0x32820038,
3342 0x14400009, 0x3c030800, 0x8f830000, 0x8c62004c, 0xac62005c, 0x3c020800,
3343 0x24445880, 0x8c820020, 0x0a001285, 0x32530040, 0xac605880, 0x97420908,
3344 0x5440001c, 0x97420908, 0x3c039000, 0x34630001, 0x8f820008, 0x32530040,
3345 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020, 0x00441024, 0x1440fffd,
3346 0x3c028000, 0x8f840000, 0x8f850008, 0x8c830050, 0x34420001, 0x00a22825,
3347 0xaf830020, 0xac830070, 0xac83005c, 0xaf450020, 0x3c050800, 0x24a45880,
3348 0x8c820020, 0x2403ffbf, 0x00431024, 0x0a001493, 0xac820020, 0x000211c0,
3349 0xaf420024, 0x97420908, 0x3c030080, 0x34630003, 0x000211c0, 0xaf42080c,
3350 0xaf43081c, 0x974209ec, 0x8f4309a4, 0xa782002c, 0x3c020800, 0x24445880,
3351 0xac83002c, 0x93420937, 0x93430934, 0x00021080, 0x00621821, 0xa4830018,
3352 0x934209d8, 0x32850038, 0xafa50028, 0x00621821, 0xa483001a, 0x934209d8,
3353 0x93430934, 0x3c1e0800, 0x00809821, 0x00431021, 0x24420010, 0xa4820016,
3354 0x24020006, 0xae620020, 0x8fa20028, 0x10400003, 0x0000a821, 0x0a0012f0,
3355 0x24120008, 0x8f420958, 0x8f830020, 0x8f840030, 0x00431023, 0x00832023,
3356 0x04800003, 0xae620004, 0x04410003, 0x0082102b, 0x0a0012bc, 0xae600004,
3357 0x54400001, 0xae640004, 0x8ee20000, 0x0040f809, 0x00000000, 0x00409021,
3358 0x32420001, 0x5440001e, 0x8ee20004, 0x8e630008, 0x1060002b, 0x3c02c000,
3359 0x00621025, 0xaf420e00, 0x8f420000, 0x30420008, 0x1040fffd, 0x00000000,
3360 0x97420e08, 0xa7820010, 0x8f430e04, 0x8e620008, 0xaf830004, 0x8f840004,
3361 0x0044102b, 0x1040000b, 0x24150001, 0x24020100, 0x3c016000, 0xac22081c,
3362 0x3c020001, 0x3c016000, 0xac22081c, 0x0000000d, 0x00000000, 0x240004cd,
3363 0x24150001, 0x8ee20004, 0x0040f809, 0x00000000, 0x02429025, 0x32420002,
3364 0x5040001d, 0x8f470940, 0x12a00006, 0x8ec258b0, 0x8f830000, 0xac6200a8,
3365 0x8f840000, 0x8e620034, 0xac8200ac, 0x32420004, 0x50400013, 0x8f470940,
3366 0x3c020800, 0x3283007d, 0x10600110, 0x24575920, 0x32820001, 0x50400006,
3367 0x36520002, 0x8f830034, 0x8f420940, 0x10620109, 0x00000000, 0x36520002,
3368 0x24020008, 0xa6600010, 0xa6620012, 0xae600008, 0xa2600024, 0x8f470940,
3369 0x3c030800, 0x24685880, 0x8d02002c, 0x8d050008, 0x95040010, 0x9506000a,
3370 0x95030026, 0x00451021, 0x00862021, 0x00641821, 0xaf870034, 0xad02002c,
3371 0x32820030, 0x10400008, 0xa5030014, 0x91020024, 0x32910040, 0x34420004,
3372 0xa1020024, 0xaf400048, 0x0a001345, 0x3c040800, 0x93420923, 0x30420002,
3373 0x10400029, 0x32910040, 0x8f830000, 0x8f840020, 0x8c620084, 0x00441023,
3374 0x0442000a, 0x3c039000, 0x95020014, 0x8c630084, 0x00821021, 0x00621823,
3375 0x1c600004, 0x3c039000, 0x91020024, 0x34420001, 0xa1020024, 0x34630001,
3376 0x8f820008, 0x32910040, 0x3c048000, 0x00431025, 0xaf420020, 0x8f420020,
3377 0x00441024, 0x1440fffd, 0x00000000, 0x8f840000, 0x9083003f, 0x2402000a,
3378 0x10620005, 0x2402000c, 0x9083003f, 0x24020008, 0x14620002, 0x24020014,
3379 0xa082003f, 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020,
3380 0x3c040800, 0x24865880, 0x94c20010, 0x94c3001a, 0x8cc40008, 0x00432821,
3381 0x14800006, 0xa4c5001c, 0x3c020800, 0x8c430048, 0x10600002, 0x24a20040,
3382 0xa4c2001c, 0x27d05880, 0x9604001c, 0x96020012, 0x00822021, 0x24840002,
3383 0x0e000faf, 0x3084ffff, 0x8f850018, 0x00a01821, 0xa2030025, 0x8ee60008,
3384 0x00402021, 0x24a50001, 0xaf850018, 0x00c0f809, 0x00000000, 0x00402021,
3385 0x0e001026, 0x02202821, 0x8ee3000c, 0x0060f809, 0x00402021, 0x9604001c,
3386 0x96020012, 0x00822021, 0x24840002, 0x0e000fc5, 0x3084ffff, 0x8fc25880,
3387 0x8e030008, 0x00431023, 0x14400012, 0xafc25880, 0x54600006, 0x8e020020,
3388 0x3243004a, 0x24020002, 0x14620005, 0x00000000, 0x8e020020, 0x34420040,
3389 0x0a001382, 0xae020020, 0x52a00006, 0x36520002, 0x8e020030, 0xaf420e10,
3390 0x8e030034, 0xaf430e18, 0x36520002, 0x52a00008, 0x96670014, 0x8f830000,
3391 0x8f420e10, 0xac6200a8, 0x8f840000, 0x8f420e18, 0xac8200ac, 0x96670014,
3392 0x92680024, 0x24020040, 0xaf420814, 0x8f830020, 0x8f82001c, 0x00671821,
3393 0x00621023, 0xaf830020, 0x18400008, 0x00000000, 0x8f820000, 0xaf83001c,
3394 0xac430054, 0x54e00005, 0xaf400040, 0x0a0013a0, 0x8f42095c, 0x54e00001,
3395 0xaf400044, 0x8f42095c, 0x31030008, 0xaf820030, 0x1060001a, 0x00000000,
3396 0x8f840000, 0x90820120, 0x90830121, 0x304600ff, 0x00c31823, 0x30630007,
3397 0x24020007, 0x1062000e, 0x00000000, 0x90820122, 0x304200fe, 0xa0820122,
3398 0x8f850000, 0x00061880, 0x8f840020, 0x24a20100, 0x00431021, 0x24c30001,
3399 0x30630007, 0xac440000, 0x0a0013bd, 0xa0a30120, 0x90820122, 0x34420001,
3400 0xa0820122, 0x14e00003, 0x31020001, 0x10400031, 0x32510002, 0x8f820000,
3401 0x8c43000c, 0x30630001, 0x1060002c, 0x32510002, 0x3c029000, 0x8f830008,
3402 0x34420001, 0x3c048000, 0x00621825, 0xaf430020, 0x8f420020, 0x00441024,
3403 0x1440fffd, 0x00000000, 0x8f870000, 0x8ce2000c, 0x30420001, 0x10400018,
3404 0x00000000, 0x94e2006a, 0x00022880, 0x50a00001, 0x24050001, 0x94e30068,
3405 0x90e40081, 0x3c020800, 0x8c460024, 0x00652821, 0x00852804, 0x00c5102b,
3406 0x54400001, 0x00a03021, 0x3c020800, 0x8c440028, 0x00c4182b, 0x54600001,
3407 0x00c02021, 0x8f430074, 0x2402fffe, 0x00822824, 0x00a31821, 0xace3000c,
3408 0x8f830008, 0x3c028000, 0x34420001, 0x00621825, 0xaf430020, 0x8f820020,
3409 0x3c050800, 0x24b05880, 0xae020028, 0x8ee30010, 0x0060f809, 0x00000000,
3410 0x8f820028, 0x24420001, 0xaf820028, 0x12a00005, 0xaf40004c, 0x8f420e10,
3411 0xae020030, 0x8f430e18, 0xae030034, 0x1220fea7, 0x24020006, 0x8f870024,
3412 0x9786002c, 0x8f830000, 0x8f820034, 0x8f840020, 0x8f85001c, 0x32530040,
3413 0xa4e6002c, 0xac620044, 0x32420008, 0xac640050, 0xac650054, 0x1040007a,
3414 0x32820020, 0x10400027, 0x32910010, 0x00003821, 0x24052000, 0x3c090800,
3415 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd, 0x8ec258b0, 0x26c458b0,
3416 0x2484ffd0, 0xaf420144, 0x8c820034, 0x3c030400, 0xaf420148, 0x24020041,
3417 0xaf43014c, 0xa3420152, 0x8d230030, 0x3c021000, 0xa7470158, 0xaf450154,
3418 0xaf420178, 0x8c860034, 0x24630001, 0xad230030, 0x9342010a, 0x3c030041,
3419 0xafa50014, 0x00021600, 0x00431025, 0x00471025, 0xafa20010, 0x9343010b,
3420 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b, 0x3c070400, 0x12200028,
3421 0x00003821, 0x24052000, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024,
3422 0x1440fffd, 0x8ec258b0, 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034,
3423 0x3c030300, 0xaf420148, 0x2402004e, 0xaf43014c, 0xa3420152, 0x8d230030,
3424 0x3c021000, 0xa7470158, 0xaf450154, 0xaf420178, 0x8c860034, 0x24630001,
3425 0xad230030, 0x9342010a, 0x3c03004e, 0xafa50014, 0x00021600, 0x00431025,
3426 0x00471025, 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100, 0x8f450104,
3427 0x0e00159b, 0x3c070300, 0x0a00148b, 0x8fa20024, 0x32820008, 0x10400026,
3428 0x24052000, 0x00003821, 0x3c090800, 0x3c038000, 0x8f420178, 0x00431024,
3429 0x1440fffd, 0x8ec258b0, 0x26c458b0, 0x2484ffd0, 0xaf420144, 0x8c820034,
3430 0x3c030200, 0xaf420148, 0x2402004b, 0xaf43014c, 0xa3420152, 0x8d230030,
3431 0x3c021000, 0xa7470158, 0xaf450154, 0xaf420178, 0x8c860034, 0x24630001,
3432 0xad230030, 0x9342010a, 0x3c03004b, 0xafa50014, 0x00021600, 0x00431025,
3433 0x00471025, 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100, 0x8f450104,
3434 0x0e00159b, 0x3c070200, 0x8fa20024, 0x14400004, 0x8fa30020, 0x32420010,
3435 0x10400004, 0x00000000, 0x8c620004, 0x0040f809, 0x00000000, 0x12600006,
3436 0x8fa40020, 0x8c820008, 0x0040f809, 0x00000000, 0x0a0014c1, 0x8fbf0054,
3437 0x3c030800, 0x8c6258a0, 0x30420040, 0x14400023, 0x8fbf0054, 0x00002821,
3438 0x24040040, 0x8f870020, 0x3c038000, 0x8f420178, 0x00431024, 0x1440fffd,
3439 0x8ec258b0, 0x26c358b0, 0x2463ffd0, 0xaf420144, 0x8c620034, 0xaf420148,
3440 0x24020049, 0xaf47014c, 0xa3420152, 0x3c021000, 0xa7450158, 0xaf440154,
3441 0xaf420178, 0x8c660034, 0x9342010a, 0x3c030049, 0xafa40014, 0x00021600,
3442 0x00431025, 0x00451025, 0xafa20010, 0x9343010b, 0xafa30018, 0x8f440100,
3443 0x0e00159b, 0x8f450104, 0x8fbf0054, 0x8fbe0050, 0x8fb7004c, 0x8fb60048,
3444 0x8fb50044, 0x8fb40040, 0x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
3445 0x03e00008, 0x27bd0058, 0x03e00008, 0x00001021, 0x3c020800, 0x24435880,
3446 0x8c650004, 0x8c445880, 0x0085182b, 0x10600002, 0x00403021, 0x00802821,
3447 0x9744093c, 0x00a4102b, 0x54400001, 0x00a02021, 0x93420923, 0x0004182b,
3448 0x00021042, 0x30420001, 0x00431024, 0x1040000d, 0x24c25880, 0x8f850000,
3449 0x8f830020, 0x8ca20084, 0x00431023, 0x04420007, 0x24c25880, 0x8ca20084,
3450 0x00641821, 0x00431023, 0x28420001, 0x00822023, 0x24c25880, 0xac440008,
3451 0xa4400026, 0x03e00008, 0x00001021, 0x8f850004, 0x97840010, 0x3c030800,
3452 0x24635880, 0x24020008, 0xa4620012, 0x8f820004, 0xa4600010, 0x000420c2,
3453 0x30840008, 0x2c420001, 0x00021023, 0x30420006, 0xac650008, 0x03e00008,
3454 0xa0640024, 0x3c020800, 0x24425880, 0x90450025, 0x9443001c, 0x3c021100,
3455 0xac800004, 0x00052c00, 0x24630002, 0x00621825, 0x00a32825, 0x24820008,
3456 0x03e00008, 0xac850000, 0x27bdffd8, 0x3c020800, 0x24425880, 0xafbf0020,
3457 0x90480025, 0x8c440008, 0x8c460020, 0x8f870020, 0x3c030800, 0x3c058000,
3458 0x8f420178, 0x00451024, 0x1440fffd, 0x8c6258b0, 0x246358b0, 0x2469ffd0,
3459 0xaf420144, 0x8d220034, 0x30c32000, 0xaf420148, 0x3c021000, 0xaf47014c,
3460 0xa3480152, 0xa7440158, 0xaf460154, 0xaf420178, 0x10600004, 0x3c030800,
3461 0x8c620030, 0x24420001, 0xac620030, 0x9342010a, 0x00081c00, 0x3084ffff,
3462 0xafa60014, 0x00021600, 0x00431025, 0x00441025, 0xafa20010, 0x9343010b,
3463 0xafa30018, 0x8f440100, 0x8f450104, 0x0e00159b, 0x8d260034, 0x8fbf0020,
3464 0x03e00008, 0x27bd0028, 0x0000000d, 0x00000000, 0x2400019d, 0x03e00008,
3465 0x00000000, 0x0000000d, 0x00000000, 0x240001a9, 0x03e00008, 0x00000000,
3466 0x03e00008, 0x00000000, 0x3c020800, 0x24425880, 0xac400008, 0xa4400026,
3467 0x03e00008, 0x24020001, 0x3c020800, 0x24425880, 0x24030008, 0xac400008,
3468 0xa4400010, 0xa4430012, 0xa0400024, 0x03e00008, 0x24020004, 0x03e00008,
3469 0x00001021, 0x10c00007, 0x00000000, 0x8ca20000, 0x24c6ffff, 0x24a50004,
3470 0xac820000, 0x14c0fffb, 0x24840004, 0x03e00008, 0x00000000, 0x0a00156c,
3471 0x00a01021, 0xac860000, 0x00000000, 0x00000000, 0x24840004, 0x00a01021,
3472 0x1440fffa, 0x24a5ffff, 0x03e00008, 0x00000000, 0x3c0a0800, 0x8d490068,
3473 0x3c050800, 0x24a52098, 0x00093140, 0x00c51021, 0xac440000, 0x8f440e04,
3474 0x00a61021, 0xac440004, 0x97430e08, 0x97420e0c, 0x00a62021, 0x00031c00,
3475 0x00431025, 0xac820008, 0x8f430e10, 0x00801021, 0xac43000c, 0x8f440e14,
3476 0xac440010, 0x8f430e18, 0x3c0800ff, 0xac430014, 0x8f470e1c, 0x3508ffff,
3477 0x25290001, 0xac470018, 0x3c070800, 0x8ce3006c, 0x9344010a, 0x3c026000,
3478 0x24630001, 0xace3006c, 0x8c434448, 0x3129007f, 0x00a62821, 0xad490068,
3479 0x00042600, 0x00681824, 0x00832025, 0x03e00008, 0xaca4001c, 0x8fac0010,
3480 0x8fad0014, 0x8fae0018, 0x3c0b0800, 0x8d6a0060, 0x3c080800, 0x25080080,
3481 0x000a4940, 0x01281021, 0x01091821, 0xac440000, 0x00601021, 0xac650004,
3482 0xac460008, 0xac67000c, 0xac4c0010, 0xac6d0014, 0x3c036000, 0xac4e0018,
3483 0x8c654448, 0x3c040800, 0x8c820064, 0x254a0001, 0x314a00ff, 0x01094021,
3484 0xad6a0060, 0x24420001, 0xac820064, 0x03e00008, 0xad05001c, 0x3c030800,
3485 0x3c090800, 0x8d250070, 0x246330b0, 0x8f460100, 0x00053900, 0x00e31021,
3486 0xac460000, 0x8f440104, 0x00671021, 0xac440004, 0x8f460108, 0x8f840014,
3487 0x24a50001, 0xac460008, 0x8c880074, 0x3c060800, 0x8cc20074, 0x30a5003f,
3488 0x00671821, 0xad250070, 0x24420001, 0xacc20074, 0x03e00008, 0xac68000c,
3489 0x00000000 };
3490 1962
3491static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x0 }; 1963static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x0 };
3492static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 }; 1964static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 };
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 55d236726d11..8171cae06688 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1199,8 +1199,7 @@ int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev)
1199} 1199}
1200 1200
1201#define BOND_INTERSECT_FEATURES \ 1201#define BOND_INTERSECT_FEATURES \
1202 (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM|\ 1202 (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_TSO | NETIF_F_UFO)
1203 NETIF_F_TSO|NETIF_F_UFO)
1204 1203
1205/* 1204/*
1206 * Compute the common dev->feature set available to all slaves. Some 1205 * Compute the common dev->feature set available to all slaves. Some
@@ -1218,9 +1217,7 @@ static int bond_compute_features(struct bonding *bond)
1218 features &= (slave->dev->features & BOND_INTERSECT_FEATURES); 1217 features &= (slave->dev->features & BOND_INTERSECT_FEATURES);
1219 1218
1220 if ((features & NETIF_F_SG) && 1219 if ((features & NETIF_F_SG) &&
1221 !(features & (NETIF_F_IP_CSUM | 1220 !(features & NETIF_F_ALL_CSUM))
1222 NETIF_F_NO_CSUM |
1223 NETIF_F_HW_CSUM)))
1224 features &= ~NETIF_F_SG; 1221 features &= ~NETIF_F_SG;
1225 1222
1226 /* 1223 /*
@@ -4191,7 +4188,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4191 */ 4188 */
4192 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 4189 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
4193 4190
4194 /* don't acquire bond device's xmit_lock when 4191 /* don't acquire bond device's netif_tx_lock when
4195 * transmitting */ 4192 * transmitting */
4196 bond_dev->features |= NETIF_F_LLTX; 4193 bond_dev->features |= NETIF_F_LLTX;
4197 4194
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index ac48f7543500..39f36aa05aa8 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4877,7 +4877,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4877 const struct pci_device_id *ent) 4877 const struct pci_device_id *ent)
4878{ 4878{
4879 static int cas_version_printed = 0; 4879 static int cas_version_printed = 0;
4880 unsigned long casreg_base, casreg_len; 4880 unsigned long casreg_len;
4881 struct net_device *dev; 4881 struct net_device *dev;
4882 struct cas *cp; 4882 struct cas *cp;
4883 int i, err, pci_using_dac; 4883 int i, err, pci_using_dac;
@@ -4972,7 +4972,6 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4972 pci_using_dac = 0; 4972 pci_using_dac = 0;
4973 } 4973 }
4974 4974
4975 casreg_base = pci_resource_start(pdev, 0);
4976 casreg_len = pci_resource_len(pdev, 0); 4975 casreg_len = pci_resource_len(pdev, 0);
4977 4976
4978 cp = netdev_priv(dev); 4977 cp = netdev_priv(dev);
@@ -5024,7 +5023,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5024 cp->timer_ticks = 0; 5023 cp->timer_ticks = 0;
5025 5024
5026 /* give us access to cassini registers */ 5025 /* give us access to cassini registers */
5027 cp->regs = ioremap(casreg_base, casreg_len); 5026 cp->regs = pci_iomap(pdev, 0, casreg_len);
5028 if (cp->regs == 0UL) { 5027 if (cp->regs == 0UL) {
5029 printk(KERN_ERR PFX "Cannot map device registers, " 5028 printk(KERN_ERR PFX "Cannot map device registers, "
5030 "aborting.\n"); 5029 "aborting.\n");
@@ -5123,7 +5122,7 @@ err_out_iounmap:
5123 cas_shutdown(cp); 5122 cas_shutdown(cp);
5124 mutex_unlock(&cp->pm_mutex); 5123 mutex_unlock(&cp->pm_mutex);
5125 5124
5126 iounmap(cp->regs); 5125 pci_iounmap(pdev, cp->regs);
5127 5126
5128 5127
5129err_out_free_res: 5128err_out_free_res:
@@ -5171,7 +5170,7 @@ static void __devexit cas_remove_one(struct pci_dev *pdev)
5171#endif 5170#endif
5172 pci_free_consistent(pdev, sizeof(struct cas_init_block), 5171 pci_free_consistent(pdev, sizeof(struct cas_init_block),
5173 cp->init_block, cp->block_dvma); 5172 cp->init_block, cp->block_dvma);
5174 iounmap(cp->regs); 5173 pci_iounmap(pdev, cp->regs);
5175 free_netdev(dev); 5174 free_netdev(dev);
5176 pci_release_regions(pdev); 5175 pci_release_regions(pdev);
5177 pci_disable_device(pdev); 5176 pci_disable_device(pdev);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 31ac001f5517..f37170cc1a37 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2780,6 +2780,80 @@ static void e100_shutdown(struct pci_dev *pdev)
2780 DPRINTK(PROBE,ERR, "Error enabling wake\n"); 2780 DPRINTK(PROBE,ERR, "Error enabling wake\n");
2781} 2781}
2782 2782
2783/* ------------------ PCI Error Recovery infrastructure -------------- */
2784/**
2785 * e100_io_error_detected - called when PCI error is detected.
2786 * @pdev: Pointer to PCI device
2787 * @state: The current pci conneection state
2788 */
2789static pci_ers_result_t e100_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
2790{
2791 struct net_device *netdev = pci_get_drvdata(pdev);
2792
2793 /* Similar to calling e100_down(), but avoids adpater I/O. */
2794 netdev->stop(netdev);
2795
2796 /* Detach; put netif into state similar to hotplug unplug. */
2797 netif_poll_enable(netdev);
2798 netif_device_detach(netdev);
2799
2800 /* Request a slot reset. */
2801 return PCI_ERS_RESULT_NEED_RESET;
2802}
2803
2804/**
2805 * e100_io_slot_reset - called after the pci bus has been reset.
2806 * @pdev: Pointer to PCI device
2807 *
2808 * Restart the card from scratch.
2809 */
2810static pci_ers_result_t e100_io_slot_reset(struct pci_dev *pdev)
2811{
2812 struct net_device *netdev = pci_get_drvdata(pdev);
2813 struct nic *nic = netdev_priv(netdev);
2814
2815 if (pci_enable_device(pdev)) {
2816 printk(KERN_ERR "e100: Cannot re-enable PCI device after reset.\n");
2817 return PCI_ERS_RESULT_DISCONNECT;
2818 }
2819 pci_set_master(pdev);
2820
2821 /* Only one device per card can do a reset */
2822 if (0 != PCI_FUNC(pdev->devfn))
2823 return PCI_ERS_RESULT_RECOVERED;
2824 e100_hw_reset(nic);
2825 e100_phy_init(nic);
2826
2827 return PCI_ERS_RESULT_RECOVERED;
2828}
2829
2830/**
2831 * e100_io_resume - resume normal operations
2832 * @pdev: Pointer to PCI device
2833 *
2834 * Resume normal operations after an error recovery
2835 * sequence has been completed.
2836 */
2837static void e100_io_resume(struct pci_dev *pdev)
2838{
2839 struct net_device *netdev = pci_get_drvdata(pdev);
2840 struct nic *nic = netdev_priv(netdev);
2841
2842 /* ack any pending wake events, disable PME */
2843 pci_enable_wake(pdev, 0, 0);
2844
2845 netif_device_attach(netdev);
2846 if (netif_running(netdev)) {
2847 e100_open(netdev);
2848 mod_timer(&nic->watchdog, jiffies);
2849 }
2850}
2851
2852static struct pci_error_handlers e100_err_handler = {
2853 .error_detected = e100_io_error_detected,
2854 .slot_reset = e100_io_slot_reset,
2855 .resume = e100_io_resume,
2856};
2783 2857
2784static struct pci_driver e100_driver = { 2858static struct pci_driver e100_driver = {
2785 .name = DRV_NAME, 2859 .name = DRV_NAME,
@@ -2791,6 +2865,7 @@ static struct pci_driver e100_driver = {
2791 .resume = e100_resume, 2865 .resume = e100_resume,
2792#endif 2866#endif
2793 .shutdown = e100_shutdown, 2867 .shutdown = e100_shutdown,
2868 .err_handler = &e100_err_handler,
2794}; 2869};
2795 2870
2796static int __init e100_init_module(void) 2871static int __init e100_init_module(void)
diff --git a/drivers/net/e1000/Makefile b/drivers/net/e1000/Makefile
index ca9f89552da3..5dea2b7dea4d 100644
--- a/drivers/net/e1000/Makefile
+++ b/drivers/net/e1000/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# 3#
4# Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved. 4# Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by the Free 7# under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22# 22#
23# Contact Information: 23# Contact Information:
24# Linux NICS <linux.nics@intel.com> 24# Linux NICS <linux.nics@intel.com>
25# e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25# Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26# Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26# 27#
27################################################################################ 28################################################################################
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 281de41d030a..2bc34fbfa69c 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
@@ -114,6 +115,8 @@ struct e1000_adapter;
114/* Supported Rx Buffer Sizes */ 115/* Supported Rx Buffer Sizes */
115#define E1000_RXBUFFER_128 128 /* Used for packet split */ 116#define E1000_RXBUFFER_128 128 /* Used for packet split */
116#define E1000_RXBUFFER_256 256 /* Used for packet split */ 117#define E1000_RXBUFFER_256 256 /* Used for packet split */
118#define E1000_RXBUFFER_512 512
119#define E1000_RXBUFFER_1024 1024
117#define E1000_RXBUFFER_2048 2048 120#define E1000_RXBUFFER_2048 2048
118#define E1000_RXBUFFER_4096 4096 121#define E1000_RXBUFFER_4096 4096
119#define E1000_RXBUFFER_8192 8192 122#define E1000_RXBUFFER_8192 8192
@@ -334,7 +337,6 @@ struct e1000_adapter {
334 boolean_t have_msi; 337 boolean_t have_msi;
335#endif 338#endif
336 /* to not mess up cache alignment, always add to the bottom */ 339 /* to not mess up cache alignment, always add to the bottom */
337 boolean_t txb2b;
338#ifdef NETIF_F_TSO 340#ifdef NETIF_F_TSO
339 boolean_t tso_force; 341 boolean_t tso_force;
340#endif 342#endif
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index d1c705b412c2..6ed7f599eba3 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
@@ -864,8 +865,8 @@ static int
864e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data) 865e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
865{ 866{
866 struct net_device *netdev = adapter->netdev; 867 struct net_device *netdev = adapter->netdev;
867 uint32_t mask, i=0, shared_int = TRUE; 868 uint32_t mask, i=0, shared_int = TRUE;
868 uint32_t irq = adapter->pdev->irq; 869 uint32_t irq = adapter->pdev->irq;
869 870
870 *data = 0; 871 *data = 0;
871 872
@@ -891,22 +892,22 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
891 /* Interrupt to test */ 892 /* Interrupt to test */
892 mask = 1 << i; 893 mask = 1 << i;
893 894
894 if (!shared_int) { 895 if (!shared_int) {
895 /* Disable the interrupt to be reported in 896 /* Disable the interrupt to be reported in
896 * the cause register and then force the same 897 * the cause register and then force the same
897 * interrupt and see if one gets posted. If 898 * interrupt and see if one gets posted. If
898 * an interrupt was posted to the bus, the 899 * an interrupt was posted to the bus, the
899 * test failed. 900 * test failed.
900 */ 901 */
901 adapter->test_icr = 0; 902 adapter->test_icr = 0;
902 E1000_WRITE_REG(&adapter->hw, IMC, mask); 903 E1000_WRITE_REG(&adapter->hw, IMC, mask);
903 E1000_WRITE_REG(&adapter->hw, ICS, mask); 904 E1000_WRITE_REG(&adapter->hw, ICS, mask);
904 msec_delay(10); 905 msec_delay(10);
905 906
906 if (adapter->test_icr & mask) { 907 if (adapter->test_icr & mask) {
907 *data = 3; 908 *data = 3;
908 break; 909 break;
909 } 910 }
910 } 911 }
911 912
912 /* Enable the interrupt to be reported in 913 /* Enable the interrupt to be reported in
@@ -925,7 +926,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
925 break; 926 break;
926 } 927 }
927 928
928 if (!shared_int) { 929 if (!shared_int) {
929 /* Disable the other interrupts to be reported in 930 /* Disable the other interrupts to be reported in
930 * the cause register and then force the other 931 * the cause register and then force the other
931 * interrupts and see if any get posted. If 932 * interrupts and see if any get posted. If
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 523c2c9fc0ac..3959039b16ec 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
@@ -764,7 +765,7 @@ e1000_init_hw(struct e1000_hw *hw)
764 } 765 }
765 766
766 if (hw->mac_type == e1000_82573) { 767 if (hw->mac_type == e1000_82573) {
767 e1000_enable_tx_pkt_filtering(hw); 768 e1000_enable_tx_pkt_filtering(hw);
768 } 769 }
769 770
770 switch (hw->mac_type) { 771 switch (hw->mac_type) {
@@ -860,7 +861,7 @@ e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
860 861
861 if(eeprom_data != EEPROM_RESERVED_WORD) { 862 if(eeprom_data != EEPROM_RESERVED_WORD) {
862 /* Adjust SERDES output amplitude only. */ 863 /* Adjust SERDES output amplitude only. */
863 eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK; 864 eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
864 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL, eeprom_data); 865 ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL, eeprom_data);
865 if(ret_val) 866 if(ret_val)
866 return ret_val; 867 return ret_val;
@@ -1227,7 +1228,7 @@ e1000_copper_link_igp_setup(struct e1000_hw *hw)
1227 1228
1228 if (hw->phy_reset_disable) 1229 if (hw->phy_reset_disable)
1229 return E1000_SUCCESS; 1230 return E1000_SUCCESS;
1230 1231
1231 ret_val = e1000_phy_reset(hw); 1232 ret_val = e1000_phy_reset(hw);
1232 if (ret_val) { 1233 if (ret_val) {
1233 DEBUGOUT("Error Resetting the PHY\n"); 1234 DEBUGOUT("Error Resetting the PHY\n");
@@ -1369,7 +1370,7 @@ e1000_copper_link_ggp_setup(struct e1000_hw *hw)
1369 DEBUGFUNC("e1000_copper_link_ggp_setup"); 1370 DEBUGFUNC("e1000_copper_link_ggp_setup");
1370 1371
1371 if(!hw->phy_reset_disable) { 1372 if(!hw->phy_reset_disable) {
1372 1373
1373 /* Enable CRS on TX for half-duplex operation. */ 1374 /* Enable CRS on TX for half-duplex operation. */
1374 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, 1375 ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
1375 &phy_data); 1376 &phy_data);
@@ -1518,7 +1519,7 @@ e1000_copper_link_mgp_setup(struct e1000_hw *hw)
1518 1519
1519 if(hw->phy_reset_disable) 1520 if(hw->phy_reset_disable)
1520 return E1000_SUCCESS; 1521 return E1000_SUCCESS;
1521 1522
1522 /* Enable CRS on TX. This must be set for half-duplex operation. */ 1523 /* Enable CRS on TX. This must be set for half-duplex operation. */
1523 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); 1524 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
1524 if(ret_val) 1525 if(ret_val)
@@ -1664,7 +1665,7 @@ e1000_copper_link_autoneg(struct e1000_hw *hw)
1664* collision distance in the Transmit Control Register. 1665* collision distance in the Transmit Control Register.
1665* 2) Set up flow control on the MAC to that established with 1666* 2) Set up flow control on the MAC to that established with
1666* the link partner. 1667* the link partner.
1667* 3) Config DSP to improve Gigabit link quality for some PHY revisions. 1668* 3) Config DSP to improve Gigabit link quality for some PHY revisions.
1668* 1669*
1669* hw - Struct containing variables accessed by shared code 1670* hw - Struct containing variables accessed by shared code
1670******************************************************************************/ 1671******************************************************************************/
@@ -1673,7 +1674,7 @@ e1000_copper_link_postconfig(struct e1000_hw *hw)
1673{ 1674{
1674 int32_t ret_val; 1675 int32_t ret_val;
1675 DEBUGFUNC("e1000_copper_link_postconfig"); 1676 DEBUGFUNC("e1000_copper_link_postconfig");
1676 1677
1677 if(hw->mac_type >= e1000_82544) { 1678 if(hw->mac_type >= e1000_82544) {
1678 e1000_config_collision_dist(hw); 1679 e1000_config_collision_dist(hw);
1679 } else { 1680 } else {
@@ -1697,7 +1698,7 @@ e1000_copper_link_postconfig(struct e1000_hw *hw)
1697 return ret_val; 1698 return ret_val;
1698 } 1699 }
1699 } 1700 }
1700 1701
1701 return E1000_SUCCESS; 1702 return E1000_SUCCESS;
1702} 1703}
1703 1704
@@ -1753,11 +1754,11 @@ e1000_setup_copper_link(struct e1000_hw *hw)
1753 } 1754 }
1754 1755
1755 if(hw->autoneg) { 1756 if(hw->autoneg) {
1756 /* Setup autoneg and flow control advertisement 1757 /* Setup autoneg and flow control advertisement
1757 * and perform autonegotiation */ 1758 * and perform autonegotiation */
1758 ret_val = e1000_copper_link_autoneg(hw); 1759 ret_val = e1000_copper_link_autoneg(hw);
1759 if(ret_val) 1760 if(ret_val)
1760 return ret_val; 1761 return ret_val;
1761 } else { 1762 } else {
1762 /* PHY will be set to 10H, 10F, 100H,or 100F 1763 /* PHY will be set to 10H, 10F, 100H,or 100F
1763 * depending on value from forced_speed_duplex. */ 1764 * depending on value from forced_speed_duplex. */
@@ -1785,7 +1786,7 @@ e1000_setup_copper_link(struct e1000_hw *hw)
1785 ret_val = e1000_copper_link_postconfig(hw); 1786 ret_val = e1000_copper_link_postconfig(hw);
1786 if(ret_val) 1787 if(ret_val)
1787 return ret_val; 1788 return ret_val;
1788 1789
1789 DEBUGOUT("Valid link established!!!\n"); 1790 DEBUGOUT("Valid link established!!!\n");
1790 return E1000_SUCCESS; 1791 return E1000_SUCCESS;
1791 } 1792 }
@@ -1983,7 +1984,7 @@ e1000_phy_setup_autoneg(struct e1000_hw *hw)
1983 1984
1984 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); 1985 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
1985 1986
1986 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); 1987 ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
1987 if(ret_val) 1988 if(ret_val)
1988 return ret_val; 1989 return ret_val;
1989 1990
@@ -2272,7 +2273,7 @@ e1000_config_mac_to_phy(struct e1000_hw *hw)
2272 2273
2273 DEBUGFUNC("e1000_config_mac_to_phy"); 2274 DEBUGFUNC("e1000_config_mac_to_phy");
2274 2275
2275 /* 82544 or newer MAC, Auto Speed Detection takes care of 2276 /* 82544 or newer MAC, Auto Speed Detection takes care of
2276 * MAC speed/duplex configuration.*/ 2277 * MAC speed/duplex configuration.*/
2277 if (hw->mac_type >= e1000_82544) 2278 if (hw->mac_type >= e1000_82544)
2278 return E1000_SUCCESS; 2279 return E1000_SUCCESS;
@@ -2291,9 +2292,9 @@ e1000_config_mac_to_phy(struct e1000_hw *hw)
2291 if(ret_val) 2292 if(ret_val)
2292 return ret_val; 2293 return ret_val;
2293 2294
2294 if(phy_data & M88E1000_PSSR_DPLX) 2295 if(phy_data & M88E1000_PSSR_DPLX)
2295 ctrl |= E1000_CTRL_FD; 2296 ctrl |= E1000_CTRL_FD;
2296 else 2297 else
2297 ctrl &= ~E1000_CTRL_FD; 2298 ctrl &= ~E1000_CTRL_FD;
2298 2299
2299 e1000_config_collision_dist(hw); 2300 e1000_config_collision_dist(hw);
@@ -2492,10 +2493,10 @@ e1000_config_fc_after_link_up(struct e1000_hw *hw)
2492 */ 2493 */
2493 if(hw->original_fc == e1000_fc_full) { 2494 if(hw->original_fc == e1000_fc_full) {
2494 hw->fc = e1000_fc_full; 2495 hw->fc = e1000_fc_full;
2495 DEBUGOUT("Flow Control = FULL.\r\n"); 2496 DEBUGOUT("Flow Control = FULL.\n");
2496 } else { 2497 } else {
2497 hw->fc = e1000_fc_rx_pause; 2498 hw->fc = e1000_fc_rx_pause;
2498 DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n"); 2499 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2499 } 2500 }
2500 } 2501 }
2501 /* For receiving PAUSE frames ONLY. 2502 /* For receiving PAUSE frames ONLY.
@@ -2511,7 +2512,7 @@ e1000_config_fc_after_link_up(struct e1000_hw *hw)
2511 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && 2512 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
2512 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { 2513 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
2513 hw->fc = e1000_fc_tx_pause; 2514 hw->fc = e1000_fc_tx_pause;
2514 DEBUGOUT("Flow Control = TX PAUSE frames only.\r\n"); 2515 DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
2515 } 2516 }
2516 /* For transmitting PAUSE frames ONLY. 2517 /* For transmitting PAUSE frames ONLY.
2517 * 2518 *
@@ -2526,7 +2527,7 @@ e1000_config_fc_after_link_up(struct e1000_hw *hw)
2526 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && 2527 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
2527 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { 2528 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
2528 hw->fc = e1000_fc_rx_pause; 2529 hw->fc = e1000_fc_rx_pause;
2529 DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n"); 2530 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2530 } 2531 }
2531 /* Per the IEEE spec, at this point flow control should be 2532 /* Per the IEEE spec, at this point flow control should be
2532 * disabled. However, we want to consider that we could 2533 * disabled. However, we want to consider that we could
@@ -2552,10 +2553,10 @@ e1000_config_fc_after_link_up(struct e1000_hw *hw)
2552 hw->original_fc == e1000_fc_tx_pause) || 2553 hw->original_fc == e1000_fc_tx_pause) ||
2553 hw->fc_strict_ieee) { 2554 hw->fc_strict_ieee) {
2554 hw->fc = e1000_fc_none; 2555 hw->fc = e1000_fc_none;
2555 DEBUGOUT("Flow Control = NONE.\r\n"); 2556 DEBUGOUT("Flow Control = NONE.\n");
2556 } else { 2557 } else {
2557 hw->fc = e1000_fc_rx_pause; 2558 hw->fc = e1000_fc_rx_pause;
2558 DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n"); 2559 DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
2559 } 2560 }
2560 2561
2561 /* Now we need to do one last check... If we auto- 2562 /* Now we need to do one last check... If we auto-
@@ -2580,7 +2581,7 @@ e1000_config_fc_after_link_up(struct e1000_hw *hw)
2580 return ret_val; 2581 return ret_val;
2581 } 2582 }
2582 } else { 2583 } else {
2583 DEBUGOUT("Copper PHY and Auto Neg has not completed.\r\n"); 2584 DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
2584 } 2585 }
2585 } 2586 }
2586 return E1000_SUCCESS; 2587 return E1000_SUCCESS;
@@ -2763,7 +2764,7 @@ e1000_check_for_link(struct e1000_hw *hw)
2763 hw->autoneg_failed = 1; 2764 hw->autoneg_failed = 1;
2764 return 0; 2765 return 0;
2765 } 2766 }
2766 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n"); 2767 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
2767 2768
2768 /* Disable auto-negotiation in the TXCW register */ 2769 /* Disable auto-negotiation in the TXCW register */
2769 E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE)); 2770 E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
@@ -2788,7 +2789,7 @@ e1000_check_for_link(struct e1000_hw *hw)
2788 else if(((hw->media_type == e1000_media_type_fiber) || 2789 else if(((hw->media_type == e1000_media_type_fiber) ||
2789 (hw->media_type == e1000_media_type_internal_serdes)) && 2790 (hw->media_type == e1000_media_type_internal_serdes)) &&
2790 (ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) { 2791 (ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
2791 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\r\n"); 2792 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
2792 E1000_WRITE_REG(hw, TXCW, hw->txcw); 2793 E1000_WRITE_REG(hw, TXCW, hw->txcw);
2793 E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU)); 2794 E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
2794 2795
@@ -2851,13 +2852,13 @@ e1000_get_speed_and_duplex(struct e1000_hw *hw,
2851 2852
2852 if(status & E1000_STATUS_FD) { 2853 if(status & E1000_STATUS_FD) {
2853 *duplex = FULL_DUPLEX; 2854 *duplex = FULL_DUPLEX;
2854 DEBUGOUT("Full Duplex\r\n"); 2855 DEBUGOUT("Full Duplex\n");
2855 } else { 2856 } else {
2856 *duplex = HALF_DUPLEX; 2857 *duplex = HALF_DUPLEX;
2857 DEBUGOUT(" Half Duplex\r\n"); 2858 DEBUGOUT(" Half Duplex\n");
2858 } 2859 }
2859 } else { 2860 } else {
2860 DEBUGOUT("1000 Mbs, Full Duplex\r\n"); 2861 DEBUGOUT("1000 Mbs, Full Duplex\n");
2861 *speed = SPEED_1000; 2862 *speed = SPEED_1000;
2862 *duplex = FULL_DUPLEX; 2863 *duplex = FULL_DUPLEX;
2863 } 2864 }
@@ -2883,7 +2884,7 @@ e1000_get_speed_and_duplex(struct e1000_hw *hw,
2883 } 2884 }
2884 } 2885 }
2885 2886
2886 if ((hw->mac_type == e1000_80003es2lan) && 2887 if ((hw->mac_type == e1000_80003es2lan) &&
2887 (hw->media_type == e1000_media_type_copper)) { 2888 (hw->media_type == e1000_media_type_copper)) {
2888 if (*speed == SPEED_1000) 2889 if (*speed == SPEED_1000)
2889 ret_val = e1000_configure_kmrn_for_1000(hw); 2890 ret_val = e1000_configure_kmrn_for_1000(hw);
@@ -3159,7 +3160,7 @@ e1000_read_phy_reg(struct e1000_hw *hw,
3159 if (e1000_swfw_sync_acquire(hw, swfw)) 3160 if (e1000_swfw_sync_acquire(hw, swfw))
3160 return -E1000_ERR_SWFW_SYNC; 3161 return -E1000_ERR_SWFW_SYNC;
3161 3162
3162 if((hw->phy_type == e1000_phy_igp || 3163 if((hw->phy_type == e1000_phy_igp ||
3163 hw->phy_type == e1000_phy_igp_2) && 3164 hw->phy_type == e1000_phy_igp_2) &&
3164 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) { 3165 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
3165 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, 3166 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
@@ -3298,7 +3299,7 @@ e1000_write_phy_reg(struct e1000_hw *hw,
3298 if (e1000_swfw_sync_acquire(hw, swfw)) 3299 if (e1000_swfw_sync_acquire(hw, swfw))
3299 return -E1000_ERR_SWFW_SYNC; 3300 return -E1000_ERR_SWFW_SYNC;
3300 3301
3301 if((hw->phy_type == e1000_phy_igp || 3302 if((hw->phy_type == e1000_phy_igp ||
3302 hw->phy_type == e1000_phy_igp_2) && 3303 hw->phy_type == e1000_phy_igp_2) &&
3303 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) { 3304 (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
3304 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT, 3305 ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
@@ -3496,22 +3497,22 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
3496 } 3497 }
3497 /* Read the device control register and assert the E1000_CTRL_PHY_RST 3498 /* Read the device control register and assert the E1000_CTRL_PHY_RST
3498 * bit. Then, take it out of reset. 3499 * bit. Then, take it out of reset.
3499 * For pre-e1000_82571 hardware, we delay for 10ms between the assert 3500 * For pre-e1000_82571 hardware, we delay for 10ms between the assert
3500 * and deassert. For e1000_82571 hardware and later, we instead delay 3501 * and deassert. For e1000_82571 hardware and later, we instead delay
3501 * for 50us between and 10ms after the deassertion. 3502 * for 50us between and 10ms after the deassertion.
3502 */ 3503 */
3503 ctrl = E1000_READ_REG(hw, CTRL); 3504 ctrl = E1000_READ_REG(hw, CTRL);
3504 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST); 3505 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
3505 E1000_WRITE_FLUSH(hw); 3506 E1000_WRITE_FLUSH(hw);
3506 3507
3507 if (hw->mac_type < e1000_82571) 3508 if (hw->mac_type < e1000_82571)
3508 msec_delay(10); 3509 msec_delay(10);
3509 else 3510 else
3510 udelay(100); 3511 udelay(100);
3511 3512
3512 E1000_WRITE_REG(hw, CTRL, ctrl); 3513 E1000_WRITE_REG(hw, CTRL, ctrl);
3513 E1000_WRITE_FLUSH(hw); 3514 E1000_WRITE_FLUSH(hw);
3514 3515
3515 if (hw->mac_type >= e1000_82571) 3516 if (hw->mac_type >= e1000_82571)
3516 msec_delay(10); 3517 msec_delay(10);
3517 e1000_swfw_sync_release(hw, swfw); 3518 e1000_swfw_sync_release(hw, swfw);
@@ -3815,7 +3816,7 @@ e1000_phy_m88_get_info(struct e1000_hw *hw,
3815 /* Check polarity status */ 3816 /* Check polarity status */
3816 ret_val = e1000_check_polarity(hw, &polarity); 3817 ret_val = e1000_check_polarity(hw, &polarity);
3817 if(ret_val) 3818 if(ret_val)
3818 return ret_val; 3819 return ret_val;
3819 phy_info->cable_polarity = polarity; 3820 phy_info->cable_polarity = polarity;
3820 3821
3821 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); 3822 ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
@@ -4540,14 +4541,14 @@ e1000_read_eeprom_eerd(struct e1000_hw *hw,
4540 4541
4541 E1000_WRITE_REG(hw, EERD, eerd); 4542 E1000_WRITE_REG(hw, EERD, eerd);
4542 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_READ); 4543 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_READ);
4543 4544
4544 if(error) { 4545 if(error) {
4545 break; 4546 break;
4546 } 4547 }
4547 data[i] = (E1000_READ_REG(hw, EERD) >> E1000_EEPROM_RW_REG_DATA); 4548 data[i] = (E1000_READ_REG(hw, EERD) >> E1000_EEPROM_RW_REG_DATA);
4548 4549
4549 } 4550 }
4550 4551
4551 return error; 4552 return error;
4552} 4553}
4553 4554
@@ -4573,24 +4574,24 @@ e1000_write_eeprom_eewr(struct e1000_hw *hw,
4573 return -E1000_ERR_SWFW_SYNC; 4574 return -E1000_ERR_SWFW_SYNC;
4574 4575
4575 for (i = 0; i < words; i++) { 4576 for (i = 0; i < words; i++) {
4576 register_value = (data[i] << E1000_EEPROM_RW_REG_DATA) | 4577 register_value = (data[i] << E1000_EEPROM_RW_REG_DATA) |
4577 ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) | 4578 ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) |
4578 E1000_EEPROM_RW_REG_START; 4579 E1000_EEPROM_RW_REG_START;
4579 4580
4580 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE); 4581 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
4581 if(error) { 4582 if(error) {
4582 break; 4583 break;
4583 } 4584 }
4584 4585
4585 E1000_WRITE_REG(hw, EEWR, register_value); 4586 E1000_WRITE_REG(hw, EEWR, register_value);
4586 4587
4587 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE); 4588 error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
4588 4589
4589 if(error) { 4590 if(error) {
4590 break; 4591 break;
4591 } 4592 }
4592 } 4593 }
4593 4594
4594 e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM); 4595 e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
4595 return error; 4596 return error;
4596} 4597}
@@ -4610,7 +4611,7 @@ e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd)
4610 for(i = 0; i < attempts; i++) { 4611 for(i = 0; i < attempts; i++) {
4611 if(eerd == E1000_EEPROM_POLL_READ) 4612 if(eerd == E1000_EEPROM_POLL_READ)
4612 reg = E1000_READ_REG(hw, EERD); 4613 reg = E1000_READ_REG(hw, EERD);
4613 else 4614 else
4614 reg = E1000_READ_REG(hw, EEWR); 4615 reg = E1000_READ_REG(hw, EEWR);
4615 4616
4616 if(reg & E1000_EEPROM_RW_REG_DONE) { 4617 if(reg & E1000_EEPROM_RW_REG_DONE) {
@@ -5135,7 +5136,7 @@ e1000_mc_addr_list_update(struct e1000_hw *hw,
5135 uint32_t i; 5136 uint32_t i;
5136 uint32_t num_rar_entry; 5137 uint32_t num_rar_entry;
5137 uint32_t num_mta_entry; 5138 uint32_t num_mta_entry;
5138 5139
5139 DEBUGFUNC("e1000_mc_addr_list_update"); 5140 DEBUGFUNC("e1000_mc_addr_list_update");
5140 5141
5141 /* Set the new number of MC addresses that we are being requested to use. */ 5142 /* Set the new number of MC addresses that we are being requested to use. */
@@ -6240,7 +6241,7 @@ e1000_check_polarity(struct e1000_hw *hw,
6240 * 1 - Downshift ocured. 6241 * 1 - Downshift ocured.
6241 * 6242 *
6242 * returns: - E1000_ERR_XXX 6243 * returns: - E1000_ERR_XXX
6243 * E1000_SUCCESS 6244 * E1000_SUCCESS
6244 * 6245 *
6245 * For phy's older then IGP, this function reads the Downshift bit in the Phy 6246 * For phy's older then IGP, this function reads the Downshift bit in the Phy
6246 * Specific Status register. For IGP phy's, it reads the Downgrade bit in the 6247 * Specific Status register. For IGP phy's, it reads the Downgrade bit in the
@@ -6255,7 +6256,7 @@ e1000_check_downshift(struct e1000_hw *hw)
6255 6256
6256 DEBUGFUNC("e1000_check_downshift"); 6257 DEBUGFUNC("e1000_check_downshift");
6257 6258
6258 if(hw->phy_type == e1000_phy_igp || 6259 if(hw->phy_type == e1000_phy_igp ||
6259 hw->phy_type == e1000_phy_igp_2) { 6260 hw->phy_type == e1000_phy_igp_2) {
6260 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH, 6261 ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH,
6261 &phy_data); 6262 &phy_data);
@@ -6684,8 +6685,8 @@ e1000_set_d0_lplu_state(struct e1000_hw *hw,
6684 6685
6685 6686
6686 } else { 6687 } else {
6687 6688
6688 phy_data |= IGP02E1000_PM_D0_LPLU; 6689 phy_data |= IGP02E1000_PM_D0_LPLU;
6689 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data); 6690 ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
6690 if (ret_val) 6691 if (ret_val)
6691 return ret_val; 6692 return ret_val;
@@ -6777,7 +6778,7 @@ int32_t
6777e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer) 6778e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer)
6778{ 6779{
6779 uint8_t i; 6780 uint8_t i;
6780 uint32_t offset = E1000_MNG_DHCP_COOKIE_OFFSET; 6781 uint32_t offset = E1000_MNG_DHCP_COOKIE_OFFSET;
6781 uint8_t length = E1000_MNG_DHCP_COOKIE_LENGTH; 6782 uint8_t length = E1000_MNG_DHCP_COOKIE_LENGTH;
6782 6783
6783 length = (length >> 2); 6784 length = (length >> 2);
@@ -6796,7 +6797,7 @@ e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer)
6796 * and also checks whether the previous command is completed. 6797 * and also checks whether the previous command is completed.
6797 * It busy waits in case of previous command is not completed. 6798 * It busy waits in case of previous command is not completed.
6798 * 6799 *
6799 * returns: - E1000_ERR_HOST_INTERFACE_COMMAND in case if is not ready or 6800 * returns: - E1000_ERR_HOST_INTERFACE_COMMAND in case if is not ready or
6800 * timeout 6801 * timeout
6801 * - E1000_SUCCESS for success. 6802 * - E1000_SUCCESS for success.
6802 ****************************************************************************/ 6803 ****************************************************************************/
@@ -6820,7 +6821,7 @@ e1000_mng_enable_host_if(struct e1000_hw * hw)
6820 msec_delay_irq(1); 6821 msec_delay_irq(1);
6821 } 6822 }
6822 6823
6823 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) { 6824 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
6824 DEBUGOUT("Previous command timeout failed .\n"); 6825 DEBUGOUT("Previous command timeout failed .\n");
6825 return -E1000_ERR_HOST_INTERFACE_COMMAND; 6826 return -E1000_ERR_HOST_INTERFACE_COMMAND;
6826 } 6827 }
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 150e45e30f87..467c9ed944f8 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
@@ -374,7 +375,7 @@ struct e1000_host_mng_dhcp_cookie{
374}; 375};
375#endif 376#endif
376 377
377int32_t e1000_mng_write_dhcp_info(struct e1000_hw *hw, uint8_t *buffer, 378int32_t e1000_mng_write_dhcp_info(struct e1000_hw *hw, uint8_t *buffer,
378 uint16_t length); 379 uint16_t length);
379boolean_t e1000_check_mng_mode(struct e1000_hw *hw); 380boolean_t e1000_check_mng_mode(struct e1000_hw *hw);
380boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw); 381boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
@@ -1801,7 +1802,7 @@ struct e1000_hw {
1801 * value2 = [0..64512], default=4096 1802 * value2 = [0..64512], default=4096
1802 * value3 = [0..64512], default=0 1803 * value3 = [0..64512], default=0
1803 */ 1804 */
1804 1805
1805#define E1000_PSRCTL_BSIZE0_MASK 0x0000007F 1806#define E1000_PSRCTL_BSIZE0_MASK 0x0000007F
1806#define E1000_PSRCTL_BSIZE1_MASK 0x00003F00 1807#define E1000_PSRCTL_BSIZE1_MASK 0x00003F00
1807#define E1000_PSRCTL_BSIZE2_MASK 0x003F0000 1808#define E1000_PSRCTL_BSIZE2_MASK 0x003F0000
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 97e71a4fe8eb..a373ccb308d8 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,51 +22,13 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
28 29
29#include "e1000.h" 30#include "e1000.h"
30 31
31/* Change Log
32 * 7.0.33 3-Feb-2006
33 * o Added another fix for the pass false carrier bit
34 * 7.0.32 24-Jan-2006
35 * o Need to rebuild with noew version number for the pass false carrier
36 * fix in e1000_hw.c
37 * 7.0.30 18-Jan-2006
38 * o fixup for tso workaround to disable it for pci-x
39 * o fix mem leak on 82542
40 * o fixes for 10 Mb/s connections and incorrect stats
41 * 7.0.28 01/06/2006
42 * o hardware workaround to only set "speed mode" bit for 1G link.
43 * 7.0.26 12/23/2005
44 * o wake on lan support modified for device ID 10B5
45 * o fix dhcp + vlan issue not making it to the iAMT firmware
46 * 7.0.24 12/9/2005
47 * o New hardware support for the Gigabit NIC embedded in the south bridge
48 * o Fixes to the recycling logic (skb->tail) from IBM LTC
49 * 6.3.9 12/16/2005
50 * o incorporate fix for recycled skbs from IBM LTC
51 * 6.3.7 11/18/2005
52 * o Honor eeprom setting for enabling/disabling Wake On Lan
53 * 6.3.5 11/17/2005
54 * o Fix memory leak in rx ring handling for PCI Express adapters
55 * 6.3.4 11/8/05
56 * o Patch from Jesper Juhl to remove redundant NULL checks for kfree
57 * 6.3.2 9/20/05
58 * o Render logic that sets/resets DRV_LOAD as inline functions to
59 * avoid code replication. If f/w is AMT then set DRV_LOAD only when
60 * network interface is open.
61 * o Handle DRV_LOAD set/reset in cases where AMT uses VLANs.
62 * o Adjust PBA partioning for Jumbo frames using MTU size and not
63 * rx_buffer_len
64 * 6.3.1 9/19/05
65 * o Use adapter->tx_timeout_factor in Tx Hung Detect logic
66 * (e1000_clean_tx_irq)
67 * o Support for 8086:10B5 device (Quad Port)
68 */
69
70char e1000_driver_name[] = "e1000"; 32char e1000_driver_name[] = "e1000";
71static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
72#ifndef CONFIG_E1000_NAPI 34#ifndef CONFIG_E1000_NAPI
@@ -74,9 +36,9 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
74#else 36#else
75#define DRIVERNAPI "-NAPI" 37#define DRIVERNAPI "-NAPI"
76#endif 38#endif
77#define DRV_VERSION "7.0.33-k2"DRIVERNAPI 39#define DRV_VERSION "7.0.38-k4"DRIVERNAPI
78char e1000_driver_version[] = DRV_VERSION; 40char e1000_driver_version[] = DRV_VERSION;
79static char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 41static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
80 42
81/* e1000_pci_tbl - PCI Device ID Table 43/* e1000_pci_tbl - PCI Device ID Table
82 * 44 *
@@ -208,8 +170,8 @@ static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
208static void e1000_tx_timeout(struct net_device *dev); 170static void e1000_tx_timeout(struct net_device *dev);
209static void e1000_reset_task(struct net_device *dev); 171static void e1000_reset_task(struct net_device *dev);
210static void e1000_smartspeed(struct e1000_adapter *adapter); 172static void e1000_smartspeed(struct e1000_adapter *adapter);
211static inline int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, 173static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
212 struct sk_buff *skb); 174 struct sk_buff *skb);
213 175
214static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp); 176static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
215static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); 177static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
@@ -227,6 +189,16 @@ static void e1000_shutdown(struct pci_dev *pdev);
227static void e1000_netpoll (struct net_device *netdev); 189static void e1000_netpoll (struct net_device *netdev);
228#endif 190#endif
229 191
192static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
193 pci_channel_state_t state);
194static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
195static void e1000_io_resume(struct pci_dev *pdev);
196
197static struct pci_error_handlers e1000_err_handler = {
198 .error_detected = e1000_io_error_detected,
199 .slot_reset = e1000_io_slot_reset,
200 .resume = e1000_io_resume,
201};
230 202
231static struct pci_driver e1000_driver = { 203static struct pci_driver e1000_driver = {
232 .name = e1000_driver_name, 204 .name = e1000_driver_name,
@@ -238,7 +210,8 @@ static struct pci_driver e1000_driver = {
238 .suspend = e1000_suspend, 210 .suspend = e1000_suspend,
239 .resume = e1000_resume, 211 .resume = e1000_resume,
240#endif 212#endif
241 .shutdown = e1000_shutdown 213 .shutdown = e1000_shutdown,
214 .err_handler = &e1000_err_handler
242}; 215};
243 216
244MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 217MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
@@ -293,7 +266,7 @@ module_exit(e1000_exit_module);
293 * @adapter: board private structure 266 * @adapter: board private structure
294 **/ 267 **/
295 268
296static inline void 269static void
297e1000_irq_disable(struct e1000_adapter *adapter) 270e1000_irq_disable(struct e1000_adapter *adapter)
298{ 271{
299 atomic_inc(&adapter->irq_sem); 272 atomic_inc(&adapter->irq_sem);
@@ -307,7 +280,7 @@ e1000_irq_disable(struct e1000_adapter *adapter)
307 * @adapter: board private structure 280 * @adapter: board private structure
308 **/ 281 **/
309 282
310static inline void 283static void
311e1000_irq_enable(struct e1000_adapter *adapter) 284e1000_irq_enable(struct e1000_adapter *adapter)
312{ 285{
313 if (likely(atomic_dec_and_test(&adapter->irq_sem))) { 286 if (likely(atomic_dec_and_test(&adapter->irq_sem))) {
@@ -348,10 +321,10 @@ e1000_update_mng_vlan(struct e1000_adapter *adapter)
348 * For ASF and Pass Through versions of f/w this means that the 321 * For ASF and Pass Through versions of f/w this means that the
349 * driver is no longer loaded. For AMT version (only with 82573) i 322 * driver is no longer loaded. For AMT version (only with 82573) i
350 * of the f/w this means that the netowrk i/f is closed. 323 * of the f/w this means that the netowrk i/f is closed.
351 * 324 *
352 **/ 325 **/
353 326
354static inline void 327static void
355e1000_release_hw_control(struct e1000_adapter *adapter) 328e1000_release_hw_control(struct e1000_adapter *adapter)
356{ 329{
357 uint32_t ctrl_ext; 330 uint32_t ctrl_ext;
@@ -361,6 +334,7 @@ e1000_release_hw_control(struct e1000_adapter *adapter)
361 switch (adapter->hw.mac_type) { 334 switch (adapter->hw.mac_type) {
362 case e1000_82571: 335 case e1000_82571:
363 case e1000_82572: 336 case e1000_82572:
337 case e1000_80003es2lan:
364 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT); 338 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
365 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, 339 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
366 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD); 340 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
@@ -379,13 +353,13 @@ e1000_release_hw_control(struct e1000_adapter *adapter)
379 * @adapter: address of board private structure 353 * @adapter: address of board private structure
380 * 354 *
381 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit. 355 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
382 * For ASF and Pass Through versions of f/w this means that 356 * For ASF and Pass Through versions of f/w this means that
383 * the driver is loaded. For AMT version (only with 82573) 357 * the driver is loaded. For AMT version (only with 82573)
384 * of the f/w this means that the netowrk i/f is open. 358 * of the f/w this means that the netowrk i/f is open.
385 * 359 *
386 **/ 360 **/
387 361
388static inline void 362static void
389e1000_get_hw_control(struct e1000_adapter *adapter) 363e1000_get_hw_control(struct e1000_adapter *adapter)
390{ 364{
391 uint32_t ctrl_ext; 365 uint32_t ctrl_ext;
@@ -394,6 +368,7 @@ e1000_get_hw_control(struct e1000_adapter *adapter)
394 switch (adapter->hw.mac_type) { 368 switch (adapter->hw.mac_type) {
395 case e1000_82571: 369 case e1000_82571:
396 case e1000_82572: 370 case e1000_82572:
371 case e1000_80003es2lan:
397 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT); 372 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
398 E1000_WRITE_REG(&adapter->hw, CTRL_EXT, 373 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
399 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD); 374 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
@@ -421,7 +396,7 @@ e1000_up(struct e1000_adapter *adapter)
421 uint16_t mii_reg; 396 uint16_t mii_reg;
422 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg); 397 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
423 if (mii_reg & MII_CR_POWER_DOWN) 398 if (mii_reg & MII_CR_POWER_DOWN)
424 e1000_phy_reset(&adapter->hw); 399 e1000_phy_hw_reset(&adapter->hw);
425 } 400 }
426 401
427 e1000_set_multi(netdev); 402 e1000_set_multi(netdev);
@@ -711,8 +686,8 @@ e1000_probe(struct pci_dev *pdev,
711 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n"); 686 DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
712 687
713 /* if ksp3, indicate if it's port a being setup */ 688 /* if ksp3, indicate if it's port a being setup */
714 if (pdev->device == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3 && 689 if (pdev->device == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3 &&
715 e1000_ksp3_port_a == 0) 690 e1000_ksp3_port_a == 0)
716 adapter->ksp3_port_a = 1; 691 adapter->ksp3_port_a = 1;
717 e1000_ksp3_port_a++; 692 e1000_ksp3_port_a++;
718 /* Reset for multiple KP3 adapters */ 693 /* Reset for multiple KP3 adapters */
@@ -740,9 +715,9 @@ e1000_probe(struct pci_dev *pdev,
740 if (pci_using_dac) 715 if (pci_using_dac)
741 netdev->features |= NETIF_F_HIGHDMA; 716 netdev->features |= NETIF_F_HIGHDMA;
742 717
743 /* hard_start_xmit is safe against parallel locking */ 718 /* hard_start_xmit is safe against parallel locking */
744 netdev->features |= NETIF_F_LLTX; 719 netdev->features |= NETIF_F_LLTX;
745 720
746 adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw); 721 adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
747 722
748 /* before reading the EEPROM, reset the controller to 723 /* before reading the EEPROM, reset the controller to
@@ -972,8 +947,8 @@ e1000_sw_init(struct e1000_adapter *adapter)
972 947
973 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); 948 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
974 949
975 adapter->rx_buffer_len = E1000_RXBUFFER_2048; 950 adapter->rx_buffer_len = MAXIMUM_ETHERNET_FRAME_SIZE;
976 adapter->rx_ps_bsize0 = E1000_RXBUFFER_256; 951 adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;
977 hw->max_frame_size = netdev->mtu + 952 hw->max_frame_size = netdev->mtu +
978 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 953 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
979 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; 954 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
@@ -1181,7 +1156,7 @@ e1000_close(struct net_device *netdev)
1181 * @start: address of beginning of memory 1156 * @start: address of beginning of memory
1182 * @len: length of memory 1157 * @len: length of memory
1183 **/ 1158 **/
1184static inline boolean_t 1159static boolean_t
1185e1000_check_64k_bound(struct e1000_adapter *adapter, 1160e1000_check_64k_bound(struct e1000_adapter *adapter,
1186 void *start, unsigned long len) 1161 void *start, unsigned long len)
1187{ 1162{
@@ -1599,14 +1574,21 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1599 rctl |= E1000_RCTL_LPE; 1574 rctl |= E1000_RCTL_LPE;
1600 1575
1601 /* Setup buffer sizes */ 1576 /* Setup buffer sizes */
1602 if (adapter->hw.mac_type >= e1000_82571) { 1577 rctl &= ~E1000_RCTL_SZ_4096;
1603 /* We can now specify buffers in 1K increments. 1578 rctl |= E1000_RCTL_BSEX;
1604 * BSIZE and BSEX are ignored in this case. */ 1579 switch (adapter->rx_buffer_len) {
1605 rctl |= adapter->rx_buffer_len << 0x11; 1580 case E1000_RXBUFFER_256:
1606 } else { 1581 rctl |= E1000_RCTL_SZ_256;
1607 rctl &= ~E1000_RCTL_SZ_4096; 1582 rctl &= ~E1000_RCTL_BSEX;
1608 rctl |= E1000_RCTL_BSEX; 1583 break;
1609 switch (adapter->rx_buffer_len) { 1584 case E1000_RXBUFFER_512:
1585 rctl |= E1000_RCTL_SZ_512;
1586 rctl &= ~E1000_RCTL_BSEX;
1587 break;
1588 case E1000_RXBUFFER_1024:
1589 rctl |= E1000_RCTL_SZ_1024;
1590 rctl &= ~E1000_RCTL_BSEX;
1591 break;
1610 case E1000_RXBUFFER_2048: 1592 case E1000_RXBUFFER_2048:
1611 default: 1593 default:
1612 rctl |= E1000_RCTL_SZ_2048; 1594 rctl |= E1000_RCTL_SZ_2048;
@@ -1621,7 +1603,6 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1621 case E1000_RXBUFFER_16384: 1603 case E1000_RXBUFFER_16384:
1622 rctl |= E1000_RCTL_SZ_16384; 1604 rctl |= E1000_RCTL_SZ_16384;
1623 break; 1605 break;
1624 }
1625 } 1606 }
1626 1607
1627#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT 1608#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
@@ -1715,7 +1696,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1715 if (hw->mac_type >= e1000_82571) { 1696 if (hw->mac_type >= e1000_82571) {
1716 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); 1697 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
1717 /* Reset delay timers after every interrupt */ 1698 /* Reset delay timers after every interrupt */
1718 ctrl_ext |= E1000_CTRL_EXT_CANC; 1699 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
1719#ifdef CONFIG_E1000_NAPI 1700#ifdef CONFIG_E1000_NAPI
1720 /* Auto-Mask interrupts upon ICR read. */ 1701 /* Auto-Mask interrupts upon ICR read. */
1721 ctrl_ext |= E1000_CTRL_EXT_IAME; 1702 ctrl_ext |= E1000_CTRL_EXT_IAME;
@@ -1807,7 +1788,7 @@ e1000_free_all_tx_resources(struct e1000_adapter *adapter)
1807 e1000_free_tx_resources(adapter, &adapter->tx_ring[i]); 1788 e1000_free_tx_resources(adapter, &adapter->tx_ring[i]);
1808} 1789}
1809 1790
1810static inline void 1791static void
1811e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter, 1792e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
1812 struct e1000_buffer *buffer_info) 1793 struct e1000_buffer *buffer_info)
1813{ 1794{
@@ -2247,6 +2228,7 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
2247 2228
2248 if (link) { 2229 if (link) {
2249 if (!netif_carrier_ok(netdev)) { 2230 if (!netif_carrier_ok(netdev)) {
2231 boolean_t txb2b = 1;
2250 e1000_get_speed_and_duplex(&adapter->hw, 2232 e1000_get_speed_and_duplex(&adapter->hw,
2251 &adapter->link_speed, 2233 &adapter->link_speed,
2252 &adapter->link_duplex); 2234 &adapter->link_duplex);
@@ -2260,23 +2242,22 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
2260 * and adjust the timeout factor */ 2242 * and adjust the timeout factor */
2261 netdev->tx_queue_len = adapter->tx_queue_len; 2243 netdev->tx_queue_len = adapter->tx_queue_len;
2262 adapter->tx_timeout_factor = 1; 2244 adapter->tx_timeout_factor = 1;
2263 adapter->txb2b = 1;
2264 switch (adapter->link_speed) { 2245 switch (adapter->link_speed) {
2265 case SPEED_10: 2246 case SPEED_10:
2266 adapter->txb2b = 0; 2247 txb2b = 0;
2267 netdev->tx_queue_len = 10; 2248 netdev->tx_queue_len = 10;
2268 adapter->tx_timeout_factor = 8; 2249 adapter->tx_timeout_factor = 8;
2269 break; 2250 break;
2270 case SPEED_100: 2251 case SPEED_100:
2271 adapter->txb2b = 0; 2252 txb2b = 0;
2272 netdev->tx_queue_len = 100; 2253 netdev->tx_queue_len = 100;
2273 /* maybe add some timeout factor ? */ 2254 /* maybe add some timeout factor ? */
2274 break; 2255 break;
2275 } 2256 }
2276 2257
2277 if ((adapter->hw.mac_type == e1000_82571 || 2258 if ((adapter->hw.mac_type == e1000_82571 ||
2278 adapter->hw.mac_type == e1000_82572) && 2259 adapter->hw.mac_type == e1000_82572) &&
2279 adapter->txb2b == 0) { 2260 txb2b == 0) {
2280#define SPEED_MODE_BIT (1 << 21) 2261#define SPEED_MODE_BIT (1 << 21)
2281 uint32_t tarc0; 2262 uint32_t tarc0;
2282 tarc0 = E1000_READ_REG(&adapter->hw, TARC0); 2263 tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
@@ -2400,7 +2381,7 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
2400#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 2381#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
2401#define E1000_TX_FLAGS_VLAN_SHIFT 16 2382#define E1000_TX_FLAGS_VLAN_SHIFT 16
2402 2383
2403static inline int 2384static int
2404e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, 2385e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2405 struct sk_buff *skb) 2386 struct sk_buff *skb)
2406{ 2387{
@@ -2422,7 +2403,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2422 2403
2423 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 2404 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
2424 mss = skb_shinfo(skb)->tso_size; 2405 mss = skb_shinfo(skb)->tso_size;
2425 if (skb->protocol == ntohs(ETH_P_IP)) { 2406 if (skb->protocol == htons(ETH_P_IP)) {
2426 skb->nh.iph->tot_len = 0; 2407 skb->nh.iph->tot_len = 0;
2427 skb->nh.iph->check = 0; 2408 skb->nh.iph->check = 0;
2428 skb->h.th->check = 2409 skb->h.th->check =
@@ -2480,7 +2461,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2480 return FALSE; 2461 return FALSE;
2481} 2462}
2482 2463
2483static inline boolean_t 2464static boolean_t
2484e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, 2465e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2485 struct sk_buff *skb) 2466 struct sk_buff *skb)
2486{ 2467{
@@ -2516,7 +2497,7 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2516#define E1000_MAX_TXD_PWR 12 2497#define E1000_MAX_TXD_PWR 12
2517#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR) 2498#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
2518 2499
2519static inline int 2500static int
2520e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, 2501e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2521 struct sk_buff *skb, unsigned int first, unsigned int max_per_txd, 2502 struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
2522 unsigned int nr_frags, unsigned int mss) 2503 unsigned int nr_frags, unsigned int mss)
@@ -2625,7 +2606,7 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2625 return count; 2606 return count;
2626} 2607}
2627 2608
2628static inline void 2609static void
2629e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, 2610e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2630 int tx_flags, int count) 2611 int tx_flags, int count)
2631{ 2612{
@@ -2689,7 +2670,7 @@ e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2689#define E1000_FIFO_HDR 0x10 2670#define E1000_FIFO_HDR 0x10
2690#define E1000_82547_PAD_LEN 0x3E0 2671#define E1000_82547_PAD_LEN 0x3E0
2691 2672
2692static inline int 2673static int
2693e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb) 2674e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb)
2694{ 2675{
2695 uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head; 2676 uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
@@ -2716,7 +2697,7 @@ no_fifo_stall_required:
2716} 2697}
2717 2698
2718#define MINIMUM_DHCP_PACKET_SIZE 282 2699#define MINIMUM_DHCP_PACKET_SIZE 282
2719static inline int 2700static int
2720e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb) 2701e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2721{ 2702{
2722 struct e1000_hw *hw = &adapter->hw; 2703 struct e1000_hw *hw = &adapter->hw;
@@ -2764,7 +2745,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2764 unsigned int nr_frags = 0; 2745 unsigned int nr_frags = 0;
2765 unsigned int mss = 0; 2746 unsigned int mss = 0;
2766 int count = 0; 2747 int count = 0;
2767 int tso; 2748 int tso;
2768 unsigned int f; 2749 unsigned int f;
2769 len -= skb->data_len; 2750 len -= skb->data_len;
2770 2751
@@ -2777,7 +2758,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2777 2758
2778#ifdef NETIF_F_TSO 2759#ifdef NETIF_F_TSO
2779 mss = skb_shinfo(skb)->tso_size; 2760 mss = skb_shinfo(skb)->tso_size;
2780 /* The controller does a simple calculation to 2761 /* The controller does a simple calculation to
2781 * make sure there is enough room in the FIFO before 2762 * make sure there is enough room in the FIFO before
2782 * initiating the DMA for each buffer. The calc is: 2763 * initiating the DMA for each buffer. The calc is:
2783 * 4 = ceil(buffer len/mss). To make sure we don't 2764 * 4 = ceil(buffer len/mss). To make sure we don't
@@ -2800,7 +2781,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2800 case e1000_82573: 2781 case e1000_82573:
2801 pull_size = min((unsigned int)4, skb->data_len); 2782 pull_size = min((unsigned int)4, skb->data_len);
2802 if (!__pskb_pull_tail(skb, pull_size)) { 2783 if (!__pskb_pull_tail(skb, pull_size)) {
2803 printk(KERN_ERR 2784 printk(KERN_ERR
2804 "__pskb_pull_tail failed.\n"); 2785 "__pskb_pull_tail failed.\n");
2805 dev_kfree_skb_any(skb); 2786 dev_kfree_skb_any(skb);
2806 return NETDEV_TX_OK; 2787 return NETDEV_TX_OK;
@@ -2901,7 +2882,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2901 /* Old method was to assume IPv4 packet by default if TSO was enabled. 2882 /* Old method was to assume IPv4 packet by default if TSO was enabled.
2902 * 82571 hardware supports TSO capabilities for IPv6 as well... 2883 * 82571 hardware supports TSO capabilities for IPv6 as well...
2903 * no longer assume, we must. */ 2884 * no longer assume, we must. */
2904 if (likely(skb->protocol == ntohs(ETH_P_IP))) 2885 if (likely(skb->protocol == htons(ETH_P_IP)))
2905 tx_flags |= E1000_TX_FLAGS_IPV4; 2886 tx_flags |= E1000_TX_FLAGS_IPV4;
2906 2887
2907 e1000_tx_queue(adapter, tx_ring, tx_flags, 2888 e1000_tx_queue(adapter, tx_ring, tx_flags,
@@ -2982,8 +2963,7 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
2982 2963
2983 /* Adapter-specific max frame size limits. */ 2964 /* Adapter-specific max frame size limits. */
2984 switch (adapter->hw.mac_type) { 2965 switch (adapter->hw.mac_type) {
2985 case e1000_82542_rev2_0: 2966 case e1000_undefined ... e1000_82542_rev2_1:
2986 case e1000_82542_rev2_1:
2987 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 2967 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
2988 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n"); 2968 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
2989 return -EINVAL; 2969 return -EINVAL;
@@ -3017,27 +2997,32 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
3017 break; 2997 break;
3018 } 2998 }
3019 2999
3020 3000 /* NOTE: dev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
3021 if (adapter->hw.mac_type > e1000_82547_rev_2) { 3001 * means we reserve 2 more, this pushes us to allocate from the next
3022 adapter->rx_buffer_len = max_frame; 3002 * larger slab size
3023 E1000_ROUNDUP(adapter->rx_buffer_len, 1024); 3003 * i.e. RXBUFFER_2048 --> size-4096 slab */
3024 } else { 3004
3025 if(unlikely((adapter->hw.mac_type < e1000_82543) && 3005 if (max_frame <= E1000_RXBUFFER_256)
3026 (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE))) { 3006 adapter->rx_buffer_len = E1000_RXBUFFER_256;
3027 DPRINTK(PROBE, ERR, "Jumbo Frames not supported " 3007 else if (max_frame <= E1000_RXBUFFER_512)
3028 "on 82542\n"); 3008 adapter->rx_buffer_len = E1000_RXBUFFER_512;
3029 return -EINVAL; 3009 else if (max_frame <= E1000_RXBUFFER_1024)
3030 } else { 3010 adapter->rx_buffer_len = E1000_RXBUFFER_1024;
3031 if(max_frame <= E1000_RXBUFFER_2048) 3011 else if (max_frame <= E1000_RXBUFFER_2048)
3032 adapter->rx_buffer_len = E1000_RXBUFFER_2048; 3012 adapter->rx_buffer_len = E1000_RXBUFFER_2048;
3033 else if(max_frame <= E1000_RXBUFFER_4096) 3013 else if (max_frame <= E1000_RXBUFFER_4096)
3034 adapter->rx_buffer_len = E1000_RXBUFFER_4096; 3014 adapter->rx_buffer_len = E1000_RXBUFFER_4096;
3035 else if(max_frame <= E1000_RXBUFFER_8192) 3015 else if (max_frame <= E1000_RXBUFFER_8192)
3036 adapter->rx_buffer_len = E1000_RXBUFFER_8192; 3016 adapter->rx_buffer_len = E1000_RXBUFFER_8192;
3037 else if(max_frame <= E1000_RXBUFFER_16384) 3017 else if (max_frame <= E1000_RXBUFFER_16384)
3038 adapter->rx_buffer_len = E1000_RXBUFFER_16384; 3018 adapter->rx_buffer_len = E1000_RXBUFFER_16384;
3039 } 3019
3040 } 3020 /* adjust allocation if LPE protects us, and we aren't using SBP */
3021#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
3022 if (!adapter->hw.tbi_compatibility_on &&
3023 ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||
3024 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
3025 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
3041 3026
3042 netdev->mtu = new_mtu; 3027 netdev->mtu = new_mtu;
3043 3028
@@ -3060,11 +3045,21 @@ void
3060e1000_update_stats(struct e1000_adapter *adapter) 3045e1000_update_stats(struct e1000_adapter *adapter)
3061{ 3046{
3062 struct e1000_hw *hw = &adapter->hw; 3047 struct e1000_hw *hw = &adapter->hw;
3048 struct pci_dev *pdev = adapter->pdev;
3063 unsigned long flags; 3049 unsigned long flags;
3064 uint16_t phy_tmp; 3050 uint16_t phy_tmp;
3065 3051
3066#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF 3052#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
3067 3053
3054 /*
3055 * Prevent stats update while adapter is being reset, or if the pci
3056 * connection is down.
3057 */
3058 if (adapter->link_speed == 0)
3059 return;
3060 if (pdev->error_state && pdev->error_state != pci_channel_io_normal)
3061 return;
3062
3068 spin_lock_irqsave(&adapter->stats_lock, flags); 3063 spin_lock_irqsave(&adapter->stats_lock, flags);
3069 3064
3070 /* these counters are modified from e1000_adjust_tbi_stats, 3065 /* these counters are modified from e1000_adjust_tbi_stats,
@@ -3165,7 +3160,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
3165 adapter->stats.crcerrs + adapter->stats.algnerrc + 3160 adapter->stats.crcerrs + adapter->stats.algnerrc +
3166 adapter->stats.ruc + adapter->stats.roc + 3161 adapter->stats.ruc + adapter->stats.roc +
3167 adapter->stats.cexterr; 3162 adapter->stats.cexterr;
3168 adapter->net_stats.rx_dropped = 0;
3169 adapter->net_stats.rx_length_errors = adapter->stats.ruc + 3163 adapter->net_stats.rx_length_errors = adapter->stats.ruc +
3170 adapter->stats.roc; 3164 adapter->stats.roc;
3171 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs; 3165 adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
@@ -3391,13 +3385,15 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3391 3385
3392 tx_ring->next_to_clean = i; 3386 tx_ring->next_to_clean = i;
3393 3387
3394 spin_lock(&tx_ring->tx_lock); 3388#define TX_WAKE_THRESHOLD 32
3395
3396 if (unlikely(cleaned && netif_queue_stopped(netdev) && 3389 if (unlikely(cleaned && netif_queue_stopped(netdev) &&
3397 netif_carrier_ok(netdev))) 3390 netif_carrier_ok(netdev))) {
3398 netif_wake_queue(netdev); 3391 spin_lock(&tx_ring->tx_lock);
3399 3392 if (netif_queue_stopped(netdev) &&
3400 spin_unlock(&tx_ring->tx_lock); 3393 (E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD))
3394 netif_wake_queue(netdev);
3395 spin_unlock(&tx_ring->tx_lock);
3396 }
3401 3397
3402 if (adapter->detect_tx_hung) { 3398 if (adapter->detect_tx_hung) {
3403 /* Detect a transmit hang in hardware, this serializes the 3399 /* Detect a transmit hang in hardware, this serializes the
@@ -3445,7 +3441,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3445 * @sk_buff: socket buffer with received data 3441 * @sk_buff: socket buffer with received data
3446 **/ 3442 **/
3447 3443
3448static inline void 3444static void
3449e1000_rx_checksum(struct e1000_adapter *adapter, 3445e1000_rx_checksum(struct e1000_adapter *adapter,
3450 uint32_t status_err, uint32_t csum, 3446 uint32_t status_err, uint32_t csum,
3451 struct sk_buff *skb) 3447 struct sk_buff *skb)
@@ -3567,7 +3563,8 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3567 flags); 3563 flags);
3568 length--; 3564 length--;
3569 } else { 3565 } else {
3570 dev_kfree_skb_irq(skb); 3566 /* recycle */
3567 buffer_info->skb = skb;
3571 goto next_desc; 3568 goto next_desc;
3572 } 3569 }
3573 } 3570 }
@@ -3675,6 +3672,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3675 i = rx_ring->next_to_clean; 3672 i = rx_ring->next_to_clean;
3676 rx_desc = E1000_RX_DESC_PS(*rx_ring, i); 3673 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
3677 staterr = le32_to_cpu(rx_desc->wb.middle.status_error); 3674 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
3675 buffer_info = &rx_ring->buffer_info[i];
3678 3676
3679 while (staterr & E1000_RXD_STAT_DD) { 3677 while (staterr & E1000_RXD_STAT_DD) {
3680 buffer_info = &rx_ring->buffer_info[i]; 3678 buffer_info = &rx_ring->buffer_info[i];
@@ -3733,9 +3731,9 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3733 3731
3734 /* page alloc/put takes too long and effects small packet 3732 /* page alloc/put takes too long and effects small packet
3735 * throughput, so unsplit small packets and save the alloc/put*/ 3733 * throughput, so unsplit small packets and save the alloc/put*/
3736 if (l1 && ((length + l1) < E1000_CB_LENGTH)) { 3734 if (l1 && ((length + l1) <= adapter->rx_ps_bsize0)) {
3737 u8 *vaddr; 3735 u8 *vaddr;
3738 /* there is no documentation about how to call 3736 /* there is no documentation about how to call
3739 * kmap_atomic, so we can't hold the mapping 3737 * kmap_atomic, so we can't hold the mapping
3740 * very long */ 3738 * very long */
3741 pci_dma_sync_single_for_cpu(pdev, 3739 pci_dma_sync_single_for_cpu(pdev,
@@ -4155,7 +4153,7 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4155 spin_unlock_irqrestore(&adapter->stats_lock, flags); 4153 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4156 return -EIO; 4154 return -EIO;
4157 } 4155 }
4158 if (adapter->hw.phy_type == e1000_media_type_copper) { 4156 if (adapter->hw.media_type == e1000_media_type_copper) {
4159 switch (data->reg_num) { 4157 switch (data->reg_num) {
4160 case PHY_CTRL: 4158 case PHY_CTRL:
4161 if (mii_reg & MII_CR_POWER_DOWN) 4159 if (mii_reg & MII_CR_POWER_DOWN)
@@ -4514,21 +4512,13 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4514 4512
4515 E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN); 4513 E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
4516 E1000_WRITE_REG(&adapter->hw, WUFC, wufc); 4514 E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
4517 retval = pci_enable_wake(pdev, PCI_D3hot, 1); 4515 pci_enable_wake(pdev, PCI_D3hot, 1);
4518 if (retval) 4516 pci_enable_wake(pdev, PCI_D3cold, 1);
4519 DPRINTK(PROBE, ERR, "Error enabling D3 wake\n");
4520 retval = pci_enable_wake(pdev, PCI_D3cold, 1);
4521 if (retval)
4522 DPRINTK(PROBE, ERR, "Error enabling D3 cold wake\n");
4523 } else { 4517 } else {
4524 E1000_WRITE_REG(&adapter->hw, WUC, 0); 4518 E1000_WRITE_REG(&adapter->hw, WUC, 0);
4525 E1000_WRITE_REG(&adapter->hw, WUFC, 0); 4519 E1000_WRITE_REG(&adapter->hw, WUFC, 0);
4526 retval = pci_enable_wake(pdev, PCI_D3hot, 0); 4520 pci_enable_wake(pdev, PCI_D3hot, 0);
4527 if (retval) 4521 pci_enable_wake(pdev, PCI_D3cold, 0);
4528 DPRINTK(PROBE, ERR, "Error enabling D3 wake\n");
4529 retval = pci_enable_wake(pdev, PCI_D3cold, 0);
4530 if (retval)
4531 DPRINTK(PROBE, ERR, "Error enabling D3 cold wake\n");
4532 } 4522 }
4533 4523
4534 if (adapter->hw.mac_type >= e1000_82540 && 4524 if (adapter->hw.mac_type >= e1000_82540 &&
@@ -4537,13 +4527,8 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4537 if (manc & E1000_MANC_SMBUS_EN) { 4527 if (manc & E1000_MANC_SMBUS_EN) {
4538 manc |= E1000_MANC_ARP_EN; 4528 manc |= E1000_MANC_ARP_EN;
4539 E1000_WRITE_REG(&adapter->hw, MANC, manc); 4529 E1000_WRITE_REG(&adapter->hw, MANC, manc);
4540 retval = pci_enable_wake(pdev, PCI_D3hot, 1); 4530 pci_enable_wake(pdev, PCI_D3hot, 1);
4541 if (retval) 4531 pci_enable_wake(pdev, PCI_D3cold, 1);
4542 DPRINTK(PROBE, ERR, "Error enabling D3 wake\n");
4543 retval = pci_enable_wake(pdev, PCI_D3cold, 1);
4544 if (retval)
4545 DPRINTK(PROBE, ERR,
4546 "Error enabling D3 cold wake\n");
4547 } 4532 }
4548 } 4533 }
4549 4534
@@ -4553,9 +4538,7 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
4553 4538
4554 pci_disable_device(pdev); 4539 pci_disable_device(pdev);
4555 4540
4556 retval = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 4541 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4557 if (retval)
4558 DPRINTK(PROBE, ERR, "Error in setting power state\n");
4559 4542
4560 return 0; 4543 return 0;
4561} 4544}
@@ -4566,22 +4549,15 @@ e1000_resume(struct pci_dev *pdev)
4566{ 4549{
4567 struct net_device *netdev = pci_get_drvdata(pdev); 4550 struct net_device *netdev = pci_get_drvdata(pdev);
4568 struct e1000_adapter *adapter = netdev_priv(netdev); 4551 struct e1000_adapter *adapter = netdev_priv(netdev);
4569 int retval;
4570 uint32_t manc, ret_val; 4552 uint32_t manc, ret_val;
4571 4553
4572 retval = pci_set_power_state(pdev, PCI_D0); 4554 pci_set_power_state(pdev, PCI_D0);
4573 if (retval)
4574 DPRINTK(PROBE, ERR, "Error in setting power state\n");
4575 e1000_pci_restore_state(adapter); 4555 e1000_pci_restore_state(adapter);
4576 ret_val = pci_enable_device(pdev); 4556 ret_val = pci_enable_device(pdev);
4577 pci_set_master(pdev); 4557 pci_set_master(pdev);
4578 4558
4579 retval = pci_enable_wake(pdev, PCI_D3hot, 0); 4559 pci_enable_wake(pdev, PCI_D3hot, 0);
4580 if (retval) 4560 pci_enable_wake(pdev, PCI_D3cold, 0);
4581 DPRINTK(PROBE, ERR, "Error enabling D3 wake\n");
4582 retval = pci_enable_wake(pdev, PCI_D3cold, 0);
4583 if (retval)
4584 DPRINTK(PROBE, ERR, "Error enabling D3 cold wake\n");
4585 4561
4586 e1000_reset(adapter); 4562 e1000_reset(adapter);
4587 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 4563 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
@@ -4635,4 +4611,101 @@ e1000_netpoll(struct net_device *netdev)
4635} 4611}
4636#endif 4612#endif
4637 4613
4614/**
4615 * e1000_io_error_detected - called when PCI error is detected
4616 * @pdev: Pointer to PCI device
4617 * @state: The current pci conneection state
4618 *
4619 * This function is called after a PCI bus error affecting
4620 * this device has been detected.
4621 */
4622static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
4623{
4624 struct net_device *netdev = pci_get_drvdata(pdev);
4625 struct e1000_adapter *adapter = netdev->priv;
4626
4627 netif_device_detach(netdev);
4628
4629 if (netif_running(netdev))
4630 e1000_down(adapter);
4631
4632 /* Request a slot slot reset. */
4633 return PCI_ERS_RESULT_NEED_RESET;
4634}
4635
4636/**
4637 * e1000_io_slot_reset - called after the pci bus has been reset.
4638 * @pdev: Pointer to PCI device
4639 *
4640 * Restart the card from scratch, as if from a cold-boot. Implementation
4641 * resembles the first-half of the e1000_resume routine.
4642 */
4643static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4644{
4645 struct net_device *netdev = pci_get_drvdata(pdev);
4646 struct e1000_adapter *adapter = netdev->priv;
4647
4648 if (pci_enable_device(pdev)) {
4649 printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n");
4650 return PCI_ERS_RESULT_DISCONNECT;
4651 }
4652 pci_set_master(pdev);
4653
4654 pci_enable_wake(pdev, 3, 0);
4655 pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
4656
4657 /* Perform card reset only on one instance of the card */
4658 if (PCI_FUNC (pdev->devfn) != 0)
4659 return PCI_ERS_RESULT_RECOVERED;
4660
4661 e1000_reset(adapter);
4662 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4663
4664 return PCI_ERS_RESULT_RECOVERED;
4665}
4666
4667/**
4668 * e1000_io_resume - called when traffic can start flowing again.
4669 * @pdev: Pointer to PCI device
4670 *
4671 * This callback is called when the error recovery driver tells us that
4672 * its OK to resume normal operation. Implementation resembles the
4673 * second-half of the e1000_resume routine.
4674 */
4675static void e1000_io_resume(struct pci_dev *pdev)
4676{
4677 struct net_device *netdev = pci_get_drvdata(pdev);
4678 struct e1000_adapter *adapter = netdev->priv;
4679 uint32_t manc, swsm;
4680
4681 if (netif_running(netdev)) {
4682 if (e1000_up(adapter)) {
4683 printk("e1000: can't bring device back up after reset\n");
4684 return;
4685 }
4686 }
4687
4688 netif_device_attach(netdev);
4689
4690 if (adapter->hw.mac_type >= e1000_82540 &&
4691 adapter->hw.media_type == e1000_media_type_copper) {
4692 manc = E1000_READ_REG(&adapter->hw, MANC);
4693 manc &= ~(E1000_MANC_ARP_EN);
4694 E1000_WRITE_REG(&adapter->hw, MANC, manc);
4695 }
4696
4697 switch (adapter->hw.mac_type) {
4698 case e1000_82573:
4699 swsm = E1000_READ_REG(&adapter->hw, SWSM);
4700 E1000_WRITE_REG(&adapter->hw, SWSM,
4701 swsm | E1000_SWSM_DRV_LOAD);
4702 break;
4703 default:
4704 break;
4705 }
4706
4707 if (netif_running(netdev))
4708 mod_timer(&adapter->watchdog_timer, jiffies);
4709}
4710
4638/* e1000_main.c */ 4711/* e1000_main.c */
diff --git a/drivers/net/e1000/e1000_osdep.h b/drivers/net/e1000/e1000_osdep.h
index 9790db974dc1..048d052be29d 100644
--- a/drivers/net/e1000/e1000_osdep.h
+++ b/drivers/net/e1000/e1000_osdep.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
index e0a4d37d1b85..e55f8969a0fb 100644
--- a/drivers/net/e1000/e1000_param.c
+++ b/drivers/net/e1000/e1000_param.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,7 @@
22 22
23 Contact Information: 23 Contact Information:
24 Linux NICS <linux.nics@intel.com> 24 Linux NICS <linux.nics@intel.com>
25 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 27
27*******************************************************************************/ 28*******************************************************************************/
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 2f7b86837fe8..8d680ce600d7 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -21,15 +21,15 @@
21 http://www.scyld.com/network/epic100.html 21 http://www.scyld.com/network/epic100.html
22 22
23 --------------------------------------------------------------------- 23 ---------------------------------------------------------------------
24 24
25 Linux kernel-specific changes: 25 Linux kernel-specific changes:
26 26
27 LK1.1.2 (jgarzik): 27 LK1.1.2 (jgarzik):
28 * Merge becker version 1.09 (4/08/2000) 28 * Merge becker version 1.09 (4/08/2000)
29 29
30 LK1.1.3: 30 LK1.1.3:
31 * Major bugfix to 1.09 driver (Francis Romieu) 31 * Major bugfix to 1.09 driver (Francis Romieu)
32 32
33 LK1.1.4 (jgarzik): 33 LK1.1.4 (jgarzik):
34 * Merge becker test version 1.09 (5/29/2000) 34 * Merge becker test version 1.09 (5/29/2000)
35 35
@@ -66,7 +66,7 @@
66 LK1.1.14 (Kryzsztof Halasa): 66 LK1.1.14 (Kryzsztof Halasa):
67 * fix spurious bad initializations 67 * fix spurious bad initializations
68 * pound phy a la SMSC's app note on the subject 68 * pound phy a la SMSC's app note on the subject
69 69
70 AC1.1.14ac 70 AC1.1.14ac
71 * fix power up/down for ethtool that broke in 1.11 71 * fix power up/down for ethtool that broke in 1.11
72 72
@@ -244,7 +244,7 @@ static struct pci_device_id epic_pci_tbl[] = {
244}; 244};
245MODULE_DEVICE_TABLE (pci, epic_pci_tbl); 245MODULE_DEVICE_TABLE (pci, epic_pci_tbl);
246 246
247 247
248#ifndef USE_IO_OPS 248#ifndef USE_IO_OPS
249#undef inb 249#undef inb
250#undef inw 250#undef inw
@@ -370,7 +370,7 @@ static int epic_close(struct net_device *dev);
370static struct net_device_stats *epic_get_stats(struct net_device *dev); 370static struct net_device_stats *epic_get_stats(struct net_device *dev);
371static void set_rx_mode(struct net_device *dev); 371static void set_rx_mode(struct net_device *dev);
372 372
373 373
374 374
375static int __devinit epic_init_one (struct pci_dev *pdev, 375static int __devinit epic_init_one (struct pci_dev *pdev,
376 const struct pci_device_id *ent) 376 const struct pci_device_id *ent)
@@ -392,9 +392,9 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
392 printk (KERN_INFO "%s" KERN_INFO "%s" KERN_INFO "%s", 392 printk (KERN_INFO "%s" KERN_INFO "%s" KERN_INFO "%s",
393 version, version2, version3); 393 version, version2, version3);
394#endif 394#endif
395 395
396 card_idx++; 396 card_idx++;
397 397
398 ret = pci_enable_device(pdev); 398 ret = pci_enable_device(pdev);
399 if (ret) 399 if (ret)
400 goto out; 400 goto out;
@@ -405,7 +405,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
405 ret = -ENODEV; 405 ret = -ENODEV;
406 goto err_out_disable; 406 goto err_out_disable;
407 } 407 }
408 408
409 pci_set_master(pdev); 409 pci_set_master(pdev);
410 410
411 ret = pci_request_regions(pdev, DRV_NAME); 411 ret = pci_request_regions(pdev, DRV_NAME);
@@ -498,7 +498,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
498 ep->pci_dev = pdev; 498 ep->pci_dev = pdev;
499 ep->chip_id = chip_idx; 499 ep->chip_id = chip_idx;
500 ep->chip_flags = pci_id_tbl[chip_idx].drv_flags; 500 ep->chip_flags = pci_id_tbl[chip_idx].drv_flags;
501 ep->irq_mask = 501 ep->irq_mask =
502 (ep->chip_flags & TYPE2_INTR ? PCIBusErr175 : PCIBusErr170) 502 (ep->chip_flags & TYPE2_INTR ? PCIBusErr175 : PCIBusErr170)
503 | CntFull | TxUnderrun | EpicNapiEvent; 503 | CntFull | TxUnderrun | EpicNapiEvent;
504 504
@@ -587,7 +587,7 @@ err_out_disable:
587 pci_disable_device(pdev); 587 pci_disable_device(pdev);
588 goto out; 588 goto out;
589} 589}
590 590
591/* Serial EEPROM section. */ 591/* Serial EEPROM section. */
592 592
593/* EEPROM_Ctrl bits. */ 593/* EEPROM_Ctrl bits. */
@@ -709,7 +709,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int value)
709 709
710 outw(value, ioaddr + MIIData); 710 outw(value, ioaddr + MIIData);
711 outl((phy_id << 9) | (loc << 4) | MII_WRITEOP, ioaddr + MIICtrl); 711 outl((phy_id << 9) | (loc << 4) | MII_WRITEOP, ioaddr + MIICtrl);
712 for (i = 10000; i > 0; i--) { 712 for (i = 10000; i > 0; i--) {
713 barrier(); 713 barrier();
714 if ((inl(ioaddr + MIICtrl) & MII_WRITEOP) == 0) 714 if ((inl(ioaddr + MIICtrl) & MII_WRITEOP) == 0)
715 break; 715 break;
@@ -717,7 +717,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int value)
717 return; 717 return;
718} 718}
719 719
720 720
721static int epic_open(struct net_device *dev) 721static int epic_open(struct net_device *dev)
722{ 722{
723 struct epic_private *ep = dev->priv; 723 struct epic_private *ep = dev->priv;
@@ -760,7 +760,7 @@ static int epic_open(struct net_device *dev)
760#endif 760#endif
761 761
762 udelay(20); /* Looks like EPII needs that if you want reliable RX init. FIXME: pci posting bug? */ 762 udelay(20); /* Looks like EPII needs that if you want reliable RX init. FIXME: pci posting bug? */
763 763
764 for (i = 0; i < 3; i++) 764 for (i = 0; i < 3; i++)
765 outl(cpu_to_le16(((u16*)dev->dev_addr)[i]), ioaddr + LAN0 + i*4); 765 outl(cpu_to_le16(((u16*)dev->dev_addr)[i]), ioaddr + LAN0 + i*4);
766 766
@@ -803,7 +803,7 @@ static int epic_open(struct net_device *dev)
803 803
804 /* Enable interrupts by setting the interrupt mask. */ 804 /* Enable interrupts by setting the interrupt mask. */
805 outl((ep->chip_flags & TYPE2_INTR ? PCIBusErr175 : PCIBusErr170) 805 outl((ep->chip_flags & TYPE2_INTR ? PCIBusErr175 : PCIBusErr170)
806 | CntFull | TxUnderrun 806 | CntFull | TxUnderrun
807 | RxError | RxHeader | EpicNapiEvent, ioaddr + INTMASK); 807 | RxError | RxHeader | EpicNapiEvent, ioaddr + INTMASK);
808 808
809 if (debug > 1) 809 if (debug > 1)
@@ -831,7 +831,7 @@ static void epic_pause(struct net_device *dev)
831 struct epic_private *ep = dev->priv; 831 struct epic_private *ep = dev->priv;
832 832
833 netif_stop_queue (dev); 833 netif_stop_queue (dev);
834 834
835 /* Disable interrupts by clearing the interrupt mask. */ 835 /* Disable interrupts by clearing the interrupt mask. */
836 outl(0x00000000, ioaddr + INTMASK); 836 outl(0x00000000, ioaddr + INTMASK);
837 /* Stop the chip's Tx and Rx DMA processes. */ 837 /* Stop the chip's Tx and Rx DMA processes. */
@@ -987,7 +987,7 @@ static void epic_init_ring(struct net_device *dev)
987 for (i = 0; i < RX_RING_SIZE; i++) { 987 for (i = 0; i < RX_RING_SIZE; i++) {
988 ep->rx_ring[i].rxstatus = 0; 988 ep->rx_ring[i].rxstatus = 0;
989 ep->rx_ring[i].buflength = cpu_to_le32(ep->rx_buf_sz); 989 ep->rx_ring[i].buflength = cpu_to_le32(ep->rx_buf_sz);
990 ep->rx_ring[i].next = ep->rx_ring_dma + 990 ep->rx_ring[i].next = ep->rx_ring_dma +
991 (i+1)*sizeof(struct epic_rx_desc); 991 (i+1)*sizeof(struct epic_rx_desc);
992 ep->rx_skbuff[i] = NULL; 992 ep->rx_skbuff[i] = NULL;
993 } 993 }
@@ -1002,7 +1002,7 @@ static void epic_init_ring(struct net_device *dev)
1002 break; 1002 break;
1003 skb->dev = dev; /* Mark as being used by this device. */ 1003 skb->dev = dev; /* Mark as being used by this device. */
1004 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1004 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1005 ep->rx_ring[i].bufaddr = pci_map_single(ep->pci_dev, 1005 ep->rx_ring[i].bufaddr = pci_map_single(ep->pci_dev,
1006 skb->data, ep->rx_buf_sz, PCI_DMA_FROMDEVICE); 1006 skb->data, ep->rx_buf_sz, PCI_DMA_FROMDEVICE);
1007 ep->rx_ring[i].rxstatus = cpu_to_le32(DescOwn); 1007 ep->rx_ring[i].rxstatus = cpu_to_le32(DescOwn);
1008 } 1008 }
@@ -1013,7 +1013,7 @@ static void epic_init_ring(struct net_device *dev)
1013 for (i = 0; i < TX_RING_SIZE; i++) { 1013 for (i = 0; i < TX_RING_SIZE; i++) {
1014 ep->tx_skbuff[i] = NULL; 1014 ep->tx_skbuff[i] = NULL;
1015 ep->tx_ring[i].txstatus = 0x0000; 1015 ep->tx_ring[i].txstatus = 0x0000;
1016 ep->tx_ring[i].next = ep->tx_ring_dma + 1016 ep->tx_ring[i].next = ep->tx_ring_dma +
1017 (i+1)*sizeof(struct epic_tx_desc); 1017 (i+1)*sizeof(struct epic_tx_desc);
1018 } 1018 }
1019 ep->tx_ring[i-1].next = ep->tx_ring_dma; 1019 ep->tx_ring[i-1].next = ep->tx_ring_dma;
@@ -1026,7 +1026,7 @@ static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev)
1026 int entry, free_count; 1026 int entry, free_count;
1027 u32 ctrl_word; 1027 u32 ctrl_word;
1028 unsigned long flags; 1028 unsigned long flags;
1029 1029
1030 if (skb->len < ETH_ZLEN) { 1030 if (skb->len < ETH_ZLEN) {
1031 skb = skb_padto(skb, ETH_ZLEN); 1031 skb = skb_padto(skb, ETH_ZLEN);
1032 if (skb == NULL) 1032 if (skb == NULL)
@@ -1042,7 +1042,7 @@ static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev)
1042 entry = ep->cur_tx % TX_RING_SIZE; 1042 entry = ep->cur_tx % TX_RING_SIZE;
1043 1043
1044 ep->tx_skbuff[entry] = skb; 1044 ep->tx_skbuff[entry] = skb;
1045 ep->tx_ring[entry].bufaddr = pci_map_single(ep->pci_dev, skb->data, 1045 ep->tx_ring[entry].bufaddr = pci_map_single(ep->pci_dev, skb->data,
1046 skb->len, PCI_DMA_TODEVICE); 1046 skb->len, PCI_DMA_TODEVICE);
1047 if (free_count < TX_QUEUE_LEN/2) {/* Typical path */ 1047 if (free_count < TX_QUEUE_LEN/2) {/* Typical path */
1048 ctrl_word = cpu_to_le32(0x100000); /* No interrupt */ 1048 ctrl_word = cpu_to_le32(0x100000); /* No interrupt */
@@ -1126,7 +1126,7 @@ static void epic_tx(struct net_device *dev, struct epic_private *ep)
1126 1126
1127 /* Free the original skb. */ 1127 /* Free the original skb. */
1128 skb = ep->tx_skbuff[entry]; 1128 skb = ep->tx_skbuff[entry];
1129 pci_unmap_single(ep->pci_dev, ep->tx_ring[entry].bufaddr, 1129 pci_unmap_single(ep->pci_dev, ep->tx_ring[entry].bufaddr,
1130 skb->len, PCI_DMA_TODEVICE); 1130 skb->len, PCI_DMA_TODEVICE);
1131 dev_kfree_skb_irq(skb); 1131 dev_kfree_skb_irq(skb);
1132 ep->tx_skbuff[entry] = NULL; 1132 ep->tx_skbuff[entry] = NULL;
@@ -1281,8 +1281,8 @@ static int epic_rx(struct net_device *dev, int budget)
1281 ep->rx_buf_sz, 1281 ep->rx_buf_sz,
1282 PCI_DMA_FROMDEVICE); 1282 PCI_DMA_FROMDEVICE);
1283 } else { 1283 } else {
1284 pci_unmap_single(ep->pci_dev, 1284 pci_unmap_single(ep->pci_dev,
1285 ep->rx_ring[entry].bufaddr, 1285 ep->rx_ring[entry].bufaddr,
1286 ep->rx_buf_sz, PCI_DMA_FROMDEVICE); 1286 ep->rx_buf_sz, PCI_DMA_FROMDEVICE);
1287 skb_put(skb = ep->rx_skbuff[entry], pkt_len); 1287 skb_put(skb = ep->rx_skbuff[entry], pkt_len);
1288 ep->rx_skbuff[entry] = NULL; 1288 ep->rx_skbuff[entry] = NULL;
@@ -1307,7 +1307,7 @@ static int epic_rx(struct net_device *dev, int budget)
1307 break; 1307 break;
1308 skb->dev = dev; /* Mark as being used by this device. */ 1308 skb->dev = dev; /* Mark as being used by this device. */
1309 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1309 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1310 ep->rx_ring[entry].bufaddr = pci_map_single(ep->pci_dev, 1310 ep->rx_ring[entry].bufaddr = pci_map_single(ep->pci_dev,
1311 skb->data, ep->rx_buf_sz, PCI_DMA_FROMDEVICE); 1311 skb->data, ep->rx_buf_sz, PCI_DMA_FROMDEVICE);
1312 work_done++; 1312 work_done++;
1313 } 1313 }
@@ -1403,7 +1403,7 @@ static int epic_close(struct net_device *dev)
1403 ep->rx_ring[i].rxstatus = 0; /* Not owned by Epic chip. */ 1403 ep->rx_ring[i].rxstatus = 0; /* Not owned by Epic chip. */
1404 ep->rx_ring[i].buflength = 0; 1404 ep->rx_ring[i].buflength = 0;
1405 if (skb) { 1405 if (skb) {
1406 pci_unmap_single(ep->pci_dev, ep->rx_ring[i].bufaddr, 1406 pci_unmap_single(ep->pci_dev, ep->rx_ring[i].bufaddr,
1407 ep->rx_buf_sz, PCI_DMA_FROMDEVICE); 1407 ep->rx_buf_sz, PCI_DMA_FROMDEVICE);
1408 dev_kfree_skb(skb); 1408 dev_kfree_skb(skb);
1409 } 1409 }
@@ -1414,7 +1414,7 @@ static int epic_close(struct net_device *dev)
1414 ep->tx_skbuff[i] = NULL; 1414 ep->tx_skbuff[i] = NULL;
1415 if (!skb) 1415 if (!skb)
1416 continue; 1416 continue;
1417 pci_unmap_single(ep->pci_dev, ep->tx_ring[i].bufaddr, 1417 pci_unmap_single(ep->pci_dev, ep->tx_ring[i].bufaddr,
1418 skb->len, PCI_DMA_TODEVICE); 1418 skb->len, PCI_DMA_TODEVICE);
1419 dev_kfree_skb(skb); 1419 dev_kfree_skb(skb);
1420 } 1420 }
@@ -1607,7 +1607,7 @@ static void __devexit epic_remove_one (struct pci_dev *pdev)
1607{ 1607{
1608 struct net_device *dev = pci_get_drvdata(pdev); 1608 struct net_device *dev = pci_get_drvdata(pdev);
1609 struct epic_private *ep = dev->priv; 1609 struct epic_private *ep = dev->priv;
1610 1610
1611 pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma); 1611 pci_free_consistent(pdev, TX_TOTAL_SIZE, ep->tx_ring, ep->tx_ring_dma);
1612 pci_free_consistent(pdev, RX_TOTAL_SIZE, ep->rx_ring, ep->rx_ring_dma); 1612 pci_free_consistent(pdev, RX_TOTAL_SIZE, ep->rx_ring, ep->rx_ring_dma);
1613 unregister_netdev(dev); 1613 unregister_netdev(dev);
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index feb5b223cd60..04a53f1dfdbd 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -107,6 +107,8 @@
107 * 0.52: 20 Jan 2006: Add MSI/MSIX support. 107 * 0.52: 20 Jan 2006: Add MSI/MSIX support.
108 * 0.53: 19 Mar 2006: Fix init from low power mode and add hw reset. 108 * 0.53: 19 Mar 2006: Fix init from low power mode and add hw reset.
109 * 0.54: 21 Mar 2006: Fix spin locks for multi irqs and cleanup. 109 * 0.54: 21 Mar 2006: Fix spin locks for multi irqs and cleanup.
110 * 0.55: 22 Mar 2006: Add flow control (pause frame).
111 * 0.56: 22 Mar 2006: Additional ethtool config and moduleparam support.
110 * 112 *
111 * Known bugs: 113 * Known bugs:
112 * We suspect that on some hardware no TX done interrupts are generated. 114 * We suspect that on some hardware no TX done interrupts are generated.
@@ -118,7 +120,7 @@
118 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 120 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
119 * superfluous timer interrupts from the nic. 121 * superfluous timer interrupts from the nic.
120 */ 122 */
121#define FORCEDETH_VERSION "0.54" 123#define FORCEDETH_VERSION "0.56"
122#define DRV_NAME "forcedeth" 124#define DRV_NAME "forcedeth"
123 125
124#include <linux/module.h> 126#include <linux/module.h>
@@ -163,6 +165,9 @@
163#define DEV_HAS_MSI 0x0040 /* device supports MSI */ 165#define DEV_HAS_MSI 0x0040 /* device supports MSI */
164#define DEV_HAS_MSI_X 0x0080 /* device supports MSI-X */ 166#define DEV_HAS_MSI_X 0x0080 /* device supports MSI-X */
165#define DEV_HAS_POWER_CNTRL 0x0100 /* device supports power savings */ 167#define DEV_HAS_POWER_CNTRL 0x0100 /* device supports power savings */
168#define DEV_HAS_PAUSEFRAME_TX 0x0200 /* device supports tx pause frames */
169#define DEV_HAS_STATISTICS 0x0400 /* device supports hw statistics */
170#define DEV_HAS_TEST_EXTENDED 0x0800 /* device supports extended diagnostic test */
166 171
167enum { 172enum {
168 NvRegIrqStatus = 0x000, 173 NvRegIrqStatus = 0x000,
@@ -203,6 +208,7 @@ enum {
203 NvRegMSIIrqMask = 0x030, 208 NvRegMSIIrqMask = 0x030,
204#define NVREG_MSI_VECTOR_0_ENABLED 0x01 209#define NVREG_MSI_VECTOR_0_ENABLED 0x01
205 NvRegMisc1 = 0x080, 210 NvRegMisc1 = 0x080,
211#define NVREG_MISC1_PAUSE_TX 0x01
206#define NVREG_MISC1_HD 0x02 212#define NVREG_MISC1_HD 0x02
207#define NVREG_MISC1_FORCE 0x3b0f3c 213#define NVREG_MISC1_FORCE 0x3b0f3c
208 214
@@ -214,9 +220,11 @@ enum {
214#define NVREG_XMITSTAT_BUSY 0x01 220#define NVREG_XMITSTAT_BUSY 0x01
215 221
216 NvRegPacketFilterFlags = 0x8c, 222 NvRegPacketFilterFlags = 0x8c,
217#define NVREG_PFF_ALWAYS 0x7F0008 223#define NVREG_PFF_PAUSE_RX 0x08
224#define NVREG_PFF_ALWAYS 0x7F0000
218#define NVREG_PFF_PROMISC 0x80 225#define NVREG_PFF_PROMISC 0x80
219#define NVREG_PFF_MYADDR 0x20 226#define NVREG_PFF_MYADDR 0x20
227#define NVREG_PFF_LOOPBACK 0x10
220 228
221 NvRegOffloadConfig = 0x90, 229 NvRegOffloadConfig = 0x90,
222#define NVREG_OFFLOAD_HOMEPHY 0x601 230#define NVREG_OFFLOAD_HOMEPHY 0x601
@@ -277,6 +285,9 @@ enum {
277#define NVREG_TXRXCTL_VLANINS 0x00080 285#define NVREG_TXRXCTL_VLANINS 0x00080
278 NvRegTxRingPhysAddrHigh = 0x148, 286 NvRegTxRingPhysAddrHigh = 0x148,
279 NvRegRxRingPhysAddrHigh = 0x14C, 287 NvRegRxRingPhysAddrHigh = 0x14C,
288 NvRegTxPauseFrame = 0x170,
289#define NVREG_TX_PAUSEFRAME_DISABLE 0x1ff0080
290#define NVREG_TX_PAUSEFRAME_ENABLE 0x0c00030
280 NvRegMIIStatus = 0x180, 291 NvRegMIIStatus = 0x180,
281#define NVREG_MIISTAT_ERROR 0x0001 292#define NVREG_MIISTAT_ERROR 0x0001
282#define NVREG_MIISTAT_LINKCHANGE 0x0008 293#define NVREG_MIISTAT_LINKCHANGE 0x0008
@@ -326,6 +337,33 @@ enum {
326#define NVREG_POWERSTATE_D1 0x0001 337#define NVREG_POWERSTATE_D1 0x0001
327#define NVREG_POWERSTATE_D2 0x0002 338#define NVREG_POWERSTATE_D2 0x0002
328#define NVREG_POWERSTATE_D3 0x0003 339#define NVREG_POWERSTATE_D3 0x0003
340 NvRegTxCnt = 0x280,
341 NvRegTxZeroReXmt = 0x284,
342 NvRegTxOneReXmt = 0x288,
343 NvRegTxManyReXmt = 0x28c,
344 NvRegTxLateCol = 0x290,
345 NvRegTxUnderflow = 0x294,
346 NvRegTxLossCarrier = 0x298,
347 NvRegTxExcessDef = 0x29c,
348 NvRegTxRetryErr = 0x2a0,
349 NvRegRxFrameErr = 0x2a4,
350 NvRegRxExtraByte = 0x2a8,
351 NvRegRxLateCol = 0x2ac,
352 NvRegRxRunt = 0x2b0,
353 NvRegRxFrameTooLong = 0x2b4,
354 NvRegRxOverflow = 0x2b8,
355 NvRegRxFCSErr = 0x2bc,
356 NvRegRxFrameAlignErr = 0x2c0,
357 NvRegRxLenErr = 0x2c4,
358 NvRegRxUnicast = 0x2c8,
359 NvRegRxMulticast = 0x2cc,
360 NvRegRxBroadcast = 0x2d0,
361 NvRegTxDef = 0x2d4,
362 NvRegTxFrame = 0x2d8,
363 NvRegRxCnt = 0x2dc,
364 NvRegTxPause = 0x2e0,
365 NvRegRxPause = 0x2e4,
366 NvRegRxDropFrame = 0x2e8,
329 NvRegVlanControl = 0x300, 367 NvRegVlanControl = 0x300,
330#define NVREG_VLANCONTROL_ENABLE 0x2000 368#define NVREG_VLANCONTROL_ENABLE 0x2000
331 NvRegMSIXMap0 = 0x3e0, 369 NvRegMSIXMap0 = 0x3e0,
@@ -449,16 +487,18 @@ typedef union _ring_type {
449/* General driver defaults */ 487/* General driver defaults */
450#define NV_WATCHDOG_TIMEO (5*HZ) 488#define NV_WATCHDOG_TIMEO (5*HZ)
451 489
452#define RX_RING 128 490#define RX_RING_DEFAULT 128
453#define TX_RING 256 491#define TX_RING_DEFAULT 256
454/* 492#define RX_RING_MIN 128
455 * If your nic mysteriously hangs then try to reduce the limits 493#define TX_RING_MIN 64
456 * to 1/0: It might be required to set NV_TX_LASTPACKET in the 494#define RING_MAX_DESC_VER_1 1024
457 * last valid ring entry. But this would be impossible to 495#define RING_MAX_DESC_VER_2_3 16384
458 * implement - probably a disassembly error. 496/*
497 * Difference between the get and put pointers for the tx ring.
498 * This is used to throttle the amount of data outstanding in the
499 * tx ring.
459 */ 500 */
460#define TX_LIMIT_STOP 255 501#define TX_LIMIT_DIFFERENCE 1
461#define TX_LIMIT_START 254
462 502
463/* rx/tx mac addr + type + vlan + align + slack*/ 503/* rx/tx mac addr + type + vlan + align + slack*/
464#define NV_RX_HEADERS (64) 504#define NV_RX_HEADERS (64)
@@ -472,8 +512,9 @@ typedef union _ring_type {
472#define OOM_REFILL (1+HZ/20) 512#define OOM_REFILL (1+HZ/20)
473#define POLL_WAIT (1+HZ/100) 513#define POLL_WAIT (1+HZ/100)
474#define LINK_TIMEOUT (3*HZ) 514#define LINK_TIMEOUT (3*HZ)
515#define STATS_INTERVAL (10*HZ)
475 516
476/* 517/*
477 * desc_ver values: 518 * desc_ver values:
478 * The nic supports three different descriptor types: 519 * The nic supports three different descriptor types:
479 * - DESC_VER_1: Original 520 * - DESC_VER_1: Original
@@ -506,13 +547,13 @@ typedef union _ring_type {
506#define PHY_1000 0x2 547#define PHY_1000 0x2
507#define PHY_HALF 0x100 548#define PHY_HALF 0x100
508 549
509/* FIXME: MII defines that should be added to <linux/mii.h> */ 550#define NV_PAUSEFRAME_RX_CAPABLE 0x0001
510#define MII_1000BT_CR 0x09 551#define NV_PAUSEFRAME_TX_CAPABLE 0x0002
511#define MII_1000BT_SR 0x0a 552#define NV_PAUSEFRAME_RX_ENABLE 0x0004
512#define ADVERTISE_1000FULL 0x0200 553#define NV_PAUSEFRAME_TX_ENABLE 0x0008
513#define ADVERTISE_1000HALF 0x0100 554#define NV_PAUSEFRAME_RX_REQ 0x0010
514#define LPA_1000FULL 0x0800 555#define NV_PAUSEFRAME_TX_REQ 0x0020
515#define LPA_1000HALF 0x0400 556#define NV_PAUSEFRAME_AUTONEG 0x0040
516 557
517/* MSI/MSI-X defines */ 558/* MSI/MSI-X defines */
518#define NV_MSI_X_MAX_VECTORS 8 559#define NV_MSI_X_MAX_VECTORS 8
@@ -527,15 +568,110 @@ typedef union _ring_type {
527#define NV_MSI_X_VECTOR_TX 0x1 568#define NV_MSI_X_VECTOR_TX 0x1
528#define NV_MSI_X_VECTOR_OTHER 0x2 569#define NV_MSI_X_VECTOR_OTHER 0x2
529 570
571/* statistics */
572struct nv_ethtool_str {
573 char name[ETH_GSTRING_LEN];
574};
575
576static const struct nv_ethtool_str nv_estats_str[] = {
577 { "tx_bytes" },
578 { "tx_zero_rexmt" },
579 { "tx_one_rexmt" },
580 { "tx_many_rexmt" },
581 { "tx_late_collision" },
582 { "tx_fifo_errors" },
583 { "tx_carrier_errors" },
584 { "tx_excess_deferral" },
585 { "tx_retry_error" },
586 { "tx_deferral" },
587 { "tx_packets" },
588 { "tx_pause" },
589 { "rx_frame_error" },
590 { "rx_extra_byte" },
591 { "rx_late_collision" },
592 { "rx_runt" },
593 { "rx_frame_too_long" },
594 { "rx_over_errors" },
595 { "rx_crc_errors" },
596 { "rx_frame_align_error" },
597 { "rx_length_error" },
598 { "rx_unicast" },
599 { "rx_multicast" },
600 { "rx_broadcast" },
601 { "rx_bytes" },
602 { "rx_pause" },
603 { "rx_drop_frame" },
604 { "rx_packets" },
605 { "rx_errors_total" }
606};
607
608struct nv_ethtool_stats {
609 u64 tx_bytes;
610 u64 tx_zero_rexmt;
611 u64 tx_one_rexmt;
612 u64 tx_many_rexmt;
613 u64 tx_late_collision;
614 u64 tx_fifo_errors;
615 u64 tx_carrier_errors;
616 u64 tx_excess_deferral;
617 u64 tx_retry_error;
618 u64 tx_deferral;
619 u64 tx_packets;
620 u64 tx_pause;
621 u64 rx_frame_error;
622 u64 rx_extra_byte;
623 u64 rx_late_collision;
624 u64 rx_runt;
625 u64 rx_frame_too_long;
626 u64 rx_over_errors;
627 u64 rx_crc_errors;
628 u64 rx_frame_align_error;
629 u64 rx_length_error;
630 u64 rx_unicast;
631 u64 rx_multicast;
632 u64 rx_broadcast;
633 u64 rx_bytes;
634 u64 rx_pause;
635 u64 rx_drop_frame;
636 u64 rx_packets;
637 u64 rx_errors_total;
638};
639
640/* diagnostics */
641#define NV_TEST_COUNT_BASE 3
642#define NV_TEST_COUNT_EXTENDED 4
643
644static const struct nv_ethtool_str nv_etests_str[] = {
645 { "link (online/offline)" },
646 { "register (offline) " },
647 { "interrupt (offline) " },
648 { "loopback (offline) " }
649};
650
651struct register_test {
652 u32 reg;
653 u32 mask;
654};
655
656static const struct register_test nv_registers_test[] = {
657 { NvRegUnknownSetupReg6, 0x01 },
658 { NvRegMisc1, 0x03c },
659 { NvRegOffloadConfig, 0x03ff },
660 { NvRegMulticastAddrA, 0xffffffff },
661 { NvRegUnknownSetupReg3, 0x0ff },
662 { NvRegWakeUpFlags, 0x07777 },
663 { 0,0 }
664};
665
530/* 666/*
531 * SMP locking: 667 * SMP locking:
532 * All hardware access under dev->priv->lock, except the performance 668 * All hardware access under dev->priv->lock, except the performance
533 * critical parts: 669 * critical parts:
534 * - rx is (pseudo-) lockless: it relies on the single-threading provided 670 * - rx is (pseudo-) lockless: it relies on the single-threading provided
535 * by the arch code for interrupts. 671 * by the arch code for interrupts.
536 * - tx setup is lockless: it relies on dev->xmit_lock. Actual submission 672 * - tx setup is lockless: it relies on netif_tx_lock. Actual submission
537 * needs dev->priv->lock :-( 673 * needs dev->priv->lock :-(
538 * - set_multicast_list: preparation lockless, relies on dev->xmit_lock. 674 * - set_multicast_list: preparation lockless, relies on netif_tx_lock.
539 */ 675 */
540 676
541/* in dev: base, irq */ 677/* in dev: base, irq */
@@ -545,6 +681,7 @@ struct fe_priv {
545 /* General data: 681 /* General data:
546 * Locking: spin_lock(&np->lock); */ 682 * Locking: spin_lock(&np->lock); */
547 struct net_device_stats stats; 683 struct net_device_stats stats;
684 struct nv_ethtool_stats estats;
548 int in_shutdown; 685 int in_shutdown;
549 u32 linkspeed; 686 u32 linkspeed;
550 int duplex; 687 int duplex;
@@ -554,6 +691,7 @@ struct fe_priv {
554 int wolenabled; 691 int wolenabled;
555 unsigned int phy_oui; 692 unsigned int phy_oui;
556 u16 gigabit; 693 u16 gigabit;
694 int intr_test;
557 695
558 /* General data: RO fields */ 696 /* General data: RO fields */
559 dma_addr_t ring_addr; 697 dma_addr_t ring_addr;
@@ -573,13 +711,15 @@ struct fe_priv {
573 */ 711 */
574 ring_type rx_ring; 712 ring_type rx_ring;
575 unsigned int cur_rx, refill_rx; 713 unsigned int cur_rx, refill_rx;
576 struct sk_buff *rx_skbuff[RX_RING]; 714 struct sk_buff **rx_skbuff;
577 dma_addr_t rx_dma[RX_RING]; 715 dma_addr_t *rx_dma;
578 unsigned int rx_buf_sz; 716 unsigned int rx_buf_sz;
579 unsigned int pkt_limit; 717 unsigned int pkt_limit;
580 struct timer_list oom_kick; 718 struct timer_list oom_kick;
581 struct timer_list nic_poll; 719 struct timer_list nic_poll;
720 struct timer_list stats_poll;
582 u32 nic_poll_irq; 721 u32 nic_poll_irq;
722 int rx_ring_size;
583 723
584 /* media detection workaround. 724 /* media detection workaround.
585 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock); 725 * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
@@ -591,10 +731,13 @@ struct fe_priv {
591 */ 731 */
592 ring_type tx_ring; 732 ring_type tx_ring;
593 unsigned int next_tx, nic_tx; 733 unsigned int next_tx, nic_tx;
594 struct sk_buff *tx_skbuff[TX_RING]; 734 struct sk_buff **tx_skbuff;
595 dma_addr_t tx_dma[TX_RING]; 735 dma_addr_t *tx_dma;
596 unsigned int tx_dma_len[TX_RING]; 736 unsigned int *tx_dma_len;
597 u32 tx_flags; 737 u32 tx_flags;
738 int tx_ring_size;
739 int tx_limit_start;
740 int tx_limit_stop;
598 741
599 /* vlan fields */ 742 /* vlan fields */
600 struct vlan_group *vlangrp; 743 struct vlan_group *vlangrp;
@@ -602,6 +745,9 @@ struct fe_priv {
602 /* msi/msi-x fields */ 745 /* msi/msi-x fields */
603 u32 msi_flags; 746 u32 msi_flags;
604 struct msix_entry msi_x_entry[NV_MSI_X_MAX_VECTORS]; 747 struct msix_entry msi_x_entry[NV_MSI_X_MAX_VECTORS];
748
749 /* flow control */
750 u32 pause_flags;
605}; 751};
606 752
607/* 753/*
@@ -612,12 +758,14 @@ static int max_interrupt_work = 5;
612 758
613/* 759/*
614 * Optimization can be either throuput mode or cpu mode 760 * Optimization can be either throuput mode or cpu mode
615 * 761 *
616 * Throughput Mode: Every tx and rx packet will generate an interrupt. 762 * Throughput Mode: Every tx and rx packet will generate an interrupt.
617 * CPU Mode: Interrupts are controlled by a timer. 763 * CPU Mode: Interrupts are controlled by a timer.
618 */ 764 */
619#define NV_OPTIMIZATION_MODE_THROUGHPUT 0 765enum {
620#define NV_OPTIMIZATION_MODE_CPU 1 766 NV_OPTIMIZATION_MODE_THROUGHPUT,
767 NV_OPTIMIZATION_MODE_CPU
768};
621static int optimization_mode = NV_OPTIMIZATION_MODE_THROUGHPUT; 769static int optimization_mode = NV_OPTIMIZATION_MODE_THROUGHPUT;
622 770
623/* 771/*
@@ -630,14 +778,31 @@ static int optimization_mode = NV_OPTIMIZATION_MODE_THROUGHPUT;
630static int poll_interval = -1; 778static int poll_interval = -1;
631 779
632/* 780/*
633 * Disable MSI interrupts 781 * MSI interrupts
634 */ 782 */
635static int disable_msi = 0; 783enum {
784 NV_MSI_INT_DISABLED,
785 NV_MSI_INT_ENABLED
786};
787static int msi = NV_MSI_INT_ENABLED;
636 788
637/* 789/*
638 * Disable MSIX interrupts 790 * MSIX interrupts
639 */ 791 */
640static int disable_msix = 0; 792enum {
793 NV_MSIX_INT_DISABLED,
794 NV_MSIX_INT_ENABLED
795};
796static int msix = NV_MSIX_INT_ENABLED;
797
798/*
799 * DMA 64bit
800 */
801enum {
802 NV_DMA_64BIT_DISABLED,
803 NV_DMA_64BIT_ENABLED
804};
805static int dma_64bit = NV_DMA_64BIT_ENABLED;
641 806
642static inline struct fe_priv *get_nvpriv(struct net_device *dev) 807static inline struct fe_priv *get_nvpriv(struct net_device *dev)
643{ 808{
@@ -697,7 +862,7 @@ static void setup_hw_rings(struct net_device *dev, int rxtx_flags)
697 writel((u32) cpu_to_le64(np->ring_addr), base + NvRegRxRingPhysAddr); 862 writel((u32) cpu_to_le64(np->ring_addr), base + NvRegRxRingPhysAddr);
698 } 863 }
699 if (rxtx_flags & NV_SETUP_TX_RING) { 864 if (rxtx_flags & NV_SETUP_TX_RING) {
700 writel((u32) cpu_to_le64(np->ring_addr + RX_RING*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr); 865 writel((u32) cpu_to_le64(np->ring_addr + np->rx_ring_size*sizeof(struct ring_desc)), base + NvRegTxRingPhysAddr);
701 } 866 }
702 } else { 867 } else {
703 if (rxtx_flags & NV_SETUP_RX_RING) { 868 if (rxtx_flags & NV_SETUP_RX_RING) {
@@ -705,12 +870,37 @@ static void setup_hw_rings(struct net_device *dev, int rxtx_flags)
705 writel((u32) (cpu_to_le64(np->ring_addr) >> 32), base + NvRegRxRingPhysAddrHigh); 870 writel((u32) (cpu_to_le64(np->ring_addr) >> 32), base + NvRegRxRingPhysAddrHigh);
706 } 871 }
707 if (rxtx_flags & NV_SETUP_TX_RING) { 872 if (rxtx_flags & NV_SETUP_TX_RING) {
708 writel((u32) cpu_to_le64(np->ring_addr + RX_RING*sizeof(struct ring_desc_ex)), base + NvRegTxRingPhysAddr); 873 writel((u32) cpu_to_le64(np->ring_addr + np->rx_ring_size*sizeof(struct ring_desc_ex)), base + NvRegTxRingPhysAddr);
709 writel((u32) (cpu_to_le64(np->ring_addr + RX_RING*sizeof(struct ring_desc_ex)) >> 32), base + NvRegTxRingPhysAddrHigh); 874 writel((u32) (cpu_to_le64(np->ring_addr + np->rx_ring_size*sizeof(struct ring_desc_ex)) >> 32), base + NvRegTxRingPhysAddrHigh);
710 } 875 }
711 } 876 }
712} 877}
713 878
879static void free_rings(struct net_device *dev)
880{
881 struct fe_priv *np = get_nvpriv(dev);
882
883 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
884 if(np->rx_ring.orig)
885 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (np->rx_ring_size + np->tx_ring_size),
886 np->rx_ring.orig, np->ring_addr);
887 } else {
888 if (np->rx_ring.ex)
889 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (np->rx_ring_size + np->tx_ring_size),
890 np->rx_ring.ex, np->ring_addr);
891 }
892 if (np->rx_skbuff)
893 kfree(np->rx_skbuff);
894 if (np->rx_dma)
895 kfree(np->rx_dma);
896 if (np->tx_skbuff)
897 kfree(np->tx_skbuff);
898 if (np->tx_dma)
899 kfree(np->tx_dma);
900 if (np->tx_dma_len)
901 kfree(np->tx_dma_len);
902}
903
714static int using_multi_irqs(struct net_device *dev) 904static int using_multi_irqs(struct net_device *dev)
715{ 905{
716 struct fe_priv *np = get_nvpriv(dev); 906 struct fe_priv *np = get_nvpriv(dev);
@@ -860,7 +1050,7 @@ static int phy_init(struct net_device *dev)
860 1050
861 /* set advertise register */ 1051 /* set advertise register */
862 reg = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); 1052 reg = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
863 reg |= (ADVERTISE_10HALF|ADVERTISE_10FULL|ADVERTISE_100HALF|ADVERTISE_100FULL|0x800|0x400); 1053 reg |= (ADVERTISE_10HALF|ADVERTISE_10FULL|ADVERTISE_100HALF|ADVERTISE_100FULL|ADVERTISE_PAUSE_ASYM|ADVERTISE_PAUSE_CAP);
864 if (mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg)) { 1054 if (mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg)) {
865 printk(KERN_INFO "%s: phy write to advertise failed.\n", pci_name(np->pci_dev)); 1055 printk(KERN_INFO "%s: phy write to advertise failed.\n", pci_name(np->pci_dev));
866 return PHY_ERROR; 1056 return PHY_ERROR;
@@ -873,14 +1063,14 @@ static int phy_init(struct net_device *dev)
873 mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ); 1063 mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
874 if (mii_status & PHY_GIGABIT) { 1064 if (mii_status & PHY_GIGABIT) {
875 np->gigabit = PHY_GIGABIT; 1065 np->gigabit = PHY_GIGABIT;
876 mii_control_1000 = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); 1066 mii_control_1000 = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
877 mii_control_1000 &= ~ADVERTISE_1000HALF; 1067 mii_control_1000 &= ~ADVERTISE_1000HALF;
878 if (phyinterface & PHY_RGMII) 1068 if (phyinterface & PHY_RGMII)
879 mii_control_1000 |= ADVERTISE_1000FULL; 1069 mii_control_1000 |= ADVERTISE_1000FULL;
880 else 1070 else
881 mii_control_1000 &= ~ADVERTISE_1000FULL; 1071 mii_control_1000 &= ~ADVERTISE_1000FULL;
882 1072
883 if (mii_rw(dev, np->phyaddr, MII_1000BT_CR, mii_control_1000)) { 1073 if (mii_rw(dev, np->phyaddr, MII_CTRL1000, mii_control_1000)) {
884 printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); 1074 printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev));
885 return PHY_ERROR; 1075 return PHY_ERROR;
886 } 1076 }
@@ -918,6 +1108,8 @@ static int phy_init(struct net_device *dev)
918 return PHY_ERROR; 1108 return PHY_ERROR;
919 } 1109 }
920 } 1110 }
1111 /* some phys clear out pause advertisment on reset, set it back */
1112 mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg);
921 1113
922 /* restart auto negotiation */ 1114 /* restart auto negotiation */
923 mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); 1115 mii_control = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
@@ -1047,7 +1239,7 @@ static int nv_alloc_rx(struct net_device *dev)
1047 while (np->cur_rx != refill_rx) { 1239 while (np->cur_rx != refill_rx) {
1048 struct sk_buff *skb; 1240 struct sk_buff *skb;
1049 1241
1050 nr = refill_rx % RX_RING; 1242 nr = refill_rx % np->rx_ring_size;
1051 if (np->rx_skbuff[nr] == NULL) { 1243 if (np->rx_skbuff[nr] == NULL) {
1052 1244
1053 skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD); 1245 skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
@@ -1076,7 +1268,7 @@ static int nv_alloc_rx(struct net_device *dev)
1076 refill_rx++; 1268 refill_rx++;
1077 } 1269 }
1078 np->refill_rx = refill_rx; 1270 np->refill_rx = refill_rx;
1079 if (np->cur_rx - refill_rx == RX_RING) 1271 if (np->cur_rx - refill_rx == np->rx_ring_size)
1080 return 1; 1272 return 1;
1081 return 0; 1273 return 0;
1082} 1274}
@@ -1110,14 +1302,14 @@ static void nv_do_rx_refill(unsigned long data)
1110 } 1302 }
1111} 1303}
1112 1304
1113static void nv_init_rx(struct net_device *dev) 1305static void nv_init_rx(struct net_device *dev)
1114{ 1306{
1115 struct fe_priv *np = netdev_priv(dev); 1307 struct fe_priv *np = netdev_priv(dev);
1116 int i; 1308 int i;
1117 1309
1118 np->cur_rx = RX_RING; 1310 np->cur_rx = np->rx_ring_size;
1119 np->refill_rx = 0; 1311 np->refill_rx = 0;
1120 for (i = 0; i < RX_RING; i++) 1312 for (i = 0; i < np->rx_ring_size; i++)
1121 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 1313 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1122 np->rx_ring.orig[i].FlagLen = 0; 1314 np->rx_ring.orig[i].FlagLen = 0;
1123 else 1315 else
@@ -1130,7 +1322,7 @@ static void nv_init_tx(struct net_device *dev)
1130 int i; 1322 int i;
1131 1323
1132 np->next_tx = np->nic_tx = 0; 1324 np->next_tx = np->nic_tx = 0;
1133 for (i = 0; i < TX_RING; i++) { 1325 for (i = 0; i < np->tx_ring_size; i++) {
1134 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 1326 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1135 np->tx_ring.orig[i].FlagLen = 0; 1327 np->tx_ring.orig[i].FlagLen = 0;
1136 else 1328 else
@@ -1174,8 +1366,8 @@ static void nv_drain_tx(struct net_device *dev)
1174{ 1366{
1175 struct fe_priv *np = netdev_priv(dev); 1367 struct fe_priv *np = netdev_priv(dev);
1176 unsigned int i; 1368 unsigned int i;
1177 1369
1178 for (i = 0; i < TX_RING; i++) { 1370 for (i = 0; i < np->tx_ring_size; i++) {
1179 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 1371 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1180 np->tx_ring.orig[i].FlagLen = 0; 1372 np->tx_ring.orig[i].FlagLen = 0;
1181 else 1373 else
@@ -1189,7 +1381,7 @@ static void nv_drain_rx(struct net_device *dev)
1189{ 1381{
1190 struct fe_priv *np = netdev_priv(dev); 1382 struct fe_priv *np = netdev_priv(dev);
1191 int i; 1383 int i;
1192 for (i = 0; i < RX_RING; i++) { 1384 for (i = 0; i < np->rx_ring_size; i++) {
1193 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 1385 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1194 np->rx_ring.orig[i].FlagLen = 0; 1386 np->rx_ring.orig[i].FlagLen = 0;
1195 else 1387 else
@@ -1213,7 +1405,7 @@ static void drain_ring(struct net_device *dev)
1213 1405
1214/* 1406/*
1215 * nv_start_xmit: dev->hard_start_xmit function 1407 * nv_start_xmit: dev->hard_start_xmit function
1216 * Called with dev->xmit_lock held. 1408 * Called with netif_tx_lock held.
1217 */ 1409 */
1218static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev) 1410static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1219{ 1411{
@@ -1221,8 +1413,8 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1221 u32 tx_flags = 0; 1413 u32 tx_flags = 0;
1222 u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET); 1414 u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET);
1223 unsigned int fragments = skb_shinfo(skb)->nr_frags; 1415 unsigned int fragments = skb_shinfo(skb)->nr_frags;
1224 unsigned int nr = (np->next_tx - 1) % TX_RING; 1416 unsigned int nr = (np->next_tx - 1) % np->tx_ring_size;
1225 unsigned int start_nr = np->next_tx % TX_RING; 1417 unsigned int start_nr = np->next_tx % np->tx_ring_size;
1226 unsigned int i; 1418 unsigned int i;
1227 u32 offset = 0; 1419 u32 offset = 0;
1228 u32 bcnt; 1420 u32 bcnt;
@@ -1238,7 +1430,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1238 1430
1239 spin_lock_irq(&np->lock); 1431 spin_lock_irq(&np->lock);
1240 1432
1241 if ((np->next_tx - np->nic_tx + entries - 1) > TX_LIMIT_STOP) { 1433 if ((np->next_tx - np->nic_tx + entries - 1) > np->tx_limit_stop) {
1242 spin_unlock_irq(&np->lock); 1434 spin_unlock_irq(&np->lock);
1243 netif_stop_queue(dev); 1435 netif_stop_queue(dev);
1244 return NETDEV_TX_BUSY; 1436 return NETDEV_TX_BUSY;
@@ -1247,7 +1439,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1247 /* setup the header buffer */ 1439 /* setup the header buffer */
1248 do { 1440 do {
1249 bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size; 1441 bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size;
1250 nr = (nr + 1) % TX_RING; 1442 nr = (nr + 1) % np->tx_ring_size;
1251 1443
1252 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data + offset, bcnt, 1444 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data + offset, bcnt,
1253 PCI_DMA_TODEVICE); 1445 PCI_DMA_TODEVICE);
@@ -1274,7 +1466,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1274 1466
1275 do { 1467 do {
1276 bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size; 1468 bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size;
1277 nr = (nr + 1) % TX_RING; 1469 nr = (nr + 1) % np->tx_ring_size;
1278 1470
1279 np->tx_dma[nr] = pci_map_page(np->pci_dev, frag->page, frag->page_offset+offset, bcnt, 1471 np->tx_dma[nr] = pci_map_page(np->pci_dev, frag->page, frag->page_offset+offset, bcnt,
1280 PCI_DMA_TODEVICE); 1472 PCI_DMA_TODEVICE);
@@ -1320,7 +1512,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1320 } else { 1512 } else {
1321 np->tx_ring.ex[start_nr].TxVlan = cpu_to_le32(tx_flags_vlan); 1513 np->tx_ring.ex[start_nr].TxVlan = cpu_to_le32(tx_flags_vlan);
1322 np->tx_ring.ex[start_nr].FlagLen |= cpu_to_le32(tx_flags | tx_flags_extra); 1514 np->tx_ring.ex[start_nr].FlagLen |= cpu_to_le32(tx_flags | tx_flags_extra);
1323 } 1515 }
1324 1516
1325 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet %d (entries %d) queued for transmission. tx_flags_extra: %x\n", 1517 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet %d (entries %d) queued for transmission. tx_flags_extra: %x\n",
1326 dev->name, np->next_tx, entries, tx_flags_extra); 1518 dev->name, np->next_tx, entries, tx_flags_extra);
@@ -1356,7 +1548,7 @@ static void nv_tx_done(struct net_device *dev)
1356 struct sk_buff *skb; 1548 struct sk_buff *skb;
1357 1549
1358 while (np->nic_tx != np->next_tx) { 1550 while (np->nic_tx != np->next_tx) {
1359 i = np->nic_tx % TX_RING; 1551 i = np->nic_tx % np->tx_ring_size;
1360 1552
1361 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 1553 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
1362 Flags = le32_to_cpu(np->tx_ring.orig[i].FlagLen); 1554 Flags = le32_to_cpu(np->tx_ring.orig[i].FlagLen);
@@ -1395,19 +1587,19 @@ static void nv_tx_done(struct net_device *dev)
1395 } else { 1587 } else {
1396 np->stats.tx_packets++; 1588 np->stats.tx_packets++;
1397 np->stats.tx_bytes += skb->len; 1589 np->stats.tx_bytes += skb->len;
1398 } 1590 }
1399 } 1591 }
1400 } 1592 }
1401 nv_release_txskb(dev, i); 1593 nv_release_txskb(dev, i);
1402 np->nic_tx++; 1594 np->nic_tx++;
1403 } 1595 }
1404 if (np->next_tx - np->nic_tx < TX_LIMIT_START) 1596 if (np->next_tx - np->nic_tx < np->tx_limit_start)
1405 netif_wake_queue(dev); 1597 netif_wake_queue(dev);
1406} 1598}
1407 1599
1408/* 1600/*
1409 * nv_tx_timeout: dev->tx_timeout function 1601 * nv_tx_timeout: dev->tx_timeout function
1410 * Called with dev->xmit_lock held. 1602 * Called with netif_tx_lock held.
1411 */ 1603 */
1412static void nv_tx_timeout(struct net_device *dev) 1604static void nv_tx_timeout(struct net_device *dev)
1413{ 1605{
@@ -1438,10 +1630,10 @@ static void nv_tx_timeout(struct net_device *dev)
1438 readl(base + i + 24), readl(base + i + 28)); 1630 readl(base + i + 24), readl(base + i + 28));
1439 } 1631 }
1440 printk(KERN_INFO "%s: Dumping tx ring\n", dev->name); 1632 printk(KERN_INFO "%s: Dumping tx ring\n", dev->name);
1441 for (i=0;i<TX_RING;i+= 4) { 1633 for (i=0;i<np->tx_ring_size;i+= 4) {
1442 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { 1634 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
1443 printk(KERN_INFO "%03x: %08x %08x // %08x %08x // %08x %08x // %08x %08x\n", 1635 printk(KERN_INFO "%03x: %08x %08x // %08x %08x // %08x %08x // %08x %08x\n",
1444 i, 1636 i,
1445 le32_to_cpu(np->tx_ring.orig[i].PacketBuffer), 1637 le32_to_cpu(np->tx_ring.orig[i].PacketBuffer),
1446 le32_to_cpu(np->tx_ring.orig[i].FlagLen), 1638 le32_to_cpu(np->tx_ring.orig[i].FlagLen),
1447 le32_to_cpu(np->tx_ring.orig[i+1].PacketBuffer), 1639 le32_to_cpu(np->tx_ring.orig[i+1].PacketBuffer),
@@ -1452,7 +1644,7 @@ static void nv_tx_timeout(struct net_device *dev)
1452 le32_to_cpu(np->tx_ring.orig[i+3].FlagLen)); 1644 le32_to_cpu(np->tx_ring.orig[i+3].FlagLen));
1453 } else { 1645 } else {
1454 printk(KERN_INFO "%03x: %08x %08x %08x // %08x %08x %08x // %08x %08x %08x // %08x %08x %08x\n", 1646 printk(KERN_INFO "%03x: %08x %08x %08x // %08x %08x %08x // %08x %08x %08x // %08x %08x %08x\n",
1455 i, 1647 i,
1456 le32_to_cpu(np->tx_ring.ex[i].PacketBufferHigh), 1648 le32_to_cpu(np->tx_ring.ex[i].PacketBufferHigh),
1457 le32_to_cpu(np->tx_ring.ex[i].PacketBufferLow), 1649 le32_to_cpu(np->tx_ring.ex[i].PacketBufferLow),
1458 le32_to_cpu(np->tx_ring.ex[i].FlagLen), 1650 le32_to_cpu(np->tx_ring.ex[i].FlagLen),
@@ -1550,15 +1742,14 @@ static void nv_rx_process(struct net_device *dev)
1550 u32 Flags; 1742 u32 Flags;
1551 u32 vlanflags = 0; 1743 u32 vlanflags = 0;
1552 1744
1553
1554 for (;;) { 1745 for (;;) {
1555 struct sk_buff *skb; 1746 struct sk_buff *skb;
1556 int len; 1747 int len;
1557 int i; 1748 int i;
1558 if (np->cur_rx - np->refill_rx >= RX_RING) 1749 if (np->cur_rx - np->refill_rx >= np->rx_ring_size)
1559 break; /* we scanned the whole ring - do not continue */ 1750 break; /* we scanned the whole ring - do not continue */
1560 1751
1561 i = np->cur_rx % RX_RING; 1752 i = np->cur_rx % np->rx_ring_size;
1562 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { 1753 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
1563 Flags = le32_to_cpu(np->rx_ring.orig[i].FlagLen); 1754 Flags = le32_to_cpu(np->rx_ring.orig[i].FlagLen);
1564 len = nv_descr_getlength(&np->rx_ring.orig[i], np->desc_ver); 1755 len = nv_descr_getlength(&np->rx_ring.orig[i], np->desc_ver);
@@ -1665,14 +1856,16 @@ static void nv_rx_process(struct net_device *dev)
1665 } 1856 }
1666 } 1857 }
1667 } 1858 }
1668 Flags &= NV_RX2_CHECKSUMMASK; 1859 if (np->txrxctl_bits & NVREG_TXRXCTL_RXCHECK) {
1669 if (Flags == NV_RX2_CHECKSUMOK1 || 1860 Flags &= NV_RX2_CHECKSUMMASK;
1670 Flags == NV_RX2_CHECKSUMOK2 || 1861 if (Flags == NV_RX2_CHECKSUMOK1 ||
1671 Flags == NV_RX2_CHECKSUMOK3) { 1862 Flags == NV_RX2_CHECKSUMOK2 ||
1672 dprintk(KERN_DEBUG "%s: hw checksum hit!.\n", dev->name); 1863 Flags == NV_RX2_CHECKSUMOK3) {
1673 np->rx_skbuff[i]->ip_summed = CHECKSUM_UNNECESSARY; 1864 dprintk(KERN_DEBUG "%s: hw checksum hit!.\n", dev->name);
1674 } else { 1865 np->rx_skbuff[i]->ip_summed = CHECKSUM_UNNECESSARY;
1675 dprintk(KERN_DEBUG "%s: hwchecksum miss!.\n", dev->name); 1866 } else {
1867 dprintk(KERN_DEBUG "%s: hwchecksum miss!.\n", dev->name);
1868 }
1676 } 1869 }
1677 } 1870 }
1678 /* got a valid packet - forward it to the network core */ 1871 /* got a valid packet - forward it to the network core */
@@ -1737,7 +1930,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
1737 * Changing the MTU is a rare event, it shouldn't matter. 1930 * Changing the MTU is a rare event, it shouldn't matter.
1738 */ 1931 */
1739 nv_disable_irq(dev); 1932 nv_disable_irq(dev);
1740 spin_lock_bh(&dev->xmit_lock); 1933 netif_tx_lock_bh(dev);
1741 spin_lock(&np->lock); 1934 spin_lock(&np->lock);
1742 /* stop engines */ 1935 /* stop engines */
1743 nv_stop_rx(dev); 1936 nv_stop_rx(dev);
@@ -1747,18 +1940,15 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
1747 nv_drain_rx(dev); 1940 nv_drain_rx(dev);
1748 nv_drain_tx(dev); 1941 nv_drain_tx(dev);
1749 /* reinit driver view of the rx queue */ 1942 /* reinit driver view of the rx queue */
1750 nv_init_rx(dev);
1751 nv_init_tx(dev);
1752 /* alloc new rx buffers */
1753 set_bufsize(dev); 1943 set_bufsize(dev);
1754 if (nv_alloc_rx(dev)) { 1944 if (nv_init_ring(dev)) {
1755 if (!np->in_shutdown) 1945 if (!np->in_shutdown)
1756 mod_timer(&np->oom_kick, jiffies + OOM_REFILL); 1946 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
1757 } 1947 }
1758 /* reinit nic view of the rx queue */ 1948 /* reinit nic view of the rx queue */
1759 writel(np->rx_buf_sz, base + NvRegOffloadConfig); 1949 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
1760 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING); 1950 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
1761 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), 1951 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
1762 base + NvRegRingSizes); 1952 base + NvRegRingSizes);
1763 pci_push(base); 1953 pci_push(base);
1764 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); 1954 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
@@ -1768,7 +1958,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
1768 nv_start_rx(dev); 1958 nv_start_rx(dev);
1769 nv_start_tx(dev); 1959 nv_start_tx(dev);
1770 spin_unlock(&np->lock); 1960 spin_unlock(&np->lock);
1771 spin_unlock_bh(&dev->xmit_lock); 1961 netif_tx_unlock_bh(dev);
1772 nv_enable_irq(dev); 1962 nv_enable_irq(dev);
1773 } 1963 }
1774 return 0; 1964 return 0;
@@ -1803,7 +1993,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr)
1803 memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN); 1993 memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
1804 1994
1805 if (netif_running(dev)) { 1995 if (netif_running(dev)) {
1806 spin_lock_bh(&dev->xmit_lock); 1996 netif_tx_lock_bh(dev);
1807 spin_lock_irq(&np->lock); 1997 spin_lock_irq(&np->lock);
1808 1998
1809 /* stop rx engine */ 1999 /* stop rx engine */
@@ -1815,7 +2005,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr)
1815 /* restart rx engine */ 2005 /* restart rx engine */
1816 nv_start_rx(dev); 2006 nv_start_rx(dev);
1817 spin_unlock_irq(&np->lock); 2007 spin_unlock_irq(&np->lock);
1818 spin_unlock_bh(&dev->xmit_lock); 2008 netif_tx_unlock_bh(dev);
1819 } else { 2009 } else {
1820 nv_copy_mac_to_hw(dev); 2010 nv_copy_mac_to_hw(dev);
1821 } 2011 }
@@ -1824,7 +2014,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr)
1824 2014
1825/* 2015/*
1826 * nv_set_multicast: dev->set_multicast function 2016 * nv_set_multicast: dev->set_multicast function
1827 * Called with dev->xmit_lock held. 2017 * Called with netif_tx_lock held.
1828 */ 2018 */
1829static void nv_set_multicast(struct net_device *dev) 2019static void nv_set_multicast(struct net_device *dev)
1830{ 2020{
@@ -1832,16 +2022,16 @@ static void nv_set_multicast(struct net_device *dev)
1832 u8 __iomem *base = get_hwbase(dev); 2022 u8 __iomem *base = get_hwbase(dev);
1833 u32 addr[2]; 2023 u32 addr[2];
1834 u32 mask[2]; 2024 u32 mask[2];
1835 u32 pff; 2025 u32 pff = readl(base + NvRegPacketFilterFlags) & NVREG_PFF_PAUSE_RX;
1836 2026
1837 memset(addr, 0, sizeof(addr)); 2027 memset(addr, 0, sizeof(addr));
1838 memset(mask, 0, sizeof(mask)); 2028 memset(mask, 0, sizeof(mask));
1839 2029
1840 if (dev->flags & IFF_PROMISC) { 2030 if (dev->flags & IFF_PROMISC) {
1841 printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name); 2031 printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
1842 pff = NVREG_PFF_PROMISC; 2032 pff |= NVREG_PFF_PROMISC;
1843 } else { 2033 } else {
1844 pff = NVREG_PFF_MYADDR; 2034 pff |= NVREG_PFF_MYADDR;
1845 2035
1846 if (dev->flags & IFF_ALLMULTI || dev->mc_list) { 2036 if (dev->flags & IFF_ALLMULTI || dev->mc_list) {
1847 u32 alwaysOff[2]; 2037 u32 alwaysOff[2];
@@ -1886,6 +2076,35 @@ static void nv_set_multicast(struct net_device *dev)
1886 spin_unlock_irq(&np->lock); 2076 spin_unlock_irq(&np->lock);
1887} 2077}
1888 2078
2079void nv_update_pause(struct net_device *dev, u32 pause_flags)
2080{
2081 struct fe_priv *np = netdev_priv(dev);
2082 u8 __iomem *base = get_hwbase(dev);
2083
2084 np->pause_flags &= ~(NV_PAUSEFRAME_TX_ENABLE | NV_PAUSEFRAME_RX_ENABLE);
2085
2086 if (np->pause_flags & NV_PAUSEFRAME_RX_CAPABLE) {
2087 u32 pff = readl(base + NvRegPacketFilterFlags) & ~NVREG_PFF_PAUSE_RX;
2088 if (pause_flags & NV_PAUSEFRAME_RX_ENABLE) {
2089 writel(pff|NVREG_PFF_PAUSE_RX, base + NvRegPacketFilterFlags);
2090 np->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
2091 } else {
2092 writel(pff, base + NvRegPacketFilterFlags);
2093 }
2094 }
2095 if (np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE) {
2096 u32 regmisc = readl(base + NvRegMisc1) & ~NVREG_MISC1_PAUSE_TX;
2097 if (pause_flags & NV_PAUSEFRAME_TX_ENABLE) {
2098 writel(NVREG_TX_PAUSEFRAME_ENABLE, base + NvRegTxPauseFrame);
2099 writel(regmisc|NVREG_MISC1_PAUSE_TX, base + NvRegMisc1);
2100 np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
2101 } else {
2102 writel(NVREG_TX_PAUSEFRAME_DISABLE, base + NvRegTxPauseFrame);
2103 writel(regmisc, base + NvRegMisc1);
2104 }
2105 }
2106}
2107
1889/** 2108/**
1890 * nv_update_linkspeed: Setup the MAC according to the link partner 2109 * nv_update_linkspeed: Setup the MAC according to the link partner
1891 * @dev: Network device to be configured 2110 * @dev: Network device to be configured
@@ -1901,12 +2120,14 @@ static int nv_update_linkspeed(struct net_device *dev)
1901{ 2120{
1902 struct fe_priv *np = netdev_priv(dev); 2121 struct fe_priv *np = netdev_priv(dev);
1903 u8 __iomem *base = get_hwbase(dev); 2122 u8 __iomem *base = get_hwbase(dev);
1904 int adv, lpa; 2123 int adv = 0;
2124 int lpa = 0;
2125 int adv_lpa, adv_pause, lpa_pause;
1905 int newls = np->linkspeed; 2126 int newls = np->linkspeed;
1906 int newdup = np->duplex; 2127 int newdup = np->duplex;
1907 int mii_status; 2128 int mii_status;
1908 int retval = 0; 2129 int retval = 0;
1909 u32 control_1000, status_1000, phyreg; 2130 u32 control_1000, status_1000, phyreg, pause_flags;
1910 2131
1911 /* BMSR_LSTATUS is latched, read it twice: 2132 /* BMSR_LSTATUS is latched, read it twice:
1912 * we want the current value. 2133 * we want the current value.
@@ -1952,10 +2173,15 @@ static int nv_update_linkspeed(struct net_device *dev)
1952 goto set_speed; 2173 goto set_speed;
1953 } 2174 }
1954 2175
2176 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
2177 lpa = mii_rw(dev, np->phyaddr, MII_LPA, MII_READ);
2178 dprintk(KERN_DEBUG "%s: nv_update_linkspeed: PHY advertises 0x%04x, lpa 0x%04x.\n",
2179 dev->name, adv, lpa);
2180
1955 retval = 1; 2181 retval = 1;
1956 if (np->gigabit == PHY_GIGABIT) { 2182 if (np->gigabit == PHY_GIGABIT) {
1957 control_1000 = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); 2183 control_1000 = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
1958 status_1000 = mii_rw(dev, np->phyaddr, MII_1000BT_SR, MII_READ); 2184 status_1000 = mii_rw(dev, np->phyaddr, MII_STAT1000, MII_READ);
1959 2185
1960 if ((control_1000 & ADVERTISE_1000FULL) && 2186 if ((control_1000 & ADVERTISE_1000FULL) &&
1961 (status_1000 & LPA_1000FULL)) { 2187 (status_1000 & LPA_1000FULL)) {
@@ -1967,27 +2193,22 @@ static int nv_update_linkspeed(struct net_device *dev)
1967 } 2193 }
1968 } 2194 }
1969 2195
1970 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
1971 lpa = mii_rw(dev, np->phyaddr, MII_LPA, MII_READ);
1972 dprintk(KERN_DEBUG "%s: nv_update_linkspeed: PHY advertises 0x%04x, lpa 0x%04x.\n",
1973 dev->name, adv, lpa);
1974
1975 /* FIXME: handle parallel detection properly */ 2196 /* FIXME: handle parallel detection properly */
1976 lpa = lpa & adv; 2197 adv_lpa = lpa & adv;
1977 if (lpa & LPA_100FULL) { 2198 if (adv_lpa & LPA_100FULL) {
1978 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100; 2199 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
1979 newdup = 1; 2200 newdup = 1;
1980 } else if (lpa & LPA_100HALF) { 2201 } else if (adv_lpa & LPA_100HALF) {
1981 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100; 2202 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_100;
1982 newdup = 0; 2203 newdup = 0;
1983 } else if (lpa & LPA_10FULL) { 2204 } else if (adv_lpa & LPA_10FULL) {
1984 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 2205 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
1985 newdup = 1; 2206 newdup = 1;
1986 } else if (lpa & LPA_10HALF) { 2207 } else if (adv_lpa & LPA_10HALF) {
1987 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 2208 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
1988 newdup = 0; 2209 newdup = 0;
1989 } else { 2210 } else {
1990 dprintk(KERN_DEBUG "%s: bad ability %04x - falling back to 10HD.\n", dev->name, lpa); 2211 dprintk(KERN_DEBUG "%s: bad ability %04x - falling back to 10HD.\n", dev->name, adv_lpa);
1991 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 2212 newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
1992 newdup = 0; 2213 newdup = 0;
1993 } 2214 }
@@ -2030,6 +2251,46 @@ set_speed:
2030 writel(np->linkspeed, base + NvRegLinkSpeed); 2251 writel(np->linkspeed, base + NvRegLinkSpeed);
2031 pci_push(base); 2252 pci_push(base);
2032 2253
2254 pause_flags = 0;
2255 /* setup pause frame */
2256 if (np->duplex != 0) {
2257 if (np->autoneg && np->pause_flags & NV_PAUSEFRAME_AUTONEG) {
2258 adv_pause = adv & (ADVERTISE_PAUSE_CAP| ADVERTISE_PAUSE_ASYM);
2259 lpa_pause = lpa & (LPA_PAUSE_CAP| LPA_PAUSE_ASYM);
2260
2261 switch (adv_pause) {
2262 case (ADVERTISE_PAUSE_CAP):
2263 if (lpa_pause & LPA_PAUSE_CAP) {
2264 pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
2265 if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
2266 pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
2267 }
2268 break;
2269 case (ADVERTISE_PAUSE_ASYM):
2270 if (lpa_pause == (LPA_PAUSE_CAP| LPA_PAUSE_ASYM))
2271 {
2272 pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
2273 }
2274 break;
2275 case (ADVERTISE_PAUSE_CAP| ADVERTISE_PAUSE_ASYM):
2276 if (lpa_pause & LPA_PAUSE_CAP)
2277 {
2278 pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
2279 if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
2280 pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
2281 }
2282 if (lpa_pause == LPA_PAUSE_ASYM)
2283 {
2284 pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
2285 }
2286 break;
2287 }
2288 } else {
2289 pause_flags = np->pause_flags;
2290 }
2291 }
2292 nv_update_pause(dev, pause_flags);
2293
2033 return retval; 2294 return retval;
2034} 2295}
2035 2296
@@ -2090,7 +2351,7 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
2090 spin_lock(&np->lock); 2351 spin_lock(&np->lock);
2091 nv_tx_done(dev); 2352 nv_tx_done(dev);
2092 spin_unlock(&np->lock); 2353 spin_unlock(&np->lock);
2093 2354
2094 nv_rx_process(dev); 2355 nv_rx_process(dev);
2095 if (nv_alloc_rx(dev)) { 2356 if (nv_alloc_rx(dev)) {
2096 spin_lock(&np->lock); 2357 spin_lock(&np->lock);
@@ -2098,7 +2359,7 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
2098 mod_timer(&np->oom_kick, jiffies + OOM_REFILL); 2359 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2099 spin_unlock(&np->lock); 2360 spin_unlock(&np->lock);
2100 } 2361 }
2101 2362
2102 if (events & NVREG_IRQ_LINK) { 2363 if (events & NVREG_IRQ_LINK) {
2103 spin_lock(&np->lock); 2364 spin_lock(&np->lock);
2104 nv_link_irq(dev); 2365 nv_link_irq(dev);
@@ -2163,7 +2424,7 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data, struct pt_regs *regs)
2163 spin_lock_irq(&np->lock); 2424 spin_lock_irq(&np->lock);
2164 nv_tx_done(dev); 2425 nv_tx_done(dev);
2165 spin_unlock_irq(&np->lock); 2426 spin_unlock_irq(&np->lock);
2166 2427
2167 if (events & (NVREG_IRQ_TX_ERR)) { 2428 if (events & (NVREG_IRQ_TX_ERR)) {
2168 dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", 2429 dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n",
2169 dev->name, events); 2430 dev->name, events);
@@ -2206,7 +2467,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data, struct pt_regs *regs)
2206 dprintk(KERN_DEBUG "%s: rx irq: %08x\n", dev->name, events); 2467 dprintk(KERN_DEBUG "%s: rx irq: %08x\n", dev->name, events);
2207 if (!(events & np->irqmask)) 2468 if (!(events & np->irqmask))
2208 break; 2469 break;
2209 2470
2210 nv_rx_process(dev); 2471 nv_rx_process(dev);
2211 if (nv_alloc_rx(dev)) { 2472 if (nv_alloc_rx(dev)) {
2212 spin_lock_irq(&np->lock); 2473 spin_lock_irq(&np->lock);
@@ -2214,7 +2475,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data, struct pt_regs *regs)
2214 mod_timer(&np->oom_kick, jiffies + OOM_REFILL); 2475 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2215 spin_unlock_irq(&np->lock); 2476 spin_unlock_irq(&np->lock);
2216 } 2477 }
2217 2478
2218 if (i > max_interrupt_work) { 2479 if (i > max_interrupt_work) {
2219 spin_lock_irq(&np->lock); 2480 spin_lock_irq(&np->lock);
2220 /* disable interrupts on the nic */ 2481 /* disable interrupts on the nic */
@@ -2253,7 +2514,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data, struct pt_regs *regs)
2253 dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events); 2514 dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
2254 if (!(events & np->irqmask)) 2515 if (!(events & np->irqmask))
2255 break; 2516 break;
2256 2517
2257 if (events & NVREG_IRQ_LINK) { 2518 if (events & NVREG_IRQ_LINK) {
2258 spin_lock_irq(&np->lock); 2519 spin_lock_irq(&np->lock);
2259 nv_link_irq(dev); 2520 nv_link_irq(dev);
@@ -2290,6 +2551,175 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data, struct pt_regs *regs)
2290 return IRQ_RETVAL(i); 2551 return IRQ_RETVAL(i);
2291} 2552}
2292 2553
2554static irqreturn_t nv_nic_irq_test(int foo, void *data, struct pt_regs *regs)
2555{
2556 struct net_device *dev = (struct net_device *) data;
2557 struct fe_priv *np = netdev_priv(dev);
2558 u8 __iomem *base = get_hwbase(dev);
2559 u32 events;
2560
2561 dprintk(KERN_DEBUG "%s: nv_nic_irq_test\n", dev->name);
2562
2563 if (!(np->msi_flags & NV_MSI_X_ENABLED)) {
2564 events = readl(base + NvRegIrqStatus) & NVREG_IRQSTAT_MASK;
2565 writel(NVREG_IRQ_TIMER, base + NvRegIrqStatus);
2566 } else {
2567 events = readl(base + NvRegMSIXIrqStatus) & NVREG_IRQSTAT_MASK;
2568 writel(NVREG_IRQ_TIMER, base + NvRegMSIXIrqStatus);
2569 }
2570 pci_push(base);
2571 dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
2572 if (!(events & NVREG_IRQ_TIMER))
2573 return IRQ_RETVAL(0);
2574
2575 spin_lock(&np->lock);
2576 np->intr_test = 1;
2577 spin_unlock(&np->lock);
2578
2579 dprintk(KERN_DEBUG "%s: nv_nic_irq_test completed\n", dev->name);
2580
2581 return IRQ_RETVAL(1);
2582}
2583
2584static void set_msix_vector_map(struct net_device *dev, u32 vector, u32 irqmask)
2585{
2586 u8 __iomem *base = get_hwbase(dev);
2587 int i;
2588 u32 msixmap = 0;
2589
2590 /* Each interrupt bit can be mapped to a MSIX vector (4 bits).
2591 * MSIXMap0 represents the first 8 interrupts and MSIXMap1 represents
2592 * the remaining 8 interrupts.
2593 */
2594 for (i = 0; i < 8; i++) {
2595 if ((irqmask >> i) & 0x1) {
2596 msixmap |= vector << (i << 2);
2597 }
2598 }
2599 writel(readl(base + NvRegMSIXMap0) | msixmap, base + NvRegMSIXMap0);
2600
2601 msixmap = 0;
2602 for (i = 0; i < 8; i++) {
2603 if ((irqmask >> (i + 8)) & 0x1) {
2604 msixmap |= vector << (i << 2);
2605 }
2606 }
2607 writel(readl(base + NvRegMSIXMap1) | msixmap, base + NvRegMSIXMap1);
2608}
2609
2610static int nv_request_irq(struct net_device *dev, int intr_test)
2611{
2612 struct fe_priv *np = get_nvpriv(dev);
2613 u8 __iomem *base = get_hwbase(dev);
2614 int ret = 1;
2615 int i;
2616
2617 if (np->msi_flags & NV_MSI_X_CAPABLE) {
2618 for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) {
2619 np->msi_x_entry[i].entry = i;
2620 }
2621 if ((ret = pci_enable_msix(np->pci_dev, np->msi_x_entry, (np->msi_flags & NV_MSI_X_VECTORS_MASK))) == 0) {
2622 np->msi_flags |= NV_MSI_X_ENABLED;
2623 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT && !intr_test) {
2624 /* Request irq for rx handling */
2625 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, SA_SHIRQ, dev->name, dev) != 0) {
2626 printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret);
2627 pci_disable_msix(np->pci_dev);
2628 np->msi_flags &= ~NV_MSI_X_ENABLED;
2629 goto out_err;
2630 }
2631 /* Request irq for tx handling */
2632 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, SA_SHIRQ, dev->name, dev) != 0) {
2633 printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret);
2634 pci_disable_msix(np->pci_dev);
2635 np->msi_flags &= ~NV_MSI_X_ENABLED;
2636 goto out_free_rx;
2637 }
2638 /* Request irq for link and timer handling */
2639 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, SA_SHIRQ, dev->name, dev) != 0) {
2640 printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret);
2641 pci_disable_msix(np->pci_dev);
2642 np->msi_flags &= ~NV_MSI_X_ENABLED;
2643 goto out_free_tx;
2644 }
2645 /* map interrupts to their respective vector */
2646 writel(0, base + NvRegMSIXMap0);
2647 writel(0, base + NvRegMSIXMap1);
2648 set_msix_vector_map(dev, NV_MSI_X_VECTOR_RX, NVREG_IRQ_RX_ALL);
2649 set_msix_vector_map(dev, NV_MSI_X_VECTOR_TX, NVREG_IRQ_TX_ALL);
2650 set_msix_vector_map(dev, NV_MSI_X_VECTOR_OTHER, NVREG_IRQ_OTHER);
2651 } else {
2652 /* Request irq for all interrupts */
2653 if ((!intr_test &&
2654 request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) ||
2655 (intr_test &&
2656 request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq_test, SA_SHIRQ, dev->name, dev) != 0)) {
2657 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2658 pci_disable_msix(np->pci_dev);
2659 np->msi_flags &= ~NV_MSI_X_ENABLED;
2660 goto out_err;
2661 }
2662
2663 /* map interrupts to vector 0 */
2664 writel(0, base + NvRegMSIXMap0);
2665 writel(0, base + NvRegMSIXMap1);
2666 }
2667 }
2668 }
2669 if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) {
2670 if ((ret = pci_enable_msi(np->pci_dev)) == 0) {
2671 np->msi_flags |= NV_MSI_ENABLED;
2672 if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) ||
2673 (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, SA_SHIRQ, dev->name, dev) != 0)) {
2674 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2675 pci_disable_msi(np->pci_dev);
2676 np->msi_flags &= ~NV_MSI_ENABLED;
2677 goto out_err;
2678 }
2679
2680 /* map interrupts to vector 0 */
2681 writel(0, base + NvRegMSIMap0);
2682 writel(0, base + NvRegMSIMap1);
2683 /* enable msi vector 0 */
2684 writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask);
2685 }
2686 }
2687 if (ret != 0) {
2688 if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) ||
2689 (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, SA_SHIRQ, dev->name, dev) != 0))
2690 goto out_err;
2691
2692 }
2693
2694 return 0;
2695out_free_tx:
2696 free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, dev);
2697out_free_rx:
2698 free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, dev);
2699out_err:
2700 return 1;
2701}
2702
2703static void nv_free_irq(struct net_device *dev)
2704{
2705 struct fe_priv *np = get_nvpriv(dev);
2706 int i;
2707
2708 if (np->msi_flags & NV_MSI_X_ENABLED) {
2709 for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) {
2710 free_irq(np->msi_x_entry[i].vector, dev);
2711 }
2712 pci_disable_msix(np->pci_dev);
2713 np->msi_flags &= ~NV_MSI_X_ENABLED;
2714 } else {
2715 free_irq(np->pci_dev->irq, dev);
2716 if (np->msi_flags & NV_MSI_ENABLED) {
2717 pci_disable_msi(np->pci_dev);
2718 np->msi_flags &= ~NV_MSI_ENABLED;
2719 }
2720 }
2721}
2722
2293static void nv_do_nic_poll(unsigned long data) 2723static void nv_do_nic_poll(unsigned long data)
2294{ 2724{
2295 struct net_device *dev = (struct net_device *) data; 2725 struct net_device *dev = (struct net_device *) data;
@@ -2326,7 +2756,7 @@ static void nv_do_nic_poll(unsigned long data)
2326 np->nic_poll_irq = 0; 2756 np->nic_poll_irq = 0;
2327 2757
2328 /* FIXME: Do we need synchronize_irq(dev->irq) here? */ 2758 /* FIXME: Do we need synchronize_irq(dev->irq) here? */
2329 2759
2330 writel(mask, base + NvRegIrqMask); 2760 writel(mask, base + NvRegIrqMask);
2331 pci_push(base); 2761 pci_push(base);
2332 2762
@@ -2359,6 +2789,56 @@ static void nv_poll_controller(struct net_device *dev)
2359} 2789}
2360#endif 2790#endif
2361 2791
2792static void nv_do_stats_poll(unsigned long data)
2793{
2794 struct net_device *dev = (struct net_device *) data;
2795 struct fe_priv *np = netdev_priv(dev);
2796 u8 __iomem *base = get_hwbase(dev);
2797
2798 np->estats.tx_bytes += readl(base + NvRegTxCnt);
2799 np->estats.tx_zero_rexmt += readl(base + NvRegTxZeroReXmt);
2800 np->estats.tx_one_rexmt += readl(base + NvRegTxOneReXmt);
2801 np->estats.tx_many_rexmt += readl(base + NvRegTxManyReXmt);
2802 np->estats.tx_late_collision += readl(base + NvRegTxLateCol);
2803 np->estats.tx_fifo_errors += readl(base + NvRegTxUnderflow);
2804 np->estats.tx_carrier_errors += readl(base + NvRegTxLossCarrier);
2805 np->estats.tx_excess_deferral += readl(base + NvRegTxExcessDef);
2806 np->estats.tx_retry_error += readl(base + NvRegTxRetryErr);
2807 np->estats.tx_deferral += readl(base + NvRegTxDef);
2808 np->estats.tx_packets += readl(base + NvRegTxFrame);
2809 np->estats.tx_pause += readl(base + NvRegTxPause);
2810 np->estats.rx_frame_error += readl(base + NvRegRxFrameErr);
2811 np->estats.rx_extra_byte += readl(base + NvRegRxExtraByte);
2812 np->estats.rx_late_collision += readl(base + NvRegRxLateCol);
2813 np->estats.rx_runt += readl(base + NvRegRxRunt);
2814 np->estats.rx_frame_too_long += readl(base + NvRegRxFrameTooLong);
2815 np->estats.rx_over_errors += readl(base + NvRegRxOverflow);
2816 np->estats.rx_crc_errors += readl(base + NvRegRxFCSErr);
2817 np->estats.rx_frame_align_error += readl(base + NvRegRxFrameAlignErr);
2818 np->estats.rx_length_error += readl(base + NvRegRxLenErr);
2819 np->estats.rx_unicast += readl(base + NvRegRxUnicast);
2820 np->estats.rx_multicast += readl(base + NvRegRxMulticast);
2821 np->estats.rx_broadcast += readl(base + NvRegRxBroadcast);
2822 np->estats.rx_bytes += readl(base + NvRegRxCnt);
2823 np->estats.rx_pause += readl(base + NvRegRxPause);
2824 np->estats.rx_drop_frame += readl(base + NvRegRxDropFrame);
2825 np->estats.rx_packets =
2826 np->estats.rx_unicast +
2827 np->estats.rx_multicast +
2828 np->estats.rx_broadcast;
2829 np->estats.rx_errors_total =
2830 np->estats.rx_crc_errors +
2831 np->estats.rx_over_errors +
2832 np->estats.rx_frame_error +
2833 (np->estats.rx_frame_align_error - np->estats.rx_extra_byte) +
2834 np->estats.rx_late_collision +
2835 np->estats.rx_runt +
2836 np->estats.rx_frame_too_long;
2837
2838 if (!np->in_shutdown)
2839 mod_timer(&np->stats_poll, jiffies + STATS_INTERVAL);
2840}
2841
2362static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 2842static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2363{ 2843{
2364 struct fe_priv *np = netdev_priv(dev); 2844 struct fe_priv *np = netdev_priv(dev);
@@ -2382,17 +2862,19 @@ static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
2382{ 2862{
2383 struct fe_priv *np = netdev_priv(dev); 2863 struct fe_priv *np = netdev_priv(dev);
2384 u8 __iomem *base = get_hwbase(dev); 2864 u8 __iomem *base = get_hwbase(dev);
2865 u32 flags = 0;
2385 2866
2386 spin_lock_irq(&np->lock);
2387 if (wolinfo->wolopts == 0) { 2867 if (wolinfo->wolopts == 0) {
2388 writel(0, base + NvRegWakeUpFlags);
2389 np->wolenabled = 0; 2868 np->wolenabled = 0;
2390 } 2869 } else if (wolinfo->wolopts & WAKE_MAGIC) {
2391 if (wolinfo->wolopts & WAKE_MAGIC) {
2392 writel(NVREG_WAKEUPFLAGS_ENABLE, base + NvRegWakeUpFlags);
2393 np->wolenabled = 1; 2870 np->wolenabled = 1;
2871 flags = NVREG_WAKEUPFLAGS_ENABLE;
2872 }
2873 if (netif_running(dev)) {
2874 spin_lock_irq(&np->lock);
2875 writel(flags, base + NvRegWakeUpFlags);
2876 spin_unlock_irq(&np->lock);
2394 } 2877 }
2395 spin_unlock_irq(&np->lock);
2396 return 0; 2878 return 0;
2397} 2879}
2398 2880
@@ -2406,9 +2888,17 @@ static int nv_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2406 if (!netif_running(dev)) { 2888 if (!netif_running(dev)) {
2407 /* We do not track link speed / duplex setting if the 2889 /* We do not track link speed / duplex setting if the
2408 * interface is disabled. Force a link check */ 2890 * interface is disabled. Force a link check */
2409 nv_update_linkspeed(dev); 2891 if (nv_update_linkspeed(dev)) {
2892 if (!netif_carrier_ok(dev))
2893 netif_carrier_on(dev);
2894 } else {
2895 if (netif_carrier_ok(dev))
2896 netif_carrier_off(dev);
2897 }
2410 } 2898 }
2411 switch(np->linkspeed & (NVREG_LINKSPEED_MASK)) { 2899
2900 if (netif_carrier_ok(dev)) {
2901 switch(np->linkspeed & (NVREG_LINKSPEED_MASK)) {
2412 case NVREG_LINKSPEED_10: 2902 case NVREG_LINKSPEED_10:
2413 ecmd->speed = SPEED_10; 2903 ecmd->speed = SPEED_10;
2414 break; 2904 break;
@@ -2418,10 +2908,14 @@ static int nv_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2418 case NVREG_LINKSPEED_1000: 2908 case NVREG_LINKSPEED_1000:
2419 ecmd->speed = SPEED_1000; 2909 ecmd->speed = SPEED_1000;
2420 break; 2910 break;
2911 }
2912 ecmd->duplex = DUPLEX_HALF;
2913 if (np->duplex)
2914 ecmd->duplex = DUPLEX_FULL;
2915 } else {
2916 ecmd->speed = -1;
2917 ecmd->duplex = -1;
2421 } 2918 }
2422 ecmd->duplex = DUPLEX_HALF;
2423 if (np->duplex)
2424 ecmd->duplex = DUPLEX_FULL;
2425 2919
2426 ecmd->autoneg = np->autoneg; 2920 ecmd->autoneg = np->autoneg;
2427 2921
@@ -2429,23 +2923,20 @@ static int nv_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2429 if (np->autoneg) { 2923 if (np->autoneg) {
2430 ecmd->advertising |= ADVERTISED_Autoneg; 2924 ecmd->advertising |= ADVERTISED_Autoneg;
2431 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); 2925 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
2432 } else { 2926 if (adv & ADVERTISE_10HALF)
2433 adv = np->fixed_mode; 2927 ecmd->advertising |= ADVERTISED_10baseT_Half;
2434 } 2928 if (adv & ADVERTISE_10FULL)
2435 if (adv & ADVERTISE_10HALF) 2929 ecmd->advertising |= ADVERTISED_10baseT_Full;
2436 ecmd->advertising |= ADVERTISED_10baseT_Half; 2930 if (adv & ADVERTISE_100HALF)
2437 if (adv & ADVERTISE_10FULL) 2931 ecmd->advertising |= ADVERTISED_100baseT_Half;
2438 ecmd->advertising |= ADVERTISED_10baseT_Full; 2932 if (adv & ADVERTISE_100FULL)
2439 if (adv & ADVERTISE_100HALF) 2933 ecmd->advertising |= ADVERTISED_100baseT_Full;
2440 ecmd->advertising |= ADVERTISED_100baseT_Half; 2934 if (np->gigabit == PHY_GIGABIT) {
2441 if (adv & ADVERTISE_100FULL) 2935 adv = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
2442 ecmd->advertising |= ADVERTISED_100baseT_Full; 2936 if (adv & ADVERTISE_1000FULL)
2443 if (np->autoneg && np->gigabit == PHY_GIGABIT) { 2937 ecmd->advertising |= ADVERTISED_1000baseT_Full;
2444 adv = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); 2938 }
2445 if (adv & ADVERTISE_1000FULL)
2446 ecmd->advertising |= ADVERTISED_1000baseT_Full;
2447 } 2939 }
2448
2449 ecmd->supported = (SUPPORTED_Autoneg | 2940 ecmd->supported = (SUPPORTED_Autoneg |
2450 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 2941 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
2451 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | 2942 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
@@ -2497,7 +2988,18 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2497 return -EINVAL; 2988 return -EINVAL;
2498 } 2989 }
2499 2990
2500 spin_lock_irq(&np->lock); 2991 netif_carrier_off(dev);
2992 if (netif_running(dev)) {
2993 nv_disable_irq(dev);
2994 spin_lock_bh(&dev->xmit_lock);
2995 spin_lock(&np->lock);
2996 /* stop engines */
2997 nv_stop_rx(dev);
2998 nv_stop_tx(dev);
2999 spin_unlock(&np->lock);
3000 spin_unlock_bh(&dev->xmit_lock);
3001 }
3002
2501 if (ecmd->autoneg == AUTONEG_ENABLE) { 3003 if (ecmd->autoneg == AUTONEG_ENABLE) {
2502 int adv, bmcr; 3004 int adv, bmcr;
2503 3005
@@ -2505,7 +3007,7 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2505 3007
2506 /* advertise only what has been requested */ 3008 /* advertise only what has been requested */
2507 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); 3009 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
2508 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4); 3010 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
2509 if (ecmd->advertising & ADVERTISED_10baseT_Half) 3011 if (ecmd->advertising & ADVERTISED_10baseT_Half)
2510 adv |= ADVERTISE_10HALF; 3012 adv |= ADVERTISE_10HALF;
2511 if (ecmd->advertising & ADVERTISED_10baseT_Full) 3013 if (ecmd->advertising & ADVERTISED_10baseT_Full)
@@ -2514,16 +3016,22 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2514 adv |= ADVERTISE_100HALF; 3016 adv |= ADVERTISE_100HALF;
2515 if (ecmd->advertising & ADVERTISED_100baseT_Full) 3017 if (ecmd->advertising & ADVERTISED_100baseT_Full)
2516 adv |= ADVERTISE_100FULL; 3018 adv |= ADVERTISE_100FULL;
3019 if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) /* for rx we set both advertisments but disable tx pause */
3020 adv |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
3021 if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
3022 adv |= ADVERTISE_PAUSE_ASYM;
2517 mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv); 3023 mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv);
2518 3024
2519 if (np->gigabit == PHY_GIGABIT) { 3025 if (np->gigabit == PHY_GIGABIT) {
2520 adv = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); 3026 adv = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
2521 adv &= ~ADVERTISE_1000FULL; 3027 adv &= ~ADVERTISE_1000FULL;
2522 if (ecmd->advertising & ADVERTISED_1000baseT_Full) 3028 if (ecmd->advertising & ADVERTISED_1000baseT_Full)
2523 adv |= ADVERTISE_1000FULL; 3029 adv |= ADVERTISE_1000FULL;
2524 mii_rw(dev, np->phyaddr, MII_1000BT_CR, adv); 3030 mii_rw(dev, np->phyaddr, MII_CTRL1000, adv);
2525 } 3031 }
2526 3032
3033 if (netif_running(dev))
3034 printk(KERN_INFO "%s: link down.\n", dev->name);
2527 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); 3035 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
2528 bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART); 3036 bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
2529 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr); 3037 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
@@ -2534,7 +3042,7 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2534 np->autoneg = 0; 3042 np->autoneg = 0;
2535 3043
2536 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); 3044 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
2537 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4); 3045 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
2538 if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF) 3046 if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF)
2539 adv |= ADVERTISE_10HALF; 3047 adv |= ADVERTISE_10HALF;
2540 if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL) 3048 if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL)
@@ -2543,30 +3051,49 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2543 adv |= ADVERTISE_100HALF; 3051 adv |= ADVERTISE_100HALF;
2544 if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL) 3052 if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL)
2545 adv |= ADVERTISE_100FULL; 3053 adv |= ADVERTISE_100FULL;
3054 np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE);
3055 if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) {/* for rx we set both advertisments but disable tx pause */
3056 adv |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
3057 np->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
3058 }
3059 if (np->pause_flags & NV_PAUSEFRAME_TX_REQ) {
3060 adv |= ADVERTISE_PAUSE_ASYM;
3061 np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
3062 }
2546 mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv); 3063 mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv);
2547 np->fixed_mode = adv; 3064 np->fixed_mode = adv;
2548 3065
2549 if (np->gigabit == PHY_GIGABIT) { 3066 if (np->gigabit == PHY_GIGABIT) {
2550 adv = mii_rw(dev, np->phyaddr, MII_1000BT_CR, MII_READ); 3067 adv = mii_rw(dev, np->phyaddr, MII_CTRL1000, MII_READ);
2551 adv &= ~ADVERTISE_1000FULL; 3068 adv &= ~ADVERTISE_1000FULL;
2552 mii_rw(dev, np->phyaddr, MII_1000BT_CR, adv); 3069 mii_rw(dev, np->phyaddr, MII_CTRL1000, adv);
2553 } 3070 }
2554 3071
2555 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); 3072 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
2556 bmcr |= ~(BMCR_ANENABLE|BMCR_SPEED100|BMCR_FULLDPLX); 3073 bmcr &= ~(BMCR_ANENABLE|BMCR_SPEED100|BMCR_SPEED1000|BMCR_FULLDPLX);
2557 if (adv & (ADVERTISE_10FULL|ADVERTISE_100FULL)) 3074 if (np->fixed_mode & (ADVERTISE_10FULL|ADVERTISE_100FULL))
2558 bmcr |= BMCR_FULLDPLX; 3075 bmcr |= BMCR_FULLDPLX;
2559 if (adv & (ADVERTISE_100HALF|ADVERTISE_100FULL)) 3076 if (np->fixed_mode & (ADVERTISE_100HALF|ADVERTISE_100FULL))
2560 bmcr |= BMCR_SPEED100; 3077 bmcr |= BMCR_SPEED100;
2561 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr); 3078 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
2562 3079 if (np->phy_oui == PHY_OUI_MARVELL) {
2563 if (netif_running(dev)) { 3080 /* reset the phy */
3081 if (phy_reset(dev)) {
3082 printk(KERN_INFO "%s: phy reset failed\n", dev->name);
3083 return -EINVAL;
3084 }
3085 } else if (netif_running(dev)) {
2564 /* Wait a bit and then reconfigure the nic. */ 3086 /* Wait a bit and then reconfigure the nic. */
2565 udelay(10); 3087 udelay(10);
2566 nv_linkchange(dev); 3088 nv_linkchange(dev);
2567 } 3089 }
2568 } 3090 }
2569 spin_unlock_irq(&np->lock); 3091
3092 if (netif_running(dev)) {
3093 nv_start_rx(dev);
3094 nv_start_tx(dev);
3095 nv_enable_irq(dev);
3096 }
2570 3097
2571 return 0; 3098 return 0;
2572} 3099}
@@ -2598,24 +3125,39 @@ static int nv_nway_reset(struct net_device *dev)
2598 struct fe_priv *np = netdev_priv(dev); 3125 struct fe_priv *np = netdev_priv(dev);
2599 int ret; 3126 int ret;
2600 3127
2601 spin_lock_irq(&np->lock);
2602 if (np->autoneg) { 3128 if (np->autoneg) {
2603 int bmcr; 3129 int bmcr;
2604 3130
3131 netif_carrier_off(dev);
3132 if (netif_running(dev)) {
3133 nv_disable_irq(dev);
3134 spin_lock_bh(&dev->xmit_lock);
3135 spin_lock(&np->lock);
3136 /* stop engines */
3137 nv_stop_rx(dev);
3138 nv_stop_tx(dev);
3139 spin_unlock(&np->lock);
3140 spin_unlock_bh(&dev->xmit_lock);
3141 printk(KERN_INFO "%s: link down.\n", dev->name);
3142 }
3143
2605 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ); 3144 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
2606 bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART); 3145 bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
2607 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr); 3146 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
2608 3147
3148 if (netif_running(dev)) {
3149 nv_start_rx(dev);
3150 nv_start_tx(dev);
3151 nv_enable_irq(dev);
3152 }
2609 ret = 0; 3153 ret = 0;
2610 } else { 3154 } else {
2611 ret = -EINVAL; 3155 ret = -EINVAL;
2612 } 3156 }
2613 spin_unlock_irq(&np->lock);
2614 3157
2615 return ret; 3158 return ret;
2616} 3159}
2617 3160
2618#ifdef NETIF_F_TSO
2619static int nv_set_tso(struct net_device *dev, u32 value) 3161static int nv_set_tso(struct net_device *dev, u32 value)
2620{ 3162{
2621 struct fe_priv *np = netdev_priv(dev); 3163 struct fe_priv *np = netdev_priv(dev);
@@ -2623,187 +3165,702 @@ static int nv_set_tso(struct net_device *dev, u32 value)
2623 if ((np->driver_data & DEV_HAS_CHECKSUM)) 3165 if ((np->driver_data & DEV_HAS_CHECKSUM))
2624 return ethtool_op_set_tso(dev, value); 3166 return ethtool_op_set_tso(dev, value);
2625 else 3167 else
2626 return value ? -EOPNOTSUPP : 0; 3168 return -EOPNOTSUPP;
2627} 3169}
2628#endif
2629 3170
2630static struct ethtool_ops ops = { 3171static void nv_get_ringparam(struct net_device *dev, struct ethtool_ringparam* ring)
2631 .get_drvinfo = nv_get_drvinfo, 3172{
2632 .get_link = ethtool_op_get_link, 3173 struct fe_priv *np = netdev_priv(dev);
2633 .get_wol = nv_get_wol,
2634 .set_wol = nv_set_wol,
2635 .get_settings = nv_get_settings,
2636 .set_settings = nv_set_settings,
2637 .get_regs_len = nv_get_regs_len,
2638 .get_regs = nv_get_regs,
2639 .nway_reset = nv_nway_reset,
2640 .get_perm_addr = ethtool_op_get_perm_addr,
2641#ifdef NETIF_F_TSO
2642 .get_tso = ethtool_op_get_tso,
2643 .set_tso = nv_set_tso
2644#endif
2645};
2646 3174
2647static void nv_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) 3175 ring->rx_max_pending = (np->desc_ver == DESC_VER_1) ? RING_MAX_DESC_VER_1 : RING_MAX_DESC_VER_2_3;
3176 ring->rx_mini_max_pending = 0;
3177 ring->rx_jumbo_max_pending = 0;
3178 ring->tx_max_pending = (np->desc_ver == DESC_VER_1) ? RING_MAX_DESC_VER_1 : RING_MAX_DESC_VER_2_3;
3179
3180 ring->rx_pending = np->rx_ring_size;
3181 ring->rx_mini_pending = 0;
3182 ring->rx_jumbo_pending = 0;
3183 ring->tx_pending = np->tx_ring_size;
3184}
3185
3186static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ring)
2648{ 3187{
2649 struct fe_priv *np = get_nvpriv(dev); 3188 struct fe_priv *np = netdev_priv(dev);
3189 u8 __iomem *base = get_hwbase(dev);
3190 u8 *rxtx_ring, *rx_skbuff, *tx_skbuff, *rx_dma, *tx_dma, *tx_dma_len;
3191 dma_addr_t ring_addr;
2650 3192
2651 spin_lock_irq(&np->lock); 3193 if (ring->rx_pending < RX_RING_MIN ||
3194 ring->tx_pending < TX_RING_MIN ||
3195 ring->rx_mini_pending != 0 ||
3196 ring->rx_jumbo_pending != 0 ||
3197 (np->desc_ver == DESC_VER_1 &&
3198 (ring->rx_pending > RING_MAX_DESC_VER_1 ||
3199 ring->tx_pending > RING_MAX_DESC_VER_1)) ||
3200 (np->desc_ver != DESC_VER_1 &&
3201 (ring->rx_pending > RING_MAX_DESC_VER_2_3 ||
3202 ring->tx_pending > RING_MAX_DESC_VER_2_3))) {
3203 return -EINVAL;
3204 }
2652 3205
2653 /* save vlan group */ 3206 /* allocate new rings */
2654 np->vlangrp = grp; 3207 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
3208 rxtx_ring = pci_alloc_consistent(np->pci_dev,
3209 sizeof(struct ring_desc) * (ring->rx_pending + ring->tx_pending),
3210 &ring_addr);
3211 } else {
3212 rxtx_ring = pci_alloc_consistent(np->pci_dev,
3213 sizeof(struct ring_desc_ex) * (ring->rx_pending + ring->tx_pending),
3214 &ring_addr);
3215 }
3216 rx_skbuff = kmalloc(sizeof(struct sk_buff*) * ring->rx_pending, GFP_KERNEL);
3217 rx_dma = kmalloc(sizeof(dma_addr_t) * ring->rx_pending, GFP_KERNEL);
3218 tx_skbuff = kmalloc(sizeof(struct sk_buff*) * ring->tx_pending, GFP_KERNEL);
3219 tx_dma = kmalloc(sizeof(dma_addr_t) * ring->tx_pending, GFP_KERNEL);
3220 tx_dma_len = kmalloc(sizeof(unsigned int) * ring->tx_pending, GFP_KERNEL);
3221 if (!rxtx_ring || !rx_skbuff || !rx_dma || !tx_skbuff || !tx_dma || !tx_dma_len) {
3222 /* fall back to old rings */
3223 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
3224 if(rxtx_ring)
3225 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (ring->rx_pending + ring->tx_pending),
3226 rxtx_ring, ring_addr);
3227 } else {
3228 if (rxtx_ring)
3229 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (ring->rx_pending + ring->tx_pending),
3230 rxtx_ring, ring_addr);
3231 }
3232 if (rx_skbuff)
3233 kfree(rx_skbuff);
3234 if (rx_dma)
3235 kfree(rx_dma);
3236 if (tx_skbuff)
3237 kfree(tx_skbuff);
3238 if (tx_dma)
3239 kfree(tx_dma);
3240 if (tx_dma_len)
3241 kfree(tx_dma_len);
3242 goto exit;
3243 }
2655 3244
2656 if (grp) { 3245 if (netif_running(dev)) {
2657 /* enable vlan on MAC */ 3246 nv_disable_irq(dev);
2658 np->txrxctl_bits |= NVREG_TXRXCTL_VLANSTRIP | NVREG_TXRXCTL_VLANINS; 3247 spin_lock_bh(&dev->xmit_lock);
3248 spin_lock(&np->lock);
3249 /* stop engines */
3250 nv_stop_rx(dev);
3251 nv_stop_tx(dev);
3252 nv_txrx_reset(dev);
3253 /* drain queues */
3254 nv_drain_rx(dev);
3255 nv_drain_tx(dev);
3256 /* delete queues */
3257 free_rings(dev);
3258 }
3259
3260 /* set new values */
3261 np->rx_ring_size = ring->rx_pending;
3262 np->tx_ring_size = ring->tx_pending;
3263 np->tx_limit_stop = ring->tx_pending - TX_LIMIT_DIFFERENCE;
3264 np->tx_limit_start = ring->tx_pending - TX_LIMIT_DIFFERENCE - 1;
3265 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
3266 np->rx_ring.orig = (struct ring_desc*)rxtx_ring;
3267 np->tx_ring.orig = &np->rx_ring.orig[np->rx_ring_size];
2659 } else { 3268 } else {
2660 /* disable vlan on MAC */ 3269 np->rx_ring.ex = (struct ring_desc_ex*)rxtx_ring;
2661 np->txrxctl_bits &= ~NVREG_TXRXCTL_VLANSTRIP; 3270 np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
2662 np->txrxctl_bits &= ~NVREG_TXRXCTL_VLANINS;
2663 } 3271 }
3272 np->rx_skbuff = (struct sk_buff**)rx_skbuff;
3273 np->rx_dma = (dma_addr_t*)rx_dma;
3274 np->tx_skbuff = (struct sk_buff**)tx_skbuff;
3275 np->tx_dma = (dma_addr_t*)tx_dma;
3276 np->tx_dma_len = (unsigned int*)tx_dma_len;
3277 np->ring_addr = ring_addr;
3278
3279 memset(np->rx_skbuff, 0, sizeof(struct sk_buff*) * np->rx_ring_size);
3280 memset(np->rx_dma, 0, sizeof(dma_addr_t) * np->rx_ring_size);
3281 memset(np->tx_skbuff, 0, sizeof(struct sk_buff*) * np->tx_ring_size);
3282 memset(np->tx_dma, 0, sizeof(dma_addr_t) * np->tx_ring_size);
3283 memset(np->tx_dma_len, 0, sizeof(unsigned int) * np->tx_ring_size);
2664 3284
2665 writel(np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); 3285 if (netif_running(dev)) {
3286 /* reinit driver view of the queues */
3287 set_bufsize(dev);
3288 if (nv_init_ring(dev)) {
3289 if (!np->in_shutdown)
3290 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
3291 }
2666 3292
2667 spin_unlock_irq(&np->lock); 3293 /* reinit nic view of the queues */
2668}; 3294 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
3295 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
3296 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
3297 base + NvRegRingSizes);
3298 pci_push(base);
3299 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
3300 pci_push(base);
2669 3301
2670static void nv_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 3302 /* restart engines */
3303 nv_start_rx(dev);
3304 nv_start_tx(dev);
3305 spin_unlock(&np->lock);
3306 spin_unlock_bh(&dev->xmit_lock);
3307 nv_enable_irq(dev);
3308 }
3309 return 0;
3310exit:
3311 return -ENOMEM;
3312}
3313
3314static void nv_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam* pause)
2671{ 3315{
2672 /* nothing to do */ 3316 struct fe_priv *np = netdev_priv(dev);
2673};
2674 3317
2675static void set_msix_vector_map(struct net_device *dev, u32 vector, u32 irqmask) 3318 pause->autoneg = (np->pause_flags & NV_PAUSEFRAME_AUTONEG) != 0;
3319 pause->rx_pause = (np->pause_flags & NV_PAUSEFRAME_RX_ENABLE) != 0;
3320 pause->tx_pause = (np->pause_flags & NV_PAUSEFRAME_TX_ENABLE) != 0;
3321}
3322
3323static int nv_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam* pause)
3324{
3325 struct fe_priv *np = netdev_priv(dev);
3326 int adv, bmcr;
3327
3328 if ((!np->autoneg && np->duplex == 0) ||
3329 (np->autoneg && !pause->autoneg && np->duplex == 0)) {
3330 printk(KERN_INFO "%s: can not set pause settings when forced link is in half duplex.\n",
3331 dev->name);
3332 return -EINVAL;
3333 }
3334 if (pause->tx_pause && !(np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE)) {
3335 printk(KERN_INFO "%s: hardware does not support tx pause frames.\n", dev->name);
3336 return -EINVAL;
3337 }
3338
3339 netif_carrier_off(dev);
3340 if (netif_running(dev)) {
3341 nv_disable_irq(dev);
3342 spin_lock_bh(&dev->xmit_lock);
3343 spin_lock(&np->lock);
3344 /* stop engines */
3345 nv_stop_rx(dev);
3346 nv_stop_tx(dev);
3347 spin_unlock(&np->lock);
3348 spin_unlock_bh(&dev->xmit_lock);
3349 }
3350
3351 np->pause_flags &= ~(NV_PAUSEFRAME_RX_REQ|NV_PAUSEFRAME_TX_REQ);
3352 if (pause->rx_pause)
3353 np->pause_flags |= NV_PAUSEFRAME_RX_REQ;
3354 if (pause->tx_pause)
3355 np->pause_flags |= NV_PAUSEFRAME_TX_REQ;
3356
3357 if (np->autoneg && pause->autoneg) {
3358 np->pause_flags |= NV_PAUSEFRAME_AUTONEG;
3359
3360 adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
3361 adv &= ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
3362 if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) /* for rx we set both advertisments but disable tx pause */
3363 adv |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
3364 if (np->pause_flags & NV_PAUSEFRAME_TX_REQ)
3365 adv |= ADVERTISE_PAUSE_ASYM;
3366 mii_rw(dev, np->phyaddr, MII_ADVERTISE, adv);
3367
3368 if (netif_running(dev))
3369 printk(KERN_INFO "%s: link down.\n", dev->name);
3370 bmcr = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
3371 bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
3372 mii_rw(dev, np->phyaddr, MII_BMCR, bmcr);
3373 } else {
3374 np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE);
3375 if (pause->rx_pause)
3376 np->pause_flags |= NV_PAUSEFRAME_RX_ENABLE;
3377 if (pause->tx_pause)
3378 np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
3379
3380 if (!netif_running(dev))
3381 nv_update_linkspeed(dev);
3382 else
3383 nv_update_pause(dev, np->pause_flags);
3384 }
3385
3386 if (netif_running(dev)) {
3387 nv_start_rx(dev);
3388 nv_start_tx(dev);
3389 nv_enable_irq(dev);
3390 }
3391 return 0;
3392}
3393
3394static u32 nv_get_rx_csum(struct net_device *dev)
3395{
3396 struct fe_priv *np = netdev_priv(dev);
3397 return (np->txrxctl_bits & NVREG_TXRXCTL_RXCHECK) != 0;
3398}
3399
3400static int nv_set_rx_csum(struct net_device *dev, u32 data)
2676{ 3401{
3402 struct fe_priv *np = netdev_priv(dev);
2677 u8 __iomem *base = get_hwbase(dev); 3403 u8 __iomem *base = get_hwbase(dev);
2678 int i; 3404 int retcode = 0;
2679 u32 msixmap = 0;
2680 3405
2681 /* Each interrupt bit can be mapped to a MSIX vector (4 bits). 3406 if (np->driver_data & DEV_HAS_CHECKSUM) {
2682 * MSIXMap0 represents the first 8 interrupts and MSIXMap1 represents 3407
2683 * the remaining 8 interrupts. 3408 if (((np->txrxctl_bits & NVREG_TXRXCTL_RXCHECK) && data) ||
2684 */ 3409 (!(np->txrxctl_bits & NVREG_TXRXCTL_RXCHECK) && !data)) {
2685 for (i = 0; i < 8; i++) { 3410 /* already set or unset */
2686 if ((irqmask >> i) & 0x1) { 3411 return 0;
2687 msixmap |= vector << (i << 2);
2688 } 3412 }
2689 }
2690 writel(readl(base + NvRegMSIXMap0) | msixmap, base + NvRegMSIXMap0);
2691 3413
2692 msixmap = 0; 3414 if (data) {
2693 for (i = 0; i < 8; i++) { 3415 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
2694 if ((irqmask >> (i + 8)) & 0x1) { 3416 } else if (!(np->vlanctl_bits & NVREG_VLANCONTROL_ENABLE)) {
2695 msixmap |= vector << (i << 2); 3417 np->txrxctl_bits &= ~NVREG_TXRXCTL_RXCHECK;
3418 } else {
3419 printk(KERN_INFO "Can not disable rx checksum if vlan is enabled\n");
3420 return -EINVAL;
3421 }
3422
3423 if (netif_running(dev)) {
3424 spin_lock_irq(&np->lock);
3425 writel(np->txrxctl_bits, base + NvRegTxRxControl);
3426 spin_unlock_irq(&np->lock);
2696 } 3427 }
3428 } else {
3429 return -EINVAL;
2697 } 3430 }
2698 writel(readl(base + NvRegMSIXMap1) | msixmap, base + NvRegMSIXMap1); 3431
3432 return retcode;
2699} 3433}
2700 3434
2701static int nv_request_irq(struct net_device *dev) 3435static int nv_set_tx_csum(struct net_device *dev, u32 data)
3436{
3437 struct fe_priv *np = netdev_priv(dev);
3438
3439 if (np->driver_data & DEV_HAS_CHECKSUM)
3440 return ethtool_op_set_tx_hw_csum(dev, data);
3441 else
3442 return -EOPNOTSUPP;
3443}
3444
3445static int nv_set_sg(struct net_device *dev, u32 data)
3446{
3447 struct fe_priv *np = netdev_priv(dev);
3448
3449 if (np->driver_data & DEV_HAS_CHECKSUM)
3450 return ethtool_op_set_sg(dev, data);
3451 else
3452 return -EOPNOTSUPP;
3453}
3454
3455static int nv_get_stats_count(struct net_device *dev)
3456{
3457 struct fe_priv *np = netdev_priv(dev);
3458
3459 if (np->driver_data & DEV_HAS_STATISTICS)
3460 return (sizeof(struct nv_ethtool_stats)/sizeof(u64));
3461 else
3462 return 0;
3463}
3464
3465static void nv_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *estats, u64 *buffer)
3466{
3467 struct fe_priv *np = netdev_priv(dev);
3468
3469 /* update stats */
3470 nv_do_stats_poll((unsigned long)dev);
3471
3472 memcpy(buffer, &np->estats, nv_get_stats_count(dev)*sizeof(u64));
3473}
3474
3475static int nv_self_test_count(struct net_device *dev)
3476{
3477 struct fe_priv *np = netdev_priv(dev);
3478
3479 if (np->driver_data & DEV_HAS_TEST_EXTENDED)
3480 return NV_TEST_COUNT_EXTENDED;
3481 else
3482 return NV_TEST_COUNT_BASE;
3483}
3484
3485static int nv_link_test(struct net_device *dev)
3486{
3487 struct fe_priv *np = netdev_priv(dev);
3488 int mii_status;
3489
3490 mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
3491 mii_status = mii_rw(dev, np->phyaddr, MII_BMSR, MII_READ);
3492
3493 /* check phy link status */
3494 if (!(mii_status & BMSR_LSTATUS))
3495 return 0;
3496 else
3497 return 1;
3498}
3499
3500static int nv_register_test(struct net_device *dev)
2702{ 3501{
2703 struct fe_priv *np = get_nvpriv(dev); 3502 u8 __iomem *base = get_hwbase(dev);
3503 int i = 0;
3504 u32 orig_read, new_read;
3505
3506 do {
3507 orig_read = readl(base + nv_registers_test[i].reg);
3508
3509 /* xor with mask to toggle bits */
3510 orig_read ^= nv_registers_test[i].mask;
3511
3512 writel(orig_read, base + nv_registers_test[i].reg);
3513
3514 new_read = readl(base + nv_registers_test[i].reg);
3515
3516 if ((new_read & nv_registers_test[i].mask) != (orig_read & nv_registers_test[i].mask))
3517 return 0;
3518
3519 /* restore original value */
3520 orig_read ^= nv_registers_test[i].mask;
3521 writel(orig_read, base + nv_registers_test[i].reg);
3522
3523 } while (nv_registers_test[++i].reg != 0);
3524
3525 return 1;
3526}
3527
3528static int nv_interrupt_test(struct net_device *dev)
3529{
3530 struct fe_priv *np = netdev_priv(dev);
2704 u8 __iomem *base = get_hwbase(dev); 3531 u8 __iomem *base = get_hwbase(dev);
2705 int ret = 1; 3532 int ret = 1;
2706 int i; 3533 int testcnt;
3534 u32 save_msi_flags, save_poll_interval = 0;
2707 3535
2708 if (np->msi_flags & NV_MSI_X_CAPABLE) { 3536 if (netif_running(dev)) {
2709 for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { 3537 /* free current irq */
2710 np->msi_x_entry[i].entry = i; 3538 nv_free_irq(dev);
3539 save_poll_interval = readl(base+NvRegPollingInterval);
3540 }
3541
3542 /* flag to test interrupt handler */
3543 np->intr_test = 0;
3544
3545 /* setup test irq */
3546 save_msi_flags = np->msi_flags;
3547 np->msi_flags &= ~NV_MSI_X_VECTORS_MASK;
3548 np->msi_flags |= 0x001; /* setup 1 vector */
3549 if (nv_request_irq(dev, 1))
3550 return 0;
3551
3552 /* setup timer interrupt */
3553 writel(NVREG_POLL_DEFAULT_CPU, base + NvRegPollingInterval);
3554 writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
3555
3556 nv_enable_hw_interrupts(dev, NVREG_IRQ_TIMER);
3557
3558 /* wait for at least one interrupt */
3559 msleep(100);
3560
3561 spin_lock_irq(&np->lock);
3562
3563 /* flag should be set within ISR */
3564 testcnt = np->intr_test;
3565 if (!testcnt)
3566 ret = 2;
3567
3568 nv_disable_hw_interrupts(dev, NVREG_IRQ_TIMER);
3569 if (!(np->msi_flags & NV_MSI_X_ENABLED))
3570 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
3571 else
3572 writel(NVREG_IRQSTAT_MASK, base + NvRegMSIXIrqStatus);
3573
3574 spin_unlock_irq(&np->lock);
3575
3576 nv_free_irq(dev);
3577
3578 np->msi_flags = save_msi_flags;
3579
3580 if (netif_running(dev)) {
3581 writel(save_poll_interval, base + NvRegPollingInterval);
3582 writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
3583 /* restore original irq */
3584 if (nv_request_irq(dev, 0))
3585 return 0;
3586 }
3587
3588 return ret;
3589}
3590
3591static int nv_loopback_test(struct net_device *dev)
3592{
3593 struct fe_priv *np = netdev_priv(dev);
3594 u8 __iomem *base = get_hwbase(dev);
3595 struct sk_buff *tx_skb, *rx_skb;
3596 dma_addr_t test_dma_addr;
3597 u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET);
3598 u32 Flags;
3599 int len, i, pkt_len;
3600 u8 *pkt_data;
3601 u32 filter_flags = 0;
3602 u32 misc1_flags = 0;
3603 int ret = 1;
3604
3605 if (netif_running(dev)) {
3606 nv_disable_irq(dev);
3607 filter_flags = readl(base + NvRegPacketFilterFlags);
3608 misc1_flags = readl(base + NvRegMisc1);
3609 } else {
3610 nv_txrx_reset(dev);
3611 }
3612
3613 /* reinit driver view of the rx queue */
3614 set_bufsize(dev);
3615 nv_init_ring(dev);
3616
3617 /* setup hardware for loopback */
3618 writel(NVREG_MISC1_FORCE, base + NvRegMisc1);
3619 writel(NVREG_PFF_ALWAYS | NVREG_PFF_LOOPBACK, base + NvRegPacketFilterFlags);
3620
3621 /* reinit nic view of the rx queue */
3622 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
3623 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
3624 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
3625 base + NvRegRingSizes);
3626 pci_push(base);
3627
3628 /* restart rx engine */
3629 nv_start_rx(dev);
3630 nv_start_tx(dev);
3631
3632 /* setup packet for tx */
3633 pkt_len = ETH_DATA_LEN;
3634 tx_skb = dev_alloc_skb(pkt_len);
3635 pkt_data = skb_put(tx_skb, pkt_len);
3636 for (i = 0; i < pkt_len; i++)
3637 pkt_data[i] = (u8)(i & 0xff);
3638 test_dma_addr = pci_map_single(np->pci_dev, tx_skb->data,
3639 tx_skb->end-tx_skb->data, PCI_DMA_FROMDEVICE);
3640
3641 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
3642 np->tx_ring.orig[0].PacketBuffer = cpu_to_le32(test_dma_addr);
3643 np->tx_ring.orig[0].FlagLen = cpu_to_le32((pkt_len-1) | np->tx_flags | tx_flags_extra);
3644 } else {
3645 np->tx_ring.ex[0].PacketBufferHigh = cpu_to_le64(test_dma_addr) >> 32;
3646 np->tx_ring.ex[0].PacketBufferLow = cpu_to_le64(test_dma_addr) & 0x0FFFFFFFF;
3647 np->tx_ring.ex[0].FlagLen = cpu_to_le32((pkt_len-1) | np->tx_flags | tx_flags_extra);
3648 }
3649 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
3650 pci_push(get_hwbase(dev));
3651
3652 msleep(500);
3653
3654 /* check for rx of the packet */
3655 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
3656 Flags = le32_to_cpu(np->rx_ring.orig[0].FlagLen);
3657 len = nv_descr_getlength(&np->rx_ring.orig[0], np->desc_ver);
3658
3659 } else {
3660 Flags = le32_to_cpu(np->rx_ring.ex[0].FlagLen);
3661 len = nv_descr_getlength_ex(&np->rx_ring.ex[0], np->desc_ver);
3662 }
3663
3664 if (Flags & NV_RX_AVAIL) {
3665 ret = 0;
3666 } else if (np->desc_ver == DESC_VER_1) {
3667 if (Flags & NV_RX_ERROR)
3668 ret = 0;
3669 } else {
3670 if (Flags & NV_RX2_ERROR) {
3671 ret = 0;
2711 } 3672 }
2712 if ((ret = pci_enable_msix(np->pci_dev, np->msi_x_entry, (np->msi_flags & NV_MSI_X_VECTORS_MASK))) == 0) { 3673 }
2713 np->msi_flags |= NV_MSI_X_ENABLED;
2714 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT) {
2715 /* Request irq for rx handling */
2716 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, SA_SHIRQ, dev->name, dev) != 0) {
2717 printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret);
2718 pci_disable_msix(np->pci_dev);
2719 np->msi_flags &= ~NV_MSI_X_ENABLED;
2720 goto out_err;
2721 }
2722 /* Request irq for tx handling */
2723 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, SA_SHIRQ, dev->name, dev) != 0) {
2724 printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret);
2725 pci_disable_msix(np->pci_dev);
2726 np->msi_flags &= ~NV_MSI_X_ENABLED;
2727 goto out_free_rx;
2728 }
2729 /* Request irq for link and timer handling */
2730 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, SA_SHIRQ, dev->name, dev) != 0) {
2731 printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret);
2732 pci_disable_msix(np->pci_dev);
2733 np->msi_flags &= ~NV_MSI_X_ENABLED;
2734 goto out_free_tx;
2735 }
2736 /* map interrupts to their respective vector */
2737 writel(0, base + NvRegMSIXMap0);
2738 writel(0, base + NvRegMSIXMap1);
2739 set_msix_vector_map(dev, NV_MSI_X_VECTOR_RX, NVREG_IRQ_RX_ALL);
2740 set_msix_vector_map(dev, NV_MSI_X_VECTOR_TX, NVREG_IRQ_TX_ALL);
2741 set_msix_vector_map(dev, NV_MSI_X_VECTOR_OTHER, NVREG_IRQ_OTHER);
2742 } else {
2743 /* Request irq for all interrupts */
2744 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) {
2745 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2746 pci_disable_msix(np->pci_dev);
2747 np->msi_flags &= ~NV_MSI_X_ENABLED;
2748 goto out_err;
2749 }
2750 3674
2751 /* map interrupts to vector 0 */ 3675 if (ret) {
2752 writel(0, base + NvRegMSIXMap0); 3676 if (len != pkt_len) {
2753 writel(0, base + NvRegMSIXMap1); 3677 ret = 0;
3678 dprintk(KERN_DEBUG "%s: loopback len mismatch %d vs %d\n",
3679 dev->name, len, pkt_len);
3680 } else {
3681 rx_skb = np->rx_skbuff[0];
3682 for (i = 0; i < pkt_len; i++) {
3683 if (rx_skb->data[i] != (u8)(i & 0xff)) {
3684 ret = 0;
3685 dprintk(KERN_DEBUG "%s: loopback pattern check failed on byte %d\n",
3686 dev->name, i);
3687 break;
3688 }
2754 } 3689 }
2755 } 3690 }
3691 } else {
3692 dprintk(KERN_DEBUG "%s: loopback - did not receive test packet\n", dev->name);
2756 } 3693 }
2757 if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) { 3694
2758 if ((ret = pci_enable_msi(np->pci_dev)) == 0) { 3695 pci_unmap_page(np->pci_dev, test_dma_addr,
2759 np->msi_flags |= NV_MSI_ENABLED; 3696 tx_skb->end-tx_skb->data,
2760 if (request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) { 3697 PCI_DMA_TODEVICE);
2761 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret); 3698 dev_kfree_skb_any(tx_skb);
2762 pci_disable_msi(np->pci_dev); 3699
2763 np->msi_flags &= ~NV_MSI_ENABLED; 3700 /* stop engines */
2764 goto out_err; 3701 nv_stop_rx(dev);
3702 nv_stop_tx(dev);
3703 nv_txrx_reset(dev);
3704 /* drain rx queue */
3705 nv_drain_rx(dev);
3706 nv_drain_tx(dev);
3707
3708 if (netif_running(dev)) {
3709 writel(misc1_flags, base + NvRegMisc1);
3710 writel(filter_flags, base + NvRegPacketFilterFlags);
3711 nv_enable_irq(dev);
3712 }
3713
3714 return ret;
3715}
3716
3717static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64 *buffer)
3718{
3719 struct fe_priv *np = netdev_priv(dev);
3720 u8 __iomem *base = get_hwbase(dev);
3721 int result;
3722 memset(buffer, 0, nv_self_test_count(dev)*sizeof(u64));
3723
3724 if (!nv_link_test(dev)) {
3725 test->flags |= ETH_TEST_FL_FAILED;
3726 buffer[0] = 1;
3727 }
3728
3729 if (test->flags & ETH_TEST_FL_OFFLINE) {
3730 if (netif_running(dev)) {
3731 netif_stop_queue(dev);
3732 spin_lock_bh(&dev->xmit_lock);
3733 spin_lock_irq(&np->lock);
3734 nv_disable_hw_interrupts(dev, np->irqmask);
3735 if (!(np->msi_flags & NV_MSI_X_ENABLED)) {
3736 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
3737 } else {
3738 writel(NVREG_IRQSTAT_MASK, base + NvRegMSIXIrqStatus);
2765 } 3739 }
3740 /* stop engines */
3741 nv_stop_rx(dev);
3742 nv_stop_tx(dev);
3743 nv_txrx_reset(dev);
3744 /* drain rx queue */
3745 nv_drain_rx(dev);
3746 nv_drain_tx(dev);
3747 spin_unlock_irq(&np->lock);
3748 spin_unlock_bh(&dev->xmit_lock);
3749 }
2766 3750
2767 /* map interrupts to vector 0 */ 3751 if (!nv_register_test(dev)) {
2768 writel(0, base + NvRegMSIMap0); 3752 test->flags |= ETH_TEST_FL_FAILED;
2769 writel(0, base + NvRegMSIMap1); 3753 buffer[1] = 1;
2770 /* enable msi vector 0 */ 3754 }
2771 writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask); 3755
3756 result = nv_interrupt_test(dev);
3757 if (result != 1) {
3758 test->flags |= ETH_TEST_FL_FAILED;
3759 buffer[2] = 1;
3760 }
3761 if (result == 0) {
3762 /* bail out */
3763 return;
3764 }
3765
3766 if (!nv_loopback_test(dev)) {
3767 test->flags |= ETH_TEST_FL_FAILED;
3768 buffer[3] = 1;
3769 }
3770
3771 if (netif_running(dev)) {
3772 /* reinit driver view of the rx queue */
3773 set_bufsize(dev);
3774 if (nv_init_ring(dev)) {
3775 if (!np->in_shutdown)
3776 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
3777 }
3778 /* reinit nic view of the rx queue */
3779 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
3780 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
3781 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
3782 base + NvRegRingSizes);
3783 pci_push(base);
3784 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
3785 pci_push(base);
3786 /* restart rx engine */
3787 nv_start_rx(dev);
3788 nv_start_tx(dev);
3789 netif_start_queue(dev);
3790 nv_enable_hw_interrupts(dev, np->irqmask);
2772 } 3791 }
2773 } 3792 }
2774 if (ret != 0) { 3793}
2775 if (request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0)
2776 goto out_err;
2777 }
2778 3794
2779 return 0; 3795static void nv_get_strings(struct net_device *dev, u32 stringset, u8 *buffer)
2780out_free_tx: 3796{
2781 free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, dev); 3797 switch (stringset) {
2782out_free_rx: 3798 case ETH_SS_STATS:
2783 free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, dev); 3799 memcpy(buffer, &nv_estats_str, nv_get_stats_count(dev)*sizeof(struct nv_ethtool_str));
2784out_err: 3800 break;
2785 return 1; 3801 case ETH_SS_TEST:
3802 memcpy(buffer, &nv_etests_str, nv_self_test_count(dev)*sizeof(struct nv_ethtool_str));
3803 break;
3804 }
2786} 3805}
2787 3806
2788static void nv_free_irq(struct net_device *dev) 3807static struct ethtool_ops ops = {
3808 .get_drvinfo = nv_get_drvinfo,
3809 .get_link = ethtool_op_get_link,
3810 .get_wol = nv_get_wol,
3811 .set_wol = nv_set_wol,
3812 .get_settings = nv_get_settings,
3813 .set_settings = nv_set_settings,
3814 .get_regs_len = nv_get_regs_len,
3815 .get_regs = nv_get_regs,
3816 .nway_reset = nv_nway_reset,
3817 .get_perm_addr = ethtool_op_get_perm_addr,
3818 .get_tso = ethtool_op_get_tso,
3819 .set_tso = nv_set_tso,
3820 .get_ringparam = nv_get_ringparam,
3821 .set_ringparam = nv_set_ringparam,
3822 .get_pauseparam = nv_get_pauseparam,
3823 .set_pauseparam = nv_set_pauseparam,
3824 .get_rx_csum = nv_get_rx_csum,
3825 .set_rx_csum = nv_set_rx_csum,
3826 .get_tx_csum = ethtool_op_get_tx_csum,
3827 .set_tx_csum = nv_set_tx_csum,
3828 .get_sg = ethtool_op_get_sg,
3829 .set_sg = nv_set_sg,
3830 .get_strings = nv_get_strings,
3831 .get_stats_count = nv_get_stats_count,
3832 .get_ethtool_stats = nv_get_ethtool_stats,
3833 .self_test_count = nv_self_test_count,
3834 .self_test = nv_self_test,
3835};
3836
3837static void nv_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
2789{ 3838{
2790 struct fe_priv *np = get_nvpriv(dev); 3839 struct fe_priv *np = get_nvpriv(dev);
2791 int i;
2792 3840
2793 if (np->msi_flags & NV_MSI_X_ENABLED) { 3841 spin_lock_irq(&np->lock);
2794 for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { 3842
2795 free_irq(np->msi_x_entry[i].vector, dev); 3843 /* save vlan group */
2796 } 3844 np->vlangrp = grp;
2797 pci_disable_msix(np->pci_dev); 3845
2798 np->msi_flags &= ~NV_MSI_X_ENABLED; 3846 if (grp) {
3847 /* enable vlan on MAC */
3848 np->txrxctl_bits |= NVREG_TXRXCTL_VLANSTRIP | NVREG_TXRXCTL_VLANINS;
2799 } else { 3849 } else {
2800 free_irq(np->pci_dev->irq, dev); 3850 /* disable vlan on MAC */
2801 if (np->msi_flags & NV_MSI_ENABLED) { 3851 np->txrxctl_bits &= ~NVREG_TXRXCTL_VLANSTRIP;
2802 pci_disable_msi(np->pci_dev); 3852 np->txrxctl_bits &= ~NVREG_TXRXCTL_VLANINS;
2803 np->msi_flags &= ~NV_MSI_ENABLED;
2804 }
2805 } 3853 }
2806} 3854
3855 writel(np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
3856
3857 spin_unlock_irq(&np->lock);
3858};
3859
3860static void nv_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
3861{
3862 /* nothing to do */
3863};
2807 3864
2808static int nv_open(struct net_device *dev) 3865static int nv_open(struct net_device *dev)
2809{ 3866{
@@ -2829,6 +3886,9 @@ static int nv_open(struct net_device *dev)
2829 3886
2830 writel(0, base + NvRegAdapterControl); 3887 writel(0, base + NvRegAdapterControl);
2831 3888
3889 if (np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE)
3890 writel(NVREG_TX_PAUSEFRAME_DISABLE, base + NvRegTxPauseFrame);
3891
2832 /* 2) initialize descriptor rings */ 3892 /* 2) initialize descriptor rings */
2833 set_bufsize(dev); 3893 set_bufsize(dev);
2834 oom = nv_init_ring(dev); 3894 oom = nv_init_ring(dev);
@@ -2845,7 +3905,7 @@ static int nv_open(struct net_device *dev)
2845 3905
2846 /* 4) give hw rings */ 3906 /* 4) give hw rings */
2847 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING); 3907 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
2848 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), 3908 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
2849 base + NvRegRingSizes); 3909 base + NvRegRingSizes);
2850 3910
2851 /* 5) continue setup */ 3911 /* 5) continue setup */
@@ -2887,7 +3947,8 @@ static int nv_open(struct net_device *dev)
2887 base + NvRegAdapterControl); 3947 base + NvRegAdapterControl);
2888 writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed); 3948 writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed);
2889 writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4); 3949 writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4);
2890 writel(NVREG_WAKEUPFLAGS_VAL, base + NvRegWakeUpFlags); 3950 if (np->wolenabled)
3951 writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags);
2891 3952
2892 i = readl(base + NvRegPowerState); 3953 i = readl(base + NvRegPowerState);
2893 if ( (i & NVREG_POWERSTATE_POWEREDUP) == 0) 3954 if ( (i & NVREG_POWERSTATE_POWEREDUP) == 0)
@@ -2903,7 +3964,7 @@ static int nv_open(struct net_device *dev)
2903 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); 3964 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
2904 pci_push(base); 3965 pci_push(base);
2905 3966
2906 if (nv_request_irq(dev)) { 3967 if (nv_request_irq(dev, 0)) {
2907 goto out_drain; 3968 goto out_drain;
2908 } 3969 }
2909 3970
@@ -2940,6 +4001,11 @@ static int nv_open(struct net_device *dev)
2940 } 4001 }
2941 if (oom) 4002 if (oom)
2942 mod_timer(&np->oom_kick, jiffies + OOM_REFILL); 4003 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
4004
4005 /* start statistics timer */
4006 if (np->driver_data & DEV_HAS_STATISTICS)
4007 mod_timer(&np->stats_poll, jiffies + STATS_INTERVAL);
4008
2943 spin_unlock_irq(&np->lock); 4009 spin_unlock_irq(&np->lock);
2944 4010
2945 return 0; 4011 return 0;
@@ -2960,6 +4026,7 @@ static int nv_close(struct net_device *dev)
2960 4026
2961 del_timer_sync(&np->oom_kick); 4027 del_timer_sync(&np->oom_kick);
2962 del_timer_sync(&np->nic_poll); 4028 del_timer_sync(&np->nic_poll);
4029 del_timer_sync(&np->stats_poll);
2963 4030
2964 netif_stop_queue(dev); 4031 netif_stop_queue(dev);
2965 spin_lock_irq(&np->lock); 4032 spin_lock_irq(&np->lock);
@@ -3019,6 +4086,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3019 init_timer(&np->nic_poll); 4086 init_timer(&np->nic_poll);
3020 np->nic_poll.data = (unsigned long) dev; 4087 np->nic_poll.data = (unsigned long) dev;
3021 np->nic_poll.function = &nv_do_nic_poll; /* timer handler */ 4088 np->nic_poll.function = &nv_do_nic_poll; /* timer handler */
4089 init_timer(&np->stats_poll);
4090 np->stats_poll.data = (unsigned long) dev;
4091 np->stats_poll.function = &nv_do_stats_poll; /* timer handler */
3022 4092
3023 err = pci_enable_device(pci_dev); 4093 err = pci_enable_device(pci_dev);
3024 if (err) { 4094 if (err) {
@@ -3033,7 +4103,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3033 if (err < 0) 4103 if (err < 0)
3034 goto out_disable; 4104 goto out_disable;
3035 4105
3036 if (id->driver_data & (DEV_HAS_VLAN|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL)) 4106 if (id->driver_data & (DEV_HAS_VLAN|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_STATISTICS))
3037 np->register_size = NV_PCI_REGSZ_VER2; 4107 np->register_size = NV_PCI_REGSZ_VER2;
3038 else 4108 else
3039 np->register_size = NV_PCI_REGSZ_VER1; 4109 np->register_size = NV_PCI_REGSZ_VER1;
@@ -3065,16 +4135,18 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3065 /* packet format 3: supports 40-bit addressing */ 4135 /* packet format 3: supports 40-bit addressing */
3066 np->desc_ver = DESC_VER_3; 4136 np->desc_ver = DESC_VER_3;
3067 np->txrxctl_bits = NVREG_TXRXCTL_DESC_3; 4137 np->txrxctl_bits = NVREG_TXRXCTL_DESC_3;
3068 if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK)) { 4138 if (dma_64bit) {
3069 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", 4139 if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK)) {
3070 pci_name(pci_dev)); 4140 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n",
3071 } else { 4141 pci_name(pci_dev));
3072 dev->features |= NETIF_F_HIGHDMA; 4142 } else {
3073 printk(KERN_INFO "forcedeth: using HIGHDMA\n"); 4143 dev->features |= NETIF_F_HIGHDMA;
3074 } 4144 printk(KERN_INFO "forcedeth: using HIGHDMA\n");
3075 if (pci_set_consistent_dma_mask(pci_dev, 0x0000007fffffffffULL)) { 4145 }
3076 printk(KERN_INFO "forcedeth: 64-bit DMA (consistent) failed for device %s.\n", 4146 if (pci_set_consistent_dma_mask(pci_dev, DMA_39BIT_MASK)) {
3077 pci_name(pci_dev)); 4147 printk(KERN_INFO "forcedeth: 64-bit DMA (consistent) failed, using 32-bit ring buffers for device %s.\n",
4148 pci_name(pci_dev));
4149 }
3078 } 4150 }
3079 } else if (id->driver_data & DEV_HAS_LARGEDESC) { 4151 } else if (id->driver_data & DEV_HAS_LARGEDESC) {
3080 /* packet format 2: supports jumbo frames */ 4152 /* packet format 2: supports jumbo frames */
@@ -3107,13 +4179,19 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3107 } 4179 }
3108 4180
3109 np->msi_flags = 0; 4181 np->msi_flags = 0;
3110 if ((id->driver_data & DEV_HAS_MSI) && !disable_msi) { 4182 if ((id->driver_data & DEV_HAS_MSI) && msi) {
3111 np->msi_flags |= NV_MSI_CAPABLE; 4183 np->msi_flags |= NV_MSI_CAPABLE;
3112 } 4184 }
3113 if ((id->driver_data & DEV_HAS_MSI_X) && !disable_msix) { 4185 if ((id->driver_data & DEV_HAS_MSI_X) && msix) {
3114 np->msi_flags |= NV_MSI_X_CAPABLE; 4186 np->msi_flags |= NV_MSI_X_CAPABLE;
3115 } 4187 }
3116 4188
4189 np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG;
4190 if (id->driver_data & DEV_HAS_PAUSEFRAME_TX) {
4191 np->pause_flags |= NV_PAUSEFRAME_TX_CAPABLE | NV_PAUSEFRAME_TX_REQ;
4192 }
4193
4194
3117 err = -ENOMEM; 4195 err = -ENOMEM;
3118 np->base = ioremap(addr, np->register_size); 4196 np->base = ioremap(addr, np->register_size);
3119 if (!np->base) 4197 if (!np->base)
@@ -3122,21 +4200,38 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3122 4200
3123 dev->irq = pci_dev->irq; 4201 dev->irq = pci_dev->irq;
3124 4202
4203 np->rx_ring_size = RX_RING_DEFAULT;
4204 np->tx_ring_size = TX_RING_DEFAULT;
4205 np->tx_limit_stop = np->tx_ring_size - TX_LIMIT_DIFFERENCE;
4206 np->tx_limit_start = np->tx_ring_size - TX_LIMIT_DIFFERENCE - 1;
4207
3125 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { 4208 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
3126 np->rx_ring.orig = pci_alloc_consistent(pci_dev, 4209 np->rx_ring.orig = pci_alloc_consistent(pci_dev,
3127 sizeof(struct ring_desc) * (RX_RING + TX_RING), 4210 sizeof(struct ring_desc) * (np->rx_ring_size + np->tx_ring_size),
3128 &np->ring_addr); 4211 &np->ring_addr);
3129 if (!np->rx_ring.orig) 4212 if (!np->rx_ring.orig)
3130 goto out_unmap; 4213 goto out_unmap;
3131 np->tx_ring.orig = &np->rx_ring.orig[RX_RING]; 4214 np->tx_ring.orig = &np->rx_ring.orig[np->rx_ring_size];
3132 } else { 4215 } else {
3133 np->rx_ring.ex = pci_alloc_consistent(pci_dev, 4216 np->rx_ring.ex = pci_alloc_consistent(pci_dev,
3134 sizeof(struct ring_desc_ex) * (RX_RING + TX_RING), 4217 sizeof(struct ring_desc_ex) * (np->rx_ring_size + np->tx_ring_size),
3135 &np->ring_addr); 4218 &np->ring_addr);
3136 if (!np->rx_ring.ex) 4219 if (!np->rx_ring.ex)
3137 goto out_unmap; 4220 goto out_unmap;
3138 np->tx_ring.ex = &np->rx_ring.ex[RX_RING]; 4221 np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
3139 } 4222 }
4223 np->rx_skbuff = kmalloc(sizeof(struct sk_buff*) * np->rx_ring_size, GFP_KERNEL);
4224 np->rx_dma = kmalloc(sizeof(dma_addr_t) * np->rx_ring_size, GFP_KERNEL);
4225 np->tx_skbuff = kmalloc(sizeof(struct sk_buff*) * np->tx_ring_size, GFP_KERNEL);
4226 np->tx_dma = kmalloc(sizeof(dma_addr_t) * np->tx_ring_size, GFP_KERNEL);
4227 np->tx_dma_len = kmalloc(sizeof(unsigned int) * np->tx_ring_size, GFP_KERNEL);
4228 if (!np->rx_skbuff || !np->rx_dma || !np->tx_skbuff || !np->tx_dma || !np->tx_dma_len)
4229 goto out_freering;
4230 memset(np->rx_skbuff, 0, sizeof(struct sk_buff*) * np->rx_ring_size);
4231 memset(np->rx_dma, 0, sizeof(dma_addr_t) * np->rx_ring_size);
4232 memset(np->tx_skbuff, 0, sizeof(struct sk_buff*) * np->tx_ring_size);
4233 memset(np->tx_dma, 0, sizeof(dma_addr_t) * np->tx_ring_size);
4234 memset(np->tx_dma_len, 0, sizeof(unsigned int) * np->tx_ring_size);
3140 4235
3141 dev->open = nv_open; 4236 dev->open = nv_open;
3142 dev->stop = nv_close; 4237 dev->stop = nv_close;
@@ -3258,9 +4353,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3258 if (i == 33) { 4353 if (i == 33) {
3259 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n", 4354 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n",
3260 pci_name(pci_dev)); 4355 pci_name(pci_dev));
3261 goto out_freering; 4356 goto out_error;
3262 } 4357 }
3263 4358
3264 /* reset it */ 4359 /* reset it */
3265 phy_init(dev); 4360 phy_init(dev);
3266 4361
@@ -3272,7 +4367,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3272 err = register_netdev(dev); 4367 err = register_netdev(dev);
3273 if (err) { 4368 if (err) {
3274 printk(KERN_INFO "forcedeth: unable to register netdev: %d\n", err); 4369 printk(KERN_INFO "forcedeth: unable to register netdev: %d\n", err);
3275 goto out_freering; 4370 goto out_error;
3276 } 4371 }
3277 printk(KERN_INFO "%s: forcedeth.c: subsystem: %05x:%04x bound to %s\n", 4372 printk(KERN_INFO "%s: forcedeth.c: subsystem: %05x:%04x bound to %s\n",
3278 dev->name, pci_dev->subsystem_vendor, pci_dev->subsystem_device, 4373 dev->name, pci_dev->subsystem_vendor, pci_dev->subsystem_device,
@@ -3280,14 +4375,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
3280 4375
3281 return 0; 4376 return 0;
3282 4377
3283out_freering: 4378out_error:
3284 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
3285 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING),
3286 np->rx_ring.orig, np->ring_addr);
3287 else
3288 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (RX_RING + TX_RING),
3289 np->rx_ring.ex, np->ring_addr);
3290 pci_set_drvdata(pci_dev, NULL); 4379 pci_set_drvdata(pci_dev, NULL);
4380out_freering:
4381 free_rings(dev);
3291out_unmap: 4382out_unmap:
3292 iounmap(get_hwbase(dev)); 4383 iounmap(get_hwbase(dev));
3293out_relreg: 4384out_relreg:
@@ -3303,15 +4394,11 @@ out:
3303static void __devexit nv_remove(struct pci_dev *pci_dev) 4394static void __devexit nv_remove(struct pci_dev *pci_dev)
3304{ 4395{
3305 struct net_device *dev = pci_get_drvdata(pci_dev); 4396 struct net_device *dev = pci_get_drvdata(pci_dev);
3306 struct fe_priv *np = netdev_priv(dev);
3307 4397
3308 unregister_netdev(dev); 4398 unregister_netdev(dev);
3309 4399
3310 /* free all structures */ 4400 /* free all structures */
3311 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 4401 free_rings(dev);
3312 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc) * (RX_RING + TX_RING), np->rx_ring.orig, np->ring_addr);
3313 else
3314 pci_free_consistent(np->pci_dev, sizeof(struct ring_desc_ex) * (RX_RING + TX_RING), np->rx_ring.ex, np->ring_addr);
3315 iounmap(get_hwbase(dev)); 4402 iounmap(get_hwbase(dev));
3316 pci_release_regions(pci_dev); 4403 pci_release_regions(pci_dev);
3317 pci_disable_device(pci_dev); 4404 pci_disable_device(pci_dev);
@@ -3374,11 +4461,43 @@ static struct pci_device_id pci_tbl[] = {
3374 }, 4461 },
3375 { /* MCP55 Ethernet Controller */ 4462 { /* MCP55 Ethernet Controller */
3376 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), 4463 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
3377 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL, 4464 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
3378 }, 4465 },
3379 { /* MCP55 Ethernet Controller */ 4466 { /* MCP55 Ethernet Controller */
3380 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), 4467 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
3381 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL, 4468 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4469 },
4470 { /* MCP61 Ethernet Controller */
4471 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16),
4472 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4473 },
4474 { /* MCP61 Ethernet Controller */
4475 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17),
4476 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4477 },
4478 { /* MCP61 Ethernet Controller */
4479 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18),
4480 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4481 },
4482 { /* MCP61 Ethernet Controller */
4483 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19),
4484 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4485 },
4486 { /* MCP65 Ethernet Controller */
4487 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20),
4488 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4489 },
4490 { /* MCP65 Ethernet Controller */
4491 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21),
4492 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4493 },
4494 { /* MCP65 Ethernet Controller */
4495 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22),
4496 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
4497 },
4498 { /* MCP65 Ethernet Controller */
4499 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23),
4500 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS|DEV_HAS_TEST_EXTENDED,
3382 }, 4501 },
3383 {0,}, 4502 {0,},
3384}; 4503};
@@ -3408,10 +4527,12 @@ module_param(optimization_mode, int, 0);
3408MODULE_PARM_DESC(optimization_mode, "In throughput mode (0), every tx & rx packet will generate an interrupt. In CPU mode (1), interrupts are controlled by a timer."); 4527MODULE_PARM_DESC(optimization_mode, "In throughput mode (0), every tx & rx packet will generate an interrupt. In CPU mode (1), interrupts are controlled by a timer.");
3409module_param(poll_interval, int, 0); 4528module_param(poll_interval, int, 0);
3410MODULE_PARM_DESC(poll_interval, "Interval determines how frequent timer interrupt is generated by [(time_in_micro_secs * 100) / (2^10)]. Min is 0 and Max is 65535."); 4529MODULE_PARM_DESC(poll_interval, "Interval determines how frequent timer interrupt is generated by [(time_in_micro_secs * 100) / (2^10)]. Min is 0 and Max is 65535.");
3411module_param(disable_msi, int, 0); 4530module_param(msi, int, 0);
3412MODULE_PARM_DESC(disable_msi, "Disable MSI interrupts by setting to 1."); 4531MODULE_PARM_DESC(msi, "MSI interrupts are enabled by setting to 1 and disabled by setting to 0.");
3413module_param(disable_msix, int, 0); 4532module_param(msix, int, 0);
3414MODULE_PARM_DESC(disable_msix, "Disable MSIX interrupts by setting to 1."); 4533MODULE_PARM_DESC(msix, "MSIX interrupts are enabled by setting to 1 and disabled by setting to 0.");
4534module_param(dma_64bit, int, 0);
4535MODULE_PARM_DESC(dma_64bit, "High DMA is enabled by setting to 1 and disabled by setting to 0.");
3415 4536
3416MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>"); 4537MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>");
3417MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver"); 4538MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver");
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 102c1f0b90da..d12605f0ac7c 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -308,9 +308,9 @@ static int sp_set_mac_address(struct net_device *dev, void *addr)
308{ 308{
309 struct sockaddr_ax25 *sa = addr; 309 struct sockaddr_ax25 *sa = addr;
310 310
311 spin_lock_irq(&dev->xmit_lock); 311 netif_tx_lock_bh(dev);
312 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN); 312 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN);
313 spin_unlock_irq(&dev->xmit_lock); 313 netif_tx_unlock_bh(dev);
314 314
315 return 0; 315 return 0;
316} 316}
@@ -767,9 +767,9 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
767 break; 767 break;
768 } 768 }
769 769
770 spin_lock_irq(&dev->xmit_lock); 770 netif_tx_lock_bh(dev);
771 memcpy(dev->dev_addr, &addr, AX25_ADDR_LEN); 771 memcpy(dev->dev_addr, &addr, AX25_ADDR_LEN);
772 spin_unlock_irq(&dev->xmit_lock); 772 netif_tx_unlock_bh(dev);
773 773
774 err = 0; 774 err = 0;
775 break; 775 break;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index d81a8e1eeb8d..3ebbbe56b6e9 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -357,9 +357,9 @@ static int ax_set_mac_address(struct net_device *dev, void *addr)
357{ 357{
358 struct sockaddr_ax25 *sa = addr; 358 struct sockaddr_ax25 *sa = addr;
359 359
360 spin_lock_irq(&dev->xmit_lock); 360 netif_tx_lock_bh(dev);
361 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN); 361 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN);
362 spin_unlock_irq(&dev->xmit_lock); 362 netif_tx_unlock_bh(dev);
363 363
364 return 0; 364 return 0;
365} 365}
@@ -886,9 +886,9 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
886 break; 886 break;
887 } 887 }
888 888
889 spin_lock_irq(&dev->xmit_lock); 889 netif_tx_lock_bh(dev);
890 memcpy(dev->dev_addr, addr, AX25_ADDR_LEN); 890 memcpy(dev->dev_addr, addr, AX25_ADDR_LEN);
891 spin_unlock_irq(&dev->xmit_lock); 891 netif_tx_unlock_bh(dev);
892 892
893 err = 0; 893 err = 0;
894 break; 894 break;
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 0d7a6250e346..e26a3e407d70 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -446,7 +446,7 @@ MODULE_LICENSE("GPL");
446 446
447/* This is set up so that only a single autoprobe takes place per call. 447/* This is set up so that only a single autoprobe takes place per call.
448ISA device autoprobes on a running machine are not recommended. */ 448ISA device autoprobes on a running machine are not recommended. */
449int 449int __init
450init_module(void) 450init_module(void)
451{ 451{
452 struct net_device *dev; 452 struct net_device *dev;
diff --git a/drivers/net/hp.c b/drivers/net/hp.c
index cf9fb3698a6b..551a71b3c5fd 100644
--- a/drivers/net/hp.c
+++ b/drivers/net/hp.c
@@ -384,7 +384,7 @@ hp_block_output(struct net_device *dev, int count,
384} 384}
385 385
386/* This function resets the ethercard if something screws up. */ 386/* This function resets the ethercard if something screws up. */
387static void 387static void __init
388hp_init_card(struct net_device *dev) 388hp_init_card(struct net_device *dev)
389{ 389{
390 int irq = dev->irq; 390 int irq = dev->irq;
@@ -409,7 +409,7 @@ MODULE_LICENSE("GPL");
409 409
410/* This is set up so that only a single autoprobe takes place per call. 410/* This is set up so that only a single autoprobe takes place per call.
411ISA device autoprobes on a running machine are not recommended. */ 411ISA device autoprobes on a running machine are not recommended. */
412int 412int __init
413init_module(void) 413init_module(void)
414{ 414{
415 struct net_device *dev; 415 struct net_device *dev;
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index 01ad904215a1..51fd51609ea9 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -1,4 +1,4 @@
1/* 1/*
2net-3-driver for the IBM LAN Adapter/A 2net-3-driver for the IBM LAN Adapter/A
3 3
4This is an extension to the Linux operating system, and is covered by the 4This is an extension to the Linux operating system, and is covered by the
@@ -11,9 +11,9 @@ This driver is based both on the SK_MCA driver, which is itself based on the
11SK_G16 and 3C523 driver. 11SK_G16 and 3C523 driver.
12 12
13paper sources: 13paper sources:
14 'PC Hardware: Aufbau, Funktionsweise, Programmierung' by 14 'PC Hardware: Aufbau, Funktionsweise, Programmierung' by
15 Hans-Peter Messmer for the basic Microchannel stuff 15 Hans-Peter Messmer for the basic Microchannel stuff
16 16
17 'Linux Geraetetreiber' by Allesandro Rubini, Kalle Dalheimer 17 'Linux Geraetetreiber' by Allesandro Rubini, Kalle Dalheimer
18 for help on Ethernet driver programming 18 for help on Ethernet driver programming
19 19
@@ -27,14 +27,14 @@ paper sources:
27 27
28special acknowledgements to: 28special acknowledgements to:
29 - Bob Eager for helping me out with documentation from IBM 29 - Bob Eager for helping me out with documentation from IBM
30 - Jim Shorney for his endless patience with me while I was using 30 - Jim Shorney for his endless patience with me while I was using
31 him as a beta tester to trace down the address filter bug ;-) 31 him as a beta tester to trace down the address filter bug ;-)
32 32
33 Missing things: 33 Missing things:
34 34
35 -> set debug level via ioctl instead of compile-time switches 35 -> set debug level via ioctl instead of compile-time switches
36 -> I didn't follow the development of the 2.1.x kernels, so my 36 -> I didn't follow the development of the 2.1.x kernels, so my
37 assumptions about which things changed with which kernel version 37 assumptions about which things changed with which kernel version
38 are probably nonsense 38 are probably nonsense
39 39
40History: 40History:
@@ -275,7 +275,7 @@ static void InitDscrs(struct net_device *dev)
275 priv->rrastart = raddr = priv->txbufstart + (TXBUFCNT * PKTSIZE); 275 priv->rrastart = raddr = priv->txbufstart + (TXBUFCNT * PKTSIZE);
276 priv->rdastart = addr = priv->rrastart + (priv->rxbufcnt * sizeof(rra_t)); 276 priv->rdastart = addr = priv->rrastart + (priv->rxbufcnt * sizeof(rra_t));
277 priv->rxbufstart = baddr = priv->rdastart + (priv->rxbufcnt * sizeof(rda_t)); 277 priv->rxbufstart = baddr = priv->rdastart + (priv->rxbufcnt * sizeof(rda_t));
278 278
279 for (z = 0; z < priv->rxbufcnt; z++) { 279 for (z = 0; z < priv->rxbufcnt; z++) {
280 rra.startlo = baddr; 280 rra.startlo = baddr;
281 rra.starthi = 0; 281 rra.starthi = 0;
@@ -570,7 +570,7 @@ static void irqrx_handler(struct net_device *dev)
570 lrdaaddr = priv->rdastart + (priv->lastrxdescr * sizeof(rda_t)); 570 lrdaaddr = priv->rdastart + (priv->lastrxdescr * sizeof(rda_t));
571 memcpy_fromio(&rda, priv->base + rdaaddr, sizeof(rda_t)); 571 memcpy_fromio(&rda, priv->base + rdaaddr, sizeof(rda_t));
572 572
573 /* iron out upper word halves of fields we use - SONIC will duplicate 573 /* iron out upper word halves of fields we use - SONIC will duplicate
574 bits 0..15 to 16..31 */ 574 bits 0..15 to 16..31 */
575 575
576 rda.status &= 0xffff; 576 rda.status &= 0xffff;
@@ -836,9 +836,9 @@ static int ibmlana_tx(struct sk_buff *skb, struct net_device *dev)
836 baddr = priv->txbufstart + (priv->nexttxdescr * PKTSIZE); 836 baddr = priv->txbufstart + (priv->nexttxdescr * PKTSIZE);
837 memcpy_toio(priv->base + baddr, skb->data, skb->len); 837 memcpy_toio(priv->base + baddr, skb->data, skb->len);
838 838
839 /* copy filler into RAM - in case we're filling up... 839 /* copy filler into RAM - in case we're filling up...
840 we're filling a bit more than necessary, but that doesn't harm 840 we're filling a bit more than necessary, but that doesn't harm
841 since the buffer is far larger... 841 since the buffer is far larger...
842 Sorry Linus for the filler string but I couldn't resist ;-) */ 842 Sorry Linus for the filler string but I couldn't resist ;-) */
843 843
844 if (tmplen > skb->len) { 844 if (tmplen > skb->len) {
@@ -952,7 +952,7 @@ static int ibmlana_probe(struct net_device *dev)
952 priv->realirq = irq; 952 priv->realirq = irq;
953 priv->medium = medium; 953 priv->medium = medium;
954 spin_lock_init(&priv->lock); 954 spin_lock_init(&priv->lock);
955 955
956 956
957 /* set base + irq for this device (irq not allocated so far) */ 957 /* set base + irq for this device (irq not allocated so far) */
958 958
diff --git a/drivers/net/ibmlana.h b/drivers/net/ibmlana.h
index 458ee226e537..6b58bab9e308 100644
--- a/drivers/net/ibmlana.h
+++ b/drivers/net/ibmlana.h
@@ -17,7 +17,7 @@
17/* media enumeration - defined in a way that it fits onto the LAN/A's 17/* media enumeration - defined in a way that it fits onto the LAN/A's
18 POS registers... */ 18 POS registers... */
19 19
20typedef enum { 20typedef enum {
21 Media_10BaseT, Media_10Base5, 21 Media_10BaseT, Media_10Base5,
22 Media_Unknown, Media_10Base2, Media_Count 22 Media_Unknown, Media_10Base2, Media_Count
23} ibmlana_medium; 23} ibmlana_medium;
@@ -27,7 +27,7 @@ typedef enum {
27typedef struct { 27typedef struct {
28 unsigned int slot; /* MCA-Slot-# */ 28 unsigned int slot; /* MCA-Slot-# */
29 struct net_device_stats stat; /* packet statistics */ 29 struct net_device_stats stat; /* packet statistics */
30 int realirq; /* memorizes actual IRQ, even when 30 int realirq; /* memorizes actual IRQ, even when
31 currently not allocated */ 31 currently not allocated */
32 ibmlana_medium medium; /* physical cannector */ 32 ibmlana_medium medium; /* physical cannector */
33 u32 tdastart, txbufstart, /* addresses */ 33 u32 tdastart, txbufstart, /* addresses */
@@ -41,7 +41,7 @@ typedef struct {
41 spinlock_t lock; 41 spinlock_t lock;
42} ibmlana_priv; 42} ibmlana_priv;
43 43
44/* this card uses quite a lot of I/O ports...luckily the MCA bus decodes 44/* this card uses quite a lot of I/O ports...luckily the MCA bus decodes
45 a full 64K I/O range... */ 45 a full 64K I/O range... */
46 46
47#define IBM_LANA_IORANGE 0xa0 47#define IBM_LANA_IORANGE 0xa0
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 52d01027d9e7..666346f6469e 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -24,7 +24,7 @@
24/* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */ 24/* for use with IBM i/pSeries LPAR Linux. It utilizes the logical LAN */
25/* option of the RS/6000 Platform Architechture to interface with virtual */ 25/* option of the RS/6000 Platform Architechture to interface with virtual */
26/* ethernet NICs that are presented to the partition by the hypervisor. */ 26/* ethernet NICs that are presented to the partition by the hypervisor. */
27/* */ 27/* */
28/**************************************************************************/ 28/**************************************************************************/
29/* 29/*
30 TODO: 30 TODO:
@@ -79,7 +79,7 @@
79#else 79#else
80#define ibmveth_debug_printk_no_adapter(fmt, args...) 80#define ibmveth_debug_printk_no_adapter(fmt, args...)
81#define ibmveth_debug_printk(fmt, args...) 81#define ibmveth_debug_printk(fmt, args...)
82#define ibmveth_assert(expr) 82#define ibmveth_assert(expr)
83#endif 83#endif
84 84
85static int ibmveth_open(struct net_device *dev); 85static int ibmveth_open(struct net_device *dev);
@@ -96,6 +96,7 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter);
96static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter); 96static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter);
97static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs *regs); 97static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
98static inline void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter); 98static inline void ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter);
99static struct kobj_type ktype_veth_pool;
99 100
100#ifdef CONFIG_PROC_FS 101#ifdef CONFIG_PROC_FS
101#define IBMVETH_PROC_DIR "net/ibmveth" 102#define IBMVETH_PROC_DIR "net/ibmveth"
@@ -133,12 +134,13 @@ static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)
133} 134}
134 135
135/* setup the initial settings for a buffer pool */ 136/* setup the initial settings for a buffer pool */
136static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size) 137static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool, u32 pool_index, u32 pool_size, u32 buff_size, u32 pool_active)
137{ 138{
138 pool->size = pool_size; 139 pool->size = pool_size;
139 pool->index = pool_index; 140 pool->index = pool_index;
140 pool->buff_size = buff_size; 141 pool->buff_size = buff_size;
141 pool->threshold = pool_size / 2; 142 pool->threshold = pool_size / 2;
143 pool->active = pool_active;
142} 144}
143 145
144/* allocate and setup an buffer pool - called during open */ 146/* allocate and setup an buffer pool - called during open */
@@ -146,13 +148,13 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool)
146{ 148{
147 int i; 149 int i;
148 150
149 pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL); 151 pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL);
150 152
151 if(!pool->free_map) { 153 if(!pool->free_map) {
152 return -1; 154 return -1;
153 } 155 }
154 156
155 pool->dma_addr = kmalloc(sizeof(dma_addr_t) * pool->size, GFP_KERNEL); 157 pool->dma_addr = kmalloc(sizeof(dma_addr_t) * pool->size, GFP_KERNEL);
156 if(!pool->dma_addr) { 158 if(!pool->dma_addr) {
157 kfree(pool->free_map); 159 kfree(pool->free_map);
158 pool->free_map = NULL; 160 pool->free_map = NULL;
@@ -180,7 +182,6 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool)
180 atomic_set(&pool->available, 0); 182 atomic_set(&pool->available, 0);
181 pool->producer_index = 0; 183 pool->producer_index = 0;
182 pool->consumer_index = 0; 184 pool->consumer_index = 0;
183 pool->active = 0;
184 185
185 return 0; 186 return 0;
186} 187}
@@ -214,7 +215,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
214 215
215 free_index = pool->consumer_index++ % pool->size; 216 free_index = pool->consumer_index++ % pool->size;
216 index = pool->free_map[free_index]; 217 index = pool->free_map[free_index];
217 218
218 ibmveth_assert(index != IBM_VETH_INVALID_MAP); 219 ibmveth_assert(index != IBM_VETH_INVALID_MAP);
219 ibmveth_assert(pool->skbuff[index] == NULL); 220 ibmveth_assert(pool->skbuff[index] == NULL);
220 221
@@ -231,10 +232,10 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
231 desc.desc = 0; 232 desc.desc = 0;
232 desc.fields.valid = 1; 233 desc.fields.valid = 1;
233 desc.fields.length = pool->buff_size; 234 desc.fields.length = pool->buff_size;
234 desc.fields.address = dma_addr; 235 desc.fields.address = dma_addr;
235 236
236 lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc); 237 lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc);
237 238
238 if(lpar_rc != H_SUCCESS) { 239 if(lpar_rc != H_SUCCESS) {
239 pool->free_map[free_index] = index; 240 pool->free_map[free_index] = index;
240 pool->skbuff[index] = NULL; 241 pool->skbuff[index] = NULL;
@@ -250,13 +251,13 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
250 adapter->replenish_add_buff_success++; 251 adapter->replenish_add_buff_success++;
251 } 252 }
252 } 253 }
253 254
254 mb(); 255 mb();
255 atomic_add(buffers_added, &(pool->available)); 256 atomic_add(buffers_added, &(pool->available));
256} 257}
257 258
258/* replenish routine */ 259/* replenish routine */
259static void ibmveth_replenish_task(struct ibmveth_adapter *adapter) 260static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
260{ 261{
261 int i; 262 int i;
262 263
@@ -264,7 +265,7 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
264 265
265 for(i = 0; i < IbmVethNumBufferPools; i++) 266 for(i = 0; i < IbmVethNumBufferPools; i++)
266 if(adapter->rx_buff_pool[i].active) 267 if(adapter->rx_buff_pool[i].active)
267 ibmveth_replenish_buffer_pool(adapter, 268 ibmveth_replenish_buffer_pool(adapter,
268 &adapter->rx_buff_pool[i]); 269 &adapter->rx_buff_pool[i]);
269 270
270 adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); 271 adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8);
@@ -301,7 +302,6 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter, struct ibm
301 kfree(pool->skbuff); 302 kfree(pool->skbuff);
302 pool->skbuff = NULL; 303 pool->skbuff = NULL;
303 } 304 }
304 pool->active = 0;
305} 305}
306 306
307/* remove a buffer from a pool */ 307/* remove a buffer from a pool */
@@ -372,7 +372,7 @@ static void ibmveth_rxq_recycle_buffer(struct ibmveth_adapter *adapter)
372 desc.fields.address = adapter->rx_buff_pool[pool].dma_addr[index]; 372 desc.fields.address = adapter->rx_buff_pool[pool].dma_addr[index];
373 373
374 lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc); 374 lpar_rc = h_add_logical_lan_buffer(adapter->vdev->unit_address, desc.desc);
375 375
376 if(lpar_rc != H_SUCCESS) { 376 if(lpar_rc != H_SUCCESS) {
377 ibmveth_debug_printk("h_add_logical_lan_buffer failed during recycle rc=%ld", lpar_rc); 377 ibmveth_debug_printk("h_add_logical_lan_buffer failed during recycle rc=%ld", lpar_rc);
378 ibmveth_remove_buffer_from_pool(adapter, adapter->rx_queue.queue_addr[adapter->rx_queue.index].correlator); 378 ibmveth_remove_buffer_from_pool(adapter, adapter->rx_queue.queue_addr[adapter->rx_queue.index].correlator);
@@ -407,7 +407,7 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
407 } 407 }
408 free_page((unsigned long)adapter->buffer_list_addr); 408 free_page((unsigned long)adapter->buffer_list_addr);
409 adapter->buffer_list_addr = NULL; 409 adapter->buffer_list_addr = NULL;
410 } 410 }
411 411
412 if(adapter->filter_list_addr != NULL) { 412 if(adapter->filter_list_addr != NULL) {
413 if(!dma_mapping_error(adapter->filter_list_dma)) { 413 if(!dma_mapping_error(adapter->filter_list_dma)) {
@@ -433,7 +433,9 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
433 } 433 }
434 434
435 for(i = 0; i<IbmVethNumBufferPools; i++) 435 for(i = 0; i<IbmVethNumBufferPools; i++)
436 ibmveth_free_buffer_pool(adapter, &adapter->rx_buff_pool[i]); 436 if (adapter->rx_buff_pool[i].active)
437 ibmveth_free_buffer_pool(adapter,
438 &adapter->rx_buff_pool[i]);
437} 439}
438 440
439static int ibmveth_open(struct net_device *netdev) 441static int ibmveth_open(struct net_device *netdev)
@@ -450,10 +452,10 @@ static int ibmveth_open(struct net_device *netdev)
450 452
451 for(i = 0; i<IbmVethNumBufferPools; i++) 453 for(i = 0; i<IbmVethNumBufferPools; i++)
452 rxq_entries += adapter->rx_buff_pool[i].size; 454 rxq_entries += adapter->rx_buff_pool[i].size;
453 455
454 adapter->buffer_list_addr = (void*) get_zeroed_page(GFP_KERNEL); 456 adapter->buffer_list_addr = (void*) get_zeroed_page(GFP_KERNEL);
455 adapter->filter_list_addr = (void*) get_zeroed_page(GFP_KERNEL); 457 adapter->filter_list_addr = (void*) get_zeroed_page(GFP_KERNEL);
456 458
457 if(!adapter->buffer_list_addr || !adapter->filter_list_addr) { 459 if(!adapter->buffer_list_addr || !adapter->filter_list_addr) {
458 ibmveth_error_printk("unable to allocate filter or buffer list pages\n"); 460 ibmveth_error_printk("unable to allocate filter or buffer list pages\n");
459 ibmveth_cleanup(adapter); 461 ibmveth_cleanup(adapter);
@@ -489,9 +491,6 @@ static int ibmveth_open(struct net_device *netdev)
489 adapter->rx_queue.num_slots = rxq_entries; 491 adapter->rx_queue.num_slots = rxq_entries;
490 adapter->rx_queue.toggle = 1; 492 adapter->rx_queue.toggle = 1;
491 493
492 /* call change_mtu to init the buffer pools based in initial mtu */
493 ibmveth_change_mtu(netdev, netdev->mtu);
494
495 memcpy(&mac_address, netdev->dev_addr, netdev->addr_len); 494 memcpy(&mac_address, netdev->dev_addr, netdev->addr_len);
496 mac_address = mac_address >> 16; 495 mac_address = mac_address >> 16;
497 496
@@ -504,7 +503,7 @@ static int ibmveth_open(struct net_device *netdev)
504 ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr); 503 ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr);
505 ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr); 504 ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr);
506 505
507 506
508 lpar_rc = h_register_logical_lan(adapter->vdev->unit_address, 507 lpar_rc = h_register_logical_lan(adapter->vdev->unit_address,
509 adapter->buffer_list_dma, 508 adapter->buffer_list_dma,
510 rxq_desc.desc, 509 rxq_desc.desc,
@@ -519,7 +518,18 @@ static int ibmveth_open(struct net_device *netdev)
519 rxq_desc.desc, 518 rxq_desc.desc,
520 mac_address); 519 mac_address);
521 ibmveth_cleanup(adapter); 520 ibmveth_cleanup(adapter);
522 return -ENONET; 521 return -ENONET;
522 }
523
524 for(i = 0; i<IbmVethNumBufferPools; i++) {
525 if(!adapter->rx_buff_pool[i].active)
526 continue;
527 if (ibmveth_alloc_buffer_pool(&adapter->rx_buff_pool[i])) {
528 ibmveth_error_printk("unable to alloc pool\n");
529 adapter->rx_buff_pool[i].active = 0;
530 ibmveth_cleanup(adapter);
531 return -ENOMEM ;
532 }
523 } 533 }
524 534
525 ibmveth_debug_printk("registering irq 0x%x\n", netdev->irq); 535 ibmveth_debug_printk("registering irq 0x%x\n", netdev->irq);
@@ -547,10 +557,11 @@ static int ibmveth_close(struct net_device *netdev)
547{ 557{
548 struct ibmveth_adapter *adapter = netdev->priv; 558 struct ibmveth_adapter *adapter = netdev->priv;
549 long lpar_rc; 559 long lpar_rc;
550 560
551 ibmveth_debug_printk("close starting\n"); 561 ibmveth_debug_printk("close starting\n");
552 562
553 netif_stop_queue(netdev); 563 if (!adapter->pool_config)
564 netif_stop_queue(netdev);
554 565
555 free_irq(netdev->irq, netdev); 566 free_irq(netdev->irq, netdev);
556 567
@@ -694,7 +705,7 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
694 desc[5].desc, 705 desc[5].desc,
695 correlator); 706 correlator);
696 } while ((lpar_rc == H_BUSY) && (retry_count--)); 707 } while ((lpar_rc == H_BUSY) && (retry_count--));
697 708
698 if(lpar_rc != H_SUCCESS && lpar_rc != H_DROPPED) { 709 if(lpar_rc != H_SUCCESS && lpar_rc != H_DROPPED) {
699 int i; 710 int i;
700 ibmveth_error_printk("tx: h_send_logical_lan failed with rc=%ld\n", lpar_rc); 711 ibmveth_error_printk("tx: h_send_logical_lan failed with rc=%ld\n", lpar_rc);
@@ -780,7 +791,7 @@ static int ibmveth_poll(struct net_device *netdev, int *budget)
780 /* more work to do - return that we are not done yet */ 791 /* more work to do - return that we are not done yet */
781 netdev->quota -= frames_processed; 792 netdev->quota -= frames_processed;
782 *budget -= frames_processed; 793 *budget -= frames_processed;
783 return 1; 794 return 1;
784 } 795 }
785 796
786 /* we think we are done - reenable interrupts, then check once more to make sure we are done */ 797 /* we think we are done - reenable interrupts, then check once more to make sure we are done */
@@ -806,7 +817,7 @@ static int ibmveth_poll(struct net_device *netdev, int *budget)
806} 817}
807 818
808static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 819static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
809{ 820{
810 struct net_device *netdev = dev_instance; 821 struct net_device *netdev = dev_instance;
811 struct ibmveth_adapter *adapter = netdev->priv; 822 struct ibmveth_adapter *adapter = netdev->priv;
812 unsigned long lpar_rc; 823 unsigned long lpar_rc;
@@ -862,7 +873,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
862 ibmveth_error_printk("h_multicast_ctrl rc=%ld when adding an entry to the filter table\n", lpar_rc); 873 ibmveth_error_printk("h_multicast_ctrl rc=%ld when adding an entry to the filter table\n", lpar_rc);
863 } 874 }
864 } 875 }
865 876
866 /* re-enable filtering */ 877 /* re-enable filtering */
867 lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, 878 lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address,
868 IbmVethMcastEnableFiltering, 879 IbmVethMcastEnableFiltering,
@@ -876,46 +887,22 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
876static int ibmveth_change_mtu(struct net_device *dev, int new_mtu) 887static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
877{ 888{
878 struct ibmveth_adapter *adapter = dev->priv; 889 struct ibmveth_adapter *adapter = dev->priv;
890 int new_mtu_oh = new_mtu + IBMVETH_BUFF_OH;
879 int i; 891 int i;
880 int prev_smaller = 1;
881 892
882 if ((new_mtu < 68) || 893 if (new_mtu < IBMVETH_MAX_MTU)
883 (new_mtu > (pool_size[IbmVethNumBufferPools-1]) - IBMVETH_BUFF_OH))
884 return -EINVAL; 894 return -EINVAL;
885 895
896 /* Look for an active buffer pool that can hold the new MTU */
886 for(i = 0; i<IbmVethNumBufferPools; i++) { 897 for(i = 0; i<IbmVethNumBufferPools; i++) {
887 int activate = 0; 898 if (!adapter->rx_buff_pool[i].active)
888 if (new_mtu > (pool_size[i] - IBMVETH_BUFF_OH)) { 899 continue;
889 activate = 1; 900 if (new_mtu_oh < adapter->rx_buff_pool[i].buff_size) {
890 prev_smaller= 1; 901 dev->mtu = new_mtu;
891 } else { 902 return 0;
892 if (prev_smaller)
893 activate = 1;
894 prev_smaller= 0;
895 } 903 }
896
897 if (activate && !adapter->rx_buff_pool[i].active) {
898 struct ibmveth_buff_pool *pool =
899 &adapter->rx_buff_pool[i];
900 if(ibmveth_alloc_buffer_pool(pool)) {
901 ibmveth_error_printk("unable to alloc pool\n");
902 return -ENOMEM;
903 }
904 adapter->rx_buff_pool[i].active = 1;
905 } else if (!activate && adapter->rx_buff_pool[i].active) {
906 adapter->rx_buff_pool[i].active = 0;
907 h_free_logical_lan_buffer(adapter->vdev->unit_address,
908 (u64)pool_size[i]);
909 }
910
911 } 904 }
912 905 return -EINVAL;
913 /* kick the interrupt handler so that the new buffer pools get
914 replenished or deallocated */
915 ibmveth_interrupt(dev->irq, dev, NULL);
916
917 dev->mtu = new_mtu;
918 return 0;
919} 906}
920 907
921static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) 908static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
@@ -928,7 +915,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
928 unsigned int *mcastFilterSize_p; 915 unsigned int *mcastFilterSize_p;
929 916
930 917
931 ibmveth_debug_printk_no_adapter("entering ibmveth_probe for UA 0x%x\n", 918 ibmveth_debug_printk_no_adapter("entering ibmveth_probe for UA 0x%x\n",
932 dev->unit_address); 919 dev->unit_address);
933 920
934 mac_addr_p = (unsigned char *) vio_get_attribute(dev, VETH_MAC_ADDR, 0); 921 mac_addr_p = (unsigned char *) vio_get_attribute(dev, VETH_MAC_ADDR, 0);
@@ -937,7 +924,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
937 "attribute\n", __FILE__, __LINE__); 924 "attribute\n", __FILE__, __LINE__);
938 return 0; 925 return 0;
939 } 926 }
940 927
941 mcastFilterSize_p= (unsigned int *) vio_get_attribute(dev, VETH_MCAST_FILTER_SIZE, 0); 928 mcastFilterSize_p= (unsigned int *) vio_get_attribute(dev, VETH_MCAST_FILTER_SIZE, 0);
942 if(!mcastFilterSize_p) { 929 if(!mcastFilterSize_p) {
943 printk(KERN_ERR "(%s:%3.3d) ERROR: Can't find " 930 printk(KERN_ERR "(%s:%3.3d) ERROR: Can't find "
@@ -945,7 +932,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
945 __FILE__, __LINE__); 932 __FILE__, __LINE__);
946 return 0; 933 return 0;
947 } 934 }
948 935
949 netdev = alloc_etherdev(sizeof(struct ibmveth_adapter)); 936 netdev = alloc_etherdev(sizeof(struct ibmveth_adapter));
950 937
951 if(!netdev) 938 if(!netdev)
@@ -960,13 +947,14 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
960 adapter->vdev = dev; 947 adapter->vdev = dev;
961 adapter->netdev = netdev; 948 adapter->netdev = netdev;
962 adapter->mcastFilterSize= *mcastFilterSize_p; 949 adapter->mcastFilterSize= *mcastFilterSize_p;
963 950 adapter->pool_config = 0;
951
964 /* Some older boxes running PHYP non-natively have an OF that 952 /* Some older boxes running PHYP non-natively have an OF that
965 returns a 8-byte local-mac-address field (and the first 953 returns a 8-byte local-mac-address field (and the first
966 2 bytes have to be ignored) while newer boxes' OF return 954 2 bytes have to be ignored) while newer boxes' OF return
967 a 6-byte field. Note that IEEE 1275 specifies that 955 a 6-byte field. Note that IEEE 1275 specifies that
968 local-mac-address must be a 6-byte field. 956 local-mac-address must be a 6-byte field.
969 The RPA doc specifies that the first byte must be 10b, so 957 The RPA doc specifies that the first byte must be 10b, so
970 we'll just look for it to solve this 8 vs. 6 byte field issue */ 958 we'll just look for it to solve this 8 vs. 6 byte field issue */
971 959
972 if ((*mac_addr_p & 0x3) != 0x02) 960 if ((*mac_addr_p & 0x3) != 0x02)
@@ -976,7 +964,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
976 memcpy(&adapter->mac_addr, mac_addr_p, 6); 964 memcpy(&adapter->mac_addr, mac_addr_p, 6);
977 965
978 adapter->liobn = dev->iommu_table->it_index; 966 adapter->liobn = dev->iommu_table->it_index;
979 967
980 netdev->irq = dev->irq; 968 netdev->irq = dev->irq;
981 netdev->open = ibmveth_open; 969 netdev->open = ibmveth_open;
982 netdev->poll = ibmveth_poll; 970 netdev->poll = ibmveth_poll;
@@ -989,14 +977,21 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
989 netdev->ethtool_ops = &netdev_ethtool_ops; 977 netdev->ethtool_ops = &netdev_ethtool_ops;
990 netdev->change_mtu = ibmveth_change_mtu; 978 netdev->change_mtu = ibmveth_change_mtu;
991 SET_NETDEV_DEV(netdev, &dev->dev); 979 SET_NETDEV_DEV(netdev, &dev->dev);
992 netdev->features |= NETIF_F_LLTX; 980 netdev->features |= NETIF_F_LLTX;
993 spin_lock_init(&adapter->stats_lock); 981 spin_lock_init(&adapter->stats_lock);
994 982
995 memcpy(&netdev->dev_addr, &adapter->mac_addr, netdev->addr_len); 983 memcpy(&netdev->dev_addr, &adapter->mac_addr, netdev->addr_len);
996 984
997 for(i = 0; i<IbmVethNumBufferPools; i++) 985 for(i = 0; i<IbmVethNumBufferPools; i++) {
998 ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i, 986 struct kobject *kobj = &adapter->rx_buff_pool[i].kobj;
999 pool_count[i], pool_size[i]); 987 ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
988 pool_count[i], pool_size[i],
989 pool_active[i]);
990 kobj->parent = &dev->dev.kobj;
991 sprintf(kobj->name, "pool%d", i);
992 kobj->ktype = &ktype_veth_pool;
993 kobject_register(kobj);
994 }
1000 995
1001 ibmveth_debug_printk("adapter @ 0x%p\n", adapter); 996 ibmveth_debug_printk("adapter @ 0x%p\n", adapter);
1002 997
@@ -1025,6 +1020,10 @@ static int __devexit ibmveth_remove(struct vio_dev *dev)
1025{ 1020{
1026 struct net_device *netdev = dev->dev.driver_data; 1021 struct net_device *netdev = dev->dev.driver_data;
1027 struct ibmveth_adapter *adapter = netdev->priv; 1022 struct ibmveth_adapter *adapter = netdev->priv;
1023 int i;
1024
1025 for(i = 0; i<IbmVethNumBufferPools; i++)
1026 kobject_unregister(&adapter->rx_buff_pool[i].kobj);
1028 1027
1029 unregister_netdev(netdev); 1028 unregister_netdev(netdev);
1030 1029
@@ -1048,7 +1047,7 @@ static void ibmveth_proc_unregister_driver(void)
1048 remove_proc_entry(IBMVETH_PROC_DIR, NULL); 1047 remove_proc_entry(IBMVETH_PROC_DIR, NULL);
1049} 1048}
1050 1049
1051static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) 1050static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos)
1052{ 1051{
1053 if (*pos == 0) { 1052 if (*pos == 0) {
1054 return (void *)1; 1053 return (void *)1;
@@ -1063,18 +1062,18 @@ static void *ibmveth_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1063 return NULL; 1062 return NULL;
1064} 1063}
1065 1064
1066static void ibmveth_seq_stop(struct seq_file *seq, void *v) 1065static void ibmveth_seq_stop(struct seq_file *seq, void *v)
1067{ 1066{
1068} 1067}
1069 1068
1070static int ibmveth_seq_show(struct seq_file *seq, void *v) 1069static int ibmveth_seq_show(struct seq_file *seq, void *v)
1071{ 1070{
1072 struct ibmveth_adapter *adapter = seq->private; 1071 struct ibmveth_adapter *adapter = seq->private;
1073 char *current_mac = ((char*) &adapter->netdev->dev_addr); 1072 char *current_mac = ((char*) &adapter->netdev->dev_addr);
1074 char *firmware_mac = ((char*) &adapter->mac_addr) ; 1073 char *firmware_mac = ((char*) &adapter->mac_addr) ;
1075 1074
1076 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version); 1075 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version);
1077 1076
1078 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address); 1077 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address);
1079 seq_printf(seq, "LIOBN: 0x%lx\n", adapter->liobn); 1078 seq_printf(seq, "LIOBN: 0x%lx\n", adapter->liobn);
1080 seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", 1079 seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
@@ -1083,7 +1082,7 @@ static int ibmveth_seq_show(struct seq_file *seq, void *v)
1083 seq_printf(seq, "Firmware MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", 1082 seq_printf(seq, "Firmware MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
1084 firmware_mac[0], firmware_mac[1], firmware_mac[2], 1083 firmware_mac[0], firmware_mac[1], firmware_mac[2],
1085 firmware_mac[3], firmware_mac[4], firmware_mac[5]); 1084 firmware_mac[3], firmware_mac[4], firmware_mac[5]);
1086 1085
1087 seq_printf(seq, "\nAdapter Statistics:\n"); 1086 seq_printf(seq, "\nAdapter Statistics:\n");
1088 seq_printf(seq, " TX: skbuffs linearized: %ld\n", adapter->tx_linearized); 1087 seq_printf(seq, " TX: skbuffs linearized: %ld\n", adapter->tx_linearized);
1089 seq_printf(seq, " multi-descriptor sends: %ld\n", adapter->tx_multidesc_send); 1088 seq_printf(seq, " multi-descriptor sends: %ld\n", adapter->tx_multidesc_send);
@@ -1095,7 +1094,7 @@ static int ibmveth_seq_show(struct seq_file *seq, void *v)
1095 seq_printf(seq, " add buffer failures: %ld\n", adapter->replenish_add_buff_failure); 1094 seq_printf(seq, " add buffer failures: %ld\n", adapter->replenish_add_buff_failure);
1096 seq_printf(seq, " invalid buffers: %ld\n", adapter->rx_invalid_buffer); 1095 seq_printf(seq, " invalid buffers: %ld\n", adapter->rx_invalid_buffer);
1097 seq_printf(seq, " no buffers: %ld\n", adapter->rx_no_buffer); 1096 seq_printf(seq, " no buffers: %ld\n", adapter->rx_no_buffer);
1098 1097
1099 return 0; 1098 return 0;
1100} 1099}
1101static struct seq_operations ibmveth_seq_ops = { 1100static struct seq_operations ibmveth_seq_ops = {
@@ -1153,11 +1152,11 @@ static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
1153} 1152}
1154 1153
1155#else /* CONFIG_PROC_FS */ 1154#else /* CONFIG_PROC_FS */
1156static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter) 1155static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
1157{ 1156{
1158} 1157}
1159 1158
1160static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter) 1159static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
1161{ 1160{
1162} 1161}
1163static void ibmveth_proc_register_driver(void) 1162static void ibmveth_proc_register_driver(void)
@@ -1169,6 +1168,132 @@ static void ibmveth_proc_unregister_driver(void)
1169} 1168}
1170#endif /* CONFIG_PROC_FS */ 1169#endif /* CONFIG_PROC_FS */
1171 1170
1171static struct attribute veth_active_attr;
1172static struct attribute veth_num_attr;
1173static struct attribute veth_size_attr;
1174
1175static ssize_t veth_pool_show(struct kobject * kobj,
1176 struct attribute * attr, char * buf)
1177{
1178 struct ibmveth_buff_pool *pool = container_of(kobj,
1179 struct ibmveth_buff_pool,
1180 kobj);
1181
1182 if (attr == &veth_active_attr)
1183 return sprintf(buf, "%d\n", pool->active);
1184 else if (attr == &veth_num_attr)
1185 return sprintf(buf, "%d\n", pool->size);
1186 else if (attr == &veth_size_attr)
1187 return sprintf(buf, "%d\n", pool->buff_size);
1188 return 0;
1189}
1190
1191static ssize_t veth_pool_store(struct kobject * kobj, struct attribute * attr,
1192const char * buf, size_t count)
1193{
1194 struct ibmveth_buff_pool *pool = container_of(kobj,
1195 struct ibmveth_buff_pool,
1196 kobj);
1197 struct net_device *netdev =
1198 container_of(kobj->parent, struct device, kobj)->driver_data;
1199 struct ibmveth_adapter *adapter = netdev->priv;
1200 long value = simple_strtol(buf, NULL, 10);
1201 long rc;
1202
1203 if (attr == &veth_active_attr) {
1204 if (value && !pool->active) {
1205 if(ibmveth_alloc_buffer_pool(pool)) {
1206 ibmveth_error_printk("unable to alloc pool\n");
1207 return -ENOMEM;
1208 }
1209 pool->active = 1;
1210 adapter->pool_config = 1;
1211 ibmveth_close(netdev);
1212 adapter->pool_config = 0;
1213 if ((rc = ibmveth_open(netdev)))
1214 return rc;
1215 } else if (!value && pool->active) {
1216 int mtu = netdev->mtu + IBMVETH_BUFF_OH;
1217 int i;
1218 /* Make sure there is a buffer pool with buffers that
1219 can hold a packet of the size of the MTU */
1220 for(i = 0; i<IbmVethNumBufferPools; i++) {
1221 if (pool == &adapter->rx_buff_pool[i])
1222 continue;
1223 if (!adapter->rx_buff_pool[i].active)
1224 continue;
1225 if (mtu < adapter->rx_buff_pool[i].buff_size) {
1226 pool->active = 0;
1227 h_free_logical_lan_buffer(adapter->
1228 vdev->
1229 unit_address,
1230 pool->
1231 buff_size);
1232 }
1233 }
1234 if (pool->active) {
1235 ibmveth_error_printk("no active pool >= MTU\n");
1236 return -EPERM;
1237 }
1238 }
1239 } else if (attr == &veth_num_attr) {
1240 if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT)
1241 return -EINVAL;
1242 else {
1243 adapter->pool_config = 1;
1244 ibmveth_close(netdev);
1245 adapter->pool_config = 0;
1246 pool->size = value;
1247 if ((rc = ibmveth_open(netdev)))
1248 return rc;
1249 }
1250 } else if (attr == &veth_size_attr) {
1251 if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE)
1252 return -EINVAL;
1253 else {
1254 adapter->pool_config = 1;
1255 ibmveth_close(netdev);
1256 adapter->pool_config = 0;
1257 pool->buff_size = value;
1258 if ((rc = ibmveth_open(netdev)))
1259 return rc;
1260 }
1261 }
1262
1263 /* kick the interrupt handler to allocate/deallocate pools */
1264 ibmveth_interrupt(netdev->irq, netdev, NULL);
1265 return count;
1266}
1267
1268
1269#define ATTR(_name, _mode) \
1270 struct attribute veth_##_name##_attr = { \
1271 .name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE \
1272 };
1273
1274static ATTR(active, 0644);
1275static ATTR(num, 0644);
1276static ATTR(size, 0644);
1277
1278static struct attribute * veth_pool_attrs[] = {
1279 &veth_active_attr,
1280 &veth_num_attr,
1281 &veth_size_attr,
1282 NULL,
1283};
1284
1285static struct sysfs_ops veth_pool_ops = {
1286 .show = veth_pool_show,
1287 .store = veth_pool_store,
1288};
1289
1290static struct kobj_type ktype_veth_pool = {
1291 .release = NULL,
1292 .sysfs_ops = &veth_pool_ops,
1293 .default_attrs = veth_pool_attrs,
1294};
1295
1296
1172static struct vio_device_id ibmveth_device_table[] __devinitdata= { 1297static struct vio_device_id ibmveth_device_table[] __devinitdata= {
1173 { "network", "IBM,l-lan"}, 1298 { "network", "IBM,l-lan"},
1174 { "", "" } 1299 { "", "" }
@@ -1198,7 +1323,7 @@ static void __exit ibmveth_module_exit(void)
1198{ 1323{
1199 vio_unregister_driver(&ibmveth_driver); 1324 vio_unregister_driver(&ibmveth_driver);
1200 ibmveth_proc_unregister_driver(); 1325 ibmveth_proc_unregister_driver();
1201} 1326}
1202 1327
1203module_init(ibmveth_module_init); 1328module_init(ibmveth_module_init);
1204module_exit(ibmveth_module_exit); 1329module_exit(ibmveth_module_exit);
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h
index 46919a814fca..8385bf836507 100644
--- a/drivers/net/ibmveth.h
+++ b/drivers/net/ibmveth.h
@@ -75,10 +75,13 @@
75 75
76#define IbmVethNumBufferPools 5 76#define IbmVethNumBufferPools 5
77#define IBMVETH_BUFF_OH 22 /* Overhead: 14 ethernet header + 8 opaque handle */ 77#define IBMVETH_BUFF_OH 22 /* Overhead: 14 ethernet header + 8 opaque handle */
78#define IBMVETH_MAX_MTU 68
79#define IBMVETH_MAX_POOL_COUNT 4096
80#define IBMVETH_MAX_BUF_SIZE (1024 * 128)
78 81
79/* pool_size should be sorted */
80static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 }; 82static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 };
81static int pool_count[] = { 256, 768, 256, 256, 256 }; 83static int pool_count[] = { 256, 768, 256, 256, 256 };
84static int pool_active[] = { 1, 1, 0, 0, 0};
82 85
83#define IBM_VETH_INVALID_MAP ((u16)0xffff) 86#define IBM_VETH_INVALID_MAP ((u16)0xffff)
84 87
@@ -94,6 +97,7 @@ struct ibmveth_buff_pool {
94 dma_addr_t *dma_addr; 97 dma_addr_t *dma_addr;
95 struct sk_buff **skbuff; 98 struct sk_buff **skbuff;
96 int active; 99 int active;
100 struct kobject kobj;
97}; 101};
98 102
99struct ibmveth_rx_q { 103struct ibmveth_rx_q {
@@ -118,6 +122,7 @@ struct ibmveth_adapter {
118 dma_addr_t filter_list_dma; 122 dma_addr_t filter_list_dma;
119 struct ibmveth_buff_pool rx_buff_pool[IbmVethNumBufferPools]; 123 struct ibmveth_buff_pool rx_buff_pool[IbmVethNumBufferPools];
120 struct ibmveth_rx_q rx_queue; 124 struct ibmveth_rx_q rx_queue;
125 int pool_config;
121 126
122 /* adapter specific stats */ 127 /* adapter specific stats */
123 u64 replenish_task_cycles; 128 u64 replenish_task_cycles;
@@ -134,7 +139,7 @@ struct ibmveth_adapter {
134 spinlock_t stats_lock; 139 spinlock_t stats_lock;
135}; 140};
136 141
137struct ibmveth_buf_desc_fields { 142struct ibmveth_buf_desc_fields {
138 u32 valid : 1; 143 u32 valid : 1;
139 u32 toggle : 1; 144 u32 toggle : 1;
140 u32 reserved : 6; 145 u32 reserved : 6;
@@ -143,7 +148,7 @@ struct ibmveth_buf_desc_fields {
143}; 148};
144 149
145union ibmveth_buf_desc { 150union ibmveth_buf_desc {
146 u64 desc; 151 u64 desc;
147 struct ibmveth_buf_desc_fields fields; 152 struct ibmveth_buf_desc_fields fields;
148}; 153};
149 154
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 31fb2d75dc44..2e222ef91e22 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -76,13 +76,13 @@ static void ri_tasklet(unsigned long dev)
76 dp->st_task_enter++; 76 dp->st_task_enter++;
77 if ((skb = skb_peek(&dp->tq)) == NULL) { 77 if ((skb = skb_peek(&dp->tq)) == NULL) {
78 dp->st_txq_refl_try++; 78 dp->st_txq_refl_try++;
79 if (spin_trylock(&_dev->xmit_lock)) { 79 if (netif_tx_trylock(_dev)) {
80 dp->st_rxq_enter++; 80 dp->st_rxq_enter++;
81 while ((skb = skb_dequeue(&dp->rq)) != NULL) { 81 while ((skb = skb_dequeue(&dp->rq)) != NULL) {
82 skb_queue_tail(&dp->tq, skb); 82 skb_queue_tail(&dp->tq, skb);
83 dp->st_rx2tx_tran++; 83 dp->st_rx2tx_tran++;
84 } 84 }
85 spin_unlock(&_dev->xmit_lock); 85 netif_tx_unlock(_dev);
86 } else { 86 } else {
87 /* reschedule */ 87 /* reschedule */
88 dp->st_rxq_notenter++; 88 dp->st_rxq_notenter++;
@@ -110,7 +110,7 @@ static void ri_tasklet(unsigned long dev)
110 } 110 }
111 } 111 }
112 112
113 if (spin_trylock(&_dev->xmit_lock)) { 113 if (netif_tx_trylock(_dev)) {
114 dp->st_rxq_check++; 114 dp->st_rxq_check++;
115 if ((skb = skb_peek(&dp->rq)) == NULL) { 115 if ((skb = skb_peek(&dp->rq)) == NULL) {
116 dp->tasklet_pending = 0; 116 dp->tasklet_pending = 0;
@@ -118,10 +118,10 @@ static void ri_tasklet(unsigned long dev)
118 netif_wake_queue(_dev); 118 netif_wake_queue(_dev);
119 } else { 119 } else {
120 dp->st_rxq_rsch++; 120 dp->st_rxq_rsch++;
121 spin_unlock(&_dev->xmit_lock); 121 netif_tx_unlock(_dev);
122 goto resched; 122 goto resched;
123 } 123 }
124 spin_unlock(&_dev->xmit_lock); 124 netif_tx_unlock(_dev);
125 } else { 125 } else {
126resched: 126resched:
127 dp->tasklet_pending = 1; 127 dp->tasklet_pending = 1;
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index cff8598aa800..d2ce4896abff 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -417,5 +417,20 @@ config PXA_FICP
417 available capabilities may vary from one PXA2xx target to 417 available capabilities may vary from one PXA2xx target to
418 another. 418 another.
419 419
420config MCS_FIR
421 tristate "MosChip MCS7780 IrDA-USB dongle"
422 depends on IRDA && USB && EXPERIMENTAL
423 help
424 Say Y or M here if you want to build support for the MosChip
425 MCS7780 IrDA-USB bridge device driver.
426
427 USB bridge based on the MosChip MCS7780 don't conform to the
428 IrDA-USB device class specification, and therefore need their
429 own specific driver. Those dongles support SIR and FIR (4Mbps)
430 speeds.
431
432 To compile it as a module, choose M here: the module will be called
433 mcs7780.
434
420endmenu 435endmenu
421 436
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index c1ce2398efea..5be09f1b9ee2 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_ALI_FIR) += ali-ircc.o
19obj-$(CONFIG_VLSI_FIR) += vlsi_ir.o 19obj-$(CONFIG_VLSI_FIR) += vlsi_ir.o
20obj-$(CONFIG_VIA_FIR) += via-ircc.o 20obj-$(CONFIG_VIA_FIR) += via-ircc.o
21obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o 21obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o
22obj-$(CONFIG_MCS_FIR) += mcs7780.o
22# Old dongle drivers for old SIR drivers 23# Old dongle drivers for old SIR drivers
23obj-$(CONFIG_ESI_DONGLE_OLD) += esi.o 24obj-$(CONFIG_ESI_DONGLE_OLD) += esi.o
24obj-$(CONFIG_TEKRAM_DONGLE_OLD) += tekram.o 25obj-$(CONFIG_TEKRAM_DONGLE_OLD) += tekram.o
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 2e7882eb7d6f..bf1fca5a3fa0 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -34,14 +34,12 @@
34#include <linux/rtnetlink.h> 34#include <linux/rtnetlink.h>
35#include <linux/serial_reg.h> 35#include <linux/serial_reg.h>
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/dma.h> 40#include <asm/dma.h>
40#include <asm/byteorder.h> 41#include <asm/byteorder.h>
41 42
42#include <linux/pm.h>
43#include <linux/pm_legacy.h>
44
45#include <net/irda/wrapper.h> 43#include <net/irda/wrapper.h>
46#include <net/irda/irda.h> 44#include <net/irda/irda.h>
47#include <net/irda/irda_device.h> 45#include <net/irda/irda_device.h>
@@ -51,7 +49,19 @@
51#define CHIP_IO_EXTENT 8 49#define CHIP_IO_EXTENT 8
52#define BROKEN_DONGLE_ID 50#define BROKEN_DONGLE_ID
53 51
54static char *driver_name = "ali-ircc"; 52#define ALI_IRCC_DRIVER_NAME "ali-ircc"
53
54/* Power Management */
55static int ali_ircc_suspend(struct platform_device *dev, pm_message_t state);
56static int ali_ircc_resume(struct platform_device *dev);
57
58static struct platform_driver ali_ircc_driver = {
59 .suspend = ali_ircc_suspend,
60 .resume = ali_ircc_resume,
61 .driver = {
62 .name = ALI_IRCC_DRIVER_NAME,
63 },
64};
55 65
56/* Module parameters */ 66/* Module parameters */
57static int qos_mtt_bits = 0x07; /* 1 ms or more */ 67static int qos_mtt_bits = 0x07; /* 1 ms or more */
@@ -97,10 +107,7 @@ static int ali_ircc_is_receiving(struct ali_ircc_cb *self);
97static int ali_ircc_net_open(struct net_device *dev); 107static int ali_ircc_net_open(struct net_device *dev);
98static int ali_ircc_net_close(struct net_device *dev); 108static int ali_ircc_net_close(struct net_device *dev);
99static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 109static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
100static int ali_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data);
101static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud); 110static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud);
102static void ali_ircc_suspend(struct ali_ircc_cb *self);
103static void ali_ircc_wakeup(struct ali_ircc_cb *self);
104static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev); 111static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev);
105 112
106/* SIR function */ 113/* SIR function */
@@ -145,6 +152,14 @@ static int __init ali_ircc_init(void)
145 int i = 0; 152 int i = 0;
146 153
147 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 154 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__);
155
156 ret = platform_driver_register(&ali_ircc_driver);
157 if (ret) {
158 IRDA_ERROR("%s, Can't register driver!\n",
159 ALI_IRCC_DRIVER_NAME);
160 return ret;
161 }
162
148 163
149 /* Probe for all the ALi chipsets we know about */ 164 /* Probe for all the ALi chipsets we know about */
150 for (chip= chips; chip->name; chip++, i++) 165 for (chip= chips; chip->name; chip++, i++)
@@ -214,6 +229,10 @@ static int __init ali_ircc_init(void)
214 } 229 }
215 230
216 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 231 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__);
232
233 if (ret)
234 platform_driver_unregister(&ali_ircc_driver);
235
217 return ret; 236 return ret;
218} 237}
219 238
@@ -228,14 +247,14 @@ static void __exit ali_ircc_cleanup(void)
228 int i; 247 int i;
229 248
230 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 249 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__);
231
232 pm_unregister_all(ali_ircc_pmproc);
233 250
234 for (i=0; i < 4; i++) { 251 for (i=0; i < 4; i++) {
235 if (dev_self[i]) 252 if (dev_self[i])
236 ali_ircc_close(dev_self[i]); 253 ali_ircc_close(dev_self[i]);
237 } 254 }
238 255
256 platform_driver_unregister(&ali_ircc_driver);
257
239 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 258 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__);
240} 259}
241 260
@@ -249,7 +268,6 @@ static int ali_ircc_open(int i, chipio_t *info)
249{ 268{
250 struct net_device *dev; 269 struct net_device *dev;
251 struct ali_ircc_cb *self; 270 struct ali_ircc_cb *self;
252 struct pm_dev *pmdev;
253 int dongle_id; 271 int dongle_id;
254 int err; 272 int err;
255 273
@@ -284,7 +302,8 @@ static int ali_ircc_open(int i, chipio_t *info)
284 self->io.fifo_size = 16; /* SIR: 16, FIR: 32 Benjamin 2000/11/1 */ 302 self->io.fifo_size = 16; /* SIR: 16, FIR: 32 Benjamin 2000/11/1 */
285 303
286 /* Reserve the ioports that we need */ 304 /* Reserve the ioports that we need */
287 if (!request_region(self->io.fir_base, self->io.fir_ext, driver_name)) { 305 if (!request_region(self->io.fir_base, self->io.fir_ext,
306 ALI_IRCC_DRIVER_NAME)) {
288 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", __FUNCTION__, 307 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", __FUNCTION__,
289 self->io.fir_base); 308 self->io.fir_base);
290 err = -ENODEV; 309 err = -ENODEV;
@@ -354,13 +373,10 @@ static int ali_ircc_open(int i, chipio_t *info)
354 373
355 /* Check dongle id */ 374 /* Check dongle id */
356 dongle_id = ali_ircc_read_dongle_id(i, info); 375 dongle_id = ali_ircc_read_dongle_id(i, info);
357 IRDA_MESSAGE("%s(), %s, Found dongle: %s\n", __FUNCTION__, driver_name, dongle_types[dongle_id]); 376 IRDA_MESSAGE("%s(), %s, Found dongle: %s\n", __FUNCTION__,
377 ALI_IRCC_DRIVER_NAME, dongle_types[dongle_id]);
358 378
359 self->io.dongle_id = dongle_id; 379 self->io.dongle_id = dongle_id;
360
361 pmdev = pm_register(PM_SYS_DEV, PM_SYS_IRDA, ali_ircc_pmproc);
362 if (pmdev)
363 pmdev->data = self;
364 380
365 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__); 381 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__);
366 382
@@ -548,12 +564,11 @@ static int ali_ircc_setup(chipio_t *info)
548 /* Should be 0x00 in the M1535/M1535D */ 564 /* Should be 0x00 in the M1535/M1535D */
549 if(version != 0x00) 565 if(version != 0x00)
550 { 566 {
551 IRDA_ERROR("%s, Wrong chip version %02x\n", driver_name, version); 567 IRDA_ERROR("%s, Wrong chip version %02x\n",
568 ALI_IRCC_DRIVER_NAME, version);
552 return -1; 569 return -1;
553 } 570 }
554 571
555 // IRDA_MESSAGE("%s, Found chip at base=0x%03x\n", driver_name, info->cfg_base);
556
557 /* Set FIR FIFO Threshold Register */ 572 /* Set FIR FIFO Threshold Register */
558 switch_bank(iobase, BANK1); 573 switch_bank(iobase, BANK1);
559 outb(RX_FIFO_Threshold, iobase+FIR_FIFO_TR); 574 outb(RX_FIFO_Threshold, iobase+FIR_FIFO_TR);
@@ -583,7 +598,8 @@ static int ali_ircc_setup(chipio_t *info)
583 /* Switch to SIR space */ 598 /* Switch to SIR space */
584 FIR2SIR(iobase); 599 FIR2SIR(iobase);
585 600
586 IRDA_MESSAGE("%s, driver loaded (Benjamin Kong)\n", driver_name); 601 IRDA_MESSAGE("%s, driver loaded (Benjamin Kong)\n",
602 ALI_IRCC_DRIVER_NAME);
587 603
588 /* Enable receive interrupts */ 604 /* Enable receive interrupts */
589 // outb(UART_IER_RDI, iobase+UART_IER); //benjamin 2000/11/23 01:25PM 605 // outb(UART_IER_RDI, iobase+UART_IER); //benjamin 2000/11/23 01:25PM
@@ -647,7 +663,8 @@ static irqreturn_t ali_ircc_interrupt(int irq, void *dev_id,
647 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); 663 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__);
648 664
649 if (!dev) { 665 if (!dev) {
650 IRDA_WARNING("%s: irq %d for unknown device.\n", driver_name, irq); 666 IRDA_WARNING("%s: irq %d for unknown device.\n",
667 ALI_IRCC_DRIVER_NAME, irq);
651 return IRQ_NONE; 668 return IRQ_NONE;
652 } 669 }
653 670
@@ -1328,7 +1345,8 @@ static int ali_ircc_net_open(struct net_device *dev)
1328 /* Request IRQ and install Interrupt Handler */ 1345 /* Request IRQ and install Interrupt Handler */
1329 if (request_irq(self->io.irq, ali_ircc_interrupt, 0, dev->name, dev)) 1346 if (request_irq(self->io.irq, ali_ircc_interrupt, 0, dev->name, dev))
1330 { 1347 {
1331 IRDA_WARNING("%s, unable to allocate irq=%d\n", driver_name, 1348 IRDA_WARNING("%s, unable to allocate irq=%d\n",
1349 ALI_IRCC_DRIVER_NAME,
1332 self->io.irq); 1350 self->io.irq);
1333 return -EAGAIN; 1351 return -EAGAIN;
1334 } 1352 }
@@ -1338,7 +1356,8 @@ static int ali_ircc_net_open(struct net_device *dev)
1338 * failure. 1356 * failure.
1339 */ 1357 */
1340 if (request_dma(self->io.dma, dev->name)) { 1358 if (request_dma(self->io.dma, dev->name)) {
1341 IRDA_WARNING("%s, unable to allocate dma=%d\n", driver_name, 1359 IRDA_WARNING("%s, unable to allocate dma=%d\n",
1360 ALI_IRCC_DRIVER_NAME,
1342 self->io.dma); 1361 self->io.dma);
1343 free_irq(self->io.irq, self); 1362 free_irq(self->io.irq, self);
1344 return -EAGAIN; 1363 return -EAGAIN;
@@ -2108,61 +2127,38 @@ static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev)
2108 return &self->stats; 2127 return &self->stats;
2109} 2128}
2110 2129
2111static void ali_ircc_suspend(struct ali_ircc_cb *self) 2130static int ali_ircc_suspend(struct platform_device *dev, pm_message_t state)
2112{ 2131{
2113 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 2132 struct ali_ircc_cb *self = platform_get_drvdata(dev);
2114 2133
2115 IRDA_MESSAGE("%s, Suspending\n", driver_name); 2134 IRDA_MESSAGE("%s, Suspending\n", ALI_IRCC_DRIVER_NAME);
2116 2135
2117 if (self->io.suspended) 2136 if (self->io.suspended)
2118 return; 2137 return 0;
2119 2138
2120 ali_ircc_net_close(self->netdev); 2139 ali_ircc_net_close(self->netdev);
2121 2140
2122 self->io.suspended = 1; 2141 self->io.suspended = 1;
2123 2142
2124 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ ); 2143 return 0;
2125} 2144}
2126 2145
2127static void ali_ircc_wakeup(struct ali_ircc_cb *self) 2146static int ali_ircc_resume(struct platform_device *dev)
2128{ 2147{
2129 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ ); 2148 struct ali_ircc_cb *self = platform_get_drvdata(dev);
2130 2149
2131 if (!self->io.suspended) 2150 if (!self->io.suspended)
2132 return; 2151 return 0;
2133 2152
2134 ali_ircc_net_open(self->netdev); 2153 ali_ircc_net_open(self->netdev);
2135 2154
2136 IRDA_MESSAGE("%s, Waking up\n", driver_name); 2155 IRDA_MESSAGE("%s, Waking up\n", ALI_IRCC_DRIVER_NAME);
2137 2156
2138 self->io.suspended = 0; 2157 self->io.suspended = 0;
2139
2140 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ );
2141}
2142 2158
2143static int ali_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data)
2144{
2145 struct ali_ircc_cb *self = (struct ali_ircc_cb*) dev->data;
2146
2147 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__ );
2148
2149 if (self) {
2150 switch (rqst) {
2151 case PM_SUSPEND:
2152 ali_ircc_suspend(self);
2153 break;
2154 case PM_RESUME:
2155 ali_ircc_wakeup(self);
2156 break;
2157 }
2158 }
2159
2160 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__ );
2161
2162 return 0; 2159 return 0;
2163} 2160}
2164 2161
2165
2166/* ALi Chip Function */ 2162/* ALi Chip Function */
2167 2163
2168static void SetCOMInterrupts(struct ali_ircc_cb *self , unsigned char enable) 2164static void SetCOMInterrupts(struct ali_ircc_cb *self , unsigned char enable)
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index cd87593e4e8a..844fa74ac9ec 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -83,9 +83,9 @@ static struct usb_device_id dongles[] = {
83 /* Extended Systems, Inc., XTNDAccess IrDA USB (ESI-9685) */ 83 /* Extended Systems, Inc., XTNDAccess IrDA USB (ESI-9685) */
84 { USB_DEVICE(0x8e9, 0x100), .driver_info = IUC_SPEED_BUG | IUC_NO_WINDOW }, 84 { USB_DEVICE(0x8e9, 0x100), .driver_info = IUC_SPEED_BUG | IUC_NO_WINDOW },
85 /* SigmaTel STIR4210/4220/4116 USB IrDA (VFIR) Bridge */ 85 /* SigmaTel STIR4210/4220/4116 USB IrDA (VFIR) Bridge */
86 { USB_DEVICE(0x66f, 0x4210), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG }, 86 { USB_DEVICE(0x66f, 0x4210), .driver_info = IUC_STIR421X | IUC_SPEED_BUG },
87 { USB_DEVICE(0x66f, 0x4220), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG }, 87 { USB_DEVICE(0x66f, 0x4220), .driver_info = IUC_STIR421X | IUC_SPEED_BUG },
88 { USB_DEVICE(0x66f, 0x4116), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG }, 88 { USB_DEVICE(0x66f, 0x4116), .driver_info = IUC_STIR421X | IUC_SPEED_BUG },
89 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | 89 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS |
90 USB_DEVICE_ID_MATCH_INT_SUBCLASS, 90 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
91 .bInterfaceClass = USB_CLASS_APP_SPEC, 91 .bInterfaceClass = USB_CLASS_APP_SPEC,
@@ -154,7 +154,7 @@ static void irda_usb_build_header(struct irda_usb_cb *self,
154 * and if either speed or xbofs (or both) needs 154 * and if either speed or xbofs (or both) needs
155 * to be changed. 155 * to be changed.
156 */ 156 */
157 if (self->capability & IUC_STIR_4210 && 157 if (self->capability & IUC_STIR421X &&
158 ((self->new_speed != -1) || (self->new_xbofs != -1))) { 158 ((self->new_speed != -1) || (self->new_xbofs != -1))) {
159 159
160 /* With STIR421x, speed and xBOFs must be set at the same 160 /* With STIR421x, speed and xBOFs must be set at the same
@@ -318,7 +318,7 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
318 /* Set the new speed and xbofs in this fake frame */ 318 /* Set the new speed and xbofs in this fake frame */
319 irda_usb_build_header(self, frame, 1); 319 irda_usb_build_header(self, frame, 1);
320 320
321 if ( self->capability & IUC_STIR_4210 ) { 321 if (self->capability & IUC_STIR421X) {
322 if (frame[0] == 0) return ; // do nothing if no change 322 if (frame[0] == 0) return ; // do nothing if no change
323 frame[1] = 0; // other parameters don't change here 323 frame[1] = 0; // other parameters don't change here
324 frame[2] = 0; 324 frame[2] = 0;
@@ -455,7 +455,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
455 455
456 /* Change setting for next frame */ 456 /* Change setting for next frame */
457 457
458 if ( self->capability & IUC_STIR_4210 ) { 458 if (self->capability & IUC_STIR421X) {
459 __u8 turnaround_time; 459 __u8 turnaround_time;
460 __u8* frame; 460 __u8* frame;
461 turnaround_time = get_turnaround_time( skb ); 461 turnaround_time = get_turnaround_time( skb );
@@ -897,10 +897,13 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
897 docopy = (urb->actual_length < IRDA_RX_COPY_THRESHOLD); 897 docopy = (urb->actual_length < IRDA_RX_COPY_THRESHOLD);
898 898
899 /* Allocate a new skb */ 899 /* Allocate a new skb */
900 if ( self->capability & IUC_STIR_4210 ) 900 if (self->capability & IUC_STIR421X)
901 newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU + USB_IRDA_SIGMATEL_HEADER); 901 newskb = dev_alloc_skb(docopy ? urb->actual_length :
902 IRDA_SKB_MAX_MTU +
903 USB_IRDA_STIR421X_HEADER);
902 else 904 else
903 newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU); 905 newskb = dev_alloc_skb(docopy ? urb->actual_length :
906 IRDA_SKB_MAX_MTU);
904 907
905 if (!newskb) { 908 if (!newskb) {
906 self->stats.rx_dropped++; 909 self->stats.rx_dropped++;
@@ -1022,188 +1025,140 @@ static int irda_usb_is_receiving(struct irda_usb_cb *self)
1022 return 0; /* For now */ 1025 return 0; /* For now */
1023} 1026}
1024 1027
1025 1028#define STIR421X_PATCH_PRODUCT_VER "Product Version: "
1026#define STIR421X_PATCH_PRODUCT_VERSION_STR "Product Version: " 1029#define STIR421X_PATCH_STMP_TAG "STMP"
1027#define STIR421X_PATCH_COMPONENT_VERSION_STR "Component Version: " 1030#define STIR421X_PATCH_CODE_OFFSET 512 /* patch image starts before here */
1028#define STIR421X_PATCH_DATA_TAG_STR "STMP" 1031/* marks end of patch file header (PC DOS text file EOF character) */
1029#define STIR421X_PATCH_FILE_VERSION_MAX_OFFSET 512 /* version info is before here */ 1032#define STIR421X_PATCH_END_OF_HDR_TAG 0x1A
1030#define STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET 512 /* patch image starts before here */ 1033#define STIR421X_PATCH_BLOCK_SIZE 1023
1031#define STIR421X_PATCH_FILE_END_OF_HEADER_TAG 0x1A /* marks end of patch file header (PC DOS text file EOF character) */
1032 1034
1033/* 1035/*
1034 * Known firmware patches for STIR421x dongles 1036 * Function stir421x_fwupload (struct irda_usb_cb *self,
1037 * unsigned char *patch,
1038 * const unsigned int patch_len)
1039 *
1040 * Upload firmware code to SigmaTel 421X IRDA-USB dongle
1035 */ 1041 */
1036static char * stir421x_patches[] = { 1042static int stir421x_fw_upload(struct irda_usb_cb *self,
1037 "42101001.sb", 1043 unsigned char *patch,
1038 "42101002.sb", 1044 const unsigned int patch_len)
1039};
1040
1041static int stir421x_get_patch_version(unsigned char * patch, const unsigned long patch_len)
1042{ 1045{
1043 unsigned int version_offset; 1046 int ret = -ENOMEM;
1044 unsigned long version_major, version_minor, version_build; 1047 int actual_len = 0;
1045 unsigned char * version_start; 1048 unsigned int i;
1046 int version_found = 0; 1049 unsigned int block_size = 0;
1047 1050 unsigned char *patch_block;
1048 for (version_offset = 0; 1051
1049 version_offset < STIR421X_PATCH_FILE_END_OF_HEADER_TAG; 1052 patch_block = kzalloc(STIR421X_PATCH_BLOCK_SIZE, GFP_KERNEL);
1050 version_offset++) { 1053 if (patch_block == NULL)
1051 if (!memcmp(patch + version_offset, 1054 return -ENOMEM;
1052 STIR421X_PATCH_PRODUCT_VERSION_STR, 1055
1053 sizeof(STIR421X_PATCH_PRODUCT_VERSION_STR) - 1)) { 1056 /* break up patch into 1023-byte sections */
1054 version_found = 1; 1057 for (i = 0; i < patch_len; i += block_size) {
1055 version_start = patch + 1058 block_size = patch_len - i;
1056 version_offset + 1059
1057 sizeof(STIR421X_PATCH_PRODUCT_VERSION_STR) - 1; 1060 if (block_size > STIR421X_PATCH_BLOCK_SIZE)
1058 break; 1061 block_size = STIR421X_PATCH_BLOCK_SIZE;
1059 } 1062
1063 /* upload the patch section */
1064 memcpy(patch_block, patch + i, block_size);
1065
1066 ret = usb_bulk_msg(self->usbdev,
1067 usb_sndbulkpipe(self->usbdev,
1068 self->bulk_out_ep),
1069 patch_block, block_size,
1070 &actual_len, msecs_to_jiffies(500));
1071 IRDA_DEBUG(3,"%s(): Bulk send %u bytes, ret=%d\n",
1072 __FUNCTION__, actual_len, ret);
1073
1074 if (ret < 0)
1075 break;
1060 } 1076 }
1061 1077
1062 /* We couldn't find a product version on this patch */ 1078 kfree(patch_block);
1063 if (!version_found)
1064 return -EINVAL;
1065
1066 /* Let's check if the product version is dotted */
1067 if (version_start[3] != '.' ||
1068 version_start[7] != '.')
1069 return -EINVAL;
1070
1071 version_major = simple_strtoul(version_start, NULL, 10);
1072 version_minor = simple_strtoul(version_start + 4, NULL, 10);
1073 version_build = simple_strtoul(version_start + 8, NULL, 10);
1074
1075 IRDA_DEBUG(2, "%s(), Major: %ld Minor: %ld Build: %ld\n",
1076 __FUNCTION__,
1077 version_major, version_minor, version_build);
1078
1079 return (((version_major) << 12) +
1080 ((version_minor) << 8) +
1081 ((version_build / 10) << 4) +
1082 (version_build % 10));
1083
1084}
1085
1086
1087static int stir421x_upload_patch (struct irda_usb_cb *self,
1088 unsigned char * patch,
1089 const unsigned int patch_len)
1090{
1091 int retval = 0;
1092 int actual_len;
1093 unsigned int i = 0, download_amount = 0;
1094 unsigned char * patch_chunk;
1095
1096 IRDA_DEBUG (2, "%s(), Uploading STIR421x Patch\n", __FUNCTION__);
1097
1098 patch_chunk = kzalloc(STIR421X_MAX_PATCH_DOWNLOAD_SIZE, GFP_KERNEL);
1099 if (patch_chunk == NULL)
1100 return -ENOMEM;
1101
1102 /* break up patch into 1023-byte sections */
1103 for (i = 0; retval >= 0 && i < patch_len; i += download_amount) {
1104 download_amount = patch_len - i;
1105 if (download_amount > STIR421X_MAX_PATCH_DOWNLOAD_SIZE)
1106 download_amount = STIR421X_MAX_PATCH_DOWNLOAD_SIZE;
1107
1108 /* download the patch section */
1109 memcpy(patch_chunk, patch + i, download_amount);
1110
1111 retval = usb_bulk_msg (self->usbdev,
1112 usb_sndbulkpipe (self->usbdev,
1113 self->bulk_out_ep),
1114 patch_chunk, download_amount,
1115 &actual_len, msecs_to_jiffies (500));
1116 IRDA_DEBUG (2, "%s(), Sent %u bytes\n", __FUNCTION__,
1117 actual_len);
1118 if (retval == 0)
1119 mdelay(10);
1120 }
1121
1122 kfree(patch_chunk);
1123
1124 if (i != patch_len) {
1125 IRDA_ERROR ("%s(), Pushed %d bytes (!= patch_len (%d))\n",
1126 __FUNCTION__, i, patch_len);
1127 retval = -EIO;
1128 }
1129
1130 if (retval < 0)
1131 /* todo - mark device as not ready */
1132 IRDA_ERROR ("%s(), STIR421x patch upload failed (%d)\n",
1133 __FUNCTION__, retval);
1134
1135 return retval;
1136}
1137 1079
1080 return ret;
1081 }
1138 1082
1083/*
1084 * Function stir421x_patch_device(struct irda_usb_cb *self)
1085 *
1086 * Get a firmware code from userspase using hotplug request_firmware() call
1087 */
1139static int stir421x_patch_device(struct irda_usb_cb *self) 1088static int stir421x_patch_device(struct irda_usb_cb *self)
1140{ 1089{
1141 unsigned int i, patch_found = 0, data_found = 0, data_offset; 1090 unsigned int i;
1142 int patch_version, ret = 0; 1091 int ret;
1143 const struct firmware *fw_entry; 1092 char stir421x_fw_name[11];
1144 1093 const struct firmware *fw;
1145 for (i = 0; i < ARRAY_SIZE(stir421x_patches); i++) { 1094 unsigned char *fw_version_ptr; /* pointer to version string */
1146 if(request_firmware(&fw_entry, stir421x_patches[i], &self->usbdev->dev) != 0) { 1095 unsigned long fw_version = 0;
1147 IRDA_ERROR( "%s(), Patch %s is not available\n", __FUNCTION__, stir421x_patches[i]); 1096
1148 continue; 1097 /*
1149 } 1098 * Known firmware patch file names for STIR421x dongles
1150 1099 * are "42101001.sb" or "42101002.sb"
1151 /* We found a patch from userspace */ 1100 */
1152 patch_version = stir421x_get_patch_version (fw_entry->data, fw_entry->size); 1101 sprintf(stir421x_fw_name, "4210%4X.sb",
1153 1102 self->usbdev->descriptor.bcdDevice);
1154 if (patch_version < 0) { 1103 ret = request_firmware(&fw, stir421x_fw_name, &self->usbdev->dev);
1155 /* Couldn't fetch a version, let's move on to the next file */ 1104 if (ret < 0)
1156 IRDA_ERROR("%s(), version parsing failed\n", __FUNCTION__); 1105 return ret;
1157 ret = patch_version; 1106
1158 release_firmware(fw_entry); 1107 /* We get a patch from userspace */
1159 continue; 1108 IRDA_MESSAGE("%s(): Received firmware %s (%u bytes)\n",
1160 } 1109 __FUNCTION__, stir421x_fw_name, fw->size);
1161 1110
1162 if (patch_version != self->usbdev->descriptor.bcdDevice) { 1111 ret = -EINVAL;
1163 /* Patch version and device don't match */ 1112
1164 IRDA_ERROR ("%s(), wrong patch version (%d <-> %d)\n", 1113 /* Get the bcd product version */
1165 __FUNCTION__, 1114 if (!memcmp(fw->data, STIR421X_PATCH_PRODUCT_VER,
1166 patch_version, self->usbdev->descriptor.bcdDevice); 1115 sizeof(STIR421X_PATCH_PRODUCT_VER) - 1)) {
1167 ret = -EINVAL; 1116 fw_version_ptr = fw->data +
1168 release_firmware(fw_entry); 1117 sizeof(STIR421X_PATCH_PRODUCT_VER) - 1;
1169 continue; 1118
1170 } 1119 /* Let's check if the product version is dotted */
1171 1120 if (fw_version_ptr[3] == '.' &&
1172 /* If we're here, we've found a correct patch */ 1121 fw_version_ptr[7] == '.') {
1173 patch_found = 1; 1122 unsigned long major, minor, build;
1174 break; 1123 major = simple_strtoul(fw_version_ptr, NULL, 10);
1175 1124 minor = simple_strtoul(fw_version_ptr + 4, NULL, 10);
1176 } 1125 build = simple_strtoul(fw_version_ptr + 8, NULL, 10);
1177 1126
1178 /* We couldn't find a valid firmware, let's leave */ 1127 fw_version = (major << 12)
1179 if (!patch_found) 1128 + (minor << 8)
1180 return ret; 1129 + ((build / 10) << 4)
1181 1130 + (build % 10);
1182 /* The actual image starts after the "STMP" keyword */ 1131
1183 for (data_offset = 0; data_offset < STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET; data_offset++) { 1132 IRDA_DEBUG(3, "%s(): Firmware Product version %ld\n",
1184 if (!memcmp(fw_entry->data + data_offset, 1133 __FUNCTION__, fw_version);
1185 STIR421X_PATCH_DATA_TAG_STR, 1134 }
1186 sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET))) { 1135 }
1187 IRDA_DEBUG(2, "%s(), found patch data for STIR421x at offset %d\n", 1136
1188 __FUNCTION__, data_offset); 1137 if (self->usbdev->descriptor.bcdDevice == fw_version) {
1189 data_found = 1; 1138 /*
1190 break; 1139 * If we're here, we've found a correct patch
1191 } 1140 * The actual image starts after the "STMP" keyword
1192 } 1141 * so forward to the firmware header tag
1193 1142 */
1194 /* We couldn't find "STMP" from the header */ 1143 for (i = 0; (fw->data[i] != STIR421X_PATCH_END_OF_HDR_TAG)
1195 if (!data_found) 1144 && (i < fw->size); i++) ;
1196 return -EINVAL; 1145 /* here we check for the out of buffer case */
1197 1146 if ((STIR421X_PATCH_END_OF_HDR_TAG == fw->data[i])
1198 /* Let's upload the patch to the target */ 1147 && (i < STIR421X_PATCH_CODE_OFFSET)) {
1199 ret = stir421x_upload_patch(self, 1148 if (!memcmp(fw->data + i + 1, STIR421X_PATCH_STMP_TAG,
1200 &fw_entry->data[data_offset + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET)], 1149 sizeof(STIR421X_PATCH_STMP_TAG) - 1)) {
1201 fw_entry->size - (data_offset + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET))); 1150
1202 1151 /* We can upload the patch to the target */
1203 release_firmware(fw_entry); 1152 i += sizeof(STIR421X_PATCH_STMP_TAG);
1204 1153 ret = stir421x_fw_upload(self, &fw->data[i],
1205 return ret; 1154 fw->size - i);
1206 1155 }
1156 }
1157 }
1158
1159 release_firmware(fw);
1160
1161 return ret;
1207} 1162}
1208 1163
1209 1164
@@ -1702,12 +1657,12 @@ static int irda_usb_probe(struct usb_interface *intf,
1702 init_timer(&self->rx_defer_timer); 1657 init_timer(&self->rx_defer_timer);
1703 1658
1704 self->capability = id->driver_info; 1659 self->capability = id->driver_info;
1705 self->needspatch = ((self->capability & IUC_STIR_4210) != 0) ; 1660 self->needspatch = ((self->capability & IUC_STIR421X) != 0);
1706 1661
1707 /* Create all of the needed urbs */ 1662 /* Create all of the needed urbs */
1708 if (self->capability & IUC_STIR_4210) { 1663 if (self->capability & IUC_STIR421X) {
1709 self->max_rx_urb = IU_SIGMATEL_MAX_RX_URBS; 1664 self->max_rx_urb = IU_SIGMATEL_MAX_RX_URBS;
1710 self->header_length = USB_IRDA_SIGMATEL_HEADER; 1665 self->header_length = USB_IRDA_STIR421X_HEADER;
1711 } else { 1666 } else {
1712 self->max_rx_urb = IU_MAX_RX_URBS; 1667 self->max_rx_urb = IU_MAX_RX_URBS;
1713 self->header_length = USB_IRDA_HEADER; 1668 self->header_length = USB_IRDA_HEADER;
@@ -1813,8 +1768,8 @@ static int irda_usb_probe(struct usb_interface *intf,
1813 /* Now we fetch and upload the firmware patch */ 1768 /* Now we fetch and upload the firmware patch */
1814 ret = stir421x_patch_device(self); 1769 ret = stir421x_patch_device(self);
1815 self->needspatch = (ret < 0); 1770 self->needspatch = (ret < 0);
1816 if (ret < 0) { 1771 if (self->needspatch) {
1817 printk("patch_device failed\n"); 1772 IRDA_ERROR("STIR421X: Couldn't upload patch\n");
1818 goto err_out_5; 1773 goto err_out_5;
1819 } 1774 }
1820 1775
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h
index d833db52cebf..6b2271f18e77 100644
--- a/drivers/net/irda/irda-usb.h
+++ b/drivers/net/irda/irda-usb.h
@@ -34,9 +34,6 @@
34#include <net/irda/irda.h> 34#include <net/irda/irda.h>
35#include <net/irda/irda_device.h> /* struct irlap_cb */ 35#include <net/irda/irda_device.h> /* struct irlap_cb */
36 36
37#define PATCH_FILE_SIZE_MAX 65536
38#define PATCH_FILE_SIZE_MIN 80
39
40#define RX_COPY_THRESHOLD 200 37#define RX_COPY_THRESHOLD 200
41#define IRDA_USB_MAX_MTU 2051 38#define IRDA_USB_MAX_MTU 2051
42#define IRDA_USB_SPEED_MTU 64 /* Weird, but work like this */ 39#define IRDA_USB_SPEED_MTU 64 /* Weird, but work like this */
@@ -107,14 +104,15 @@
107#define IUC_SMALL_PKT 0x10 /* Device doesn't behave with big Rx packets */ 104#define IUC_SMALL_PKT 0x10 /* Device doesn't behave with big Rx packets */
108#define IUC_MAX_WINDOW 0x20 /* Device underestimate the Rx window */ 105#define IUC_MAX_WINDOW 0x20 /* Device underestimate the Rx window */
109#define IUC_MAX_XBOFS 0x40 /* Device need more xbofs than advertised */ 106#define IUC_MAX_XBOFS 0x40 /* Device need more xbofs than advertised */
110#define IUC_STIR_4210 0x80 /* SigmaTel 4210/4220/4116 VFIR */ 107#define IUC_STIR421X 0x80 /* SigmaTel 4210/4220/4116 VFIR */
111 108
112/* USB class definitions */ 109/* USB class definitions */
113#define USB_IRDA_HEADER 0x01 110#define USB_IRDA_HEADER 0x01
114#define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */ 111#define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */
115#define USB_DT_IRDA 0x21 112#define USB_DT_IRDA 0x21
116#define USB_IRDA_SIGMATEL_HEADER 0x03 113#define USB_IRDA_STIR421X_HEADER 0x03
117#define IU_SIGMATEL_MAX_RX_URBS (IU_MAX_ACTIVE_RX_URBS + USB_IRDA_SIGMATEL_HEADER) 114#define IU_SIGMATEL_MAX_RX_URBS (IU_MAX_ACTIVE_RX_URBS + \
115 USB_IRDA_STIR421X_HEADER)
118 116
119struct irda_class_desc { 117struct irda_class_desc {
120 __u8 bLength; 118 __u8 bLength;
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
new file mode 100644
index 000000000000..754297fc8f22
--- /dev/null
+++ b/drivers/net/irda/mcs7780.c
@@ -0,0 +1,1009 @@
1/*****************************************************************************
2*
3* Filename: mcs7780.c
4* Version: 0.4-alpha
5* Description: Irda MosChip USB Dongle Driver
6* Authors: Lukasz Stelmach <stlman@poczta.fm>
7* Brian Pugh <bpugh@cs.pdx.edu>
8* Judy Fischbach <jfisch@cs.pdx.edu>
9*
10* Based on stir4200 driver, but some things done differently.
11* Based on earlier driver by Paul Stewart <stewart@parc.com>
12*
13* Copyright (C) 2000, Roman Weissgaerber <weissg@vienna.at>
14* Copyright (C) 2001, Dag Brattli <dag@brattli.net>
15* Copyright (C) 2001, Jean Tourrilhes <jt@hpl.hp.com>
16* Copyright (C) 2004, Stephen Hemminger <shemminger@osdl.org>
17* Copyright (C) 2005, Lukasz Stelmach <stlman@poczta.fm>
18* Copyright (C) 2005, Brian Pugh <bpugh@cs.pdx.edu>
19* Copyright (C) 2005, Judy Fischbach <jfisch@cs.pdx.edu>
20*
21* This program is free software; you can redistribute it and/or modify
22* it under the terms of the GNU General Public License as published by
23* the Free Software Foundation; either version 2 of the License, or
24* (at your option) any later version.
25*
26* This program is distributed in the hope that it will be useful,
27* but WITHOUT ANY WARRANTY; without even the implied warranty of
28* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29* GNU General Public License for more details.
30*
31* You should have received a copy of the GNU General Public License
32* along with this program; if not, write to the Free Software
33* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34*
35*****************************************************************************/
36
37/*
38 * MCS7780 is a simple USB to IrDA bridge by MosChip. It is neither
39 * compatibile with irda-usb nor with stir4200. Although it is quite
40 * similar to the later as far as general idea of operation is concerned.
41 * That is it requires the software to do all the framing job at SIR speeds.
42 * The hardware does take care of the framing at MIR and FIR speeds.
43 * It supports all speeds from 2400 through 4Mbps
44 */
45
46#include <linux/module.h>
47#include <linux/moduleparam.h>
48#include <linux/config.h>
49#include <linux/kernel.h>
50#include <linux/types.h>
51#include <linux/errno.h>
52#include <linux/init.h>
53#include <linux/slab.h>
54#include <linux/module.h>
55#include <linux/kref.h>
56#include <linux/usb.h>
57#include <linux/device.h>
58#include <linux/crc32.h>
59
60#include <asm/unaligned.h>
61#include <asm/byteorder.h>
62#include <asm/uaccess.h>
63
64#include <net/irda/irda.h>
65#include <net/irda/wrapper.h>
66#include <net/irda/crc.h>
67
68#include "mcs7780.h"
69
70#define MCS_VENDOR_ID 0x9710
71#define MCS_PRODUCT_ID 0x7780
72
73static struct usb_device_id mcs_table[] = {
74 /* MosChip Corp., MCS7780 FIR-USB Adapter */
75 {USB_DEVICE(MCS_VENDOR_ID, MCS_PRODUCT_ID)},
76 {},
77};
78
79MODULE_AUTHOR("Brian Pugh <bpugh@cs.pdx.edu>");
80MODULE_DESCRIPTION("IrDA-USB Dongle Driver for MosChip MCS7780");
81MODULE_VERSION("0.3alpha");
82MODULE_LICENSE("GPL");
83
84MODULE_DEVICE_TABLE(usb, mcs_table);
85
86static int qos_mtt_bits = 0x07 /* > 1ms */ ;
87module_param(qos_mtt_bits, int, 0);
88MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time");
89
90static int receive_mode = 0x1;
91module_param(receive_mode, int, 0);
92MODULE_PARM_DESC(receive_mode,
93 "Receive mode of the device (1:fast, 0:slow, default:1)");
94
95static int sir_tweak = 1;
96module_param(sir_tweak, int, 0444);
97MODULE_PARM_DESC(sir_tweak,
98 "Default pulse width (1:1.6us, 0:3/16 bit, default:1).");
99
100static int transceiver_type = MCS_TSC_VISHAY;
101module_param(transceiver_type, int, 0444);
102MODULE_PARM_DESC(transceiver_type, "IR transceiver type, see mcs7780.h.");
103
104struct usb_driver mcs_driver = {
105 .name = "mcs7780",
106 .probe = mcs_probe,
107 .disconnect = mcs_disconnect,
108 .id_table = mcs_table,
109};
110
111/* speed flag selection by direct addressing.
112addr = (speed >> 8) & 0x0f
113
1140x1 57600 0x2 115200 0x4 1152000 0x5 9600
1150x6 38400 0x9 2400 0xa 576000 0xb 19200
116
1174Mbps (or 2400) must be checked separately. Since it also has
118to be programmed in a different manner that is not a big problem.
119*/
120static __u16 mcs_speed_set[16] = { 0,
121 MCS_SPEED_57600,
122 MCS_SPEED_115200,
123 0,
124 MCS_SPEED_1152000,
125 MCS_SPEED_9600,
126 MCS_SPEED_38400,
127 0, 0,
128 MCS_SPEED_2400,
129 MCS_SPEED_576000,
130 MCS_SPEED_19200,
131 0, 0, 0,
132};
133
134/* Set given 16 bit register with a 16 bit value. Send control message
135 * to set dongle register. */
136static int mcs_set_reg(struct mcs_cb *mcs, __u16 reg, __u16 val)
137{
138 struct usb_device *dev = mcs->usbdev;
139 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
140 MCS_WR_RTYPE, val, reg, NULL, 0,
141 msecs_to_jiffies(MCS_CTRL_TIMEOUT));
142}
143
144/* Get 16 bit register value. Send contol message to read dongle register. */
145static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val)
146{
147 struct usb_device *dev = mcs->usbdev;
148 int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
149 MCS_RD_RTYPE, 0, reg, val, 2,
150 msecs_to_jiffies(MCS_CTRL_TIMEOUT));
151
152 return ret;
153}
154
155/* Setup a communication between mcs7780 and TFDU chips. It is described
156 * in more detail in the data sheet. The setup sequence puts the the
157 * vishay tranceiver into high speed mode. It will also receive SIR speed
158 * packets but at reduced sensitivity.
159 */
160
161/* 0: OK 1:ERROR */
162static inline int mcs_setup_transceiver_vishay(struct mcs_cb *mcs)
163{
164 int ret = 0;
165 __u16 rval;
166
167 /* mcs_get_reg should read exactly two bytes from the dongle */
168 ret = mcs_get_reg(mcs, MCS_XCVR_REG, &rval);
169 if (unlikely(ret != 2)) {
170 ret = -EIO;
171 goto error;
172 }
173
174 /* The MCS_XCVR_CONF bit puts the transceiver into configuration
175 * mode. The MCS_MODE0 bit must start out high (1) and then
176 * transition to low and the MCS_STFIR and MCS_MODE1 bits must
177 * be low.
178 */
179 rval |= (MCS_MODE0 | MCS_XCVR_CONF);
180 rval &= ~MCS_STFIR;
181 rval &= ~MCS_MODE1;
182 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval);
183 if (unlikely(ret))
184 goto error;
185
186 rval &= ~MCS_MODE0;
187 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval);
188 if (unlikely(ret))
189 goto error;
190
191 rval &= ~MCS_XCVR_CONF;
192 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval);
193 if (unlikely(ret))
194 goto error;
195
196 ret = 0;
197 error:
198 return ret;
199}
200
201/* Setup a communication between mcs7780 and agilent chip. */
202static inline int mcs_setup_transceiver_agilent(struct mcs_cb *mcs)
203{
204 IRDA_WARNING("This transceiver type is not supported yet.");
205 return 1;
206}
207
208/* Setup a communication between mcs7780 and sharp chip. */
209static inline int mcs_setup_transceiver_sharp(struct mcs_cb *mcs)
210{
211 IRDA_WARNING("This transceiver type is not supported yet.");
212 return 1;
213}
214
215/* Common setup for all transceivers */
216static inline int mcs_setup_transceiver(struct mcs_cb *mcs)
217{
218 int ret = 0;
219 __u16 rval;
220 char *msg;
221
222 msg = "Basic transceiver setup error.";
223
224 /* read value of MODE Register, set the DRIVER and RESET bits
225 * and write value back out to MODE Register
226 */
227 ret = mcs_get_reg(mcs, MCS_MODE_REG, &rval);
228 if(unlikely(ret != 2))
229 goto error;
230 rval |= MCS_DRIVER; /* put the mcs7780 into configuration mode. */
231 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval);
232 if(unlikely(ret))
233 goto error;
234
235 rval = 0; /* set min pulse width to 0 initially. */
236 ret = mcs_set_reg(mcs, MCS_MINRXPW_REG, rval);
237 if(unlikely(ret))
238 goto error;
239
240 ret = mcs_get_reg(mcs, MCS_MODE_REG, &rval);
241 if(unlikely(ret != 2))
242 goto error;
243
244 rval &= ~MCS_FIR; /* turn off fir mode. */
245 if(mcs->sir_tweak)
246 rval |= MCS_SIR16US; /* 1.6us pulse width */
247 else
248 rval &= ~MCS_SIR16US; /* 3/16 bit time pulse width */
249
250 /* make sure ask mode and back to back packets are off. */
251 rval &= ~(MCS_BBTG | MCS_ASK);
252
253 rval &= ~MCS_SPEED_MASK;
254 rval |= MCS_SPEED_9600; /* make sure initial speed is 9600. */
255 mcs->speed = 9600;
256 mcs->new_speed = 0; /* new_speed is set to 0 */
257 rval &= ~MCS_PLLPWDN; /* disable power down. */
258
259 /* make sure device determines direction and that the auto send sip
260 * pulse are on.
261 */
262 rval |= MCS_DTD | MCS_SIPEN;
263
264 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval);
265 if(unlikely(ret))
266 goto error;
267
268 msg = "transceiver model specific setup error.";
269 switch (mcs->transceiver_type) {
270 case MCS_TSC_VISHAY:
271 ret = mcs_setup_transceiver_vishay(mcs);
272 break;
273
274 case MCS_TSC_SHARP:
275 ret = mcs_setup_transceiver_sharp(mcs);
276 break;
277
278 case MCS_TSC_AGILENT:
279 ret = mcs_setup_transceiver_agilent(mcs);
280 break;
281
282 default:
283 IRDA_WARNING("Unknown transceiver type: %d",
284 mcs->transceiver_type);
285 ret = 1;
286 }
287 if (unlikely(ret))
288 goto error;
289
290 /* If transceiver is not SHARP, then if receive mode set
291 * on the RXFAST bit in the XCVR Register otherwise unset it
292 */
293 if (mcs->transceiver_type != MCS_TSC_SHARP) {
294
295 ret = mcs_get_reg(mcs, MCS_XCVR_REG, &rval);
296 if (unlikely(ret != 2))
297 goto error;
298 if (mcs->receive_mode)
299 rval |= MCS_RXFAST;
300 else
301 rval &= ~MCS_RXFAST;
302 ret = mcs_set_reg(mcs, MCS_XCVR_REG, rval);
303 if (unlikely(ret))
304 goto error;
305 }
306
307 msg = "transceiver reset.";
308
309 ret = mcs_get_reg(mcs, MCS_MODE_REG, &rval);
310 if (unlikely(ret != 2))
311 goto error;
312
313 /* reset the mcs7780 so all changes take effect. */
314 rval &= ~MCS_RESET;
315 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval);
316 if (unlikely(ret))
317 goto error;
318 else
319 return ret;
320
321error:
322 IRDA_ERROR("%s", msg);
323 return ret;
324}
325
326/* Wraps the data in format for SIR */
327static inline int mcs_wrap_sir_skb(struct sk_buff *skb, __u8 * buf)
328{
329 int wraplen;
330
331 /* 2: full frame length, including "the length" */
332 wraplen = async_wrap_skb(skb, buf + 2, 4094);
333
334 wraplen += 2;
335 buf[0] = wraplen & 0xff;
336 buf[1] = (wraplen >> 8) & 0xff;
337
338 return wraplen;
339}
340
341/* Wraps the data in format for FIR */
342static unsigned mcs_wrap_fir_skb(const struct sk_buff *skb, __u8 *buf)
343{
344 unsigned int len = 0;
345 __u32 fcs = ~(crc32_le(~0, skb->data, skb->len));
346
347 /* add 2 bytes for length value and 4 bytes for fcs. */
348 len = skb->len + 6;
349
350 /* The mcs7780 requires that the first two bytes are the packet
351 * length in little endian order. Note: the length value includes
352 * the two bytes for the length value itself.
353 */
354 buf[0] = len & 0xff;
355 buf[1] = (len >> 8) & 0xff;
356 /* copy the data into the tx buffer. */
357 memcpy(buf+2, skb->data, skb->len);
358 /* put the fcs in the last four bytes in little endian order. */
359 buf[len - 4] = fcs & 0xff;
360 buf[len - 3] = (fcs >> 8) & 0xff;
361 buf[len - 2] = (fcs >> 16) & 0xff;
362 buf[len - 1] = (fcs >> 24) & 0xff;
363
364 return len;
365}
366
367/* Wraps the data in format for MIR */
368static unsigned mcs_wrap_mir_skb(const struct sk_buff *skb, __u8 *buf)
369{
370 __u16 fcs = 0;
371 int len = skb->len + 4;
372
373 fcs = ~(irda_calc_crc16(~fcs, skb->data, skb->len));
374 /* put the total packet length in first. Note: packet length
375 * value includes the two bytes that hold the packet length
376 * itself.
377 */
378 buf[0] = len & 0xff;
379 buf[1] = (len >> 8) & 0xff;
380 /* copy the data */
381 memcpy(buf+2, skb->data, skb->len);
382 /* put the fcs in last two bytes in little endian order. */
383 buf[len - 2] = fcs & 0xff;
384 buf[len - 1] = (fcs >> 8) & 0xff;
385
386 return len;
387}
388
389/* Unwrap received packets at MIR speed. A 16 bit crc_ccitt checksum is
390 * used for the fcs. When performed over the entire packet the result
391 * should be GOOD_FCS = 0xf0b8. Hands the unwrapped data off to the IrDA
392 * layer via a sk_buff.
393 */
394static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len)
395{
396 __u16 fcs;
397 int new_len;
398 struct sk_buff *skb;
399
400 /* Assume that the frames are going to fill a single packet
401 * rather than span multiple packets.
402 */
403
404 new_len = len - 2;
405 if(unlikely(new_len <= 0)) {
406 IRDA_ERROR("%s short frame length %d\n",
407 mcs->netdev->name, new_len);
408 ++mcs->stats.rx_errors;
409 ++mcs->stats.rx_length_errors;
410 return;
411 }
412 fcs = 0;
413 fcs = irda_calc_crc16(~fcs, buf, len);
414
415 if(fcs != GOOD_FCS) {
416 IRDA_ERROR("crc error calc 0x%x len %d\n",
417 fcs, new_len);
418 mcs->stats.rx_errors++;
419 mcs->stats.rx_crc_errors++;
420 return;
421 }
422
423 skb = dev_alloc_skb(new_len + 1);
424 if(unlikely(!skb)) {
425 ++mcs->stats.rx_dropped;
426 return;
427 }
428
429 skb_reserve(skb, 1);
430 memcpy(skb->data, buf, new_len);
431 skb_put(skb, new_len);
432 skb->mac.raw = skb->data;
433 skb->protocol = htons(ETH_P_IRDA);
434 skb->dev = mcs->netdev;
435
436 netif_rx(skb);
437
438 mcs->stats.rx_packets++;
439 mcs->stats.rx_bytes += new_len;
440
441 return;
442}
443
444/* Unwrap received packets at FIR speed. A 32 bit crc_ccitt checksum is
445 * used for the fcs. Hands the unwrapped data off to the IrDA
446 * layer via a sk_buff.
447 */
448static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len)
449{
450 __u32 fcs;
451 int new_len;
452 struct sk_buff *skb;
453
454 /* Assume that the frames are going to fill a single packet
455 * rather than span multiple packets. This is most likely a false
456 * assumption.
457 */
458
459 new_len = len - 4;
460 if(unlikely(new_len <= 0)) {
461 IRDA_ERROR("%s short frame length %d\n",
462 mcs->netdev->name, new_len);
463 ++mcs->stats.rx_errors;
464 ++mcs->stats.rx_length_errors;
465 return;
466 }
467
468 fcs = ~(crc32_le(~0, buf, new_len));
469 if(fcs != le32_to_cpu(get_unaligned((u32 *)(buf+new_len)))) {
470 IRDA_ERROR("crc error calc 0x%x len %d\n", fcs, new_len);
471 mcs->stats.rx_errors++;
472 mcs->stats.rx_crc_errors++;
473 return;
474 }
475
476 skb = dev_alloc_skb(new_len + 1);
477 if(unlikely(!skb)) {
478 ++mcs->stats.rx_dropped;
479 return;
480 }
481
482 skb_reserve(skb, 1);
483 memcpy(skb->data, buf, new_len);
484 skb_put(skb, new_len);
485 skb->mac.raw = skb->data;
486 skb->protocol = htons(ETH_P_IRDA);
487 skb->dev = mcs->netdev;
488
489 netif_rx(skb);
490
491 mcs->stats.rx_packets++;
492 mcs->stats.rx_bytes += new_len;
493
494 return;
495}
496
497
498/* Allocates urbs for both receive and transmit.
499 * If alloc fails return error code 0 (fail) otherwise
500 * return error code 1 (success).
501 */
502static inline int mcs_setup_urbs(struct mcs_cb *mcs)
503{
504 mcs->rx_urb = NULL;
505
506 mcs->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
507 if (!mcs->tx_urb)
508 return 0;
509
510 mcs->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
511 if (!mcs->rx_urb)
512 return 0;
513
514 return 1;
515}
516
517/* Sets up state to be initially outside frame, gets receive urb,
518 * sets status to successful and then submits the urb to start
519 * receiving the data.
520 */
521static inline int mcs_receive_start(struct mcs_cb *mcs)
522{
523 mcs->rx_buff.in_frame = FALSE;
524 mcs->rx_buff.state = OUTSIDE_FRAME;
525
526 usb_fill_bulk_urb(mcs->rx_urb, mcs->usbdev,
527 usb_rcvbulkpipe(mcs->usbdev, mcs->ep_in),
528 mcs->in_buf, 4096, mcs_receive_irq, mcs);
529
530 mcs->rx_urb->status = 0;
531 return usb_submit_urb(mcs->rx_urb, GFP_KERNEL);
532}
533
534/* Finds the in and out endpoints for the mcs control block */
535static inline int mcs_find_endpoints(struct mcs_cb *mcs,
536 struct usb_host_endpoint *ep, int epnum)
537{
538 int i;
539 int ret = 0;
540
541 /* If no place to store the endpoints just return */
542 if (!ep)
543 return ret;
544
545 /* cycle through all endpoints, find the first two that are DIR_IN */
546 for (i = 0; i < epnum; i++) {
547 if (ep[i].desc.bEndpointAddress & USB_DIR_IN)
548 mcs->ep_in = ep[i].desc.bEndpointAddress;
549 else
550 mcs->ep_out = ep[i].desc.bEndpointAddress;
551
552 /* MosChip says that the chip has only two bulk
553 * endpoints. Find one for each direction and move on.
554 */
555 if ((mcs->ep_in != 0) && (mcs->ep_out != 0)) {
556 ret = 1;
557 break;
558 }
559 }
560
561 return ret;
562}
563
564static void mcs_speed_work(void *arg)
565{
566 struct mcs_cb *mcs = arg;
567 struct net_device *netdev = mcs->netdev;
568
569 mcs_speed_change(mcs);
570 netif_wake_queue(netdev);
571}
572
573/* Function to change the speed of the mcs7780. Fully supports SIR,
574 * MIR, and FIR speeds.
575 */
576static int mcs_speed_change(struct mcs_cb *mcs)
577{
578 int ret = 0;
579 int rst = 0;
580 int cnt = 0;
581 __u16 nspeed;
582 __u16 rval;
583
584 nspeed = mcs_speed_set[(mcs->new_speed >> 8) & 0x0f];
585
586 do {
587 mcs_get_reg(mcs, MCS_RESV_REG, &rval);
588 } while(cnt++ < 100 && (rval & MCS_IRINTX));
589
590 if(cnt >= 100) {
591 IRDA_ERROR("unable to change speed");
592 ret = -EIO;
593 goto error;
594 }
595
596 mcs_get_reg(mcs, MCS_MODE_REG, &rval);
597
598 /* MINRXPW values recomended by MosChip */
599 if (mcs->new_speed <= 115200) {
600 rval &= ~MCS_FIR;
601
602 if ((rst = (mcs->speed > 115200)))
603 mcs_set_reg(mcs, MCS_MINRXPW_REG, 0);
604
605 } else if (mcs->new_speed <= 1152000) {
606 rval &= ~MCS_FIR;
607
608 if ((rst = !(mcs->speed == 576000 || mcs->speed == 1152000)))
609 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5);
610
611 } else {
612 rval |= MCS_FIR;
613
614 if ((rst = (mcs->speed != 4000000)))
615 mcs_set_reg(mcs, MCS_MINRXPW_REG, 5);
616
617 }
618
619 rval &= ~MCS_SPEED_MASK;
620 rval |= nspeed;
621
622 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval);
623 if (unlikely(ret))
624 goto error;
625
626 if (rst)
627 switch (mcs->transceiver_type) {
628 case MCS_TSC_VISHAY:
629 ret = mcs_setup_transceiver_vishay(mcs);
630 break;
631
632 case MCS_TSC_SHARP:
633 ret = mcs_setup_transceiver_sharp(mcs);
634 break;
635
636 case MCS_TSC_AGILENT:
637 ret = mcs_setup_transceiver_agilent(mcs);
638 break;
639
640 default:
641 ret = 1;
642 IRDA_WARNING("Unknown transceiver type: %d",
643 mcs->transceiver_type);
644 }
645 if (unlikely(ret))
646 goto error;
647
648 mcs_get_reg(mcs, MCS_MODE_REG, &rval);
649 rval &= ~MCS_RESET;
650 ret = mcs_set_reg(mcs, MCS_MODE_REG, rval);
651
652 mcs->speed = mcs->new_speed;
653 error:
654 mcs->new_speed = 0;
655 return ret;
656}
657
658/* Ioctl calls not supported at this time. Can be an area of future work. */
659static int mcs_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
660{
661 /* struct if_irda_req *irq = (struct if_irda_req *)rq; */
662 /* struct mcs_cb *mcs = netdev_priv(netdev); */
663 int ret = 0;
664
665 switch (cmd) {
666 default:
667 ret = -EOPNOTSUPP;
668 }
669
670 return ret;
671}
672
673/* Network device is taken down, done by "ifconfig irda0 down" */
674static int mcs_net_close(struct net_device *netdev)
675{
676 int ret = 0;
677 struct mcs_cb *mcs = netdev_priv(netdev);
678
679 /* Stop transmit processing */
680 netif_stop_queue(netdev);
681
682 /* kill and free the receive and transmit URBs */
683 usb_kill_urb(mcs->rx_urb);
684 usb_free_urb(mcs->rx_urb);
685 usb_kill_urb(mcs->tx_urb);
686 usb_free_urb(mcs->tx_urb);
687
688 /* Stop and remove instance of IrLAP */
689 if (mcs->irlap)
690 irlap_close(mcs->irlap);
691
692 mcs->irlap = NULL;
693 return ret;
694}
695
696/* Network device is taken up, done by "ifconfig irda0 up" */
697static int mcs_net_open(struct net_device *netdev)
698{
699 struct mcs_cb *mcs = netdev_priv(netdev);
700 char hwname[16];
701 int ret = 0;
702
703 ret = usb_clear_halt(mcs->usbdev,
704 usb_sndbulkpipe(mcs->usbdev, mcs->ep_in));
705 if (ret)
706 goto error1;
707 ret = usb_clear_halt(mcs->usbdev,
708 usb_rcvbulkpipe(mcs->usbdev, mcs->ep_out));
709 if (ret)
710 goto error1;
711
712 ret = mcs_setup_transceiver(mcs);
713 if (ret)
714 goto error1;
715
716 ret = -ENOMEM;
717
718 /* Initialize for SIR/FIR to copy data directly into skb. */
719 mcs->receiving = 0;
720 mcs->rx_buff.truesize = IRDA_SKB_MAX_MTU;
721 mcs->rx_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU);
722 if (!mcs->rx_buff.skb)
723 goto error1;
724
725 skb_reserve(mcs->rx_buff.skb, 1);
726 mcs->rx_buff.head = mcs->rx_buff.skb->data;
727 do_gettimeofday(&mcs->rx_time);
728
729 /*
730 * Now that everything should be initialized properly,
731 * Open new IrLAP layer instance to take care of us...
732 * Note : will send immediately a speed change...
733 */
734 sprintf(hwname, "usb#%d", mcs->usbdev->devnum);
735 mcs->irlap = irlap_open(netdev, &mcs->qos, hwname);
736 if (!mcs->irlap) {
737 IRDA_ERROR("mcs7780: irlap_open failed");
738 goto error2;
739 }
740
741 if (!mcs_setup_urbs(mcs))
742 goto error3;
743
744 ret = mcs_receive_start(mcs);
745 if (ret)
746 goto error3;
747
748 netif_start_queue(netdev);
749 return 0;
750
751 error3:
752 irlap_close(mcs->irlap);
753 error2:
754 kfree_skb(mcs->rx_buff.skb);
755 error1:
756 return ret;
757}
758
759
760/* Get device stats for /proc/net/dev and ifconfig */
761static struct net_device_stats *mcs_net_get_stats(struct net_device *netdev)
762{
763 struct mcs_cb *mcs = netdev_priv(netdev);
764 return &mcs->stats;
765}
766
767/* Receive callback function. */
768static void mcs_receive_irq(struct urb *urb, struct pt_regs *regs)
769{
770 __u8 *bytes;
771 struct mcs_cb *mcs = urb->context;
772 int i;
773 int ret;
774
775 if (!netif_running(mcs->netdev))
776 return;
777
778 if (urb->status)
779 return;
780
781 if (urb->actual_length > 0) {
782 bytes = urb->transfer_buffer;
783
784 /* MCS returns frames without BOF and EOF
785 * I assume it returns whole frames.
786 */
787 /* SIR speed */
788 if(mcs->speed < 576000) {
789 async_unwrap_char(mcs->netdev, &mcs->stats,
790 &mcs->rx_buff, 0xc0);
791
792 for (i = 0; i < urb->actual_length; i++)
793 async_unwrap_char(mcs->netdev, &mcs->stats,
794 &mcs->rx_buff, bytes[i]);
795
796 async_unwrap_char(mcs->netdev, &mcs->stats,
797 &mcs->rx_buff, 0xc1);
798 }
799 /* MIR speed */
800 else if(mcs->speed == 576000 || mcs->speed == 1152000) {
801 mcs_unwrap_mir(mcs, urb->transfer_buffer,
802 urb->actual_length);
803 }
804 /* FIR speed */
805 else {
806 mcs_unwrap_fir(mcs, urb->transfer_buffer,
807 urb->actual_length);
808 }
809 mcs->netdev->last_rx = jiffies;
810 do_gettimeofday(&mcs->rx_time);
811 }
812
813 ret = usb_submit_urb(urb, GFP_ATOMIC);
814}
815
816/* Transmit callback funtion. */
817static void mcs_send_irq(struct urb *urb, struct pt_regs *regs)
818{
819 struct mcs_cb *mcs = urb->context;
820 struct net_device *ndev = mcs->netdev;
821
822 if (unlikely(mcs->new_speed))
823 schedule_work(&mcs->work);
824 else
825 netif_wake_queue(ndev);
826}
827
828/* Transmit callback funtion. */
829static int mcs_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
830{
831 unsigned long flags;
832 struct mcs_cb *mcs;
833 int wraplen;
834 int ret = 0;
835
836
837 if (skb == NULL || ndev == NULL)
838 return -EINVAL;
839
840 netif_stop_queue(ndev);
841 mcs = netdev_priv(ndev);
842
843 spin_lock_irqsave(&mcs->lock, flags);
844
845 mcs->new_speed = irda_get_next_speed(skb);
846 if (likely(mcs->new_speed == mcs->speed))
847 mcs->new_speed = 0;
848
849 /* SIR speed */
850 if(mcs->speed < 576000) {
851 wraplen = mcs_wrap_sir_skb(skb, mcs->out_buf);
852 }
853 /* MIR speed */
854 else if(mcs->speed == 576000 || mcs->speed == 1152000) {
855 wraplen = mcs_wrap_mir_skb(skb, mcs->out_buf);
856 }
857 /* FIR speed */
858 else {
859 wraplen = mcs_wrap_fir_skb(skb, mcs->out_buf);
860 }
861 usb_fill_bulk_urb(mcs->tx_urb, mcs->usbdev,
862 usb_sndbulkpipe(mcs->usbdev, mcs->ep_out),
863 mcs->out_buf, wraplen, mcs_send_irq, mcs);
864
865 if ((ret = usb_submit_urb(mcs->tx_urb, GFP_ATOMIC))) {
866 IRDA_ERROR("failed tx_urb: %d", ret);
867 switch (ret) {
868 case -ENODEV:
869 case -EPIPE:
870 break;
871 default:
872 mcs->stats.tx_errors++;
873 netif_start_queue(ndev);
874 }
875 } else {
876 mcs->stats.tx_packets++;
877 mcs->stats.tx_bytes += skb->len;
878 }
879
880 dev_kfree_skb(skb);
881 spin_unlock_irqrestore(&mcs->lock, flags);
882 return ret;
883}
884
885/*
886 * This function is called by the USB subsystem for each new device in the
887 * system. Need to verify the device and if it is, then start handling it.
888 */
889static int mcs_probe(struct usb_interface *intf,
890 const struct usb_device_id *id)
891{
892 struct usb_device *udev = interface_to_usbdev(intf);
893 struct net_device *ndev = NULL;
894 struct mcs_cb *mcs;
895 int ret = -ENOMEM;
896
897 ndev = alloc_irdadev(sizeof(*mcs));
898 if (!ndev)
899 goto error1;
900
901 IRDA_DEBUG(1, "MCS7780 USB-IrDA bridge found at %d.", udev->devnum);
902
903 /* what is it realy for? */
904 SET_MODULE_OWNER(ndev);
905 SET_NETDEV_DEV(ndev, &intf->dev);
906
907 ret = usb_reset_configuration(udev);
908 if (ret != 0) {
909 IRDA_ERROR("mcs7780: usb reset configuration failed");
910 goto error2;
911 }
912
913 mcs = netdev_priv(ndev);
914 mcs->usbdev = udev;
915 mcs->netdev = ndev;
916 spin_lock_init(&mcs->lock);
917
918 /* Initialize QoS for this device */
919 irda_init_max_qos_capabilies(&mcs->qos);
920
921 /* That's the Rx capability. */
922 mcs->qos.baud_rate.bits &=
923 IR_2400 | IR_9600 | IR_19200 | IR_38400 | IR_57600 | IR_115200
924 | IR_576000 | IR_1152000 | (IR_4000000 << 8);
925
926
927 mcs->qos.min_turn_time.bits &= qos_mtt_bits;
928 irda_qos_bits_to_value(&mcs->qos);
929
930 /* Speed change work initialisation*/
931 INIT_WORK(&mcs->work, mcs_speed_work, mcs);
932
933 /* Override the network functions we need to use */
934 ndev->hard_start_xmit = mcs_hard_xmit;
935 ndev->open = mcs_net_open;
936 ndev->stop = mcs_net_close;
937 ndev->get_stats = mcs_net_get_stats;
938 ndev->do_ioctl = mcs_net_ioctl;
939
940 if (!intf->cur_altsetting)
941 goto error2;
942
943 ret = mcs_find_endpoints(mcs, intf->cur_altsetting->endpoint,
944 intf->cur_altsetting->desc.bNumEndpoints);
945 if (!ret) {
946 ret = -ENODEV;
947 goto error2;
948 }
949
950 ret = register_netdev(ndev);
951 if (ret != 0)
952 goto error2;
953
954 IRDA_DEBUG(1, "IrDA: Registered MosChip MCS7780 device as %s",
955 ndev->name);
956
957 mcs->transceiver_type = transceiver_type;
958 mcs->sir_tweak = sir_tweak;
959 mcs->receive_mode = receive_mode;
960
961 usb_set_intfdata(intf, mcs);
962 return 0;
963
964 error2:
965 free_netdev(ndev);
966
967 error1:
968 return ret;
969}
970
971/* The current device is removed, the USB layer tells us to shut down. */
972static void mcs_disconnect(struct usb_interface *intf)
973{
974 struct mcs_cb *mcs = usb_get_intfdata(intf);
975
976 if (!mcs)
977 return;
978
979 flush_scheduled_work();
980
981 unregister_netdev(mcs->netdev);
982 free_netdev(mcs->netdev);
983
984 usb_set_intfdata(intf, NULL);
985 IRDA_DEBUG(0, "MCS7780 now disconnected.");
986}
987
988/* Module insertion */
989static int __init mcs_init(void)
990{
991 int result;
992
993 /* register this driver with the USB subsystem */
994 result = usb_register(&mcs_driver);
995 if (result)
996 IRDA_ERROR("usb_register failed. Error number %d", result);
997
998 return result;
999}
1000module_init(mcs_init);
1001
1002/* Module removal */
1003static void __exit mcs_exit(void)
1004{
1005 /* deregister this driver with the USB subsystem */
1006 usb_deregister(&mcs_driver);
1007}
1008module_exit(mcs_exit);
1009
diff --git a/drivers/net/irda/mcs7780.h b/drivers/net/irda/mcs7780.h
new file mode 100644
index 000000000000..1a723d725c2a
--- /dev/null
+++ b/drivers/net/irda/mcs7780.h
@@ -0,0 +1,167 @@
1/*****************************************************************************
2*
3* Filename: mcs7780.h
4* Version: 0.2-alpha
5* Description: Irda MosChip USB Dongle
6* Status: Experimental
7* Authors: Lukasz Stelmach <stlman@poczta.fm>
8* Brian Pugh <bpugh@cs.pdx.edu>
9*
10* Copyright (C) 2005, Lukasz Stelmach <stlman@poczta.fm>
11* Copyright (C) 2005, Brian Pugh <bpugh@cs.pdx.edu>
12*
13* This program is free software; you can redistribute it and/or modify
14* it under the terms of the GNU General Public License as published by
15* the Free Software Foundation; either version 2 of the License, or
16* (at your option) any later version.
17*
18* This program is distributed in the hope that it will be useful,
19* but WITHOUT ANY WARRANTY; without even the implied warranty of
20* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21* GNU General Public License for more details.
22*
23* You should have received a copy of the GNU General Public License
24* along with this program; if not, write to the Free Software
25* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26*
27*****************************************************************************/
28#ifndef _MCS7780_H
29#define _MCS7780_H
30
31#define MCS_MODE_SIR 0
32#define MCS_MODE_MIR 1
33#define MCS_MODE_FIR 2
34
35#define MCS_CTRL_TIMEOUT 500
36#define MCS_XMIT_TIMEOUT 500
37/* Possible transceiver types */
38#define MCS_TSC_VISHAY 0 /* Vishay TFD, default choice */
39#define MCS_TSC_AGILENT 1 /* Agilent 3602/3600 */
40#define MCS_TSC_SHARP 2 /* Sharp GP2W1000YP */
41
42/* Requests */
43#define MCS_RD_RTYPE 0xC0
44#define MCS_WR_RTYPE 0x40
45#define MCS_RDREQ 0x0F
46#define MCS_WRREQ 0x0E
47
48/* Register 0x00 */
49#define MCS_MODE_REG 0
50#define MCS_FIR ((__u16)0x0001)
51#define MCS_SIR16US ((__u16)0x0002)
52#define MCS_BBTG ((__u16)0x0004)
53#define MCS_ASK ((__u16)0x0008)
54#define MCS_PARITY ((__u16)0x0010)
55
56/* SIR/MIR speed constants */
57#define MCS_SPEED_SHIFT 5
58#define MCS_SPEED_MASK ((__u16)0x00E0)
59#define MCS_SPEED(x) ((x & MCS_SPEED_MASK) >> MCS_SPEED_SHIFT)
60#define MCS_SPEED_2400 ((0 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
61#define MCS_SPEED_9600 ((1 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
62#define MCS_SPEED_19200 ((2 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
63#define MCS_SPEED_38400 ((3 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
64#define MCS_SPEED_57600 ((4 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
65#define MCS_SPEED_115200 ((5 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
66#define MCS_SPEED_576000 ((6 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
67#define MCS_SPEED_1152000 ((7 << MCS_SPEED_SHIFT) & MCS_SPEED_MASK)
68
69#define MCS_PLLPWDN ((__u16)0x0100)
70#define MCS_DRIVER ((__u16)0x0200)
71#define MCS_DTD ((__u16)0x0400)
72#define MCS_DIR ((__u16)0x0800)
73#define MCS_SIPEN ((__u16)0x1000)
74#define MCS_SENDSIP ((__u16)0x2000)
75#define MCS_CHGDIR ((__u16)0x4000)
76#define MCS_RESET ((__u16)0x8000)
77
78/* Register 0x02 */
79#define MCS_XCVR_REG 2
80#define MCS_MODE0 ((__u16)0x0001)
81#define MCS_STFIR ((__u16)0x0002)
82#define MCS_XCVR_CONF ((__u16)0x0004)
83#define MCS_RXFAST ((__u16)0x0008)
84/* TXCUR [6:4] */
85#define MCS_TXCUR_SHIFT 4
86#define MCS_TXCUR_MASK ((__u16)0x0070)
87#define MCS_TXCUR(x) ((x & MCS_TXCUR_MASK) >> MCS_TXCUR_SHIFT)
88#define MCS_SETTXCUR(x,y) \
89 ((x & ~MCS_TXCUR_MASK) | (y << MCS_TXCUR_SHIFT) & MCS_TXCUR_MASK)
90
91#define MCS_MODE1 ((__u16)0x0080)
92#define MCS_SMODE0 ((__u16)0x0100)
93#define MCS_SMODE1 ((__u16)0x0200)
94#define MCS_INVTX ((__u16)0x0400)
95#define MCS_INVRX ((__u16)0x0800)
96
97#define MCS_MINRXPW_REG 4
98
99#define MCS_RESV_REG 7
100#define MCS_IRINTX ((__u16)0x0001)
101#define MCS_IRINRX ((__u16)0x0002)
102
103struct mcs_cb {
104 struct usb_device *usbdev; /* init: probe_irda */
105 struct net_device *netdev; /* network layer */
106 struct irlap_cb *irlap; /* The link layer we are binded to */
107 struct net_device_stats stats; /* network statistics */
108 struct qos_info qos;
109 unsigned int speed; /* Current speed */
110 unsigned int new_speed; /* new speed */
111
112 struct work_struct work; /* Change speed work */
113
114 struct sk_buff *tx_pending;
115 char in_buf[4096]; /* transmit/receive buffer */
116 char out_buf[4096]; /* transmit/receive buffer */
117 __u8 *fifo_status;
118
119 iobuff_t rx_buff; /* receive unwrap state machine */
120 struct timeval rx_time;
121 spinlock_t lock;
122 int receiving;
123
124 __u8 ep_in;
125 __u8 ep_out;
126
127 struct urb *rx_urb;
128 struct urb *tx_urb;
129
130 int transceiver_type;
131 int sir_tweak;
132 int receive_mode;
133};
134
135static int mcs_set_reg(struct mcs_cb *mcs, __u16 reg, __u16 val);
136static int mcs_get_reg(struct mcs_cb *mcs, __u16 reg, __u16 * val);
137
138static inline int mcs_setup_transceiver_vishay(struct mcs_cb *mcs);
139static inline int mcs_setup_transceiver_agilent(struct mcs_cb *mcs);
140static inline int mcs_setup_transceiver_sharp(struct mcs_cb *mcs);
141static inline int mcs_setup_transceiver(struct mcs_cb *mcs);
142static inline int mcs_wrap_sir_skb(struct sk_buff *skb, __u8 * buf);
143static unsigned mcs_wrap_fir_skb(const struct sk_buff *skb, __u8 *buf);
144static unsigned mcs_wrap_mir_skb(const struct sk_buff *skb, __u8 *buf);
145static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len);
146static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len);
147static inline int mcs_setup_urbs(struct mcs_cb *mcs);
148static inline int mcs_receive_start(struct mcs_cb *mcs);
149static inline int mcs_find_endpoints(struct mcs_cb *mcs,
150 struct usb_host_endpoint *ep, int epnum);
151
152static int mcs_speed_change(struct mcs_cb *mcs);
153
154static int mcs_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd);
155static int mcs_net_close(struct net_device *netdev);
156static int mcs_net_open(struct net_device *netdev);
157static struct net_device_stats *mcs_net_get_stats(struct net_device *netdev);
158
159static void mcs_receive_irq(struct urb *urb, struct pt_regs *regs);
160static void mcs_send_irq(struct urb *urb, struct pt_regs *regs);
161static int mcs_hard_xmit(struct sk_buff *skb, struct net_device *netdev);
162
163static int mcs_probe(struct usb_interface *intf,
164 const struct usb_device_id *id);
165static void mcs_disconnect(struct usb_interface *intf);
166
167#endif /* _MCS7780_H */
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 31867e4b891b..d61b208b52a2 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -50,6 +50,7 @@
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/usb.h> 51#include <linux/usb.h>
52#include <linux/crc32.h> 52#include <linux/crc32.h>
53#include <linux/kthread.h>
53#include <net/irda/irda.h> 54#include <net/irda/irda.h>
54#include <net/irda/irlap.h> 55#include <net/irda/irlap.h>
55#include <net/irda/irda_device.h> 56#include <net/irda/irda_device.h>
@@ -173,9 +174,7 @@ struct stir_cb {
173 struct qos_info qos; 174 struct qos_info qos;
174 unsigned speed; /* Current speed */ 175 unsigned speed; /* Current speed */
175 176
176 wait_queue_head_t thr_wait; /* transmit thread wakeup */ 177 struct task_struct *thread; /* transmit thread */
177 struct completion thr_exited;
178 pid_t thr_pid;
179 178
180 struct sk_buff *tx_pending; 179 struct sk_buff *tx_pending;
181 void *io_buf; /* transmit/receive buffer */ 180 void *io_buf; /* transmit/receive buffer */
@@ -577,7 +576,7 @@ static int stir_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
577 SKB_LINEAR_ASSERT(skb); 576 SKB_LINEAR_ASSERT(skb);
578 577
579 skb = xchg(&stir->tx_pending, skb); 578 skb = xchg(&stir->tx_pending, skb);
580 wake_up(&stir->thr_wait); 579 wake_up_process(stir->thread);
581 580
582 /* this should never happen unless stop/wakeup problem */ 581 /* this should never happen unless stop/wakeup problem */
583 if (unlikely(skb)) { 582 if (unlikely(skb)) {
@@ -753,13 +752,7 @@ static int stir_transmit_thread(void *arg)
753 struct net_device *dev = stir->netdev; 752 struct net_device *dev = stir->netdev;
754 struct sk_buff *skb; 753 struct sk_buff *skb;
755 754
756 daemonize("%s", dev->name); 755 while (!kthread_should_stop()) {
757 allow_signal(SIGTERM);
758
759 while (netif_running(dev)
760 && netif_device_present(dev)
761 && !signal_pending(current))
762 {
763#ifdef CONFIG_PM 756#ifdef CONFIG_PM
764 /* if suspending, then power off and wait */ 757 /* if suspending, then power off and wait */
765 if (unlikely(freezing(current))) { 758 if (unlikely(freezing(current))) {
@@ -813,10 +806,11 @@ static int stir_transmit_thread(void *arg)
813 } 806 }
814 807
815 /* sleep if nothing to send */ 808 /* sleep if nothing to send */
816 wait_event_interruptible(stir->thr_wait, stir->tx_pending); 809 set_current_state(TASK_INTERRUPTIBLE);
817 } 810 schedule();
818 811
819 complete_and_exit (&stir->thr_exited, 0); 812 }
813 return 0;
820} 814}
821 815
822 816
@@ -859,7 +853,7 @@ static void stir_rcv_irq(struct urb *urb, struct pt_regs *regs)
859 warn("%s: usb receive submit error: %d", 853 warn("%s: usb receive submit error: %d",
860 stir->netdev->name, err); 854 stir->netdev->name, err);
861 stir->receiving = 0; 855 stir->receiving = 0;
862 wake_up(&stir->thr_wait); 856 wake_up_process(stir->thread);
863 } 857 }
864} 858}
865 859
@@ -928,10 +922,10 @@ static int stir_net_open(struct net_device *netdev)
928 } 922 }
929 923
930 /** Start kernel thread for transmit. */ 924 /** Start kernel thread for transmit. */
931 stir->thr_pid = kernel_thread(stir_transmit_thread, stir, 925 stir->thread = kthread_run(stir_transmit_thread, stir,
932 CLONE_FS|CLONE_FILES); 926 "%s", stir->netdev->name);
933 if (stir->thr_pid < 0) { 927 if (IS_ERR(stir->thread)) {
934 err = stir->thr_pid; 928 err = PTR_ERR(stir->thread);
935 err("stir4200: unable to start kernel thread"); 929 err("stir4200: unable to start kernel thread");
936 goto err_out6; 930 goto err_out6;
937 } 931 }
@@ -968,8 +962,7 @@ static int stir_net_close(struct net_device *netdev)
968 netif_stop_queue(netdev); 962 netif_stop_queue(netdev);
969 963
970 /* Kill transmit thread */ 964 /* Kill transmit thread */
971 kill_proc(stir->thr_pid, SIGTERM, 1); 965 kthread_stop(stir->thread);
972 wait_for_completion(&stir->thr_exited);
973 kfree(stir->fifo_status); 966 kfree(stir->fifo_status);
974 967
975 /* Mop up receive urb's */ 968 /* Mop up receive urb's */
@@ -1084,9 +1077,6 @@ static int stir_probe(struct usb_interface *intf,
1084 stir->qos.min_turn_time.bits &= qos_mtt_bits; 1077 stir->qos.min_turn_time.bits &= qos_mtt_bits;
1085 irda_qos_bits_to_value(&stir->qos); 1078 irda_qos_bits_to_value(&stir->qos);
1086 1079
1087 init_completion (&stir->thr_exited);
1088 init_waitqueue_head (&stir->thr_wait);
1089
1090 /* Override the network functions we need to use */ 1080 /* Override the network functions we need to use */
1091 net->hard_start_xmit = stir_hard_xmit; 1081 net->hard_start_xmit = stir_hard_xmit;
1092 net->open = stir_net_open; 1082 net->open = stir_net_open;
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 97a49e0be76b..d70b9e8d6e60 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -959,7 +959,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
959 || (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec)) 959 || (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
960 break; 960 break;
961 udelay(100); 961 udelay(100);
962 /* must not sleep here - we are called under xmit_lock! */ 962 /* must not sleep here - called under netif_tx_lock! */
963 } 963 }
964 } 964 }
965 965
diff --git a/drivers/net/ixgb/Makefile b/drivers/net/ixgb/Makefile
index 7c7aff1ea7d5..a8a2d3d03567 100644
--- a/drivers/net/ixgb/Makefile
+++ b/drivers/net/ixgb/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# 3#
4# Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved. 4# Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by the Free 7# under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
index c83271b38621..a83ef28dadb0 100644
--- a/drivers/net/ixgb/ixgb.h
+++ b/drivers/net/ixgb/ixgb.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -84,7 +84,12 @@ struct ixgb_adapter;
84#define IXGB_DBG(args...) 84#define IXGB_DBG(args...)
85#endif 85#endif
86 86
87#define IXGB_ERR(args...) printk(KERN_ERR "ixgb: " args) 87#define PFX "ixgb: "
88#define DPRINTK(nlevel, klevel, fmt, args...) \
89 (void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \
90 printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \
91 __FUNCTION__ , ## args))
92
88 93
89/* TX/RX descriptor defines */ 94/* TX/RX descriptor defines */
90#define DEFAULT_TXD 256 95#define DEFAULT_TXD 256
@@ -175,6 +180,7 @@ struct ixgb_adapter {
175 uint64_t hw_csum_tx_good; 180 uint64_t hw_csum_tx_good;
176 uint64_t hw_csum_tx_error; 181 uint64_t hw_csum_tx_error;
177 uint32_t tx_int_delay; 182 uint32_t tx_int_delay;
183 uint32_t tx_timeout_count;
178 boolean_t tx_int_delay_enable; 184 boolean_t tx_int_delay_enable;
179 boolean_t detect_tx_hung; 185 boolean_t detect_tx_hung;
180 186
@@ -192,7 +198,9 @@ struct ixgb_adapter {
192 198
193 /* structs defined in ixgb_hw.h */ 199 /* structs defined in ixgb_hw.h */
194 struct ixgb_hw hw; 200 struct ixgb_hw hw;
201 u16 msg_enable;
195 struct ixgb_hw_stats stats; 202 struct ixgb_hw_stats stats;
203 uint32_t alloc_rx_buff_failed;
196#ifdef CONFIG_PCI_MSI 204#ifdef CONFIG_PCI_MSI
197 boolean_t have_msi; 205 boolean_t have_msi;
198#endif 206#endif
diff --git a/drivers/net/ixgb/ixgb_ee.c b/drivers/net/ixgb/ixgb_ee.c
index 661a46b95a61..8357c5590bfb 100644
--- a/drivers/net/ixgb/ixgb_ee.c
+++ b/drivers/net/ixgb/ixgb_ee.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/net/ixgb/ixgb_ee.h b/drivers/net/ixgb/ixgb_ee.h
index 5190aa8761a2..bf6fa220f38e 100644
--- a/drivers/net/ixgb/ixgb_ee.h
+++ b/drivers/net/ixgb/ixgb_ee.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index d38ade5f2f4e..cf19b898ba9b 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -44,6 +44,8 @@ extern void ixgb_free_rx_resources(struct ixgb_adapter *adapter);
44extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter); 44extern void ixgb_free_tx_resources(struct ixgb_adapter *adapter);
45extern void ixgb_update_stats(struct ixgb_adapter *adapter); 45extern void ixgb_update_stats(struct ixgb_adapter *adapter);
46 46
47#define IXGB_ALL_RAR_ENTRIES 16
48
47struct ixgb_stats { 49struct ixgb_stats {
48 char stat_string[ETH_GSTRING_LEN]; 50 char stat_string[ETH_GSTRING_LEN];
49 int sizeof_stat; 51 int sizeof_stat;
@@ -76,6 +78,7 @@ static struct ixgb_stats ixgb_gstrings_stats[] = {
76 {"tx_heartbeat_errors", IXGB_STAT(net_stats.tx_heartbeat_errors)}, 78 {"tx_heartbeat_errors", IXGB_STAT(net_stats.tx_heartbeat_errors)},
77 {"tx_window_errors", IXGB_STAT(net_stats.tx_window_errors)}, 79 {"tx_window_errors", IXGB_STAT(net_stats.tx_window_errors)},
78 {"tx_deferred_ok", IXGB_STAT(stats.dc)}, 80 {"tx_deferred_ok", IXGB_STAT(stats.dc)},
81 {"tx_timeout_count", IXGB_STAT(tx_timeout_count) },
79 {"rx_long_length_errors", IXGB_STAT(stats.roc)}, 82 {"rx_long_length_errors", IXGB_STAT(stats.roc)},
80 {"rx_short_length_errors", IXGB_STAT(stats.ruc)}, 83 {"rx_short_length_errors", IXGB_STAT(stats.ruc)},
81#ifdef NETIF_F_TSO 84#ifdef NETIF_F_TSO
@@ -117,6 +120,16 @@ ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
117 return 0; 120 return 0;
118} 121}
119 122
123static void ixgb_set_speed_duplex(struct net_device *netdev)
124{
125 struct ixgb_adapter *adapter = netdev_priv(netdev);
126 /* be optimistic about our link, since we were up before */
127 adapter->link_speed = 10000;
128 adapter->link_duplex = FULL_DUPLEX;
129 netif_carrier_on(netdev);
130 netif_wake_queue(netdev);
131}
132
120static int 133static int
121ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 134ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
122{ 135{
@@ -130,12 +143,7 @@ ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
130 ixgb_down(adapter, TRUE); 143 ixgb_down(adapter, TRUE);
131 ixgb_reset(adapter); 144 ixgb_reset(adapter);
132 ixgb_up(adapter); 145 ixgb_up(adapter);
133 /* be optimistic about our link, since we were up before */ 146 ixgb_set_speed_duplex(netdev);
134 adapter->link_speed = 10000;
135 adapter->link_duplex = FULL_DUPLEX;
136 netif_carrier_on(netdev);
137 netif_wake_queue(netdev);
138
139 } else 147 } else
140 ixgb_reset(adapter); 148 ixgb_reset(adapter);
141 149
@@ -183,11 +191,7 @@ ixgb_set_pauseparam(struct net_device *netdev,
183 if(netif_running(adapter->netdev)) { 191 if(netif_running(adapter->netdev)) {
184 ixgb_down(adapter, TRUE); 192 ixgb_down(adapter, TRUE);
185 ixgb_up(adapter); 193 ixgb_up(adapter);
186 /* be optimistic about our link, since we were up before */ 194 ixgb_set_speed_duplex(netdev);
187 adapter->link_speed = 10000;
188 adapter->link_duplex = FULL_DUPLEX;
189 netif_carrier_on(netdev);
190 netif_wake_queue(netdev);
191 } else 195 } else
192 ixgb_reset(adapter); 196 ixgb_reset(adapter);
193 197
@@ -212,11 +216,7 @@ ixgb_set_rx_csum(struct net_device *netdev, uint32_t data)
212 if(netif_running(netdev)) { 216 if(netif_running(netdev)) {
213 ixgb_down(adapter,TRUE); 217 ixgb_down(adapter,TRUE);
214 ixgb_up(adapter); 218 ixgb_up(adapter);
215 /* be optimistic about our link, since we were up before */ 219 ixgb_set_speed_duplex(netdev);
216 adapter->link_speed = 10000;
217 adapter->link_duplex = FULL_DUPLEX;
218 netif_carrier_on(netdev);
219 netif_wake_queue(netdev);
220 } else 220 } else
221 ixgb_reset(adapter); 221 ixgb_reset(adapter);
222 return 0; 222 return 0;
@@ -251,6 +251,19 @@ ixgb_set_tso(struct net_device *netdev, uint32_t data)
251} 251}
252#endif /* NETIF_F_TSO */ 252#endif /* NETIF_F_TSO */
253 253
254static uint32_t
255ixgb_get_msglevel(struct net_device *netdev)
256{
257 struct ixgb_adapter *adapter = netdev_priv(netdev);
258 return adapter->msg_enable;
259}
260
261static void
262ixgb_set_msglevel(struct net_device *netdev, uint32_t data)
263{
264 struct ixgb_adapter *adapter = netdev_priv(netdev);
265 adapter->msg_enable = data;
266}
254#define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_ 267#define IXGB_GET_STAT(_A_, _R_) _A_->stats._R_
255 268
256static int 269static int
@@ -303,7 +316,7 @@ ixgb_get_regs(struct net_device *netdev,
303 *reg++ = IXGB_READ_REG(hw, RXCSUM); /* 20 */ 316 *reg++ = IXGB_READ_REG(hw, RXCSUM); /* 20 */
304 317
305 /* there are 16 RAR entries in hardware, we only use 3 */ 318 /* there are 16 RAR entries in hardware, we only use 3 */
306 for(i = 0; i < 16; i++) { 319 for(i = 0; i < IXGB_ALL_RAR_ENTRIES; i++) {
307 *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */ 320 *reg++ = IXGB_READ_REG_ARRAY(hw, RAL, (i << 1)); /*21,...,51 */
308 *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */ 321 *reg++ = IXGB_READ_REG_ARRAY(hw, RAH, (i << 1)); /*22,...,52 */
309 } 322 }
@@ -593,11 +606,7 @@ ixgb_set_ringparam(struct net_device *netdev,
593 adapter->tx_ring = tx_new; 606 adapter->tx_ring = tx_new;
594 if((err = ixgb_up(adapter))) 607 if((err = ixgb_up(adapter)))
595 return err; 608 return err;
596 /* be optimistic about our link, since we were up before */ 609 ixgb_set_speed_duplex(netdev);
597 adapter->link_speed = 10000;
598 adapter->link_duplex = FULL_DUPLEX;
599 netif_carrier_on(netdev);
600 netif_wake_queue(netdev);
601 } 610 }
602 611
603 return 0; 612 return 0;
@@ -714,6 +723,8 @@ static struct ethtool_ops ixgb_ethtool_ops = {
714 .set_tx_csum = ixgb_set_tx_csum, 723 .set_tx_csum = ixgb_set_tx_csum,
715 .get_sg = ethtool_op_get_sg, 724 .get_sg = ethtool_op_get_sg,
716 .set_sg = ethtool_op_set_sg, 725 .set_sg = ethtool_op_set_sg,
726 .get_msglevel = ixgb_get_msglevel,
727 .set_msglevel = ixgb_set_msglevel,
717#ifdef NETIF_F_TSO 728#ifdef NETIF_F_TSO
718 .get_tso = ethtool_op_get_tso, 729 .get_tso = ethtool_op_get_tso,
719 .set_tso = ixgb_set_tso, 730 .set_tso = ixgb_set_tso,
diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
index 620cad48bdea..f7fa10e47fa2 100644
--- a/drivers/net/ixgb/ixgb_hw.c
+++ b/drivers/net/ixgb/ixgb_hw.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/net/ixgb/ixgb_hw.h b/drivers/net/ixgb/ixgb_hw.h
index 382c6300ccc2..cb4568915ada 100644
--- a/drivers/net/ixgb/ixgb_hw.h
+++ b/drivers/net/ixgb/ixgb_hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -57,6 +57,7 @@ typedef enum {
57typedef enum { 57typedef enum {
58 ixgb_media_type_unknown = 0, 58 ixgb_media_type_unknown = 0,
59 ixgb_media_type_fiber = 1, 59 ixgb_media_type_fiber = 1,
60 ixgb_media_type_copper = 2,
60 ixgb_num_media_types 61 ixgb_num_media_types
61} ixgb_media_type; 62} ixgb_media_type;
62 63
diff --git a/drivers/net/ixgb/ixgb_ids.h b/drivers/net/ixgb/ixgb_ids.h
index aee207eaa287..40a085f94c7b 100644
--- a/drivers/net/ixgb/ixgb_ids.h
+++ b/drivers/net/ixgb/ixgb_ids.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -43,6 +43,8 @@
43#define IXGB_SUBDEVICE_ID_A11F 0xA11F 43#define IXGB_SUBDEVICE_ID_A11F 0xA11F
44#define IXGB_SUBDEVICE_ID_A01F 0xA01F 44#define IXGB_SUBDEVICE_ID_A01F 0xA01F
45 45
46#endif /* #ifndef _IXGB_IDS_H_ */ 46#define IXGB_DEVICE_ID_82597EX_CX4 0x109E
47#define IXGB_SUBDEVICE_ID_A00C 0xA00C
47 48
49#endif /* #ifndef _IXGB_IDS_H_ */
48/* End of File */ 50/* End of File */
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index cfd67d812f0d..57006fb8840e 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -28,22 +28,6 @@
28 28
29#include "ixgb.h" 29#include "ixgb.h"
30 30
31/* Change Log
32 * 1.0.96 04/19/05
33 * - Make needlessly global code static -- bunk@stusta.de
34 * - ethtool cleanup -- shemminger@osdl.org
35 * - Support for MODULE_VERSION -- linville@tuxdriver.com
36 * - add skb_header_cloned check to the tso path -- herbert@apana.org.au
37 * 1.0.88 01/05/05
38 * - include fix to the condition that determines when to quit NAPI - Robert Olsson
39 * - use netif_poll_{disable/enable} to synchronize between NAPI and i/f up/down
40 * 1.0.84 10/26/04
41 * - reset buffer_info->dma in Tx resource cleanup logic
42 * 1.0.83 10/12/04
43 * - sparse cleanup - shemminger@osdl.org
44 * - fix tx resource cleanup logic
45 */
46
47char ixgb_driver_name[] = "ixgb"; 31char ixgb_driver_name[] = "ixgb";
48static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver"; 32static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
49 33
@@ -52,9 +36,9 @@ static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
52#else 36#else
53#define DRIVERNAPI "-NAPI" 37#define DRIVERNAPI "-NAPI"
54#endif 38#endif
55#define DRV_VERSION "1.0.100-k2"DRIVERNAPI 39#define DRV_VERSION "1.0.109-k2"DRIVERNAPI
56char ixgb_driver_version[] = DRV_VERSION; 40char ixgb_driver_version[] = DRV_VERSION;
57static char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 41static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
58 42
59/* ixgb_pci_tbl - PCI Device ID Table 43/* ixgb_pci_tbl - PCI Device ID Table
60 * 44 *
@@ -67,6 +51,8 @@ static char ixgb_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
67static struct pci_device_id ixgb_pci_tbl[] = { 51static struct pci_device_id ixgb_pci_tbl[] = {
68 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX, 52 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
69 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 53 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
54 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_CX4,
55 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
70 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR, 56 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
71 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 57 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
72 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_LR, 58 {INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_LR,
@@ -148,6 +134,11 @@ MODULE_DESCRIPTION("Intel(R) PRO/10GbE Network Driver");
148MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL");
149MODULE_VERSION(DRV_VERSION); 135MODULE_VERSION(DRV_VERSION);
150 136
137#define DEFAULT_DEBUG_LEVEL_SHIFT 3
138static int debug = DEFAULT_DEBUG_LEVEL_SHIFT;
139module_param(debug, int, 0);
140MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
141
151/* some defines for controlling descriptor fetches in h/w */ 142/* some defines for controlling descriptor fetches in h/w */
152#define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */ 143#define RXDCTL_WTHRESH_DEFAULT 16 /* chip writes back at this many or RXT0 */
153#define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below 144#define RXDCTL_PTHRESH_DEFAULT 0 /* chip considers prefech below
@@ -196,7 +187,7 @@ module_exit(ixgb_exit_module);
196 * @adapter: board private structure 187 * @adapter: board private structure
197 **/ 188 **/
198 189
199static inline void 190static void
200ixgb_irq_disable(struct ixgb_adapter *adapter) 191ixgb_irq_disable(struct ixgb_adapter *adapter)
201{ 192{
202 atomic_inc(&adapter->irq_sem); 193 atomic_inc(&adapter->irq_sem);
@@ -210,7 +201,7 @@ ixgb_irq_disable(struct ixgb_adapter *adapter)
210 * @adapter: board private structure 201 * @adapter: board private structure
211 **/ 202 **/
212 203
213static inline void 204static void
214ixgb_irq_enable(struct ixgb_adapter *adapter) 205ixgb_irq_enable(struct ixgb_adapter *adapter)
215{ 206{
216 if(atomic_dec_and_test(&adapter->irq_sem)) { 207 if(atomic_dec_and_test(&adapter->irq_sem)) {
@@ -231,6 +222,7 @@ ixgb_up(struct ixgb_adapter *adapter)
231 222
232 /* hardware has been reset, we need to reload some things */ 223 /* hardware has been reset, we need to reload some things */
233 224
225 ixgb_rar_set(hw, netdev->dev_addr, 0);
234 ixgb_set_multi(netdev); 226 ixgb_set_multi(netdev);
235 227
236 ixgb_restore_vlan(adapter); 228 ixgb_restore_vlan(adapter);
@@ -240,6 +232,9 @@ ixgb_up(struct ixgb_adapter *adapter)
240 ixgb_configure_rx(adapter); 232 ixgb_configure_rx(adapter);
241 ixgb_alloc_rx_buffers(adapter); 233 ixgb_alloc_rx_buffers(adapter);
242 234
235 /* disable interrupts and get the hardware into a known state */
236 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
237
243#ifdef CONFIG_PCI_MSI 238#ifdef CONFIG_PCI_MSI
244 { 239 {
245 boolean_t pcix = (IXGB_READ_REG(&adapter->hw, STATUS) & 240 boolean_t pcix = (IXGB_READ_REG(&adapter->hw, STATUS) &
@@ -249,7 +244,7 @@ ixgb_up(struct ixgb_adapter *adapter)
249 if (!pcix) 244 if (!pcix)
250 adapter->have_msi = FALSE; 245 adapter->have_msi = FALSE;
251 else if((err = pci_enable_msi(adapter->pdev))) { 246 else if((err = pci_enable_msi(adapter->pdev))) {
252 printk (KERN_ERR 247 DPRINTK(PROBE, ERR,
253 "Unable to allocate MSI interrupt Error: %d\n", err); 248 "Unable to allocate MSI interrupt Error: %d\n", err);
254 adapter->have_msi = FALSE; 249 adapter->have_msi = FALSE;
255 /* proceed to try to request regular interrupt */ 250 /* proceed to try to request regular interrupt */
@@ -259,11 +254,11 @@ ixgb_up(struct ixgb_adapter *adapter)
259#endif 254#endif
260 if((err = request_irq(adapter->pdev->irq, &ixgb_intr, 255 if((err = request_irq(adapter->pdev->irq, &ixgb_intr,
261 SA_SHIRQ | SA_SAMPLE_RANDOM, 256 SA_SHIRQ | SA_SAMPLE_RANDOM,
262 netdev->name, netdev))) 257 netdev->name, netdev))) {
258 DPRINTK(PROBE, ERR,
259 "Unable to allocate interrupt Error: %d\n", err);
263 return err; 260 return err;
264 261 }
265 /* disable interrupts and get the hardware into a known state */
266 IXGB_WRITE_REG(&adapter->hw, IMC, 0xffffffff);
267 262
268 if((hw->max_frame_size != max_frame) || 263 if((hw->max_frame_size != max_frame) ||
269 (hw->max_frame_size != 264 (hw->max_frame_size !=
@@ -285,11 +280,12 @@ ixgb_up(struct ixgb_adapter *adapter)
285 } 280 }
286 281
287 mod_timer(&adapter->watchdog_timer, jiffies); 282 mod_timer(&adapter->watchdog_timer, jiffies);
288 ixgb_irq_enable(adapter);
289 283
290#ifdef CONFIG_IXGB_NAPI 284#ifdef CONFIG_IXGB_NAPI
291 netif_poll_enable(netdev); 285 netif_poll_enable(netdev);
292#endif 286#endif
287 ixgb_irq_enable(adapter);
288
293 return 0; 289 return 0;
294} 290}
295 291
@@ -326,7 +322,7 @@ ixgb_reset(struct ixgb_adapter *adapter)
326 322
327 ixgb_adapter_stop(&adapter->hw); 323 ixgb_adapter_stop(&adapter->hw);
328 if(!ixgb_init_hw(&adapter->hw)) 324 if(!ixgb_init_hw(&adapter->hw))
329 IXGB_DBG("ixgb_init_hw failed.\n"); 325 DPRINTK(PROBE, ERR, "ixgb_init_hw failed.\n");
330} 326}
331 327
332/** 328/**
@@ -363,7 +359,8 @@ ixgb_probe(struct pci_dev *pdev,
363 } else { 359 } else {
364 if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) || 360 if((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
365 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) { 361 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
366 IXGB_ERR("No usable DMA configuration, aborting\n"); 362 printk(KERN_ERR
363 "ixgb: No usable DMA configuration, aborting\n");
367 goto err_dma_mask; 364 goto err_dma_mask;
368 } 365 }
369 pci_using_dac = 0; 366 pci_using_dac = 0;
@@ -388,6 +385,7 @@ ixgb_probe(struct pci_dev *pdev,
388 adapter->netdev = netdev; 385 adapter->netdev = netdev;
389 adapter->pdev = pdev; 386 adapter->pdev = pdev;
390 adapter->hw.back = adapter; 387 adapter->hw.back = adapter;
388 adapter->msg_enable = netif_msg_init(debug, DEFAULT_DEBUG_LEVEL_SHIFT);
391 389
392 mmio_start = pci_resource_start(pdev, BAR_0); 390 mmio_start = pci_resource_start(pdev, BAR_0);
393 mmio_len = pci_resource_len(pdev, BAR_0); 391 mmio_len = pci_resource_len(pdev, BAR_0);
@@ -416,7 +414,7 @@ ixgb_probe(struct pci_dev *pdev,
416 netdev->change_mtu = &ixgb_change_mtu; 414 netdev->change_mtu = &ixgb_change_mtu;
417 ixgb_set_ethtool_ops(netdev); 415 ixgb_set_ethtool_ops(netdev);
418 netdev->tx_timeout = &ixgb_tx_timeout; 416 netdev->tx_timeout = &ixgb_tx_timeout;
419 netdev->watchdog_timeo = HZ; 417 netdev->watchdog_timeo = 5 * HZ;
420#ifdef CONFIG_IXGB_NAPI 418#ifdef CONFIG_IXGB_NAPI
421 netdev->poll = &ixgb_clean; 419 netdev->poll = &ixgb_clean;
422 netdev->weight = 64; 420 netdev->weight = 64;
@@ -428,6 +426,7 @@ ixgb_probe(struct pci_dev *pdev,
428 netdev->poll_controller = ixgb_netpoll; 426 netdev->poll_controller = ixgb_netpoll;
429#endif 427#endif
430 428
429 strcpy(netdev->name, pci_name(pdev));
431 netdev->mem_start = mmio_start; 430 netdev->mem_start = mmio_start;
432 netdev->mem_end = mmio_start + mmio_len; 431 netdev->mem_end = mmio_start + mmio_len;
433 netdev->base_addr = adapter->hw.io_base; 432 netdev->base_addr = adapter->hw.io_base;
@@ -449,6 +448,9 @@ ixgb_probe(struct pci_dev *pdev,
449#ifdef NETIF_F_TSO 448#ifdef NETIF_F_TSO
450 netdev->features |= NETIF_F_TSO; 449 netdev->features |= NETIF_F_TSO;
451#endif 450#endif
451#ifdef NETIF_F_LLTX
452 netdev->features |= NETIF_F_LLTX;
453#endif
452 454
453 if(pci_using_dac) 455 if(pci_using_dac)
454 netdev->features |= NETIF_F_HIGHDMA; 456 netdev->features |= NETIF_F_HIGHDMA;
@@ -456,7 +458,7 @@ ixgb_probe(struct pci_dev *pdev,
456 /* make sure the EEPROM is good */ 458 /* make sure the EEPROM is good */
457 459
458 if(!ixgb_validate_eeprom_checksum(&adapter->hw)) { 460 if(!ixgb_validate_eeprom_checksum(&adapter->hw)) {
459 printk(KERN_ERR "The EEPROM Checksum Is Not Valid\n"); 461 DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
460 err = -EIO; 462 err = -EIO;
461 goto err_eeprom; 463 goto err_eeprom;
462 } 464 }
@@ -465,6 +467,7 @@ ixgb_probe(struct pci_dev *pdev,
465 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len); 467 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
466 468
467 if(!is_valid_ether_addr(netdev->perm_addr)) { 469 if(!is_valid_ether_addr(netdev->perm_addr)) {
470 DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
468 err = -EIO; 471 err = -EIO;
469 goto err_eeprom; 472 goto err_eeprom;
470 } 473 }
@@ -478,6 +481,7 @@ ixgb_probe(struct pci_dev *pdev,
478 INIT_WORK(&adapter->tx_timeout_task, 481 INIT_WORK(&adapter->tx_timeout_task,
479 (void (*)(void *))ixgb_tx_timeout_task, netdev); 482 (void (*)(void *))ixgb_tx_timeout_task, netdev);
480 483
484 strcpy(netdev->name, "eth%d");
481 if((err = register_netdev(netdev))) 485 if((err = register_netdev(netdev)))
482 goto err_register; 486 goto err_register;
483 487
@@ -486,8 +490,7 @@ ixgb_probe(struct pci_dev *pdev,
486 netif_carrier_off(netdev); 490 netif_carrier_off(netdev);
487 netif_stop_queue(netdev); 491 netif_stop_queue(netdev);
488 492
489 printk(KERN_INFO "%s: Intel(R) PRO/10GbE Network Connection\n", 493 DPRINTK(PROBE, INFO, "Intel(R) PRO/10GbE Network Connection\n");
490 netdev->name);
491 ixgb_check_options(adapter); 494 ixgb_check_options(adapter);
492 /* reset the hardware with the new settings */ 495 /* reset the hardware with the new settings */
493 496
@@ -557,17 +560,17 @@ ixgb_sw_init(struct ixgb_adapter *adapter)
557 hw->subsystem_vendor_id = pdev->subsystem_vendor; 560 hw->subsystem_vendor_id = pdev->subsystem_vendor;
558 hw->subsystem_id = pdev->subsystem_device; 561 hw->subsystem_id = pdev->subsystem_device;
559 562
560 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
561
562 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH; 563 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ENET_FCS_LENGTH;
564 adapter->rx_buffer_len = hw->max_frame_size;
563 565
564 if((hw->device_id == IXGB_DEVICE_ID_82597EX) 566 if((hw->device_id == IXGB_DEVICE_ID_82597EX)
565 ||(hw->device_id == IXGB_DEVICE_ID_82597EX_LR) 567 || (hw->device_id == IXGB_DEVICE_ID_82597EX_CX4)
566 ||(hw->device_id == IXGB_DEVICE_ID_82597EX_SR)) 568 || (hw->device_id == IXGB_DEVICE_ID_82597EX_LR)
569 || (hw->device_id == IXGB_DEVICE_ID_82597EX_SR))
567 hw->mac_type = ixgb_82597; 570 hw->mac_type = ixgb_82597;
568 else { 571 else {
569 /* should never have loaded on this device */ 572 /* should never have loaded on this device */
570 printk(KERN_ERR "ixgb: unsupported device id\n"); 573 DPRINTK(PROBE, ERR, "unsupported device id\n");
571 } 574 }
572 575
573 /* enable flow control to be programmed */ 576 /* enable flow control to be programmed */
@@ -665,6 +668,8 @@ ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
665 size = sizeof(struct ixgb_buffer) * txdr->count; 668 size = sizeof(struct ixgb_buffer) * txdr->count;
666 txdr->buffer_info = vmalloc(size); 669 txdr->buffer_info = vmalloc(size);
667 if(!txdr->buffer_info) { 670 if(!txdr->buffer_info) {
671 DPRINTK(PROBE, ERR,
672 "Unable to allocate transmit descriptor ring memory\n");
668 return -ENOMEM; 673 return -ENOMEM;
669 } 674 }
670 memset(txdr->buffer_info, 0, size); 675 memset(txdr->buffer_info, 0, size);
@@ -677,6 +682,8 @@ ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
677 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma); 682 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
678 if(!txdr->desc) { 683 if(!txdr->desc) {
679 vfree(txdr->buffer_info); 684 vfree(txdr->buffer_info);
685 DPRINTK(PROBE, ERR,
686 "Unable to allocate transmit descriptor memory\n");
680 return -ENOMEM; 687 return -ENOMEM;
681 } 688 }
682 memset(txdr->desc, 0, txdr->size); 689 memset(txdr->desc, 0, txdr->size);
@@ -750,6 +757,8 @@ ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
750 size = sizeof(struct ixgb_buffer) * rxdr->count; 757 size = sizeof(struct ixgb_buffer) * rxdr->count;
751 rxdr->buffer_info = vmalloc(size); 758 rxdr->buffer_info = vmalloc(size);
752 if(!rxdr->buffer_info) { 759 if(!rxdr->buffer_info) {
760 DPRINTK(PROBE, ERR,
761 "Unable to allocate receive descriptor ring\n");
753 return -ENOMEM; 762 return -ENOMEM;
754 } 763 }
755 memset(rxdr->buffer_info, 0, size); 764 memset(rxdr->buffer_info, 0, size);
@@ -763,6 +772,8 @@ ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
763 772
764 if(!rxdr->desc) { 773 if(!rxdr->desc) {
765 vfree(rxdr->buffer_info); 774 vfree(rxdr->buffer_info);
775 DPRINTK(PROBE, ERR,
776 "Unable to allocate receive descriptors\n");
766 return -ENOMEM; 777 return -ENOMEM;
767 } 778 }
768 memset(rxdr->desc, 0, rxdr->size); 779 memset(rxdr->desc, 0, rxdr->size);
@@ -794,21 +805,14 @@ ixgb_setup_rctl(struct ixgb_adapter *adapter)
794 805
795 rctl |= IXGB_RCTL_SECRC; 806 rctl |= IXGB_RCTL_SECRC;
796 807
797 switch (adapter->rx_buffer_len) { 808 if (adapter->rx_buffer_len <= IXGB_RXBUFFER_2048)
798 case IXGB_RXBUFFER_2048:
799 default:
800 rctl |= IXGB_RCTL_BSIZE_2048; 809 rctl |= IXGB_RCTL_BSIZE_2048;
801 break; 810 else if (adapter->rx_buffer_len <= IXGB_RXBUFFER_4096)
802 case IXGB_RXBUFFER_4096:
803 rctl |= IXGB_RCTL_BSIZE_4096; 811 rctl |= IXGB_RCTL_BSIZE_4096;
804 break; 812 else if (adapter->rx_buffer_len <= IXGB_RXBUFFER_8192)
805 case IXGB_RXBUFFER_8192:
806 rctl |= IXGB_RCTL_BSIZE_8192; 813 rctl |= IXGB_RCTL_BSIZE_8192;
807 break; 814 else if (adapter->rx_buffer_len <= IXGB_RXBUFFER_16384)
808 case IXGB_RXBUFFER_16384:
809 rctl |= IXGB_RCTL_BSIZE_16384; 815 rctl |= IXGB_RCTL_BSIZE_16384;
810 break;
811 }
812 816
813 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl); 817 IXGB_WRITE_REG(&adapter->hw, RCTL, rctl);
814} 818}
@@ -898,22 +902,25 @@ ixgb_free_tx_resources(struct ixgb_adapter *adapter)
898 adapter->tx_ring.desc = NULL; 902 adapter->tx_ring.desc = NULL;
899} 903}
900 904
901static inline void 905static void
902ixgb_unmap_and_free_tx_resource(struct ixgb_adapter *adapter, 906ixgb_unmap_and_free_tx_resource(struct ixgb_adapter *adapter,
903 struct ixgb_buffer *buffer_info) 907 struct ixgb_buffer *buffer_info)
904{ 908{
905 struct pci_dev *pdev = adapter->pdev; 909 struct pci_dev *pdev = adapter->pdev;
906 if(buffer_info->dma) { 910
907 pci_unmap_page(pdev, 911 if (buffer_info->dma)
908 buffer_info->dma, 912 pci_unmap_page(pdev, buffer_info->dma, buffer_info->length,
909 buffer_info->length, 913 PCI_DMA_TODEVICE);
910 PCI_DMA_TODEVICE); 914
911 buffer_info->dma = 0; 915 if (buffer_info->skb)
912 }
913 if(buffer_info->skb) {
914 dev_kfree_skb_any(buffer_info->skb); 916 dev_kfree_skb_any(buffer_info->skb);
915 buffer_info->skb = NULL; 917
916 } 918 buffer_info->skb = NULL;
919 buffer_info->dma = 0;
920 buffer_info->time_stamp = 0;
921 /* these fields must always be initialized in tx
922 * buffer_info->length = 0;
923 * buffer_info->next_to_watch = 0; */
917} 924}
918 925
919/** 926/**
@@ -1112,8 +1119,8 @@ ixgb_watchdog(unsigned long data)
1112 1119
1113 if(adapter->hw.link_up) { 1120 if(adapter->hw.link_up) {
1114 if(!netif_carrier_ok(netdev)) { 1121 if(!netif_carrier_ok(netdev)) {
1115 printk(KERN_INFO "ixgb: %s NIC Link is Up %d Mbps %s\n", 1122 DPRINTK(LINK, INFO,
1116 netdev->name, 10000, "Full Duplex"); 1123 "NIC Link is Up 10000 Mbps Full Duplex\n");
1117 adapter->link_speed = 10000; 1124 adapter->link_speed = 10000;
1118 adapter->link_duplex = FULL_DUPLEX; 1125 adapter->link_duplex = FULL_DUPLEX;
1119 netif_carrier_on(netdev); 1126 netif_carrier_on(netdev);
@@ -1123,9 +1130,7 @@ ixgb_watchdog(unsigned long data)
1123 if(netif_carrier_ok(netdev)) { 1130 if(netif_carrier_ok(netdev)) {
1124 adapter->link_speed = 0; 1131 adapter->link_speed = 0;
1125 adapter->link_duplex = 0; 1132 adapter->link_duplex = 0;
1126 printk(KERN_INFO 1133 DPRINTK(LINK, INFO, "NIC Link is Down\n");
1127 "ixgb: %s NIC Link is Down\n",
1128 netdev->name);
1129 netif_carrier_off(netdev); 1134 netif_carrier_off(netdev);
1130 netif_stop_queue(netdev); 1135 netif_stop_queue(netdev);
1131 1136
@@ -1158,7 +1163,7 @@ ixgb_watchdog(unsigned long data)
1158#define IXGB_TX_FLAGS_VLAN 0x00000002 1163#define IXGB_TX_FLAGS_VLAN 0x00000002
1159#define IXGB_TX_FLAGS_TSO 0x00000004 1164#define IXGB_TX_FLAGS_TSO 0x00000004
1160 1165
1161static inline int 1166static int
1162ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb) 1167ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1163{ 1168{
1164#ifdef NETIF_F_TSO 1169#ifdef NETIF_F_TSO
@@ -1220,7 +1225,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1220 return 0; 1225 return 0;
1221} 1226}
1222 1227
1223static inline boolean_t 1228static boolean_t
1224ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb) 1229ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1225{ 1230{
1226 struct ixgb_context_desc *context_desc; 1231 struct ixgb_context_desc *context_desc;
@@ -1258,7 +1263,7 @@ ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1258#define IXGB_MAX_TXD_PWR 14 1263#define IXGB_MAX_TXD_PWR 14
1259#define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR) 1264#define IXGB_MAX_DATA_PER_TXD (1<<IXGB_MAX_TXD_PWR)
1260 1265
1261static inline int 1266static int
1262ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb, 1267ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1263 unsigned int first) 1268 unsigned int first)
1264{ 1269{
@@ -1284,6 +1289,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1284 size, 1289 size,
1285 PCI_DMA_TODEVICE); 1290 PCI_DMA_TODEVICE);
1286 buffer_info->time_stamp = jiffies; 1291 buffer_info->time_stamp = jiffies;
1292 buffer_info->next_to_watch = 0;
1287 1293
1288 len -= size; 1294 len -= size;
1289 offset += size; 1295 offset += size;
@@ -1309,6 +1315,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1309 size, 1315 size,
1310 PCI_DMA_TODEVICE); 1316 PCI_DMA_TODEVICE);
1311 buffer_info->time_stamp = jiffies; 1317 buffer_info->time_stamp = jiffies;
1318 buffer_info->next_to_watch = 0;
1312 1319
1313 len -= size; 1320 len -= size;
1314 offset += size; 1321 offset += size;
@@ -1323,7 +1330,7 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
1323 return count; 1330 return count;
1324} 1331}
1325 1332
1326static inline void 1333static void
1327ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,int tx_flags) 1334ixgb_tx_queue(struct ixgb_adapter *adapter, int count, int vlan_id,int tx_flags)
1328{ 1335{
1329 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring; 1336 struct ixgb_desc_ring *tx_ring = &adapter->tx_ring;
@@ -1395,13 +1402,26 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1395 return 0; 1402 return 0;
1396 } 1403 }
1397 1404
1405#ifdef NETIF_F_LLTX
1406 local_irq_save(flags);
1407 if (!spin_trylock(&adapter->tx_lock)) {
1408 /* Collision - tell upper layer to requeue */
1409 local_irq_restore(flags);
1410 return NETDEV_TX_LOCKED;
1411 }
1412#else
1398 spin_lock_irqsave(&adapter->tx_lock, flags); 1413 spin_lock_irqsave(&adapter->tx_lock, flags);
1414#endif
1415
1399 if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) { 1416 if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED)) {
1400 netif_stop_queue(netdev); 1417 netif_stop_queue(netdev);
1401 spin_unlock_irqrestore(&adapter->tx_lock, flags); 1418 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1402 return 1; 1419 return NETDEV_TX_BUSY;
1403 } 1420 }
1421
1422#ifndef NETIF_F_LLTX
1404 spin_unlock_irqrestore(&adapter->tx_lock, flags); 1423 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1424#endif
1405 1425
1406 if(adapter->vlgrp && vlan_tx_tag_present(skb)) { 1426 if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
1407 tx_flags |= IXGB_TX_FLAGS_VLAN; 1427 tx_flags |= IXGB_TX_FLAGS_VLAN;
@@ -1413,10 +1433,13 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1413 tso = ixgb_tso(adapter, skb); 1433 tso = ixgb_tso(adapter, skb);
1414 if (tso < 0) { 1434 if (tso < 0) {
1415 dev_kfree_skb_any(skb); 1435 dev_kfree_skb_any(skb);
1436#ifdef NETIF_F_LLTX
1437 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1438#endif
1416 return NETDEV_TX_OK; 1439 return NETDEV_TX_OK;
1417 } 1440 }
1418 1441
1419 if (tso) 1442 if (likely(tso))
1420 tx_flags |= IXGB_TX_FLAGS_TSO; 1443 tx_flags |= IXGB_TX_FLAGS_TSO;
1421 else if(ixgb_tx_csum(adapter, skb)) 1444 else if(ixgb_tx_csum(adapter, skb))
1422 tx_flags |= IXGB_TX_FLAGS_CSUM; 1445 tx_flags |= IXGB_TX_FLAGS_CSUM;
@@ -1426,7 +1449,15 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1426 1449
1427 netdev->trans_start = jiffies; 1450 netdev->trans_start = jiffies;
1428 1451
1429 return 0; 1452#ifdef NETIF_F_LLTX
1453 /* Make sure there is space in the ring for the next send. */
1454 if(unlikely(IXGB_DESC_UNUSED(&adapter->tx_ring) < DESC_NEEDED))
1455 netif_stop_queue(netdev);
1456
1457 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1458
1459#endif
1460 return NETDEV_TX_OK;
1430} 1461}
1431 1462
1432/** 1463/**
@@ -1448,6 +1479,7 @@ ixgb_tx_timeout_task(struct net_device *netdev)
1448{ 1479{
1449 struct ixgb_adapter *adapter = netdev_priv(netdev); 1480 struct ixgb_adapter *adapter = netdev_priv(netdev);
1450 1481
1482 adapter->tx_timeout_count++;
1451 ixgb_down(adapter, TRUE); 1483 ixgb_down(adapter, TRUE);
1452 ixgb_up(adapter); 1484 ixgb_up(adapter);
1453} 1485}
@@ -1486,28 +1518,15 @@ ixgb_change_mtu(struct net_device *netdev, int new_mtu)
1486 1518
1487 if((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) 1519 if((max_frame < IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH)
1488 || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) { 1520 || (max_frame > IXGB_MAX_JUMBO_FRAME_SIZE + ENET_FCS_LENGTH)) {
1489 IXGB_ERR("Invalid MTU setting\n"); 1521 DPRINTK(PROBE, ERR, "Invalid MTU setting %d\n", new_mtu);
1490 return -EINVAL; 1522 return -EINVAL;
1491 } 1523 }
1492 1524
1493 if((max_frame <= IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) 1525 adapter->rx_buffer_len = max_frame;
1494 || (max_frame <= IXGB_RXBUFFER_2048)) {
1495 adapter->rx_buffer_len = IXGB_RXBUFFER_2048;
1496
1497 } else if(max_frame <= IXGB_RXBUFFER_4096) {
1498 adapter->rx_buffer_len = IXGB_RXBUFFER_4096;
1499
1500 } else if(max_frame <= IXGB_RXBUFFER_8192) {
1501 adapter->rx_buffer_len = IXGB_RXBUFFER_8192;
1502
1503 } else {
1504 adapter->rx_buffer_len = IXGB_RXBUFFER_16384;
1505 }
1506 1526
1507 netdev->mtu = new_mtu; 1527 netdev->mtu = new_mtu;
1508 1528
1509 if(old_max_frame != max_frame && netif_running(netdev)) { 1529 if ((old_max_frame != max_frame) && netif_running(netdev)) {
1510
1511 ixgb_down(adapter, TRUE); 1530 ixgb_down(adapter, TRUE);
1512 ixgb_up(adapter); 1531 ixgb_up(adapter);
1513 } 1532 }
@@ -1765,23 +1784,43 @@ ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1765 1784
1766 tx_ring->next_to_clean = i; 1785 tx_ring->next_to_clean = i;
1767 1786
1768 spin_lock(&adapter->tx_lock); 1787 if (unlikely(netif_queue_stopped(netdev))) {
1769 if(cleaned && netif_queue_stopped(netdev) && netif_carrier_ok(netdev) && 1788 spin_lock(&adapter->tx_lock);
1770 (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE)) { 1789 if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev) &&
1771 1790 (IXGB_DESC_UNUSED(tx_ring) > IXGB_TX_QUEUE_WAKE))
1772 netif_wake_queue(netdev); 1791 netif_wake_queue(netdev);
1792 spin_unlock(&adapter->tx_lock);
1773 } 1793 }
1774 spin_unlock(&adapter->tx_lock);
1775 1794
1776 if(adapter->detect_tx_hung) { 1795 if(adapter->detect_tx_hung) {
1777 /* detect a transmit hang in hardware, this serializes the 1796 /* detect a transmit hang in hardware, this serializes the
1778 * check with the clearing of time_stamp and movement of i */ 1797 * check with the clearing of time_stamp and movement of i */
1779 adapter->detect_tx_hung = FALSE; 1798 adapter->detect_tx_hung = FALSE;
1780 if(tx_ring->buffer_info[i].dma && 1799 if (tx_ring->buffer_info[eop].dma &&
1781 time_after(jiffies, tx_ring->buffer_info[i].time_stamp + HZ) 1800 time_after(jiffies, tx_ring->buffer_info[eop].time_stamp + HZ)
1782 && !(IXGB_READ_REG(&adapter->hw, STATUS) & 1801 && !(IXGB_READ_REG(&adapter->hw, STATUS) &
1783 IXGB_STATUS_TXOFF)) 1802 IXGB_STATUS_TXOFF)) {
1803 /* detected Tx unit hang */
1804 DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
1805 " TDH <%x>\n"
1806 " TDT <%x>\n"
1807 " next_to_use <%x>\n"
1808 " next_to_clean <%x>\n"
1809 "buffer_info[next_to_clean]\n"
1810 " time_stamp <%lx>\n"
1811 " next_to_watch <%x>\n"
1812 " jiffies <%lx>\n"
1813 " next_to_watch.status <%x>\n",
1814 IXGB_READ_REG(&adapter->hw, TDH),
1815 IXGB_READ_REG(&adapter->hw, TDT),
1816 tx_ring->next_to_use,
1817 tx_ring->next_to_clean,
1818 tx_ring->buffer_info[eop].time_stamp,
1819 eop,
1820 jiffies,
1821 eop_desc->status);
1784 netif_stop_queue(netdev); 1822 netif_stop_queue(netdev);
1823 }
1785 } 1824 }
1786 1825
1787 return cleaned; 1826 return cleaned;
@@ -1794,7 +1833,7 @@ ixgb_clean_tx_irq(struct ixgb_adapter *adapter)
1794 * @sk_buff: socket buffer with received data 1833 * @sk_buff: socket buffer with received data
1795 **/ 1834 **/
1796 1835
1797static inline void 1836static void
1798ixgb_rx_checksum(struct ixgb_adapter *adapter, 1837ixgb_rx_checksum(struct ixgb_adapter *adapter,
1799 struct ixgb_rx_desc *rx_desc, 1838 struct ixgb_rx_desc *rx_desc,
1800 struct sk_buff *skb) 1839 struct sk_buff *skb)
@@ -1858,6 +1897,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1858#endif 1897#endif
1859 status = rx_desc->status; 1898 status = rx_desc->status;
1860 skb = buffer_info->skb; 1899 skb = buffer_info->skb;
1900 buffer_info->skb = NULL;
1861 1901
1862 prefetch(skb->data); 1902 prefetch(skb->data);
1863 1903
@@ -1902,6 +1942,26 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1902 goto rxdesc_done; 1942 goto rxdesc_done;
1903 } 1943 }
1904 1944
1945 /* code added for copybreak, this should improve
1946 * performance for small packets with large amounts
1947 * of reassembly being done in the stack */
1948#define IXGB_CB_LENGTH 256
1949 if (length < IXGB_CB_LENGTH) {
1950 struct sk_buff *new_skb =
1951 dev_alloc_skb(length + NET_IP_ALIGN);
1952 if (new_skb) {
1953 skb_reserve(new_skb, NET_IP_ALIGN);
1954 new_skb->dev = netdev;
1955 memcpy(new_skb->data - NET_IP_ALIGN,
1956 skb->data - NET_IP_ALIGN,
1957 length + NET_IP_ALIGN);
1958 /* save the skb in buffer_info as good */
1959 buffer_info->skb = skb;
1960 skb = new_skb;
1961 }
1962 }
1963 /* end copybreak code */
1964
1905 /* Good Receive */ 1965 /* Good Receive */
1906 skb_put(skb, length); 1966 skb_put(skb, length);
1907 1967
@@ -1931,7 +1991,6 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter)
1931rxdesc_done: 1991rxdesc_done:
1932 /* clean up descriptor, might be written over by hw */ 1992 /* clean up descriptor, might be written over by hw */
1933 rx_desc->status = 0; 1993 rx_desc->status = 0;
1934 buffer_info->skb = NULL;
1935 1994
1936 /* use prefetched values */ 1995 /* use prefetched values */
1937 rx_desc = next_rxd; 1996 rx_desc = next_rxd;
@@ -1971,12 +2030,18 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1971 2030
1972 /* leave three descriptors unused */ 2031 /* leave three descriptors unused */
1973 while(--cleancount > 2) { 2032 while(--cleancount > 2) {
1974 rx_desc = IXGB_RX_DESC(*rx_ring, i); 2033 /* recycle! its good for you */
1975 2034 if (!(skb = buffer_info->skb))
1976 skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN); 2035 skb = dev_alloc_skb(adapter->rx_buffer_len
2036 + NET_IP_ALIGN);
2037 else {
2038 skb_trim(skb, 0);
2039 goto map_skb;
2040 }
1977 2041
1978 if(unlikely(!skb)) { 2042 if (unlikely(!skb)) {
1979 /* Better luck next round */ 2043 /* Better luck next round */
2044 adapter->alloc_rx_buff_failed++;
1980 break; 2045 break;
1981 } 2046 }
1982 2047
@@ -1990,33 +2055,36 @@ ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter)
1990 2055
1991 buffer_info->skb = skb; 2056 buffer_info->skb = skb;
1992 buffer_info->length = adapter->rx_buffer_len; 2057 buffer_info->length = adapter->rx_buffer_len;
1993 buffer_info->dma = 2058map_skb:
1994 pci_map_single(pdev, 2059 buffer_info->dma = pci_map_single(pdev,
1995 skb->data, 2060 skb->data,
1996 adapter->rx_buffer_len, 2061 adapter->rx_buffer_len,
1997 PCI_DMA_FROMDEVICE); 2062 PCI_DMA_FROMDEVICE);
1998 2063
2064 rx_desc = IXGB_RX_DESC(*rx_ring, i);
1999 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma); 2065 rx_desc->buff_addr = cpu_to_le64(buffer_info->dma);
2000 /* guarantee DD bit not set now before h/w gets descriptor 2066 /* guarantee DD bit not set now before h/w gets descriptor
2001 * this is the rest of the workaround for h/w double 2067 * this is the rest of the workaround for h/w double
2002 * writeback. */ 2068 * writeback. */
2003 rx_desc->status = 0; 2069 rx_desc->status = 0;
2004 2070
2005 if((i & ~(num_group_tail_writes- 1)) == i) {
2006 /* Force memory writes to complete before letting h/w
2007 * know there are new descriptors to fetch. (Only
2008 * applicable for weak-ordered memory model archs,
2009 * such as IA-64). */
2010 wmb();
2011
2012 IXGB_WRITE_REG(&adapter->hw, RDT, i);
2013 }
2014 2071
2015 if(++i == rx_ring->count) i = 0; 2072 if(++i == rx_ring->count) i = 0;
2016 buffer_info = &rx_ring->buffer_info[i]; 2073 buffer_info = &rx_ring->buffer_info[i];
2017 } 2074 }
2018 2075
2019 rx_ring->next_to_use = i; 2076 if (likely(rx_ring->next_to_use != i)) {
2077 rx_ring->next_to_use = i;
2078 if (unlikely(i-- == 0))
2079 i = (rx_ring->count - 1);
2080
2081 /* Force memory writes to complete before letting h/w
2082 * know there are new descriptors to fetch. (Only
2083 * applicable for weak-ordered memory model archs, such
2084 * as IA-64). */
2085 wmb();
2086 IXGB_WRITE_REG(&adapter->hw, RDT, i);
2087 }
2020} 2088}
2021 2089
2022/** 2090/**
diff --git a/drivers/net/ixgb/ixgb_osdep.h b/drivers/net/ixgb/ixgb_osdep.h
index dba20481ee80..ee982feac64d 100644
--- a/drivers/net/ixgb/ixgb_osdep.h
+++ b/drivers/net/ixgb/ixgb_osdep.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
diff --git a/drivers/net/ixgb/ixgb_param.c b/drivers/net/ixgb/ixgb_param.c
index 8a83dfdf746d..39fbed29a3df 100644
--- a/drivers/net/ixgb/ixgb_param.c
+++ b/drivers/net/ixgb/ixgb_param.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 3
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 4 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free 7 under the terms of the GNU General Public License as published by the Free
@@ -76,7 +76,7 @@ IXGB_PARAM(RxDescriptors, "Number of receive descriptors");
76 * - 2 - Tx only, generate PAUSE frames but ignore them on receive 76 * - 2 - Tx only, generate PAUSE frames but ignore them on receive
77 * - 3 - Full Flow Control Support 77 * - 3 - Full Flow Control Support
78 * 78 *
79 * Default Value: Read flow control settings from the EEPROM 79 * Default Value: 2 - Tx only (silicon bug avoidance)
80 */ 80 */
81 81
82IXGB_PARAM(FlowControl, "Flow Control setting"); 82IXGB_PARAM(FlowControl, "Flow Control setting");
@@ -137,7 +137,7 @@ IXGB_PARAM(RxFCLowThresh, "Receive Flow Control Low Threshold");
137 * 137 *
138 * Valid Range: 1 - 65535 138 * Valid Range: 1 - 65535
139 * 139 *
140 * Default Value: 256 (0x100) 140 * Default Value: 65535 (0xffff) (we'll send an xon if we recover)
141 */ 141 */
142 142
143IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout"); 143IXGB_PARAM(FCReqTimeout, "Flow Control Request Timeout");
@@ -165,8 +165,6 @@ IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
165 165
166#define XSUMRX_DEFAULT OPTION_ENABLED 166#define XSUMRX_DEFAULT OPTION_ENABLED
167 167
168#define FLOW_CONTROL_FULL ixgb_fc_full
169#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
170#define DEFAULT_FCRTL 0x28000 168#define DEFAULT_FCRTL 0x28000
171#define DEFAULT_FCRTH 0x30000 169#define DEFAULT_FCRTH 0x30000
172#define MIN_FCRTL 0 170#define MIN_FCRTL 0
@@ -174,9 +172,9 @@ IXGB_PARAM(IntDelayEnable, "Transmit Interrupt Delay Enable");
174#define MIN_FCRTH 8 172#define MIN_FCRTH 8
175#define MAX_FCRTH 0x3FFF0 173#define MAX_FCRTH 0x3FFF0
176 174
177#define DEFAULT_FCPAUSE 0x100 /* this may be too long */
178#define MIN_FCPAUSE 1 175#define MIN_FCPAUSE 1
179#define MAX_FCPAUSE 0xffff 176#define MAX_FCPAUSE 0xffff
177#define DEFAULT_FCPAUSE 0xFFFF /* this may be too long */
180 178
181struct ixgb_option { 179struct ixgb_option {
182 enum { enable_option, range_option, list_option } type; 180 enum { enable_option, range_option, list_option } type;
@@ -336,7 +334,7 @@ ixgb_check_options(struct ixgb_adapter *adapter)
336 .type = list_option, 334 .type = list_option,
337 .name = "Flow Control", 335 .name = "Flow Control",
338 .err = "reading default settings from EEPROM", 336 .err = "reading default settings from EEPROM",
339 .def = ixgb_fc_full, 337 .def = ixgb_fc_tx_pause,
340 .arg = { .l = { .nr = LIST_LEN(fc_list), 338 .arg = { .l = { .nr = LIST_LEN(fc_list),
341 .p = fc_list }} 339 .p = fc_list }}
342 }; 340 };
@@ -365,8 +363,8 @@ ixgb_check_options(struct ixgb_adapter *adapter)
365 } else { 363 } else {
366 adapter->hw.fc.high_water = opt.def; 364 adapter->hw.fc.high_water = opt.def;
367 } 365 }
368 if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) ) 366 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
369 printk (KERN_INFO 367 printk (KERN_INFO
370 "Ignoring RxFCHighThresh when no RxFC\n"); 368 "Ignoring RxFCHighThresh when no RxFC\n");
371 } 369 }
372 { /* Receive Flow Control Low Threshold */ 370 { /* Receive Flow Control Low Threshold */
@@ -385,8 +383,8 @@ ixgb_check_options(struct ixgb_adapter *adapter)
385 } else { 383 } else {
386 adapter->hw.fc.low_water = opt.def; 384 adapter->hw.fc.low_water = opt.def;
387 } 385 }
388 if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) ) 386 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
389 printk (KERN_INFO 387 printk (KERN_INFO
390 "Ignoring RxFCLowThresh when no RxFC\n"); 388 "Ignoring RxFCLowThresh when no RxFC\n");
391 } 389 }
392 { /* Flow Control Pause Time Request*/ 390 { /* Flow Control Pause Time Request*/
@@ -406,12 +404,12 @@ ixgb_check_options(struct ixgb_adapter *adapter)
406 } else { 404 } else {
407 adapter->hw.fc.pause_time = opt.def; 405 adapter->hw.fc.pause_time = opt.def;
408 } 406 }
409 if(!(adapter->hw.fc.type & ixgb_fc_rx_pause) ) 407 if (!(adapter->hw.fc.type & ixgb_fc_tx_pause) )
410 printk (KERN_INFO 408 printk (KERN_INFO
411 "Ignoring FCReqTimeout when no RxFC\n"); 409 "Ignoring FCReqTimeout when no RxFC\n");
412 } 410 }
413 /* high low and spacing check for rx flow control thresholds */ 411 /* high low and spacing check for rx flow control thresholds */
414 if (adapter->hw.fc.type & ixgb_fc_rx_pause) { 412 if (adapter->hw.fc.type & ixgb_fc_tx_pause) {
415 /* high must be greater than low */ 413 /* high must be greater than low */
416 if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) { 414 if (adapter->hw.fc.high_water < (adapter->hw.fc.low_water + 8)) {
417 /* set defaults */ 415 /* set defaults */
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 411f4d809c47..625ff61c9988 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1200,7 +1200,7 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
1200 } 1200 }
1201 1201
1202 if (has_tiny_unaligned_frags(skb)) { 1202 if (has_tiny_unaligned_frags(skb)) {
1203 if ((skb_linearize(skb, GFP_ATOMIC) != 0)) { 1203 if (__skb_linearize(skb)) {
1204 stats->tx_dropped++; 1204 stats->tx_dropped++;
1205 printk(KERN_DEBUG "%s: failed to linearize tiny " 1205 printk(KERN_DEBUG "%s: failed to linearize tiny "
1206 "unaligned fragment\n", dev->name); 1206 "unaligned fragment\n", dev->name);
diff --git a/drivers/net/myri10ge/Makefile b/drivers/net/myri10ge/Makefile
new file mode 100644
index 000000000000..5df891647aee
--- /dev/null
+++ b/drivers/net/myri10ge/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the Myricom Myri-10G ethernet driver
3#
4
5obj-$(CONFIG_MYRI10GE) += myri10ge.o
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
new file mode 100644
index 000000000000..e1feb58bd661
--- /dev/null
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -0,0 +1,2869 @@
1/*************************************************************************
2 * myri10ge.c: Myricom Myri-10G Ethernet driver.
3 *
4 * Copyright (C) 2005, 2006 Myricom, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Myricom, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 *
32 * If the eeprom on your board is not recent enough, you will need to get a
33 * newer firmware image at:
34 * http://www.myri.com/scs/download-Myri10GE.html
35 *
36 * Contact Information:
37 * <help@myri.com>
38 * Myricom, Inc., 325N Santa Anita Avenue, Arcadia, CA 91006
39 *************************************************************************/
40
41#include <linux/tcp.h>
42#include <linux/netdevice.h>
43#include <linux/skbuff.h>
44#include <linux/string.h>
45#include <linux/module.h>
46#include <linux/pci.h>
47#include <linux/dma-mapping.h>
48#include <linux/etherdevice.h>
49#include <linux/if_ether.h>
50#include <linux/if_vlan.h>
51#include <linux/ip.h>
52#include <linux/inet.h>
53#include <linux/in.h>
54#include <linux/ethtool.h>
55#include <linux/firmware.h>
56#include <linux/delay.h>
57#include <linux/version.h>
58#include <linux/timer.h>
59#include <linux/vmalloc.h>
60#include <linux/crc32.h>
61#include <linux/moduleparam.h>
62#include <linux/io.h>
63#include <net/checksum.h>
64#include <asm/byteorder.h>
65#include <asm/io.h>
66#include <asm/processor.h>
67#ifdef CONFIG_MTRR
68#include <asm/mtrr.h>
69#endif
70
71#include "myri10ge_mcp.h"
72#include "myri10ge_mcp_gen_header.h"
73
74#define MYRI10GE_VERSION_STR "1.0.0"
75
76MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
77MODULE_AUTHOR("Maintainer: help@myri.com");
78MODULE_VERSION(MYRI10GE_VERSION_STR);
79MODULE_LICENSE("Dual BSD/GPL");
80
81#define MYRI10GE_MAX_ETHER_MTU 9014
82
83#define MYRI10GE_ETH_STOPPED 0
84#define MYRI10GE_ETH_STOPPING 1
85#define MYRI10GE_ETH_STARTING 2
86#define MYRI10GE_ETH_RUNNING 3
87#define MYRI10GE_ETH_OPEN_FAILED 4
88
89#define MYRI10GE_EEPROM_STRINGS_SIZE 256
90#define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
91
92#define MYRI10GE_NO_CONFIRM_DATA 0xffffffff
93#define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
94
95struct myri10ge_rx_buffer_state {
96 struct sk_buff *skb;
97 DECLARE_PCI_UNMAP_ADDR(bus)
98 DECLARE_PCI_UNMAP_LEN(len)
99};
100
101struct myri10ge_tx_buffer_state {
102 struct sk_buff *skb;
103 int last;
104 DECLARE_PCI_UNMAP_ADDR(bus)
105 DECLARE_PCI_UNMAP_LEN(len)
106};
107
108struct myri10ge_cmd {
109 u32 data0;
110 u32 data1;
111 u32 data2;
112};
113
114struct myri10ge_rx_buf {
115 struct mcp_kreq_ether_recv __iomem *lanai; /* lanai ptr for recv ring */
116 u8 __iomem *wc_fifo; /* w/c rx dma addr fifo address */
117 struct mcp_kreq_ether_recv *shadow; /* host shadow of recv ring */
118 struct myri10ge_rx_buffer_state *info;
119 int cnt;
120 int alloc_fail;
121 int mask; /* number of rx slots -1 */
122};
123
124struct myri10ge_tx_buf {
125 struct mcp_kreq_ether_send __iomem *lanai; /* lanai ptr for sendq */
126 u8 __iomem *wc_fifo; /* w/c send fifo address */
127 struct mcp_kreq_ether_send *req_list; /* host shadow of sendq */
128 char *req_bytes;
129 struct myri10ge_tx_buffer_state *info;
130 int mask; /* number of transmit slots -1 */
131 int boundary; /* boundary transmits cannot cross */
132 int req ____cacheline_aligned; /* transmit slots submitted */
133 int pkt_start; /* packets started */
134 int done ____cacheline_aligned; /* transmit slots completed */
135 int pkt_done; /* packets completed */
136};
137
138struct myri10ge_rx_done {
139 struct mcp_slot *entry;
140 dma_addr_t bus;
141 int cnt;
142 int idx;
143};
144
145struct myri10ge_priv {
146 int running; /* running? */
147 int csum_flag; /* rx_csums? */
148 struct myri10ge_tx_buf tx; /* transmit ring */
149 struct myri10ge_rx_buf rx_small;
150 struct myri10ge_rx_buf rx_big;
151 struct myri10ge_rx_done rx_done;
152 int small_bytes;
153 struct net_device *dev;
154 struct net_device_stats stats;
155 u8 __iomem *sram;
156 int sram_size;
157 unsigned long board_span;
158 unsigned long iomem_base;
159 u32 __iomem *irq_claim;
160 u32 __iomem *irq_deassert;
161 char *mac_addr_string;
162 struct mcp_cmd_response *cmd;
163 dma_addr_t cmd_bus;
164 struct mcp_irq_data *fw_stats;
165 dma_addr_t fw_stats_bus;
166 struct pci_dev *pdev;
167 int msi_enabled;
168 unsigned int link_state;
169 unsigned int rdma_tags_available;
170 int intr_coal_delay;
171 u32 __iomem *intr_coal_delay_ptr;
172 int mtrr;
173 int wake_queue;
174 int stop_queue;
175 int down_cnt;
176 wait_queue_head_t down_wq;
177 struct work_struct watchdog_work;
178 struct timer_list watchdog_timer;
179 int watchdog_tx_done;
180 int watchdog_resets;
181 int tx_linearized;
182 int pause;
183 char *fw_name;
184 char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE];
185 char fw_version[128];
186 u8 mac_addr[6]; /* eeprom mac address */
187 unsigned long serial_number;
188 int vendor_specific_offset;
189 u32 devctl;
190 u16 msi_flags;
191 u32 pm_state[16];
192 u32 read_dma;
193 u32 write_dma;
194 u32 read_write_dma;
195};
196
197static char *myri10ge_fw_unaligned = "myri10ge_ethp_z8e.dat";
198static char *myri10ge_fw_aligned = "myri10ge_eth_z8e.dat";
199
200static char *myri10ge_fw_name = NULL;
201module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR);
202MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name\n");
203
204static int myri10ge_ecrc_enable = 1;
205module_param(myri10ge_ecrc_enable, int, S_IRUGO);
206MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E\n");
207
208static int myri10ge_max_intr_slots = 1024;
209module_param(myri10ge_max_intr_slots, int, S_IRUGO);
210MODULE_PARM_DESC(myri10ge_max_intr_slots, "Interrupt queue slots\n");
211
212static int myri10ge_small_bytes = -1; /* -1 == auto */
213module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR);
214MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets\n");
215
216static int myri10ge_msi = 1; /* enable msi by default */
217module_param(myri10ge_msi, int, S_IRUGO);
218MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts\n");
219
220static int myri10ge_intr_coal_delay = 25;
221module_param(myri10ge_intr_coal_delay, int, S_IRUGO);
222MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay\n");
223
224static int myri10ge_flow_control = 1;
225module_param(myri10ge_flow_control, int, S_IRUGO);
226MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter\n");
227
228static int myri10ge_deassert_wait = 1;
229module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR);
230MODULE_PARM_DESC(myri10ge_deassert_wait,
231 "Wait when deasserting legacy interrupts\n");
232
233static int myri10ge_force_firmware = 0;
234module_param(myri10ge_force_firmware, int, S_IRUGO);
235MODULE_PARM_DESC(myri10ge_force_firmware,
236 "Force firmware to assume aligned completions\n");
237
238static int myri10ge_skb_cross_4k = 0;
239module_param(myri10ge_skb_cross_4k, int, S_IRUGO | S_IWUSR);
240MODULE_PARM_DESC(myri10ge_skb_cross_4k,
241 "Can a small skb cross a 4KB boundary?\n");
242
243static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
244module_param(myri10ge_initial_mtu, int, S_IRUGO);
245MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU\n");
246
247static int myri10ge_napi_weight = 64;
248module_param(myri10ge_napi_weight, int, S_IRUGO);
249MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight\n");
250
251static int myri10ge_watchdog_timeout = 1;
252module_param(myri10ge_watchdog_timeout, int, S_IRUGO);
253MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout\n");
254
255static int myri10ge_max_irq_loops = 1048576;
256module_param(myri10ge_max_irq_loops, int, S_IRUGO);
257MODULE_PARM_DESC(myri10ge_max_irq_loops,
258 "Set stuck legacy IRQ detection threshold\n");
259
260#define MYRI10GE_FW_OFFSET 1024*1024
261#define MYRI10GE_HIGHPART_TO_U32(X) \
262(sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
263#define MYRI10GE_LOWPART_TO_U32(X) ((u32)(X))
264
265#define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
266
267static int
268myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
269 struct myri10ge_cmd *data, int atomic)
270{
271 struct mcp_cmd *buf;
272 char buf_bytes[sizeof(*buf) + 8];
273 struct mcp_cmd_response *response = mgp->cmd;
274 char __iomem *cmd_addr = mgp->sram + MXGEFW_CMD_OFFSET;
275 u32 dma_low, dma_high, result, value;
276 int sleep_total = 0;
277
278 /* ensure buf is aligned to 8 bytes */
279 buf = (struct mcp_cmd *)ALIGN((unsigned long)buf_bytes, 8);
280
281 buf->data0 = htonl(data->data0);
282 buf->data1 = htonl(data->data1);
283 buf->data2 = htonl(data->data2);
284 buf->cmd = htonl(cmd);
285 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus);
286 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus);
287
288 buf->response_addr.low = htonl(dma_low);
289 buf->response_addr.high = htonl(dma_high);
290 response->result = MYRI10GE_NO_RESPONSE_RESULT;
291 mb();
292 myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf));
293
294 /* wait up to 15ms. Longest command is the DMA benchmark,
295 * which is capped at 5ms, but runs from a timeout handler
296 * that runs every 7.8ms. So a 15ms timeout leaves us with
297 * a 2.2ms margin
298 */
299 if (atomic) {
300 /* if atomic is set, do not sleep,
301 * and try to get the completion quickly
302 * (1ms will be enough for those commands) */
303 for (sleep_total = 0;
304 sleep_total < 1000
305 && response->result == MYRI10GE_NO_RESPONSE_RESULT;
306 sleep_total += 10)
307 udelay(10);
308 } else {
309 /* use msleep for most command */
310 for (sleep_total = 0;
311 sleep_total < 15
312 && response->result == MYRI10GE_NO_RESPONSE_RESULT;
313 sleep_total++)
314 msleep(1);
315 }
316
317 result = ntohl(response->result);
318 value = ntohl(response->data);
319 if (result != MYRI10GE_NO_RESPONSE_RESULT) {
320 if (result == 0) {
321 data->data0 = value;
322 return 0;
323 } else {
324 dev_err(&mgp->pdev->dev,
325 "command %d failed, result = %d\n",
326 cmd, result);
327 return -ENXIO;
328 }
329 }
330
331 dev_err(&mgp->pdev->dev, "command %d timed out, result = %d\n",
332 cmd, result);
333 return -EAGAIN;
334}
335
336/*
337 * The eeprom strings on the lanaiX have the format
338 * SN=x\0
339 * MAC=x:x:x:x:x:x\0
340 * PT:ddd mmm xx xx:xx:xx xx\0
341 * PV:ddd mmm xx xx:xx:xx xx\0
342 */
343static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp)
344{
345 char *ptr, *limit;
346 int i;
347
348 ptr = mgp->eeprom_strings;
349 limit = mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE;
350
351 while (*ptr != '\0' && ptr < limit) {
352 if (memcmp(ptr, "MAC=", 4) == 0) {
353 ptr += 4;
354 mgp->mac_addr_string = ptr;
355 for (i = 0; i < 6; i++) {
356 if ((ptr + 2) > limit)
357 goto abort;
358 mgp->mac_addr[i] =
359 simple_strtoul(ptr, &ptr, 16);
360 ptr += 1;
361 }
362 }
363 if (memcmp((const void *)ptr, "SN=", 3) == 0) {
364 ptr += 3;
365 mgp->serial_number = simple_strtoul(ptr, &ptr, 10);
366 }
367 while (ptr < limit && *ptr++) ;
368 }
369
370 return 0;
371
372abort:
373 dev_err(&mgp->pdev->dev, "failed to parse eeprom_strings\n");
374 return -ENXIO;
375}
376
377/*
378 * Enable or disable periodic RDMAs from the host to make certain
379 * chipsets resend dropped PCIe messages
380 */
381
382static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
383{
384 char __iomem *submit;
385 u32 buf[16];
386 u32 dma_low, dma_high;
387 int i;
388
389 /* clear confirmation addr */
390 mgp->cmd->data = 0;
391 mb();
392
393 /* send a rdma command to the PCIe engine, and wait for the
394 * response in the confirmation address. The firmware should
395 * write a -1 there to indicate it is alive and well
396 */
397 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus);
398 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus);
399
400 buf[0] = htonl(dma_high); /* confirm addr MSW */
401 buf[1] = htonl(dma_low); /* confirm addr LSW */
402 buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */
403 buf[3] = htonl(dma_high); /* dummy addr MSW */
404 buf[4] = htonl(dma_low); /* dummy addr LSW */
405 buf[5] = htonl(enable); /* enable? */
406
407 submit = mgp->sram + 0xfc01c0;
408
409 myri10ge_pio_copy(submit, &buf, sizeof(buf));
410 for (i = 0; mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20; i++)
411 msleep(1);
412 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA)
413 dev_err(&mgp->pdev->dev, "dummy rdma %s failed\n",
414 (enable ? "enable" : "disable"));
415}
416
417static int
418myri10ge_validate_firmware(struct myri10ge_priv *mgp,
419 struct mcp_gen_header *hdr)
420{
421 struct device *dev = &mgp->pdev->dev;
422 int major, minor;
423
424 /* check firmware type */
425 if (ntohl(hdr->mcp_type) != MCP_TYPE_ETH) {
426 dev_err(dev, "Bad firmware type: 0x%x\n", ntohl(hdr->mcp_type));
427 return -EINVAL;
428 }
429
430 /* save firmware version for ethtool */
431 strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
432
433 sscanf(mgp->fw_version, "%d.%d", &major, &minor);
434
435 if (!(major == MXGEFW_VERSION_MAJOR && minor == MXGEFW_VERSION_MINOR)) {
436 dev_err(dev, "Found firmware version %s\n", mgp->fw_version);
437 dev_err(dev, "Driver needs %d.%d\n", MXGEFW_VERSION_MAJOR,
438 MXGEFW_VERSION_MINOR);
439 return -EINVAL;
440 }
441 return 0;
442}
443
444static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
445{
446 unsigned crc, reread_crc;
447 const struct firmware *fw;
448 struct device *dev = &mgp->pdev->dev;
449 struct mcp_gen_header *hdr;
450 size_t hdr_offset;
451 int status;
452
453 if ((status = request_firmware(&fw, mgp->fw_name, dev)) < 0) {
454 dev_err(dev, "Unable to load %s firmware image via hotplug\n",
455 mgp->fw_name);
456 status = -EINVAL;
457 goto abort_with_nothing;
458 }
459
460 /* check size */
461
462 if (fw->size >= mgp->sram_size - MYRI10GE_FW_OFFSET ||
463 fw->size < MCP_HEADER_PTR_OFFSET + 4) {
464 dev_err(dev, "Firmware size invalid:%d\n", (int)fw->size);
465 status = -EINVAL;
466 goto abort_with_fw;
467 }
468
469 /* check id */
470 hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
471 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) {
472 dev_err(dev, "Bad firmware file\n");
473 status = -EINVAL;
474 goto abort_with_fw;
475 }
476 hdr = (void *)(fw->data + hdr_offset);
477
478 status = myri10ge_validate_firmware(mgp, hdr);
479 if (status != 0)
480 goto abort_with_fw;
481
482 crc = crc32(~0, fw->data, fw->size);
483 if (mgp->tx.boundary == 2048) {
484 /* Avoid PCI burst on chipset with unaligned completions. */
485 int i;
486 __iomem u32 *ptr = (__iomem u32 *) (mgp->sram +
487 MYRI10GE_FW_OFFSET);
488 for (i = 0; i < fw->size / 4; i++) {
489 __raw_writel(((u32 *) fw->data)[i], ptr + i);
490 wmb();
491 }
492 } else {
493 myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET, fw->data,
494 fw->size);
495 }
496 /* corruption checking is good for parity recovery and buggy chipset */
497 memcpy_fromio(fw->data, mgp->sram + MYRI10GE_FW_OFFSET, fw->size);
498 reread_crc = crc32(~0, fw->data, fw->size);
499 if (crc != reread_crc) {
500 dev_err(dev, "CRC failed(fw-len=%u), got 0x%x (expect 0x%x)\n",
501 (unsigned)fw->size, reread_crc, crc);
502 status = -EIO;
503 goto abort_with_fw;
504 }
505 *size = (u32) fw->size;
506
507abort_with_fw:
508 release_firmware(fw);
509
510abort_with_nothing:
511 return status;
512}
513
514static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
515{
516 struct mcp_gen_header *hdr;
517 struct device *dev = &mgp->pdev->dev;
518 const size_t bytes = sizeof(struct mcp_gen_header);
519 size_t hdr_offset;
520 int status;
521
522 /* find running firmware header */
523 hdr_offset = ntohl(__raw_readl(mgp->sram + MCP_HEADER_PTR_OFFSET));
524
525 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > mgp->sram_size) {
526 dev_err(dev, "Running firmware has bad header offset (%d)\n",
527 (int)hdr_offset);
528 return -EIO;
529 }
530
531 /* copy header of running firmware from SRAM to host memory to
532 * validate firmware */
533 hdr = kmalloc(bytes, GFP_KERNEL);
534 if (hdr == NULL) {
535 dev_err(dev, "could not malloc firmware hdr\n");
536 return -ENOMEM;
537 }
538 memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes);
539 status = myri10ge_validate_firmware(mgp, hdr);
540 kfree(hdr);
541 return status;
542}
543
544static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
545{
546 char __iomem *submit;
547 u32 buf[16];
548 u32 dma_low, dma_high, size;
549 int status, i;
550
551 size = 0;
552 status = myri10ge_load_hotplug_firmware(mgp, &size);
553 if (status) {
554 dev_warn(&mgp->pdev->dev, "hotplug firmware loading failed\n");
555
556 /* Do not attempt to adopt firmware if there
557 * was a bad crc */
558 if (status == -EIO)
559 return status;
560
561 status = myri10ge_adopt_running_firmware(mgp);
562 if (status != 0) {
563 dev_err(&mgp->pdev->dev,
564 "failed to adopt running firmware\n");
565 return status;
566 }
567 dev_info(&mgp->pdev->dev,
568 "Successfully adopted running firmware\n");
569 if (mgp->tx.boundary == 4096) {
570 dev_warn(&mgp->pdev->dev,
571 "Using firmware currently running on NIC"
572 ". For optimal\n");
573 dev_warn(&mgp->pdev->dev,
574 "performance consider loading optimized "
575 "firmware\n");
576 dev_warn(&mgp->pdev->dev, "via hotplug\n");
577 }
578
579 mgp->fw_name = "adopted";
580 mgp->tx.boundary = 2048;
581 return status;
582 }
583
584 /* clear confirmation addr */
585 mgp->cmd->data = 0;
586 mb();
587
588 /* send a reload command to the bootstrap MCP, and wait for the
589 * response in the confirmation address. The firmware should
590 * write a -1 there to indicate it is alive and well
591 */
592 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus);
593 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus);
594
595 buf[0] = htonl(dma_high); /* confirm addr MSW */
596 buf[1] = htonl(dma_low); /* confirm addr LSW */
597 buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */
598
599 /* FIX: All newest firmware should un-protect the bottom of
600 * the sram before handoff. However, the very first interfaces
601 * do not. Therefore the handoff copy must skip the first 8 bytes
602 */
603 buf[3] = htonl(MYRI10GE_FW_OFFSET + 8); /* where the code starts */
604 buf[4] = htonl(size - 8); /* length of code */
605 buf[5] = htonl(8); /* where to copy to */
606 buf[6] = htonl(0); /* where to jump to */
607
608 submit = mgp->sram + 0xfc0000;
609
610 myri10ge_pio_copy(submit, &buf, sizeof(buf));
611 mb();
612 msleep(1);
613 mb();
614 i = 0;
615 while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20) {
616 msleep(1);
617 i++;
618 }
619 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) {
620 dev_err(&mgp->pdev->dev, "handoff failed\n");
621 return -ENXIO;
622 }
623 dev_info(&mgp->pdev->dev, "handoff confirmed\n");
624 myri10ge_dummy_rdma(mgp, mgp->tx.boundary != 4096);
625
626 return 0;
627}
628
629static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr)
630{
631 struct myri10ge_cmd cmd;
632 int status;
633
634 cmd.data0 = ((addr[0] << 24) | (addr[1] << 16)
635 | (addr[2] << 8) | addr[3]);
636
637 cmd.data1 = ((addr[4] << 8) | (addr[5]));
638
639 status = myri10ge_send_cmd(mgp, MXGEFW_SET_MAC_ADDRESS, &cmd, 0);
640 return status;
641}
642
643static int myri10ge_change_pause(struct myri10ge_priv *mgp, int pause)
644{
645 struct myri10ge_cmd cmd;
646 int status, ctl;
647
648 ctl = pause ? MXGEFW_ENABLE_FLOW_CONTROL : MXGEFW_DISABLE_FLOW_CONTROL;
649 status = myri10ge_send_cmd(mgp, ctl, &cmd, 0);
650
651 if (status) {
652 printk(KERN_ERR
653 "myri10ge: %s: Failed to set flow control mode\n",
654 mgp->dev->name);
655 return status;
656 }
657 mgp->pause = pause;
658 return 0;
659}
660
661static void
662myri10ge_change_promisc(struct myri10ge_priv *mgp, int promisc, int atomic)
663{
664 struct myri10ge_cmd cmd;
665 int status, ctl;
666
667 ctl = promisc ? MXGEFW_ENABLE_PROMISC : MXGEFW_DISABLE_PROMISC;
668 status = myri10ge_send_cmd(mgp, ctl, &cmd, atomic);
669 if (status)
670 printk(KERN_ERR "myri10ge: %s: Failed to set promisc mode\n",
671 mgp->dev->name);
672}
673
674static int myri10ge_reset(struct myri10ge_priv *mgp)
675{
676 struct myri10ge_cmd cmd;
677 int status;
678 size_t bytes;
679 u32 len;
680
681 /* try to send a reset command to the card to see if it
682 * is alive */
683 memset(&cmd, 0, sizeof(cmd));
684 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_RESET, &cmd, 0);
685 if (status != 0) {
686 dev_err(&mgp->pdev->dev, "failed reset\n");
687 return -ENXIO;
688 }
689
690 /* Now exchange information about interrupts */
691
692 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
693 memset(mgp->rx_done.entry, 0, bytes);
694 cmd.data0 = (u32) bytes;
695 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0);
696 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
697 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
698 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0);
699
700 status |=
701 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
702 mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0);
703 if (!mgp->msi_enabled) {
704 status |= myri10ge_send_cmd
705 (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0);
706 mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0);
707
708 }
709 status |= myri10ge_send_cmd
710 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0);
711 mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0);
712 if (status != 0) {
713 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
714 return status;
715 }
716 __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
717
718 /* Run a small DMA test.
719 * The magic multipliers to the length tell the firmware
720 * to do DMA read, write, or read+write tests. The
721 * results are returned in cmd.data0. The upper 16
722 * bits or the return is the number of transfers completed.
723 * The lower 16 bits is the time in 0.5us ticks that the
724 * transfers took to complete.
725 */
726
727 len = mgp->tx.boundary;
728
729 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
730 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
731 cmd.data2 = len * 0x10000;
732 status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
733 if (status == 0)
734 mgp->read_dma = ((cmd.data0 >> 16) * len * 2) /
735 (cmd.data0 & 0xffff);
736 else
737 dev_warn(&mgp->pdev->dev, "DMA read benchmark failed: %d\n",
738 status);
739 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
740 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
741 cmd.data2 = len * 0x1;
742 status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
743 if (status == 0)
744 mgp->write_dma = ((cmd.data0 >> 16) * len * 2) /
745 (cmd.data0 & 0xffff);
746 else
747 dev_warn(&mgp->pdev->dev, "DMA write benchmark failed: %d\n",
748 status);
749
750 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus);
751 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus);
752 cmd.data2 = len * 0x10001;
753 status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
754 if (status == 0)
755 mgp->read_write_dma = ((cmd.data0 >> 16) * len * 2 * 2) /
756 (cmd.data0 & 0xffff);
757 else
758 dev_warn(&mgp->pdev->dev,
759 "DMA read/write benchmark failed: %d\n", status);
760
761 memset(mgp->rx_done.entry, 0, bytes);
762
763 /* reset mcp/driver shared state back to 0 */
764 mgp->tx.req = 0;
765 mgp->tx.done = 0;
766 mgp->tx.pkt_start = 0;
767 mgp->tx.pkt_done = 0;
768 mgp->rx_big.cnt = 0;
769 mgp->rx_small.cnt = 0;
770 mgp->rx_done.idx = 0;
771 mgp->rx_done.cnt = 0;
772 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
773 myri10ge_change_promisc(mgp, 0, 0);
774 myri10ge_change_pause(mgp, mgp->pause);
775 return status;
776}
777
778static inline void
779myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
780 struct mcp_kreq_ether_recv *src)
781{
782 u32 low;
783
784 low = src->addr_low;
785 src->addr_low = DMA_32BIT_MASK;
786 myri10ge_pio_copy(dst, src, 8 * sizeof(*src));
787 mb();
788 src->addr_low = low;
789 __raw_writel(low, &dst->addr_low);
790 mb();
791}
792
793/*
794 * Set of routines to get a new receive buffer. Any buffer which
795 * crosses a 4KB boundary must start on a 4KB boundary due to PCIe
796 * wdma restrictions. We also try to align any smaller allocation to
797 * at least a 16 byte boundary for efficiency. We assume the linux
798 * memory allocator works by powers of 2, and will not return memory
799 * smaller than 2KB which crosses a 4KB boundary. If it does, we fall
800 * back to allocating 2x as much space as required.
801 *
802 * We intend to replace large (>4KB) skb allocations by using
803 * pages directly and building a fraglist in the near future.
804 */
805
806static inline struct sk_buff *myri10ge_alloc_big(int bytes)
807{
808 struct sk_buff *skb;
809 unsigned long data, roundup;
810
811 skb = dev_alloc_skb(bytes + 4096 + MXGEFW_PAD);
812 if (skb == NULL)
813 return NULL;
814
815 /* Correct skb->truesize so that socket buffer
816 * accounting is not confused the rounding we must
817 * do to satisfy alignment constraints.
818 */
819 skb->truesize -= 4096;
820
821 data = (unsigned long)(skb->data);
822 roundup = (-data) & (4095);
823 skb_reserve(skb, roundup);
824 return skb;
825}
826
827/* Allocate 2x as much space as required and use whichever portion
828 * does not cross a 4KB boundary */
829static inline struct sk_buff *myri10ge_alloc_small_safe(unsigned int bytes)
830{
831 struct sk_buff *skb;
832 unsigned long data, boundary;
833
834 skb = dev_alloc_skb(2 * (bytes + MXGEFW_PAD) - 1);
835 if (unlikely(skb == NULL))
836 return NULL;
837
838 /* Correct skb->truesize so that socket buffer
839 * accounting is not confused the rounding we must
840 * do to satisfy alignment constraints.
841 */
842 skb->truesize -= bytes + MXGEFW_PAD;
843
844 data = (unsigned long)(skb->data);
845 boundary = (data + 4095UL) & ~4095UL;
846 if ((boundary - data) >= (bytes + MXGEFW_PAD))
847 return skb;
848
849 skb_reserve(skb, boundary - data);
850 return skb;
851}
852
853/* Allocate just enough space, and verify that the allocated
854 * space does not cross a 4KB boundary */
855static inline struct sk_buff *myri10ge_alloc_small(int bytes)
856{
857 struct sk_buff *skb;
858 unsigned long roundup, data, end;
859
860 skb = dev_alloc_skb(bytes + 16 + MXGEFW_PAD);
861 if (unlikely(skb == NULL))
862 return NULL;
863
864 /* Round allocated buffer to 16 byte boundary */
865 data = (unsigned long)(skb->data);
866 roundup = (-data) & 15UL;
867 skb_reserve(skb, roundup);
868 /* Verify that the data buffer does not cross a page boundary */
869 data = (unsigned long)(skb->data);
870 end = data + bytes + MXGEFW_PAD - 1;
871 if (unlikely(((end >> 12) != (data >> 12)) && (data & 4095UL))) {
872 printk(KERN_NOTICE
873 "myri10ge_alloc_small: small skb crossed 4KB boundary\n");
874 myri10ge_skb_cross_4k = 1;
875 dev_kfree_skb_any(skb);
876 skb = myri10ge_alloc_small_safe(bytes);
877 }
878 return skb;
879}
880
881static inline int
882myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct pci_dev *pdev, int bytes,
883 int idx)
884{
885 struct sk_buff *skb;
886 dma_addr_t bus;
887 int len, retval = 0;
888
889 bytes += VLAN_HLEN; /* account for 802.1q vlan tag */
890
891 if ((bytes + MXGEFW_PAD) > (4096 - 16) /* linux overhead */ )
892 skb = myri10ge_alloc_big(bytes);
893 else if (myri10ge_skb_cross_4k)
894 skb = myri10ge_alloc_small_safe(bytes);
895 else
896 skb = myri10ge_alloc_small(bytes);
897
898 if (unlikely(skb == NULL)) {
899 rx->alloc_fail++;
900 retval = -ENOBUFS;
901 goto done;
902 }
903
904 /* set len so that it only covers the area we
905 * need mapped for DMA */
906 len = bytes + MXGEFW_PAD;
907
908 bus = pci_map_single(pdev, skb->data, len, PCI_DMA_FROMDEVICE);
909 rx->info[idx].skb = skb;
910 pci_unmap_addr_set(&rx->info[idx], bus, bus);
911 pci_unmap_len_set(&rx->info[idx], len, len);
912 rx->shadow[idx].addr_low = htonl(MYRI10GE_LOWPART_TO_U32(bus));
913 rx->shadow[idx].addr_high = htonl(MYRI10GE_HIGHPART_TO_U32(bus));
914
915done:
916 /* copy 8 descriptors (64-bytes) to the mcp at a time */
917 if ((idx & 7) == 7) {
918 if (rx->wc_fifo == NULL)
919 myri10ge_submit_8rx(&rx->lanai[idx - 7],
920 &rx->shadow[idx - 7]);
921 else {
922 mb();
923 myri10ge_pio_copy(rx->wc_fifo,
924 &rx->shadow[idx - 7], 64);
925 }
926 }
927 return retval;
928}
929
930static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
931{
932 struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
933
934 if ((skb->protocol == ntohs(ETH_P_8021Q)) &&
935 (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
936 vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
937 skb->csum = hw_csum;
938 skb->ip_summed = CHECKSUM_HW;
939 }
940}
941
942static inline unsigned long
943myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
944 int bytes, int len, int csum)
945{
946 dma_addr_t bus;
947 struct sk_buff *skb;
948 int idx, unmap_len;
949
950 idx = rx->cnt & rx->mask;
951 rx->cnt++;
952
953 /* save a pointer to the received skb */
954 skb = rx->info[idx].skb;
955 bus = pci_unmap_addr(&rx->info[idx], bus);
956 unmap_len = pci_unmap_len(&rx->info[idx], len);
957
958 /* try to replace the received skb */
959 if (myri10ge_getbuf(rx, mgp->pdev, bytes, idx)) {
960 /* drop the frame -- the old skbuf is re-cycled */
961 mgp->stats.rx_dropped += 1;
962 return 0;
963 }
964
965 /* unmap the recvd skb */
966 pci_unmap_single(mgp->pdev, bus, unmap_len, PCI_DMA_FROMDEVICE);
967
968 /* mcp implicitly skips 1st bytes so that packet is properly
969 * aligned */
970 skb_reserve(skb, MXGEFW_PAD);
971
972 /* set the length of the frame */
973 skb_put(skb, len);
974
975 skb->protocol = eth_type_trans(skb, mgp->dev);
976 skb->dev = mgp->dev;
977 if (mgp->csum_flag) {
978 if ((skb->protocol == ntohs(ETH_P_IP)) ||
979 (skb->protocol == ntohs(ETH_P_IPV6))) {
980 skb->csum = ntohs((u16) csum);
981 skb->ip_summed = CHECKSUM_HW;
982 } else
983 myri10ge_vlan_ip_csum(skb, ntohs((u16) csum));
984 }
985
986 netif_receive_skb(skb);
987 mgp->dev->last_rx = jiffies;
988 return 1;
989}
990
991static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
992{
993 struct pci_dev *pdev = mgp->pdev;
994 struct myri10ge_tx_buf *tx = &mgp->tx;
995 struct sk_buff *skb;
996 int idx, len;
997 int limit = 0;
998
999 while (tx->pkt_done != mcp_index) {
1000 idx = tx->done & tx->mask;
1001 skb = tx->info[idx].skb;
1002
1003 /* Mark as free */
1004 tx->info[idx].skb = NULL;
1005 if (tx->info[idx].last) {
1006 tx->pkt_done++;
1007 tx->info[idx].last = 0;
1008 }
1009 tx->done++;
1010 len = pci_unmap_len(&tx->info[idx], len);
1011 pci_unmap_len_set(&tx->info[idx], len, 0);
1012 if (skb) {
1013 mgp->stats.tx_bytes += skb->len;
1014 mgp->stats.tx_packets++;
1015 dev_kfree_skb_irq(skb);
1016 if (len)
1017 pci_unmap_single(pdev,
1018 pci_unmap_addr(&tx->info[idx],
1019 bus), len,
1020 PCI_DMA_TODEVICE);
1021 } else {
1022 if (len)
1023 pci_unmap_page(pdev,
1024 pci_unmap_addr(&tx->info[idx],
1025 bus), len,
1026 PCI_DMA_TODEVICE);
1027 }
1028
1029 /* limit potential for livelock by only handling
1030 * 2 full tx rings per call */
1031 if (unlikely(++limit > 2 * tx->mask))
1032 break;
1033 }
1034 /* start the queue if we've stopped it */
1035 if (netif_queue_stopped(mgp->dev)
1036 && tx->req - tx->done < (tx->mask >> 1)) {
1037 mgp->wake_queue++;
1038 netif_wake_queue(mgp->dev);
1039 }
1040}
1041
1042static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit)
1043{
1044 struct myri10ge_rx_done *rx_done = &mgp->rx_done;
1045 unsigned long rx_bytes = 0;
1046 unsigned long rx_packets = 0;
1047 unsigned long rx_ok;
1048
1049 int idx = rx_done->idx;
1050 int cnt = rx_done->cnt;
1051 u16 length;
1052 u16 checksum;
1053
1054 while (rx_done->entry[idx].length != 0 && *limit != 0) {
1055 length = ntohs(rx_done->entry[idx].length);
1056 rx_done->entry[idx].length = 0;
1057 checksum = ntohs(rx_done->entry[idx].checksum);
1058 if (length <= mgp->small_bytes)
1059 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small,
1060 mgp->small_bytes,
1061 length, checksum);
1062 else
1063 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_big,
1064 mgp->dev->mtu + ETH_HLEN,
1065 length, checksum);
1066 rx_packets += rx_ok;
1067 rx_bytes += rx_ok * (unsigned long)length;
1068 cnt++;
1069 idx = cnt & (myri10ge_max_intr_slots - 1);
1070
1071 /* limit potential for livelock by only handling a
1072 * limited number of frames. */
1073 (*limit)--;
1074 }
1075 rx_done->idx = idx;
1076 rx_done->cnt = cnt;
1077 mgp->stats.rx_packets += rx_packets;
1078 mgp->stats.rx_bytes += rx_bytes;
1079}
1080
1081static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1082{
1083 struct mcp_irq_data *stats = mgp->fw_stats;
1084
1085 if (unlikely(stats->stats_updated)) {
1086 if (mgp->link_state != stats->link_up) {
1087 mgp->link_state = stats->link_up;
1088 if (mgp->link_state) {
1089 printk(KERN_INFO "myri10ge: %s: link up\n",
1090 mgp->dev->name);
1091 netif_carrier_on(mgp->dev);
1092 } else {
1093 printk(KERN_INFO "myri10ge: %s: link down\n",
1094 mgp->dev->name);
1095 netif_carrier_off(mgp->dev);
1096 }
1097 }
1098 if (mgp->rdma_tags_available !=
1099 ntohl(mgp->fw_stats->rdma_tags_available)) {
1100 mgp->rdma_tags_available =
1101 ntohl(mgp->fw_stats->rdma_tags_available);
1102 printk(KERN_WARNING "myri10ge: %s: RDMA timed out! "
1103 "%d tags left\n", mgp->dev->name,
1104 mgp->rdma_tags_available);
1105 }
1106 mgp->down_cnt += stats->link_down;
1107 if (stats->link_down)
1108 wake_up(&mgp->down_wq);
1109 }
1110}
1111
1112static int myri10ge_poll(struct net_device *netdev, int *budget)
1113{
1114 struct myri10ge_priv *mgp = netdev_priv(netdev);
1115 struct myri10ge_rx_done *rx_done = &mgp->rx_done;
1116 int limit, orig_limit, work_done;
1117
1118 /* process as many rx events as NAPI will allow */
1119 limit = min(*budget, netdev->quota);
1120 orig_limit = limit;
1121 myri10ge_clean_rx_done(mgp, &limit);
1122 work_done = orig_limit - limit;
1123 *budget -= work_done;
1124 netdev->quota -= work_done;
1125
1126 if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) {
1127 netif_rx_complete(netdev);
1128 __raw_writel(htonl(3), mgp->irq_claim);
1129 return 0;
1130 }
1131 return 1;
1132}
1133
1134static irqreturn_t myri10ge_intr(int irq, void *arg, struct pt_regs *regs)
1135{
1136 struct myri10ge_priv *mgp = arg;
1137 struct mcp_irq_data *stats = mgp->fw_stats;
1138 struct myri10ge_tx_buf *tx = &mgp->tx;
1139 u32 send_done_count;
1140 int i;
1141
1142 /* make sure it is our IRQ, and that the DMA has finished */
1143 if (unlikely(!stats->valid))
1144 return (IRQ_NONE);
1145
1146 /* low bit indicates receives are present, so schedule
1147 * napi poll handler */
1148 if (stats->valid & 1)
1149 netif_rx_schedule(mgp->dev);
1150
1151 if (!mgp->msi_enabled) {
1152 __raw_writel(0, mgp->irq_deassert);
1153 if (!myri10ge_deassert_wait)
1154 stats->valid = 0;
1155 mb();
1156 } else
1157 stats->valid = 0;
1158
1159 /* Wait for IRQ line to go low, if using INTx */
1160 i = 0;
1161 while (1) {
1162 i++;
1163 /* check for transmit completes and receives */
1164 send_done_count = ntohl(stats->send_done_count);
1165 if (send_done_count != tx->pkt_done)
1166 myri10ge_tx_done(mgp, (int)send_done_count);
1167 if (unlikely(i > myri10ge_max_irq_loops)) {
1168 printk(KERN_WARNING "myri10ge: %s: irq stuck?\n",
1169 mgp->dev->name);
1170 stats->valid = 0;
1171 schedule_work(&mgp->watchdog_work);
1172 }
1173 if (likely(stats->valid == 0))
1174 break;
1175 cpu_relax();
1176 barrier();
1177 }
1178
1179 myri10ge_check_statblock(mgp);
1180
1181 __raw_writel(htonl(3), mgp->irq_claim + 1);
1182 return (IRQ_HANDLED);
1183}
1184
1185static int
1186myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
1187{
1188 cmd->autoneg = AUTONEG_DISABLE;
1189 cmd->speed = SPEED_10000;
1190 cmd->duplex = DUPLEX_FULL;
1191 return 0;
1192}
1193
1194static void
1195myri10ge_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info)
1196{
1197 struct myri10ge_priv *mgp = netdev_priv(netdev);
1198
1199 strlcpy(info->driver, "myri10ge", sizeof(info->driver));
1200 strlcpy(info->version, MYRI10GE_VERSION_STR, sizeof(info->version));
1201 strlcpy(info->fw_version, mgp->fw_version, sizeof(info->fw_version));
1202 strlcpy(info->bus_info, pci_name(mgp->pdev), sizeof(info->bus_info));
1203}
1204
1205static int
1206myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
1207{
1208 struct myri10ge_priv *mgp = netdev_priv(netdev);
1209 coal->rx_coalesce_usecs = mgp->intr_coal_delay;
1210 return 0;
1211}
1212
1213static int
1214myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
1215{
1216 struct myri10ge_priv *mgp = netdev_priv(netdev);
1217
1218 mgp->intr_coal_delay = coal->rx_coalesce_usecs;
1219 __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
1220 return 0;
1221}
1222
1223static void
1224myri10ge_get_pauseparam(struct net_device *netdev,
1225 struct ethtool_pauseparam *pause)
1226{
1227 struct myri10ge_priv *mgp = netdev_priv(netdev);
1228
1229 pause->autoneg = 0;
1230 pause->rx_pause = mgp->pause;
1231 pause->tx_pause = mgp->pause;
1232}
1233
1234static int
1235myri10ge_set_pauseparam(struct net_device *netdev,
1236 struct ethtool_pauseparam *pause)
1237{
1238 struct myri10ge_priv *mgp = netdev_priv(netdev);
1239
1240 if (pause->tx_pause != mgp->pause)
1241 return myri10ge_change_pause(mgp, pause->tx_pause);
1242 if (pause->rx_pause != mgp->pause)
1243 return myri10ge_change_pause(mgp, pause->tx_pause);
1244 if (pause->autoneg != 0)
1245 return -EINVAL;
1246 return 0;
1247}
1248
1249static void
1250myri10ge_get_ringparam(struct net_device *netdev,
1251 struct ethtool_ringparam *ring)
1252{
1253 struct myri10ge_priv *mgp = netdev_priv(netdev);
1254
1255 ring->rx_mini_max_pending = mgp->rx_small.mask + 1;
1256 ring->rx_max_pending = mgp->rx_big.mask + 1;
1257 ring->rx_jumbo_max_pending = 0;
1258 ring->tx_max_pending = mgp->rx_small.mask + 1;
1259 ring->rx_mini_pending = ring->rx_mini_max_pending;
1260 ring->rx_pending = ring->rx_max_pending;
1261 ring->rx_jumbo_pending = ring->rx_jumbo_max_pending;
1262 ring->tx_pending = ring->tx_max_pending;
1263}
1264
1265static u32 myri10ge_get_rx_csum(struct net_device *netdev)
1266{
1267 struct myri10ge_priv *mgp = netdev_priv(netdev);
1268 if (mgp->csum_flag)
1269 return 1;
1270 else
1271 return 0;
1272}
1273
1274static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
1275{
1276 struct myri10ge_priv *mgp = netdev_priv(netdev);
1277 if (csum_enabled)
1278 mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
1279 else
1280 mgp->csum_flag = 0;
1281 return 0;
1282}
1283
1284static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
1285 "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
1286 "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
1287 "rx_length_errors", "rx_over_errors", "rx_crc_errors",
1288 "rx_frame_errors", "rx_fifo_errors", "rx_missed_errors",
1289 "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors",
1290 "tx_heartbeat_errors", "tx_window_errors",
1291 /* device-specific stats */
1292 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs",
1293 "serial_number", "tx_pkt_start", "tx_pkt_done",
1294 "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
1295 "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
1296 "link_up", "dropped_link_overflow", "dropped_link_error_or_filtered",
1297 "dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
1298 "dropped_no_big_buffer"
1299};
1300
1301#define MYRI10GE_NET_STATS_LEN 21
1302#define MYRI10GE_STATS_LEN sizeof(myri10ge_gstrings_stats) / ETH_GSTRING_LEN
1303
1304static void
1305myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data)
1306{
1307 switch (stringset) {
1308 case ETH_SS_STATS:
1309 memcpy(data, *myri10ge_gstrings_stats,
1310 sizeof(myri10ge_gstrings_stats));
1311 break;
1312 }
1313}
1314
1315static int myri10ge_get_stats_count(struct net_device *netdev)
1316{
1317 return MYRI10GE_STATS_LEN;
1318}
1319
1320static void
1321myri10ge_get_ethtool_stats(struct net_device *netdev,
1322 struct ethtool_stats *stats, u64 * data)
1323{
1324 struct myri10ge_priv *mgp = netdev_priv(netdev);
1325 int i;
1326
1327 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
1328 data[i] = ((unsigned long *)&mgp->stats)[i];
1329
1330 data[i++] = (unsigned int)mgp->read_dma;
1331 data[i++] = (unsigned int)mgp->write_dma;
1332 data[i++] = (unsigned int)mgp->read_write_dma;
1333 data[i++] = (unsigned int)mgp->serial_number;
1334 data[i++] = (unsigned int)mgp->tx.pkt_start;
1335 data[i++] = (unsigned int)mgp->tx.pkt_done;
1336 data[i++] = (unsigned int)mgp->tx.req;
1337 data[i++] = (unsigned int)mgp->tx.done;
1338 data[i++] = (unsigned int)mgp->rx_small.cnt;
1339 data[i++] = (unsigned int)mgp->rx_big.cnt;
1340 data[i++] = (unsigned int)mgp->wake_queue;
1341 data[i++] = (unsigned int)mgp->stop_queue;
1342 data[i++] = (unsigned int)mgp->watchdog_resets;
1343 data[i++] = (unsigned int)mgp->tx_linearized;
1344 data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up);
1345 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow);
1346 data[i++] =
1347 (unsigned int)ntohl(mgp->fw_stats->dropped_link_error_or_filtered);
1348 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_runt);
1349 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_overrun);
1350 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_small_buffer);
1351 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer);
1352}
1353
1354static struct ethtool_ops myri10ge_ethtool_ops = {
1355 .get_settings = myri10ge_get_settings,
1356 .get_drvinfo = myri10ge_get_drvinfo,
1357 .get_coalesce = myri10ge_get_coalesce,
1358 .set_coalesce = myri10ge_set_coalesce,
1359 .get_pauseparam = myri10ge_get_pauseparam,
1360 .set_pauseparam = myri10ge_set_pauseparam,
1361 .get_ringparam = myri10ge_get_ringparam,
1362 .get_rx_csum = myri10ge_get_rx_csum,
1363 .set_rx_csum = myri10ge_set_rx_csum,
1364 .get_tx_csum = ethtool_op_get_tx_csum,
1365 .set_tx_csum = ethtool_op_set_tx_hw_csum,
1366 .get_sg = ethtool_op_get_sg,
1367 .set_sg = ethtool_op_set_sg,
1368#ifdef NETIF_F_TSO
1369 .get_tso = ethtool_op_get_tso,
1370 .set_tso = ethtool_op_set_tso,
1371#endif
1372 .get_strings = myri10ge_get_strings,
1373 .get_stats_count = myri10ge_get_stats_count,
1374 .get_ethtool_stats = myri10ge_get_ethtool_stats
1375};
1376
1377static int myri10ge_allocate_rings(struct net_device *dev)
1378{
1379 struct myri10ge_priv *mgp;
1380 struct myri10ge_cmd cmd;
1381 int tx_ring_size, rx_ring_size;
1382 int tx_ring_entries, rx_ring_entries;
1383 int i, status;
1384 size_t bytes;
1385
1386 mgp = netdev_priv(dev);
1387
1388 /* get ring sizes */
1389
1390 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0);
1391 tx_ring_size = cmd.data0;
1392 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
1393 rx_ring_size = cmd.data0;
1394
1395 tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send);
1396 rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr);
1397 mgp->tx.mask = tx_ring_entries - 1;
1398 mgp->rx_small.mask = mgp->rx_big.mask = rx_ring_entries - 1;
1399
1400 /* allocate the host shadow rings */
1401
1402 bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4)
1403 * sizeof(*mgp->tx.req_list);
1404 mgp->tx.req_bytes = kzalloc(bytes, GFP_KERNEL);
1405 if (mgp->tx.req_bytes == NULL)
1406 goto abort_with_nothing;
1407
1408 /* ensure req_list entries are aligned to 8 bytes */
1409 mgp->tx.req_list = (struct mcp_kreq_ether_send *)
1410 ALIGN((unsigned long)mgp->tx.req_bytes, 8);
1411
1412 bytes = rx_ring_entries * sizeof(*mgp->rx_small.shadow);
1413 mgp->rx_small.shadow = kzalloc(bytes, GFP_KERNEL);
1414 if (mgp->rx_small.shadow == NULL)
1415 goto abort_with_tx_req_bytes;
1416
1417 bytes = rx_ring_entries * sizeof(*mgp->rx_big.shadow);
1418 mgp->rx_big.shadow = kzalloc(bytes, GFP_KERNEL);
1419 if (mgp->rx_big.shadow == NULL)
1420 goto abort_with_rx_small_shadow;
1421
1422 /* allocate the host info rings */
1423
1424 bytes = tx_ring_entries * sizeof(*mgp->tx.info);
1425 mgp->tx.info = kzalloc(bytes, GFP_KERNEL);
1426 if (mgp->tx.info == NULL)
1427 goto abort_with_rx_big_shadow;
1428
1429 bytes = rx_ring_entries * sizeof(*mgp->rx_small.info);
1430 mgp->rx_small.info = kzalloc(bytes, GFP_KERNEL);
1431 if (mgp->rx_small.info == NULL)
1432 goto abort_with_tx_info;
1433
1434 bytes = rx_ring_entries * sizeof(*mgp->rx_big.info);
1435 mgp->rx_big.info = kzalloc(bytes, GFP_KERNEL);
1436 if (mgp->rx_big.info == NULL)
1437 goto abort_with_rx_small_info;
1438
1439 /* Fill the receive rings */
1440
1441 for (i = 0; i <= mgp->rx_small.mask; i++) {
1442 status = myri10ge_getbuf(&mgp->rx_small, mgp->pdev,
1443 mgp->small_bytes, i);
1444 if (status) {
1445 printk(KERN_ERR
1446 "myri10ge: %s: alloced only %d small bufs\n",
1447 dev->name, i);
1448 goto abort_with_rx_small_ring;
1449 }
1450 }
1451
1452 for (i = 0; i <= mgp->rx_big.mask; i++) {
1453 status =
1454 myri10ge_getbuf(&mgp->rx_big, mgp->pdev,
1455 dev->mtu + ETH_HLEN, i);
1456 if (status) {
1457 printk(KERN_ERR
1458 "myri10ge: %s: alloced only %d big bufs\n",
1459 dev->name, i);
1460 goto abort_with_rx_big_ring;
1461 }
1462 }
1463
1464 return 0;
1465
1466abort_with_rx_big_ring:
1467 for (i = 0; i <= mgp->rx_big.mask; i++) {
1468 if (mgp->rx_big.info[i].skb != NULL)
1469 dev_kfree_skb_any(mgp->rx_big.info[i].skb);
1470 if (pci_unmap_len(&mgp->rx_big.info[i], len))
1471 pci_unmap_single(mgp->pdev,
1472 pci_unmap_addr(&mgp->rx_big.info[i],
1473 bus),
1474 pci_unmap_len(&mgp->rx_big.info[i],
1475 len),
1476 PCI_DMA_FROMDEVICE);
1477 }
1478
1479abort_with_rx_small_ring:
1480 for (i = 0; i <= mgp->rx_small.mask; i++) {
1481 if (mgp->rx_small.info[i].skb != NULL)
1482 dev_kfree_skb_any(mgp->rx_small.info[i].skb);
1483 if (pci_unmap_len(&mgp->rx_small.info[i], len))
1484 pci_unmap_single(mgp->pdev,
1485 pci_unmap_addr(&mgp->rx_small.info[i],
1486 bus),
1487 pci_unmap_len(&mgp->rx_small.info[i],
1488 len),
1489 PCI_DMA_FROMDEVICE);
1490 }
1491 kfree(mgp->rx_big.info);
1492
1493abort_with_rx_small_info:
1494 kfree(mgp->rx_small.info);
1495
1496abort_with_tx_info:
1497 kfree(mgp->tx.info);
1498
1499abort_with_rx_big_shadow:
1500 kfree(mgp->rx_big.shadow);
1501
1502abort_with_rx_small_shadow:
1503 kfree(mgp->rx_small.shadow);
1504
1505abort_with_tx_req_bytes:
1506 kfree(mgp->tx.req_bytes);
1507 mgp->tx.req_bytes = NULL;
1508 mgp->tx.req_list = NULL;
1509
1510abort_with_nothing:
1511 return status;
1512}
1513
1514static void myri10ge_free_rings(struct net_device *dev)
1515{
1516 struct myri10ge_priv *mgp;
1517 struct sk_buff *skb;
1518 struct myri10ge_tx_buf *tx;
1519 int i, len, idx;
1520
1521 mgp = netdev_priv(dev);
1522
1523 for (i = 0; i <= mgp->rx_big.mask; i++) {
1524 if (mgp->rx_big.info[i].skb != NULL)
1525 dev_kfree_skb_any(mgp->rx_big.info[i].skb);
1526 if (pci_unmap_len(&mgp->rx_big.info[i], len))
1527 pci_unmap_single(mgp->pdev,
1528 pci_unmap_addr(&mgp->rx_big.info[i],
1529 bus),
1530 pci_unmap_len(&mgp->rx_big.info[i],
1531 len),
1532 PCI_DMA_FROMDEVICE);
1533 }
1534
1535 for (i = 0; i <= mgp->rx_small.mask; i++) {
1536 if (mgp->rx_small.info[i].skb != NULL)
1537 dev_kfree_skb_any(mgp->rx_small.info[i].skb);
1538 if (pci_unmap_len(&mgp->rx_small.info[i], len))
1539 pci_unmap_single(mgp->pdev,
1540 pci_unmap_addr(&mgp->rx_small.info[i],
1541 bus),
1542 pci_unmap_len(&mgp->rx_small.info[i],
1543 len),
1544 PCI_DMA_FROMDEVICE);
1545 }
1546
1547 tx = &mgp->tx;
1548 while (tx->done != tx->req) {
1549 idx = tx->done & tx->mask;
1550 skb = tx->info[idx].skb;
1551
1552 /* Mark as free */
1553 tx->info[idx].skb = NULL;
1554 tx->done++;
1555 len = pci_unmap_len(&tx->info[idx], len);
1556 pci_unmap_len_set(&tx->info[idx], len, 0);
1557 if (skb) {
1558 mgp->stats.tx_dropped++;
1559 dev_kfree_skb_any(skb);
1560 if (len)
1561 pci_unmap_single(mgp->pdev,
1562 pci_unmap_addr(&tx->info[idx],
1563 bus), len,
1564 PCI_DMA_TODEVICE);
1565 } else {
1566 if (len)
1567 pci_unmap_page(mgp->pdev,
1568 pci_unmap_addr(&tx->info[idx],
1569 bus), len,
1570 PCI_DMA_TODEVICE);
1571 }
1572 }
1573 kfree(mgp->rx_big.info);
1574
1575 kfree(mgp->rx_small.info);
1576
1577 kfree(mgp->tx.info);
1578
1579 kfree(mgp->rx_big.shadow);
1580
1581 kfree(mgp->rx_small.shadow);
1582
1583 kfree(mgp->tx.req_bytes);
1584 mgp->tx.req_bytes = NULL;
1585 mgp->tx.req_list = NULL;
1586}
1587
1588static int myri10ge_open(struct net_device *dev)
1589{
1590 struct myri10ge_priv *mgp;
1591 struct myri10ge_cmd cmd;
1592 int status, big_pow2;
1593
1594 mgp = netdev_priv(dev);
1595
1596 if (mgp->running != MYRI10GE_ETH_STOPPED)
1597 return -EBUSY;
1598
1599 mgp->running = MYRI10GE_ETH_STARTING;
1600 status = myri10ge_reset(mgp);
1601 if (status != 0) {
1602 printk(KERN_ERR "myri10ge: %s: failed reset\n", dev->name);
1603 mgp->running = MYRI10GE_ETH_STOPPED;
1604 return -ENXIO;
1605 }
1606
1607 /* decide what small buffer size to use. For good TCP rx
1608 * performance, it is important to not receive 1514 byte
1609 * frames into jumbo buffers, as it confuses the socket buffer
1610 * accounting code, leading to drops and erratic performance.
1611 */
1612
1613 if (dev->mtu <= ETH_DATA_LEN)
1614 mgp->small_bytes = 128; /* enough for a TCP header */
1615 else
1616 mgp->small_bytes = ETH_FRAME_LEN; /* enough for an ETH_DATA_LEN frame */
1617
1618 /* Override the small buffer size? */
1619 if (myri10ge_small_bytes > 0)
1620 mgp->small_bytes = myri10ge_small_bytes;
1621
1622 /* If the user sets an obscenely small MTU, adjust the small
1623 * bytes down to nearly nothing */
1624 if (mgp->small_bytes >= (dev->mtu + ETH_HLEN))
1625 mgp->small_bytes = 64;
1626
1627 /* get the lanai pointers to the send and receive rings */
1628
1629 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0);
1630 mgp->tx.lanai =
1631 (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0);
1632
1633 status |=
1634 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0);
1635 mgp->rx_small.lanai =
1636 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
1637
1638 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0);
1639 mgp->rx_big.lanai =
1640 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
1641
1642 if (status != 0) {
1643 printk(KERN_ERR
1644 "myri10ge: %s: failed to get ring sizes or locations\n",
1645 dev->name);
1646 mgp->running = MYRI10GE_ETH_STOPPED;
1647 return -ENXIO;
1648 }
1649
1650 if (mgp->mtrr >= 0) {
1651 mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + 0x200000;
1652 mgp->rx_small.wc_fifo = (u8 __iomem *) mgp->sram + 0x300000;
1653 mgp->rx_big.wc_fifo = (u8 __iomem *) mgp->sram + 0x340000;
1654 } else {
1655 mgp->tx.wc_fifo = NULL;
1656 mgp->rx_small.wc_fifo = NULL;
1657 mgp->rx_big.wc_fifo = NULL;
1658 }
1659
1660 status = myri10ge_allocate_rings(dev);
1661 if (status != 0)
1662 goto abort_with_nothing;
1663
1664 /* Firmware needs the big buff size as a power of 2. Lie and
1665 * tell him the buffer is larger, because we only use 1
1666 * buffer/pkt, and the mtu will prevent overruns.
1667 */
1668 big_pow2 = dev->mtu + ETH_HLEN + MXGEFW_PAD;
1669 while ((big_pow2 & (big_pow2 - 1)) != 0)
1670 big_pow2++;
1671
1672 /* now give firmware buffers sizes, and MTU */
1673 cmd.data0 = dev->mtu + ETH_HLEN + VLAN_HLEN;
1674 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_MTU, &cmd, 0);
1675 cmd.data0 = mgp->small_bytes;
1676 status |=
1677 myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_SMALL_BUFFER_SIZE, &cmd, 0);
1678 cmd.data0 = big_pow2;
1679 status |=
1680 myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_BIG_BUFFER_SIZE, &cmd, 0);
1681 if (status) {
1682 printk(KERN_ERR "myri10ge: %s: Couldn't set buffer sizes\n",
1683 dev->name);
1684 goto abort_with_rings;
1685 }
1686
1687 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->fw_stats_bus);
1688 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->fw_stats_bus);
1689 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA, &cmd, 0);
1690 if (status) {
1691 printk(KERN_ERR "myri10ge: %s: Couldn't set stats DMA\n",
1692 dev->name);
1693 goto abort_with_rings;
1694 }
1695
1696 mgp->link_state = -1;
1697 mgp->rdma_tags_available = 15;
1698
1699 netif_poll_enable(mgp->dev); /* must happen prior to any irq */
1700
1701 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0);
1702 if (status) {
1703 printk(KERN_ERR "myri10ge: %s: Couldn't bring up link\n",
1704 dev->name);
1705 goto abort_with_rings;
1706 }
1707
1708 mgp->wake_queue = 0;
1709 mgp->stop_queue = 0;
1710 mgp->running = MYRI10GE_ETH_RUNNING;
1711 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ;
1712 add_timer(&mgp->watchdog_timer);
1713 netif_wake_queue(dev);
1714 return 0;
1715
1716abort_with_rings:
1717 myri10ge_free_rings(dev);
1718
1719abort_with_nothing:
1720 mgp->running = MYRI10GE_ETH_STOPPED;
1721 return -ENOMEM;
1722}
1723
1724static int myri10ge_close(struct net_device *dev)
1725{
1726 struct myri10ge_priv *mgp;
1727 struct myri10ge_cmd cmd;
1728 int status, old_down_cnt;
1729
1730 mgp = netdev_priv(dev);
1731
1732 if (mgp->running != MYRI10GE_ETH_RUNNING)
1733 return 0;
1734
1735 if (mgp->tx.req_bytes == NULL)
1736 return 0;
1737
1738 del_timer_sync(&mgp->watchdog_timer);
1739 mgp->running = MYRI10GE_ETH_STOPPING;
1740 netif_poll_disable(mgp->dev);
1741 netif_carrier_off(dev);
1742 netif_stop_queue(dev);
1743 old_down_cnt = mgp->down_cnt;
1744 mb();
1745 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_DOWN, &cmd, 0);
1746 if (status)
1747 printk(KERN_ERR "myri10ge: %s: Couldn't bring down link\n",
1748 dev->name);
1749
1750 wait_event_timeout(mgp->down_wq, old_down_cnt != mgp->down_cnt, HZ);
1751 if (old_down_cnt == mgp->down_cnt)
1752 printk(KERN_ERR "myri10ge: %s never got down irq\n", dev->name);
1753
1754 netif_tx_disable(dev);
1755
1756 myri10ge_free_rings(dev);
1757
1758 mgp->running = MYRI10GE_ETH_STOPPED;
1759 return 0;
1760}
1761
1762/* copy an array of struct mcp_kreq_ether_send's to the mcp. Copy
1763 * backwards one at a time and handle ring wraps */
1764
1765static inline void
1766myri10ge_submit_req_backwards(struct myri10ge_tx_buf *tx,
1767 struct mcp_kreq_ether_send *src, int cnt)
1768{
1769 int idx, starting_slot;
1770 starting_slot = tx->req;
1771 while (cnt > 1) {
1772 cnt--;
1773 idx = (starting_slot + cnt) & tx->mask;
1774 myri10ge_pio_copy(&tx->lanai[idx], &src[cnt], sizeof(*src));
1775 mb();
1776 }
1777}
1778
1779/*
1780 * copy an array of struct mcp_kreq_ether_send's to the mcp. Copy
1781 * at most 32 bytes at a time, so as to avoid involving the software
1782 * pio handler in the nic. We re-write the first segment's flags
1783 * to mark them valid only after writing the entire chain.
1784 */
1785
1786static inline void
1787myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
1788 int cnt)
1789{
1790 int idx, i;
1791 struct mcp_kreq_ether_send __iomem *dstp, *dst;
1792 struct mcp_kreq_ether_send *srcp;
1793 u8 last_flags;
1794
1795 idx = tx->req & tx->mask;
1796
1797 last_flags = src->flags;
1798 src->flags = 0;
1799 mb();
1800 dst = dstp = &tx->lanai[idx];
1801 srcp = src;
1802
1803 if ((idx + cnt) < tx->mask) {
1804 for (i = 0; i < (cnt - 1); i += 2) {
1805 myri10ge_pio_copy(dstp, srcp, 2 * sizeof(*src));
1806 mb(); /* force write every 32 bytes */
1807 srcp += 2;
1808 dstp += 2;
1809 }
1810 } else {
1811 /* submit all but the first request, and ensure
1812 * that it is submitted below */
1813 myri10ge_submit_req_backwards(tx, src, cnt);
1814 i = 0;
1815 }
1816 if (i < cnt) {
1817 /* submit the first request */
1818 myri10ge_pio_copy(dstp, srcp, sizeof(*src));
1819 mb(); /* barrier before setting valid flag */
1820 }
1821
1822 /* re-write the last 32-bits with the valid flags */
1823 src->flags = last_flags;
1824 __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3);
1825 tx->req += cnt;
1826 mb();
1827}
1828
1829static inline void
1830myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
1831 struct mcp_kreq_ether_send *src, int cnt)
1832{
1833 tx->req += cnt;
1834 mb();
1835 while (cnt >= 4) {
1836 myri10ge_pio_copy(tx->wc_fifo, src, 64);
1837 mb();
1838 src += 4;
1839 cnt -= 4;
1840 }
1841 if (cnt > 0) {
1842 /* pad it to 64 bytes. The src is 64 bytes bigger than it
1843 * needs to be so that we don't overrun it */
1844 myri10ge_pio_copy(tx->wc_fifo + (cnt << 18), src, 64);
1845 mb();
1846 }
1847}
1848
1849/*
1850 * Transmit a packet. We need to split the packet so that a single
1851 * segment does not cross myri10ge->tx.boundary, so this makes segment
1852 * counting tricky. So rather than try to count segments up front, we
1853 * just give up if there are too few segments to hold a reasonably
1854 * fragmented packet currently available. If we run
1855 * out of segments while preparing a packet for DMA, we just linearize
1856 * it and try again.
1857 */
1858
1859static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
1860{
1861 struct myri10ge_priv *mgp = netdev_priv(dev);
1862 struct mcp_kreq_ether_send *req;
1863 struct myri10ge_tx_buf *tx = &mgp->tx;
1864 struct skb_frag_struct *frag;
1865 dma_addr_t bus;
1866 u32 low, high_swapped;
1867 unsigned int len;
1868 int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
1869 u16 pseudo_hdr_offset, cksum_offset;
1870 int cum_len, seglen, boundary, rdma_count;
1871 u8 flags, odd_flag;
1872
1873again:
1874 req = tx->req_list;
1875 avail = tx->mask - 1 - (tx->req - tx->done);
1876
1877 mss = 0;
1878 max_segments = MXGEFW_MAX_SEND_DESC;
1879
1880#ifdef NETIF_F_TSO
1881 if (skb->len > (dev->mtu + ETH_HLEN)) {
1882 mss = skb_shinfo(skb)->tso_size;
1883 if (mss != 0)
1884 max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
1885 }
1886#endif /*NETIF_F_TSO */
1887
1888 if ((unlikely(avail < max_segments))) {
1889 /* we are out of transmit resources */
1890 mgp->stop_queue++;
1891 netif_stop_queue(dev);
1892 return 1;
1893 }
1894
1895 /* Setup checksum offloading, if needed */
1896 cksum_offset = 0;
1897 pseudo_hdr_offset = 0;
1898 odd_flag = 0;
1899 flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST);
1900 if (likely(skb->ip_summed == CHECKSUM_HW)) {
1901 cksum_offset = (skb->h.raw - skb->data);
1902 pseudo_hdr_offset = (skb->h.raw + skb->csum) - skb->data;
1903 /* If the headers are excessively large, then we must
1904 * fall back to a software checksum */
1905 if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) {
1906 if (skb_checksum_help(skb, 0))
1907 goto drop;
1908 cksum_offset = 0;
1909 pseudo_hdr_offset = 0;
1910 } else {
1911 pseudo_hdr_offset = htons(pseudo_hdr_offset);
1912 odd_flag = MXGEFW_FLAGS_ALIGN_ODD;
1913 flags |= MXGEFW_FLAGS_CKSUM;
1914 }
1915 }
1916
1917 cum_len = 0;
1918
1919#ifdef NETIF_F_TSO
1920 if (mss) { /* TSO */
1921 /* this removes any CKSUM flag from before */
1922 flags = (MXGEFW_FLAGS_TSO_HDR | MXGEFW_FLAGS_FIRST);
1923
1924 /* negative cum_len signifies to the
1925 * send loop that we are still in the
1926 * header portion of the TSO packet.
1927 * TSO header must be at most 134 bytes long */
1928 cum_len = -((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1929
1930 /* for TSO, pseudo_hdr_offset holds mss.
1931 * The firmware figures out where to put
1932 * the checksum by parsing the header. */
1933 pseudo_hdr_offset = htons(mss);
1934 } else
1935#endif /*NETIF_F_TSO */
1936 /* Mark small packets, and pad out tiny packets */
1937 if (skb->len <= MXGEFW_SEND_SMALL_SIZE) {
1938 flags |= MXGEFW_FLAGS_SMALL;
1939
1940 /* pad frames to at least ETH_ZLEN bytes */
1941 if (unlikely(skb->len < ETH_ZLEN)) {
1942 skb = skb_padto(skb, ETH_ZLEN);
1943 if (skb == NULL) {
1944 /* The packet is gone, so we must
1945 * return 0 */
1946 mgp->stats.tx_dropped += 1;
1947 return 0;
1948 }
1949 /* adjust the len to account for the zero pad
1950 * so that the nic can know how long it is */
1951 skb->len = ETH_ZLEN;
1952 }
1953 }
1954
1955 /* map the skb for DMA */
1956 len = skb->len - skb->data_len;
1957 idx = tx->req & tx->mask;
1958 tx->info[idx].skb = skb;
1959 bus = pci_map_single(mgp->pdev, skb->data, len, PCI_DMA_TODEVICE);
1960 pci_unmap_addr_set(&tx->info[idx], bus, bus);
1961 pci_unmap_len_set(&tx->info[idx], len, len);
1962
1963 frag_cnt = skb_shinfo(skb)->nr_frags;
1964 frag_idx = 0;
1965 count = 0;
1966 rdma_count = 0;
1967
1968 /* "rdma_count" is the number of RDMAs belonging to the
1969 * current packet BEFORE the current send request. For
1970 * non-TSO packets, this is equal to "count".
1971 * For TSO packets, rdma_count needs to be reset
1972 * to 0 after a segment cut.
1973 *
1974 * The rdma_count field of the send request is
1975 * the number of RDMAs of the packet starting at
1976 * that request. For TSO send requests with one ore more cuts
1977 * in the middle, this is the number of RDMAs starting
1978 * after the last cut in the request. All previous
1979 * segments before the last cut implicitly have 1 RDMA.
1980 *
1981 * Since the number of RDMAs is not known beforehand,
1982 * it must be filled-in retroactively - after each
1983 * segmentation cut or at the end of the entire packet.
1984 */
1985
1986 while (1) {
1987 /* Break the SKB or Fragment up into pieces which
1988 * do not cross mgp->tx.boundary */
1989 low = MYRI10GE_LOWPART_TO_U32(bus);
1990 high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus));
1991 while (len) {
1992 u8 flags_next;
1993 int cum_len_next;
1994
1995 if (unlikely(count == max_segments))
1996 goto abort_linearize;
1997
1998 boundary = (low + tx->boundary) & ~(tx->boundary - 1);
1999 seglen = boundary - low;
2000 if (seglen > len)
2001 seglen = len;
2002 flags_next = flags & ~MXGEFW_FLAGS_FIRST;
2003 cum_len_next = cum_len + seglen;
2004#ifdef NETIF_F_TSO
2005 if (mss) { /* TSO */
2006 (req - rdma_count)->rdma_count = rdma_count + 1;
2007
2008 if (likely(cum_len >= 0)) { /* payload */
2009 int next_is_first, chop;
2010
2011 chop = (cum_len_next > mss);
2012 cum_len_next = cum_len_next % mss;
2013 next_is_first = (cum_len_next == 0);
2014 flags |= chop * MXGEFW_FLAGS_TSO_CHOP;
2015 flags_next |= next_is_first *
2016 MXGEFW_FLAGS_FIRST;
2017 rdma_count |= -(chop | next_is_first);
2018 rdma_count += chop & !next_is_first;
2019 } else if (likely(cum_len_next >= 0)) { /* header ends */
2020 int small;
2021
2022 rdma_count = -1;
2023 cum_len_next = 0;
2024 seglen = -cum_len;
2025 small = (mss <= MXGEFW_SEND_SMALL_SIZE);
2026 flags_next = MXGEFW_FLAGS_TSO_PLD |
2027 MXGEFW_FLAGS_FIRST |
2028 (small * MXGEFW_FLAGS_SMALL);
2029 }
2030 }
2031#endif /* NETIF_F_TSO */
2032 req->addr_high = high_swapped;
2033 req->addr_low = htonl(low);
2034 req->pseudo_hdr_offset = pseudo_hdr_offset;
2035 req->pad = 0; /* complete solid 16-byte block; does this matter? */
2036 req->rdma_count = 1;
2037 req->length = htons(seglen);
2038 req->cksum_offset = cksum_offset;
2039 req->flags = flags | ((cum_len & 1) * odd_flag);
2040
2041 low += seglen;
2042 len -= seglen;
2043 cum_len = cum_len_next;
2044 flags = flags_next;
2045 req++;
2046 count++;
2047 rdma_count++;
2048 if (unlikely(cksum_offset > seglen))
2049 cksum_offset -= seglen;
2050 else
2051 cksum_offset = 0;
2052 }
2053 if (frag_idx == frag_cnt)
2054 break;
2055
2056 /* map next fragment for DMA */
2057 idx = (count + tx->req) & tx->mask;
2058 frag = &skb_shinfo(skb)->frags[frag_idx];
2059 frag_idx++;
2060 len = frag->size;
2061 bus = pci_map_page(mgp->pdev, frag->page, frag->page_offset,
2062 len, PCI_DMA_TODEVICE);
2063 pci_unmap_addr_set(&tx->info[idx], bus, bus);
2064 pci_unmap_len_set(&tx->info[idx], len, len);
2065 }
2066
2067 (req - rdma_count)->rdma_count = rdma_count;
2068#ifdef NETIF_F_TSO
2069 if (mss)
2070 do {
2071 req--;
2072 req->flags |= MXGEFW_FLAGS_TSO_LAST;
2073 } while (!(req->flags & (MXGEFW_FLAGS_TSO_CHOP |
2074 MXGEFW_FLAGS_FIRST)));
2075#endif
2076 idx = ((count - 1) + tx->req) & tx->mask;
2077 tx->info[idx].last = 1;
2078 if (tx->wc_fifo == NULL)
2079 myri10ge_submit_req(tx, tx->req_list, count);
2080 else
2081 myri10ge_submit_req_wc(tx, tx->req_list, count);
2082 tx->pkt_start++;
2083 if ((avail - count) < MXGEFW_MAX_SEND_DESC) {
2084 mgp->stop_queue++;
2085 netif_stop_queue(dev);
2086 }
2087 dev->trans_start = jiffies;
2088 return 0;
2089
2090abort_linearize:
2091 /* Free any DMA resources we've alloced and clear out the skb
2092 * slot so as to not trip up assertions, and to avoid a
2093 * double-free if linearizing fails */
2094
2095 last_idx = (idx + 1) & tx->mask;
2096 idx = tx->req & tx->mask;
2097 tx->info[idx].skb = NULL;
2098 do {
2099 len = pci_unmap_len(&tx->info[idx], len);
2100 if (len) {
2101 if (tx->info[idx].skb != NULL)
2102 pci_unmap_single(mgp->pdev,
2103 pci_unmap_addr(&tx->info[idx],
2104 bus), len,
2105 PCI_DMA_TODEVICE);
2106 else
2107 pci_unmap_page(mgp->pdev,
2108 pci_unmap_addr(&tx->info[idx],
2109 bus), len,
2110 PCI_DMA_TODEVICE);
2111 pci_unmap_len_set(&tx->info[idx], len, 0);
2112 tx->info[idx].skb = NULL;
2113 }
2114 idx = (idx + 1) & tx->mask;
2115 } while (idx != last_idx);
2116 if (skb_shinfo(skb)->tso_size) {
2117 printk(KERN_ERR
2118 "myri10ge: %s: TSO but wanted to linearize?!?!?\n",
2119 mgp->dev->name);
2120 goto drop;
2121 }
2122
2123 if (skb_linearize(skb, GFP_ATOMIC))
2124 goto drop;
2125
2126 mgp->tx_linearized++;
2127 goto again;
2128
2129drop:
2130 dev_kfree_skb_any(skb);
2131 mgp->stats.tx_dropped += 1;
2132 return 0;
2133
2134}
2135
2136static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
2137{
2138 struct myri10ge_priv *mgp = netdev_priv(dev);
2139 return &mgp->stats;
2140}
2141
2142static void myri10ge_set_multicast_list(struct net_device *dev)
2143{
2144 /* can be called from atomic contexts,
2145 * pass 1 to force atomicity in myri10ge_send_cmd() */
2146 myri10ge_change_promisc(netdev_priv(dev), dev->flags & IFF_PROMISC, 1);
2147}
2148
2149static int myri10ge_set_mac_address(struct net_device *dev, void *addr)
2150{
2151 struct sockaddr *sa = addr;
2152 struct myri10ge_priv *mgp = netdev_priv(dev);
2153 int status;
2154
2155 if (!is_valid_ether_addr(sa->sa_data))
2156 return -EADDRNOTAVAIL;
2157
2158 status = myri10ge_update_mac_address(mgp, sa->sa_data);
2159 if (status != 0) {
2160 printk(KERN_ERR
2161 "myri10ge: %s: changing mac address failed with %d\n",
2162 dev->name, status);
2163 return status;
2164 }
2165
2166 /* change the dev structure */
2167 memcpy(dev->dev_addr, sa->sa_data, 6);
2168 return 0;
2169}
2170
2171static int myri10ge_change_mtu(struct net_device *dev, int new_mtu)
2172{
2173 struct myri10ge_priv *mgp = netdev_priv(dev);
2174 int error = 0;
2175
2176 if ((new_mtu < 68) || (ETH_HLEN + new_mtu > MYRI10GE_MAX_ETHER_MTU)) {
2177 printk(KERN_ERR "myri10ge: %s: new mtu (%d) is not valid\n",
2178 dev->name, new_mtu);
2179 return -EINVAL;
2180 }
2181 printk(KERN_INFO "%s: changing mtu from %d to %d\n",
2182 dev->name, dev->mtu, new_mtu);
2183 if (mgp->running) {
2184 /* if we change the mtu on an active device, we must
2185 * reset the device so the firmware sees the change */
2186 myri10ge_close(dev);
2187 dev->mtu = new_mtu;
2188 myri10ge_open(dev);
2189 } else
2190 dev->mtu = new_mtu;
2191
2192 return error;
2193}
2194
2195/*
2196 * Enable ECRC to align PCI-E Completion packets on an 8-byte boundary.
2197 * Only do it if the bridge is a root port since we don't want to disturb
2198 * any other device, except if forced with myri10ge_ecrc_enable > 1.
2199 */
2200
2201#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_PCIE 0x005d
2202
2203static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2204{
2205 struct pci_dev *bridge = mgp->pdev->bus->self;
2206 struct device *dev = &mgp->pdev->dev;
2207 unsigned cap;
2208 unsigned err_cap;
2209 u16 val;
2210 u8 ext_type;
2211 int ret;
2212
2213 if (!myri10ge_ecrc_enable || !bridge)
2214 return;
2215
2216 /* check that the bridge is a root port */
2217 cap = pci_find_capability(bridge, PCI_CAP_ID_EXP);
2218 pci_read_config_word(bridge, cap + PCI_CAP_FLAGS, &val);
2219 ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
2220 if (ext_type != PCI_EXP_TYPE_ROOT_PORT) {
2221 if (myri10ge_ecrc_enable > 1) {
2222 struct pci_dev *old_bridge = bridge;
2223
2224 /* Walk the hierarchy up to the root port
2225 * where ECRC has to be enabled */
2226 do {
2227 bridge = bridge->bus->self;
2228 if (!bridge) {
2229 dev_err(dev,
2230 "Failed to find root port"
2231 " to force ECRC\n");
2232 return;
2233 }
2234 cap =
2235 pci_find_capability(bridge, PCI_CAP_ID_EXP);
2236 pci_read_config_word(bridge,
2237 cap + PCI_CAP_FLAGS, &val);
2238 ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
2239 } while (ext_type != PCI_EXP_TYPE_ROOT_PORT);
2240
2241 dev_info(dev,
2242 "Forcing ECRC on non-root port %s"
2243 " (enabling on root port %s)\n",
2244 pci_name(old_bridge), pci_name(bridge));
2245 } else {
2246 dev_err(dev,
2247 "Not enabling ECRC on non-root port %s\n",
2248 pci_name(bridge));
2249 return;
2250 }
2251 }
2252
2253 cap = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ERR);
2254 /* nvidia ext cap is not always linked in ext cap chain */
2255 if (!cap
2256 && bridge->vendor == PCI_VENDOR_ID_NVIDIA
2257 && bridge->device == PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_PCIE)
2258 cap = 0x160;
2259
2260 if (!cap)
2261 return;
2262
2263 ret = pci_read_config_dword(bridge, cap + PCI_ERR_CAP, &err_cap);
2264 if (ret) {
2265 dev_err(dev, "failed reading ext-conf-space of %s\n",
2266 pci_name(bridge));
2267 dev_err(dev, "\t pci=nommconf in use? "
2268 "or buggy/incomplete/absent ACPI MCFG attr?\n");
2269 return;
2270 }
2271 if (!(err_cap & PCI_ERR_CAP_ECRC_GENC))
2272 return;
2273
2274 err_cap |= PCI_ERR_CAP_ECRC_GENE;
2275 pci_write_config_dword(bridge, cap + PCI_ERR_CAP, err_cap);
2276 dev_info(dev, "Enabled ECRC on upstream bridge %s\n", pci_name(bridge));
2277 mgp->tx.boundary = 4096;
2278 mgp->fw_name = myri10ge_fw_aligned;
2279}
2280
2281/*
2282 * The Lanai Z8E PCI-E interface achieves higher Read-DMA throughput
2283 * when the PCI-E Completion packets are aligned on an 8-byte
2284 * boundary. Some PCI-E chip sets always align Completion packets; on
2285 * the ones that do not, the alignment can be enforced by enabling
2286 * ECRC generation (if supported).
2287 *
2288 * When PCI-E Completion packets are not aligned, it is actually more
2289 * efficient to limit Read-DMA transactions to 2KB, rather than 4KB.
2290 *
2291 * If the driver can neither enable ECRC nor verify that it has
2292 * already been enabled, then it must use a firmware image which works
2293 * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it
2294 * should also ensure that it never gives the device a Read-DMA which is
2295 * larger than 2KB by setting the tx.boundary to 2KB. If ECRC is
2296 * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat)
2297 * firmware image, and set tx.boundary to 4KB.
2298 */
2299
2300#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132
2301
2302static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
2303{
2304 struct pci_dev *bridge = mgp->pdev->bus->self;
2305
2306 mgp->tx.boundary = 2048;
2307 mgp->fw_name = myri10ge_fw_unaligned;
2308
2309 if (myri10ge_force_firmware == 0) {
2310 myri10ge_enable_ecrc(mgp);
2311
2312 /* Check to see if the upstream bridge is known to
2313 * provide aligned completions */
2314 if (bridge
2315 /* ServerWorks HT2000/HT1000 */
2316 && bridge->vendor == PCI_VENDOR_ID_SERVERWORKS
2317 && bridge->device ==
2318 PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE) {
2319 dev_info(&mgp->pdev->dev,
2320 "Assuming aligned completions (0x%x:0x%x)\n",
2321 bridge->vendor, bridge->device);
2322 mgp->tx.boundary = 4096;
2323 mgp->fw_name = myri10ge_fw_aligned;
2324 }
2325 } else {
2326 if (myri10ge_force_firmware == 1) {
2327 dev_info(&mgp->pdev->dev,
2328 "Assuming aligned completions (forced)\n");
2329 mgp->tx.boundary = 4096;
2330 mgp->fw_name = myri10ge_fw_aligned;
2331 } else {
2332 dev_info(&mgp->pdev->dev,
2333 "Assuming unaligned completions (forced)\n");
2334 mgp->tx.boundary = 2048;
2335 mgp->fw_name = myri10ge_fw_unaligned;
2336 }
2337 }
2338 if (myri10ge_fw_name != NULL) {
2339 dev_info(&mgp->pdev->dev, "overriding firmware to %s\n",
2340 myri10ge_fw_name);
2341 mgp->fw_name = myri10ge_fw_name;
2342 }
2343}
2344
2345static void myri10ge_save_state(struct myri10ge_priv *mgp)
2346{
2347 struct pci_dev *pdev = mgp->pdev;
2348 int cap;
2349
2350 pci_save_state(pdev);
2351 /* now save PCIe and MSI state that Linux will not
2352 * save for us */
2353 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
2354 pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL, &mgp->devctl);
2355 cap = pci_find_capability(pdev, PCI_CAP_ID_MSI);
2356 pci_read_config_word(pdev, cap + PCI_MSI_FLAGS, &mgp->msi_flags);
2357}
2358
2359static void myri10ge_restore_state(struct myri10ge_priv *mgp)
2360{
2361 struct pci_dev *pdev = mgp->pdev;
2362 int cap;
2363
2364 /* restore PCIe and MSI state that linux will not */
2365 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
2366 pci_write_config_dword(pdev, cap + PCI_CAP_ID_EXP, mgp->devctl);
2367 cap = pci_find_capability(pdev, PCI_CAP_ID_MSI);
2368 pci_write_config_word(pdev, cap + PCI_MSI_FLAGS, mgp->msi_flags);
2369
2370 pci_restore_state(pdev);
2371}
2372
2373#ifdef CONFIG_PM
2374
2375static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
2376{
2377 struct myri10ge_priv *mgp;
2378 struct net_device *netdev;
2379
2380 mgp = pci_get_drvdata(pdev);
2381 if (mgp == NULL)
2382 return -EINVAL;
2383 netdev = mgp->dev;
2384
2385 netif_device_detach(netdev);
2386 if (netif_running(netdev)) {
2387 printk(KERN_INFO "myri10ge: closing %s\n", netdev->name);
2388 rtnl_lock();
2389 myri10ge_close(netdev);
2390 rtnl_unlock();
2391 }
2392 myri10ge_dummy_rdma(mgp, 0);
2393 free_irq(pdev->irq, mgp);
2394 myri10ge_save_state(mgp);
2395 pci_disable_device(pdev);
2396 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2397 return 0;
2398}
2399
2400static int myri10ge_resume(struct pci_dev *pdev)
2401{
2402 struct myri10ge_priv *mgp;
2403 struct net_device *netdev;
2404 int status;
2405 u16 vendor;
2406
2407 mgp = pci_get_drvdata(pdev);
2408 if (mgp == NULL)
2409 return -EINVAL;
2410 netdev = mgp->dev;
2411 pci_set_power_state(pdev, 0); /* zeros conf space as a side effect */
2412 msleep(5); /* give card time to respond */
2413 pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor);
2414 if (vendor == 0xffff) {
2415 printk(KERN_ERR "myri10ge: %s: device disappeared!\n",
2416 mgp->dev->name);
2417 return -EIO;
2418 }
2419 myri10ge_restore_state(mgp);
2420 pci_enable_device(pdev);
2421 pci_set_master(pdev);
2422
2423 status = request_irq(pdev->irq, myri10ge_intr, SA_SHIRQ,
2424 netdev->name, mgp);
2425 if (status != 0) {
2426 dev_err(&pdev->dev, "failed to allocate IRQ\n");
2427 goto abort_with_msi;
2428 }
2429
2430 myri10ge_reset(mgp);
2431 myri10ge_dummy_rdma(mgp, mgp->tx.boundary != 4096);
2432
2433 /* Save configuration space to be restored if the
2434 * nic resets due to a parity error */
2435 myri10ge_save_state(mgp);
2436
2437 if (netif_running(netdev)) {
2438 rtnl_lock();
2439 myri10ge_open(netdev);
2440 rtnl_unlock();
2441 }
2442 netif_device_attach(netdev);
2443
2444 return 0;
2445
2446abort_with_msi:
2447 return -EIO;
2448
2449}
2450
2451#endif /* CONFIG_PM */
2452
2453static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
2454{
2455 struct pci_dev *pdev = mgp->pdev;
2456 int vs = mgp->vendor_specific_offset;
2457 u32 reboot;
2458
2459 /*enter read32 mode */
2460 pci_write_config_byte(pdev, vs + 0x10, 0x3);
2461
2462 /*read REBOOT_STATUS (0xfffffff0) */
2463 pci_write_config_dword(pdev, vs + 0x18, 0xfffffff0);
2464 pci_read_config_dword(pdev, vs + 0x14, &reboot);
2465 return reboot;
2466}
2467
2468/*
2469 * This watchdog is used to check whether the board has suffered
2470 * from a parity error and needs to be recovered.
2471 */
2472static void myri10ge_watchdog(void *arg)
2473{
2474 struct myri10ge_priv *mgp = arg;
2475 u32 reboot;
2476 int status;
2477 u16 cmd, vendor;
2478
2479 mgp->watchdog_resets++;
2480 pci_read_config_word(mgp->pdev, PCI_COMMAND, &cmd);
2481 if ((cmd & PCI_COMMAND_MASTER) == 0) {
2482 /* Bus master DMA disabled? Check to see
2483 * if the card rebooted due to a parity error
2484 * For now, just report it */
2485 reboot = myri10ge_read_reboot(mgp);
2486 printk(KERN_ERR
2487 "myri10ge: %s: NIC rebooted (0x%x), resetting\n",
2488 mgp->dev->name, reboot);
2489 /*
2490 * A rebooted nic will come back with config space as
2491 * it was after power was applied to PCIe bus.
2492 * Attempt to restore config space which was saved
2493 * when the driver was loaded, or the last time the
2494 * nic was resumed from power saving mode.
2495 */
2496 myri10ge_restore_state(mgp);
2497 } else {
2498 /* if we get back -1's from our slot, perhaps somebody
2499 * powered off our card. Don't try to reset it in
2500 * this case */
2501 if (cmd == 0xffff) {
2502 pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor);
2503 if (vendor == 0xffff) {
2504 printk(KERN_ERR
2505 "myri10ge: %s: device disappeared!\n",
2506 mgp->dev->name);
2507 return;
2508 }
2509 }
2510 /* Perhaps it is a software error. Try to reset */
2511
2512 printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n",
2513 mgp->dev->name);
2514 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
2515 mgp->dev->name, mgp->tx.req, mgp->tx.done,
2516 mgp->tx.pkt_start, mgp->tx.pkt_done,
2517 (int)ntohl(mgp->fw_stats->send_done_count));
2518 msleep(2000);
2519 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
2520 mgp->dev->name, mgp->tx.req, mgp->tx.done,
2521 mgp->tx.pkt_start, mgp->tx.pkt_done,
2522 (int)ntohl(mgp->fw_stats->send_done_count));
2523 }
2524 rtnl_lock();
2525 myri10ge_close(mgp->dev);
2526 status = myri10ge_load_firmware(mgp);
2527 if (status != 0)
2528 printk(KERN_ERR "myri10ge: %s: failed to load firmware\n",
2529 mgp->dev->name);
2530 else
2531 myri10ge_open(mgp->dev);
2532 rtnl_unlock();
2533}
2534
2535/*
2536 * We use our own timer routine rather than relying upon
2537 * netdev->tx_timeout because we have a very large hardware transmit
2538 * queue. Due to the large queue, the netdev->tx_timeout function
2539 * cannot detect a NIC with a parity error in a timely fashion if the
2540 * NIC is lightly loaded.
2541 */
2542static void myri10ge_watchdog_timer(unsigned long arg)
2543{
2544 struct myri10ge_priv *mgp;
2545
2546 mgp = (struct myri10ge_priv *)arg;
2547 if (mgp->tx.req != mgp->tx.done &&
2548 mgp->tx.done == mgp->watchdog_tx_done)
2549 /* nic seems like it might be stuck.. */
2550 schedule_work(&mgp->watchdog_work);
2551 else
2552 /* rearm timer */
2553 mod_timer(&mgp->watchdog_timer,
2554 jiffies + myri10ge_watchdog_timeout * HZ);
2555
2556 mgp->watchdog_tx_done = mgp->tx.done;
2557}
2558
2559static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2560{
2561 struct net_device *netdev;
2562 struct myri10ge_priv *mgp;
2563 struct device *dev = &pdev->dev;
2564 size_t bytes;
2565 int i;
2566 int status = -ENXIO;
2567 int cap;
2568 int dac_enabled;
2569 u16 val;
2570
2571 netdev = alloc_etherdev(sizeof(*mgp));
2572 if (netdev == NULL) {
2573 dev_err(dev, "Could not allocate ethernet device\n");
2574 return -ENOMEM;
2575 }
2576
2577 mgp = netdev_priv(netdev);
2578 memset(mgp, 0, sizeof(*mgp));
2579 mgp->dev = netdev;
2580 mgp->pdev = pdev;
2581 mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
2582 mgp->pause = myri10ge_flow_control;
2583 mgp->intr_coal_delay = myri10ge_intr_coal_delay;
2584 init_waitqueue_head(&mgp->down_wq);
2585
2586 if (pci_enable_device(pdev)) {
2587 dev_err(&pdev->dev, "pci_enable_device call failed\n");
2588 status = -ENODEV;
2589 goto abort_with_netdev;
2590 }
2591 myri10ge_select_firmware(mgp);
2592
2593 /* Find the vendor-specific cap so we can check
2594 * the reboot register later on */
2595 mgp->vendor_specific_offset
2596 = pci_find_capability(pdev, PCI_CAP_ID_VNDR);
2597
2598 /* Set our max read request to 4KB */
2599 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
2600 if (cap < 64) {
2601 dev_err(&pdev->dev, "Bad PCI_CAP_ID_EXP location %d\n", cap);
2602 goto abort_with_netdev;
2603 }
2604 status = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &val);
2605 if (status != 0) {
2606 dev_err(&pdev->dev, "Error %d reading PCI_EXP_DEVCTL\n",
2607 status);
2608 goto abort_with_netdev;
2609 }
2610 val = (val & ~PCI_EXP_DEVCTL_READRQ) | (5 << 12);
2611 status = pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, val);
2612 if (status != 0) {
2613 dev_err(&pdev->dev, "Error %d writing PCI_EXP_DEVCTL\n",
2614 status);
2615 goto abort_with_netdev;
2616 }
2617
2618 pci_set_master(pdev);
2619 dac_enabled = 1;
2620 status = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
2621 if (status != 0) {
2622 dac_enabled = 0;
2623 dev_err(&pdev->dev,
2624 "64-bit pci address mask was refused, trying 32-bit");
2625 status = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
2626 }
2627 if (status != 0) {
2628 dev_err(&pdev->dev, "Error %d setting DMA mask\n", status);
2629 goto abort_with_netdev;
2630 }
2631 mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd),
2632 &mgp->cmd_bus, GFP_KERNEL);
2633 if (mgp->cmd == NULL)
2634 goto abort_with_netdev;
2635
2636 mgp->fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->fw_stats),
2637 &mgp->fw_stats_bus, GFP_KERNEL);
2638 if (mgp->fw_stats == NULL)
2639 goto abort_with_cmd;
2640
2641 mgp->board_span = pci_resource_len(pdev, 0);
2642 mgp->iomem_base = pci_resource_start(pdev, 0);
2643 mgp->mtrr = -1;
2644#ifdef CONFIG_MTRR
2645 mgp->mtrr = mtrr_add(mgp->iomem_base, mgp->board_span,
2646 MTRR_TYPE_WRCOMB, 1);
2647#endif
2648 /* Hack. need to get rid of these magic numbers */
2649 mgp->sram_size =
2650 2 * 1024 * 1024 - (2 * (48 * 1024) + (32 * 1024)) - 0x100;
2651 if (mgp->sram_size > mgp->board_span) {
2652 dev_err(&pdev->dev, "board span %ld bytes too small\n",
2653 mgp->board_span);
2654 goto abort_with_wc;
2655 }
2656 mgp->sram = ioremap(mgp->iomem_base, mgp->board_span);
2657 if (mgp->sram == NULL) {
2658 dev_err(&pdev->dev, "ioremap failed for %ld bytes at 0x%lx\n",
2659 mgp->board_span, mgp->iomem_base);
2660 status = -ENXIO;
2661 goto abort_with_wc;
2662 }
2663 memcpy_fromio(mgp->eeprom_strings,
2664 mgp->sram + mgp->sram_size - MYRI10GE_EEPROM_STRINGS_SIZE,
2665 MYRI10GE_EEPROM_STRINGS_SIZE);
2666 memset(mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE - 2, 0, 2);
2667 status = myri10ge_read_mac_addr(mgp);
2668 if (status)
2669 goto abort_with_ioremap;
2670
2671 for (i = 0; i < ETH_ALEN; i++)
2672 netdev->dev_addr[i] = mgp->mac_addr[i];
2673
2674 /* allocate rx done ring */
2675 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
2676 mgp->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes,
2677 &mgp->rx_done.bus, GFP_KERNEL);
2678 if (mgp->rx_done.entry == NULL)
2679 goto abort_with_ioremap;
2680 memset(mgp->rx_done.entry, 0, bytes);
2681
2682 status = myri10ge_load_firmware(mgp);
2683 if (status != 0) {
2684 dev_err(&pdev->dev, "failed to load firmware\n");
2685 goto abort_with_rx_done;
2686 }
2687
2688 status = myri10ge_reset(mgp);
2689 if (status != 0) {
2690 dev_err(&pdev->dev, "failed reset\n");
2691 goto abort_with_firmware;
2692 }
2693
2694 if (myri10ge_msi) {
2695 status = pci_enable_msi(pdev);
2696 if (status != 0)
2697 dev_err(&pdev->dev,
2698 "Error %d setting up MSI; falling back to xPIC\n",
2699 status);
2700 else
2701 mgp->msi_enabled = 1;
2702 }
2703
2704 status = request_irq(pdev->irq, myri10ge_intr, SA_SHIRQ,
2705 netdev->name, mgp);
2706 if (status != 0) {
2707 dev_err(&pdev->dev, "failed to allocate IRQ\n");
2708 goto abort_with_firmware;
2709 }
2710
2711 pci_set_drvdata(pdev, mgp);
2712 if ((myri10ge_initial_mtu + ETH_HLEN) > MYRI10GE_MAX_ETHER_MTU)
2713 myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
2714 if ((myri10ge_initial_mtu + ETH_HLEN) < 68)
2715 myri10ge_initial_mtu = 68;
2716 netdev->mtu = myri10ge_initial_mtu;
2717 netdev->open = myri10ge_open;
2718 netdev->stop = myri10ge_close;
2719 netdev->hard_start_xmit = myri10ge_xmit;
2720 netdev->get_stats = myri10ge_get_stats;
2721 netdev->base_addr = mgp->iomem_base;
2722 netdev->irq = pdev->irq;
2723 netdev->change_mtu = myri10ge_change_mtu;
2724 netdev->set_multicast_list = myri10ge_set_multicast_list;
2725 netdev->set_mac_address = myri10ge_set_mac_address;
2726 netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
2727 if (dac_enabled)
2728 netdev->features |= NETIF_F_HIGHDMA;
2729 netdev->poll = myri10ge_poll;
2730 netdev->weight = myri10ge_napi_weight;
2731
2732 /* Save configuration space to be restored if the
2733 * nic resets due to a parity error */
2734 myri10ge_save_state(mgp);
2735 /* Restore state immediately since pci_save_msi_state disables MSI */
2736 myri10ge_restore_state(mgp);
2737
2738 /* Setup the watchdog timer */
2739 setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
2740 (unsigned long)mgp);
2741
2742 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
2743 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog, mgp);
2744 status = register_netdev(netdev);
2745 if (status != 0) {
2746 dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
2747 goto abort_with_irq;
2748 }
2749
2750 printk(KERN_INFO "myri10ge: %s: %s IRQ %d, tx bndry %d, fw %s, WC %s\n",
2751 netdev->name, (mgp->msi_enabled ? "MSI" : "xPIC"),
2752 pdev->irq, mgp->tx.boundary, mgp->fw_name,
2753 (mgp->mtrr >= 0 ? "Enabled" : "Disabled"));
2754
2755 return 0;
2756
2757abort_with_irq:
2758 free_irq(pdev->irq, mgp);
2759 if (mgp->msi_enabled)
2760 pci_disable_msi(pdev);
2761
2762abort_with_firmware:
2763 myri10ge_dummy_rdma(mgp, 0);
2764
2765abort_with_rx_done:
2766 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
2767 dma_free_coherent(&pdev->dev, bytes,
2768 mgp->rx_done.entry, mgp->rx_done.bus);
2769
2770abort_with_ioremap:
2771 iounmap(mgp->sram);
2772
2773abort_with_wc:
2774#ifdef CONFIG_MTRR
2775 if (mgp->mtrr >= 0)
2776 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
2777#endif
2778 dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats),
2779 mgp->fw_stats, mgp->fw_stats_bus);
2780
2781abort_with_cmd:
2782 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
2783 mgp->cmd, mgp->cmd_bus);
2784
2785abort_with_netdev:
2786
2787 free_netdev(netdev);
2788 return status;
2789}
2790
2791/*
2792 * myri10ge_remove
2793 *
2794 * Does what is necessary to shutdown one Myrinet device. Called
2795 * once for each Myrinet card by the kernel when a module is
2796 * unloaded.
2797 */
2798static void myri10ge_remove(struct pci_dev *pdev)
2799{
2800 struct myri10ge_priv *mgp;
2801 struct net_device *netdev;
2802 size_t bytes;
2803
2804 mgp = pci_get_drvdata(pdev);
2805 if (mgp == NULL)
2806 return;
2807
2808 flush_scheduled_work();
2809 netdev = mgp->dev;
2810 unregister_netdev(netdev);
2811 free_irq(pdev->irq, mgp);
2812 if (mgp->msi_enabled)
2813 pci_disable_msi(pdev);
2814
2815 myri10ge_dummy_rdma(mgp, 0);
2816
2817 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
2818 dma_free_coherent(&pdev->dev, bytes,
2819 mgp->rx_done.entry, mgp->rx_done.bus);
2820
2821 iounmap(mgp->sram);
2822
2823#ifdef CONFIG_MTRR
2824 if (mgp->mtrr >= 0)
2825 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
2826#endif
2827 dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats),
2828 mgp->fw_stats, mgp->fw_stats_bus);
2829
2830 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
2831 mgp->cmd, mgp->cmd_bus);
2832
2833 free_netdev(netdev);
2834 pci_set_drvdata(pdev, NULL);
2835}
2836
2837#define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E 0x0008
2838
2839static struct pci_device_id myri10ge_pci_tbl[] = {
2840 {PCI_DEVICE(PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E)},
2841 {0},
2842};
2843
2844static struct pci_driver myri10ge_driver = {
2845 .name = "myri10ge",
2846 .probe = myri10ge_probe,
2847 .remove = myri10ge_remove,
2848 .id_table = myri10ge_pci_tbl,
2849#ifdef CONFIG_PM
2850 .suspend = myri10ge_suspend,
2851 .resume = myri10ge_resume,
2852#endif
2853};
2854
2855static __init int myri10ge_init_module(void)
2856{
2857 printk(KERN_INFO "%s: Version %s\n", myri10ge_driver.name,
2858 MYRI10GE_VERSION_STR);
2859 return pci_register_driver(&myri10ge_driver);
2860}
2861
2862module_init(myri10ge_init_module);
2863
2864static __exit void myri10ge_cleanup_module(void)
2865{
2866 pci_unregister_driver(&myri10ge_driver);
2867}
2868
2869module_exit(myri10ge_cleanup_module);
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h
new file mode 100644
index 000000000000..0a6cae6cb186
--- /dev/null
+++ b/drivers/net/myri10ge/myri10ge_mcp.h
@@ -0,0 +1,205 @@
1#ifndef __MYRI10GE_MCP_H__
2#define __MYRI10GE_MCP_H__
3
4#define MXGEFW_VERSION_MAJOR 1
5#define MXGEFW_VERSION_MINOR 4
6
7/* 8 Bytes */
8struct mcp_dma_addr {
9 u32 high;
10 u32 low;
11};
12
13/* 4 Bytes */
14struct mcp_slot {
15 u16 checksum;
16 u16 length;
17};
18
19/* 64 Bytes */
20struct mcp_cmd {
21 u32 cmd;
22 u32 data0; /* will be low portion if data > 32 bits */
23 /* 8 */
24 u32 data1; /* will be high portion if data > 32 bits */
25 u32 data2; /* currently unused.. */
26 /* 16 */
27 struct mcp_dma_addr response_addr;
28 /* 24 */
29 u8 pad[40];
30};
31
32/* 8 Bytes */
33struct mcp_cmd_response {
34 u32 data;
35 u32 result;
36};
37
38/*
39 * flags used in mcp_kreq_ether_send_t:
40 *
41 * The SMALL flag is only needed in the first segment. It is raised
42 * for packets that are total less or equal 512 bytes.
43 *
44 * The CKSUM flag must be set in all segments.
45 *
46 * The PADDED flags is set if the packet needs to be padded, and it
47 * must be set for all segments.
48 *
49 * The MXGEFW_FLAGS_ALIGN_ODD must be set if the cumulative
50 * length of all previous segments was odd.
51 */
52
53#define MXGEFW_FLAGS_SMALL 0x1
54#define MXGEFW_FLAGS_TSO_HDR 0x1
55#define MXGEFW_FLAGS_FIRST 0x2
56#define MXGEFW_FLAGS_ALIGN_ODD 0x4
57#define MXGEFW_FLAGS_CKSUM 0x8
58#define MXGEFW_FLAGS_TSO_LAST 0x8
59#define MXGEFW_FLAGS_NO_TSO 0x10
60#define MXGEFW_FLAGS_TSO_CHOP 0x10
61#define MXGEFW_FLAGS_TSO_PLD 0x20
62
63#define MXGEFW_SEND_SMALL_SIZE 1520
64#define MXGEFW_MAX_MTU 9400
65
66union mcp_pso_or_cumlen {
67 u16 pseudo_hdr_offset;
68 u16 cum_len;
69};
70
71#define MXGEFW_MAX_SEND_DESC 12
72#define MXGEFW_PAD 2
73
74/* 16 Bytes */
75struct mcp_kreq_ether_send {
76 u32 addr_high;
77 u32 addr_low;
78 u16 pseudo_hdr_offset;
79 u16 length;
80 u8 pad;
81 u8 rdma_count;
82 u8 cksum_offset; /* where to start computing cksum */
83 u8 flags; /* as defined above */
84};
85
86/* 8 Bytes */
87struct mcp_kreq_ether_recv {
88 u32 addr_high;
89 u32 addr_low;
90};
91
92/* Commands */
93
94#define MXGEFW_CMD_OFFSET 0xf80000
95
96enum myri10ge_mcp_cmd_type {
97 MXGEFW_CMD_NONE = 0,
98 /* Reset the mcp, it is left in a safe state, waiting
99 * for the driver to set all its parameters */
100 MXGEFW_CMD_RESET,
101
102 /* get the version number of the current firmware..
103 * (may be available in the eeprom strings..? */
104 MXGEFW_GET_MCP_VERSION,
105
106 /* Parameters which must be set by the driver before it can
107 * issue MXGEFW_CMD_ETHERNET_UP. They persist until the next
108 * MXGEFW_CMD_RESET is issued */
109
110 MXGEFW_CMD_SET_INTRQ_DMA,
111 MXGEFW_CMD_SET_BIG_BUFFER_SIZE, /* in bytes, power of 2 */
112 MXGEFW_CMD_SET_SMALL_BUFFER_SIZE, /* in bytes */
113
114 /* Parameters which refer to lanai SRAM addresses where the
115 * driver must issue PIO writes for various things */
116
117 MXGEFW_CMD_GET_SEND_OFFSET,
118 MXGEFW_CMD_GET_SMALL_RX_OFFSET,
119 MXGEFW_CMD_GET_BIG_RX_OFFSET,
120 MXGEFW_CMD_GET_IRQ_ACK_OFFSET,
121 MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET,
122
123 /* Parameters which refer to rings stored on the MCP,
124 * and whose size is controlled by the mcp */
125
126 MXGEFW_CMD_GET_SEND_RING_SIZE, /* in bytes */
127 MXGEFW_CMD_GET_RX_RING_SIZE, /* in bytes */
128
129 /* Parameters which refer to rings stored in the host,
130 * and whose size is controlled by the host. Note that
131 * all must be physically contiguous and must contain
132 * a power of 2 number of entries. */
133
134 MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */
135
136 /* command to bring ethernet interface up. Above parameters
137 * (plus mtu & mac address) must have been exchanged prior
138 * to issuing this command */
139 MXGEFW_CMD_ETHERNET_UP,
140
141 /* command to bring ethernet interface down. No further sends
142 * or receives may be processed until an MXGEFW_CMD_ETHERNET_UP
143 * is issued, and all interrupt queues must be flushed prior
144 * to ack'ing this command */
145
146 MXGEFW_CMD_ETHERNET_DOWN,
147
148 /* commands the driver may issue live, without resetting
149 * the nic. Note that increasing the mtu "live" should
150 * only be done if the driver has already supplied buffers
151 * sufficiently large to handle the new mtu. Decreasing
152 * the mtu live is safe */
153
154 MXGEFW_CMD_SET_MTU,
155 MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, /* in microseconds */
156 MXGEFW_CMD_SET_STATS_INTERVAL, /* in microseconds */
157 MXGEFW_CMD_SET_STATS_DMA,
158
159 MXGEFW_ENABLE_PROMISC,
160 MXGEFW_DISABLE_PROMISC,
161 MXGEFW_SET_MAC_ADDRESS,
162
163 MXGEFW_ENABLE_FLOW_CONTROL,
164 MXGEFW_DISABLE_FLOW_CONTROL,
165
166 /* do a DMA test
167 * data0,data1 = DMA address
168 * data2 = RDMA length (MSH), WDMA length (LSH)
169 * command return data = repetitions (MSH), 0.5-ms ticks (LSH)
170 */
171 MXGEFW_DMA_TEST
172};
173
174enum myri10ge_mcp_cmd_status {
175 MXGEFW_CMD_OK = 0,
176 MXGEFW_CMD_UNKNOWN,
177 MXGEFW_CMD_ERROR_RANGE,
178 MXGEFW_CMD_ERROR_BUSY,
179 MXGEFW_CMD_ERROR_EMPTY,
180 MXGEFW_CMD_ERROR_CLOSED,
181 MXGEFW_CMD_ERROR_HASH_ERROR,
182 MXGEFW_CMD_ERROR_BAD_PORT,
183 MXGEFW_CMD_ERROR_RESOURCES
184};
185
186/* 40 Bytes */
187struct mcp_irq_data {
188 u32 send_done_count;
189
190 u32 link_up;
191 u32 dropped_link_overflow;
192 u32 dropped_link_error_or_filtered;
193 u32 dropped_runt;
194 u32 dropped_overrun;
195 u32 dropped_no_small_buffer;
196 u32 dropped_no_big_buffer;
197 u32 rdma_tags_available;
198
199 u8 tx_stopped;
200 u8 link_down;
201 u8 stats_updated;
202 u8 valid;
203};
204
205#endif /* __MYRI10GE_MCP_H__ */
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
new file mode 100644
index 000000000000..487f7792fd46
--- /dev/null
+++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
@@ -0,0 +1,58 @@
1#ifndef __MYRI10GE_MCP_GEN_HEADER_H__
2#define __MYRI10GE_MCP_GEN_HEADER_H__
3
4/* this file define a standard header used as a first entry point to
5 * exchange information between firmware/driver and driver. The
6 * header structure can be anywhere in the mcp. It will usually be in
7 * the .data section, because some fields needs to be initialized at
8 * compile time.
9 * The 32bit word at offset MX_HEADER_PTR_OFFSET in the mcp must
10 * contains the location of the header.
11 *
12 * Typically a MCP will start with the following:
13 * .text
14 * .space 52 ! to help catch MEMORY_INT errors
15 * bt start ! jump to real code
16 * nop
17 * .long _gen_mcp_header
18 *
19 * The source will have a definition like:
20 *
21 * mcp_gen_header_t gen_mcp_header = {
22 * .header_length = sizeof(mcp_gen_header_t),
23 * .mcp_type = MCP_TYPE_XXX,
24 * .version = "something $Id: mcp_gen_header.h,v 1.2 2006/05/13 10:04:35 bgoglin Exp $",
25 * .mcp_globals = (unsigned)&Globals
26 * };
27 */
28
29#define MCP_HEADER_PTR_OFFSET 0x3c
30
31#define MCP_TYPE_MX 0x4d582020 /* "MX " */
32#define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */
33#define MCP_TYPE_ETH 0x45544820 /* "ETH " */
34#define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */
35
36struct mcp_gen_header {
37 /* the first 4 fields are filled at compile time */
38 unsigned header_length;
39 unsigned mcp_type;
40 char version[128];
41 unsigned mcp_globals; /* pointer to mcp-type specific structure */
42
43 /* filled by the MCP at run-time */
44 unsigned sram_size;
45 unsigned string_specs; /* either the original STRING_SPECS or a superset */
46 unsigned string_specs_len;
47
48 /* Fields above this comment are guaranteed to be present.
49 *
50 * Fields below this comment are extensions added in later versions
51 * of this struct, drivers should compare the header_length against
52 * offsetof(field) to check wether a given MCP implements them.
53 *
54 * Never remove any field. Keep everything naturally align.
55 */
56};
57
58#endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 90627756d6fa..2e4ecedba057 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -318,12 +318,12 @@ performance critical codepaths:
318The rx process only runs in the interrupt handler. Access from outside 318The rx process only runs in the interrupt handler. Access from outside
319the interrupt handler is only permitted after disable_irq(). 319the interrupt handler is only permitted after disable_irq().
320 320
321The rx process usually runs under the dev->xmit_lock. If np->intr_tx_reap 321The rx process usually runs under the netif_tx_lock. If np->intr_tx_reap
322is set, then access is permitted under spin_lock_irq(&np->lock). 322is set, then access is permitted under spin_lock_irq(&np->lock).
323 323
324Thus configuration functions that want to access everything must call 324Thus configuration functions that want to access everything must call
325 disable_irq(dev->irq); 325 disable_irq(dev->irq);
326 spin_lock_bh(dev->xmit_lock); 326 netif_tx_lock_bh(dev);
327 spin_lock_irq(&np->lock); 327 spin_lock_irq(&np->lock);
328 328
329IV. Notes 329IV. Notes
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index b32765215f75..963a11fa9fe2 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -829,7 +829,7 @@ that the ne2k probe is the last 8390 based probe to take place (as it
829is at boot) and so the probe will get confused by any other 8390 cards. 829is at boot) and so the probe will get confused by any other 8390 cards.
830ISA device autoprobes on a running machine are not recommended anyway. */ 830ISA device autoprobes on a running machine are not recommended anyway. */
831 831
832int init_module(void) 832int __init init_module(void)
833{ 833{
834 int this_dev, found = 0; 834 int this_dev, found = 0;
835 835
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index 2aa7b77f84f8..eebf5f02b476 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -780,7 +780,7 @@ MODULE_PARM_DESC(bad, "(ignored)");
780 780
781/* Module code fixed by David Weinehall */ 781/* Module code fixed by David Weinehall */
782 782
783int init_module(void) 783int __init init_module(void)
784{ 784{
785 struct net_device *dev; 785 struct net_device *dev;
786 int this_dev, found = 0; 786 int this_dev, found = 0;
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index d090df413049..661bfe54ff5d 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -12,7 +12,7 @@
12 Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net 12 Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net
13 13
14 pcnet_cs.c 1.153 2003/11/09 18:53:09 14 pcnet_cs.c 1.153 2003/11/09 18:53:09
15 15
16 The network driver code is based on Donald Becker's NE2000 code: 16 The network driver code is based on Donald Becker's NE2000 code:
17 17
18 Written 1992,1993 by Donald Becker. 18 Written 1992,1993 by Donald Becker.
@@ -146,7 +146,7 @@ typedef struct hw_info_t {
146#define MII_PHYID_REG2 0x03 146#define MII_PHYID_REG2 0x03
147 147
148static hw_info_t hw_info[] = { 148static hw_info_t hw_info[] = {
149 { /* Accton EN2212 */ 0x0ff0, 0x00, 0x00, 0xe8, DELAY_OUTPUT }, 149 { /* Accton EN2212 */ 0x0ff0, 0x00, 0x00, 0xe8, DELAY_OUTPUT },
150 { /* Allied Telesis LA-PCM */ 0x0ff0, 0x00, 0x00, 0xf4, 0 }, 150 { /* Allied Telesis LA-PCM */ 0x0ff0, 0x00, 0x00, 0xf4, 0 },
151 { /* APEX MultiCard */ 0x03f4, 0x00, 0x20, 0xe5, 0 }, 151 { /* APEX MultiCard */ 0x03f4, 0x00, 0x20, 0xe5, 0 },
152 { /* ASANTE FriendlyNet */ 0x4910, 0x00, 0x00, 0x94, 152 { /* ASANTE FriendlyNet */ 0x4910, 0x00, 0x00, 0x94,
@@ -193,7 +193,7 @@ static hw_info_t hw_info[] = {
193 { /* NE2000 Compatible */ 0x0ff0, 0x00, 0xa0, 0x0c, 0 }, 193 { /* NE2000 Compatible */ 0x0ff0, 0x00, 0xa0, 0x0c, 0 },
194 { /* Network General Sniffer */ 0x0ff0, 0x00, 0x00, 0x65, 194 { /* Network General Sniffer */ 0x0ff0, 0x00, 0x00, 0x65,
195 HAS_MISC_REG | HAS_IBM_MISC }, 195 HAS_MISC_REG | HAS_IBM_MISC },
196 { /* Panasonic VEL211 */ 0x0ff0, 0x00, 0x80, 0x45, 196 { /* Panasonic VEL211 */ 0x0ff0, 0x00, 0x80, 0x45,
197 HAS_MISC_REG | HAS_IBM_MISC }, 197 HAS_MISC_REG | HAS_IBM_MISC },
198 { /* PreMax PE-200 */ 0x07f0, 0x00, 0x20, 0xe0, 0 }, 198 { /* PreMax PE-200 */ 0x07f0, 0x00, 0x20, 0xe0, 0 },
199 { /* RPTI EP400 */ 0x0110, 0x00, 0x40, 0x95, 0 }, 199 { /* RPTI EP400 */ 0x0110, 0x00, 0x40, 0x95, 0 },
@@ -330,7 +330,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
330 for (j = 0; j < 6; j++) 330 for (j = 0; j < 6; j++)
331 dev->dev_addr[j] = readb(base + (j<<1)); 331 dev->dev_addr[j] = readb(base + (j<<1));
332 } 332 }
333 333
334 iounmap(virt); 334 iounmap(virt);
335 j = pcmcia_release_window(link->win); 335 j = pcmcia_release_window(link->win);
336 if (j != CS_SUCCESS) 336 if (j != CS_SUCCESS)
@@ -490,7 +490,7 @@ static int try_io_port(struct pcmcia_device *link)
490 if (link->io.NumPorts2 > 0) { 490 if (link->io.NumPorts2 > 0) {
491 /* for master/slave multifunction cards */ 491 /* for master/slave multifunction cards */
492 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 492 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
493 link->irq.Attributes = 493 link->irq.Attributes =
494 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 494 IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
495 } 495 }
496 } else { 496 } else {
@@ -543,19 +543,19 @@ static int pcnet_config(struct pcmcia_device *link)
543 manfid = le16_to_cpu(buf[0]); 543 manfid = le16_to_cpu(buf[0]);
544 prodid = le16_to_cpu(buf[1]); 544 prodid = le16_to_cpu(buf[1]);
545 } 545 }
546 546
547 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 547 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
548 tuple.Attributes = 0; 548 tuple.Attributes = 0;
549 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 549 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
550 while (last_ret == CS_SUCCESS) { 550 while (last_ret == CS_SUCCESS) {
551 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 551 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
552 cistpl_io_t *io = &(parse.cftable_entry.io); 552 cistpl_io_t *io = &(parse.cftable_entry.io);
553 553
554 if (pcmcia_get_tuple_data(link, &tuple) != 0 || 554 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
555 pcmcia_parse_tuple(link, &tuple, &parse) != 0 || 555 pcmcia_parse_tuple(link, &tuple, &parse) != 0 ||
556 cfg->index == 0 || cfg->io.nwin == 0) 556 cfg->index == 0 || cfg->io.nwin == 0)
557 goto next_entry; 557 goto next_entry;
558 558
559 link->conf.ConfigIndex = cfg->index; 559 link->conf.ConfigIndex = cfg->index;
560 /* For multifunction cards, by convention, we configure the 560 /* For multifunction cards, by convention, we configure the
561 network function with window 0, and serial with window 1 */ 561 network function with window 0, and serial with window 1 */
@@ -584,7 +584,7 @@ static int pcnet_config(struct pcmcia_device *link)
584 } 584 }
585 585
586 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 586 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
587 587
588 if (link->io.NumPorts2 == 8) { 588 if (link->io.NumPorts2 == 8) {
589 link->conf.Attributes |= CONF_ENABLE_SPKR; 589 link->conf.Attributes |= CONF_ENABLE_SPKR;
590 link->conf.Status = CCSR_AUDIO_ENA; 590 link->conf.Status = CCSR_AUDIO_ENA;
@@ -592,7 +592,7 @@ static int pcnet_config(struct pcmcia_device *link)
592 if ((manfid == MANFID_IBM) && 592 if ((manfid == MANFID_IBM) &&
593 (prodid == PRODID_IBM_HOME_AND_AWAY)) 593 (prodid == PRODID_IBM_HOME_AND_AWAY))
594 link->conf.ConfigIndex |= 0x10; 594 link->conf.ConfigIndex |= 0x10;
595 595
596 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 596 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
597 dev->irq = link->irq.AssignedIRQ; 597 dev->irq = link->irq.AssignedIRQ;
598 dev->base_addr = link->io.BasePort1; 598 dev->base_addr = link->io.BasePort1;
@@ -614,7 +614,7 @@ static int pcnet_config(struct pcmcia_device *link)
614 hw_info = get_ax88190(link); 614 hw_info = get_ax88190(link);
615 if (hw_info == NULL) 615 if (hw_info == NULL)
616 hw_info = get_hwired(link); 616 hw_info = get_hwired(link);
617 617
618 if (hw_info == NULL) { 618 if (hw_info == NULL) {
619 printk(KERN_NOTICE "pcnet_cs: unable to read hardware net" 619 printk(KERN_NOTICE "pcnet_cs: unable to read hardware net"
620 " address for io base %#3lx\n", dev->base_addr); 620 " address for io base %#3lx\n", dev->base_addr);
@@ -631,7 +631,7 @@ static int pcnet_config(struct pcmcia_device *link)
631 info->flags &= ~USE_BIG_BUF; 631 info->flags &= ~USE_BIG_BUF;
632 if (!use_big_buf) 632 if (!use_big_buf)
633 info->flags &= ~USE_BIG_BUF; 633 info->flags &= ~USE_BIG_BUF;
634 634
635 if (info->flags & USE_BIG_BUF) { 635 if (info->flags & USE_BIG_BUF) {
636 start_pg = SOCKET_START_PG; 636 start_pg = SOCKET_START_PG;
637 stop_pg = SOCKET_STOP_PG; 637 stop_pg = SOCKET_STOP_PG;
@@ -929,7 +929,7 @@ static void set_misc_reg(struct net_device *dev)
929 kio_addr_t nic_base = dev->base_addr; 929 kio_addr_t nic_base = dev->base_addr;
930 pcnet_dev_t *info = PRIV(dev); 930 pcnet_dev_t *info = PRIV(dev);
931 u_char tmp; 931 u_char tmp;
932 932
933 if (info->flags & HAS_MISC_REG) { 933 if (info->flags & HAS_MISC_REG) {
934 tmp = inb_p(nic_base + PCNET_MISC) & ~3; 934 tmp = inb_p(nic_base + PCNET_MISC) & ~3;
935 if (dev->if_port == 2) 935 if (dev->if_port == 2)
@@ -1022,7 +1022,7 @@ static int pcnet_close(struct net_device *dev)
1022 1022
1023 ei_close(dev); 1023 ei_close(dev);
1024 free_irq(dev->irq, dev); 1024 free_irq(dev->irq, dev);
1025 1025
1026 link->open--; 1026 link->open--;
1027 netif_stop_queue(dev); 1027 netif_stop_queue(dev);
1028 del_timer_sync(&info->watchdog); 1028 del_timer_sync(&info->watchdog);
@@ -1054,12 +1054,12 @@ static void pcnet_reset_8390(struct net_device *dev)
1054 udelay(100); 1054 udelay(100);
1055 } 1055 }
1056 outb_p(ENISR_RESET, nic_base + EN0_ISR); /* Ack intr. */ 1056 outb_p(ENISR_RESET, nic_base + EN0_ISR); /* Ack intr. */
1057 1057
1058 if (i == 100) 1058 if (i == 100)
1059 printk(KERN_ERR "%s: pcnet_reset_8390() did not complete.\n", 1059 printk(KERN_ERR "%s: pcnet_reset_8390() did not complete.\n",
1060 dev->name); 1060 dev->name);
1061 set_misc_reg(dev); 1061 set_misc_reg(dev);
1062 1062
1063} /* pcnet_reset_8390 */ 1063} /* pcnet_reset_8390 */
1064 1064
1065/*====================================================================*/ 1065/*====================================================================*/
@@ -1233,7 +1233,7 @@ static void dma_get_8390_hdr(struct net_device *dev,
1233 dev->name, ei_status.dmaing, ei_status.irqlock); 1233 dev->name, ei_status.dmaing, ei_status.irqlock);
1234 return; 1234 return;
1235 } 1235 }
1236 1236
1237 ei_status.dmaing |= 0x01; 1237 ei_status.dmaing |= 0x01;
1238 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base + PCNET_CMD); 1238 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base + PCNET_CMD);
1239 outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); 1239 outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
@@ -1458,7 +1458,7 @@ static void shmem_get_8390_hdr(struct net_device *dev,
1458 void __iomem *xfer_start = ei_status.mem + (TX_PAGES<<8) 1458 void __iomem *xfer_start = ei_status.mem + (TX_PAGES<<8)
1459 + (ring_page << 8) 1459 + (ring_page << 8)
1460 - (ei_status.rx_start_page << 8); 1460 - (ei_status.rx_start_page << 8);
1461 1461
1462 copyin(hdr, xfer_start, sizeof(struct e8390_pkt_hdr)); 1462 copyin(hdr, xfer_start, sizeof(struct e8390_pkt_hdr));
1463 /* Fix for big endian systems */ 1463 /* Fix for big endian systems */
1464 hdr->count = le16_to_cpu(hdr->count); 1464 hdr->count = le16_to_cpu(hdr->count);
@@ -1473,7 +1473,7 @@ static void shmem_block_input(struct net_device *dev, int count,
1473 unsigned long offset = (TX_PAGES<<8) + ring_offset 1473 unsigned long offset = (TX_PAGES<<8) + ring_offset
1474 - (ei_status.rx_start_page << 8); 1474 - (ei_status.rx_start_page << 8);
1475 char *buf = skb->data; 1475 char *buf = skb->data;
1476 1476
1477 if (offset + count > ei_status.priv) { 1477 if (offset + count > ei_status.priv) {
1478 /* We must wrap the input move. */ 1478 /* We must wrap the input move. */
1479 int semi_count = ei_status.priv - offset; 1479 int semi_count = ei_status.priv - offset;
@@ -1541,7 +1541,7 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1541 info->base = NULL; link->win = NULL; 1541 info->base = NULL; link->win = NULL;
1542 goto failed; 1542 goto failed;
1543 } 1543 }
1544 1544
1545 ei_status.mem = info->base + offset; 1545 ei_status.mem = info->base + offset;
1546 ei_status.priv = req.Size; 1546 ei_status.priv = req.Size;
1547 dev->mem_start = (u_long)ei_status.mem; 1547 dev->mem_start = (u_long)ei_status.mem;
@@ -1768,6 +1768,8 @@ static struct pcmcia_device_id pcnet_ids[] = {
1768 PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "NE2K.cis"), 1768 PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "NE2K.cis"),
1769 PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"), 1769 PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"),
1770 PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "tamarack.cis"), 1770 PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "tamarack.cis"),
1771 PCMCIA_DEVICE_PROD_ID123("Fast Ethernet", "CF Size PC Card", "1.0",
1772 0xb4be14e3, 0x43ac239b, 0x0877b627),
1771 PCMCIA_DEVICE_NULL 1773 PCMCIA_DEVICE_NULL
1772}; 1774};
1773MODULE_DEVICE_TABLE(pcmcia, pcnet_ids); 1775MODULE_DEVICE_TABLE(pcmcia, pcnet_ids);
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index fa39b944bc46..cda3e53d6917 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -45,5 +45,11 @@ config CICADA_PHY
45 ---help--- 45 ---help---
46 Currently supports the cis8204 46 Currently supports the cis8204
47 47
48config SMSC_PHY
49 tristate "Drivers for SMSC PHYs"
50 depends on PHYLIB
51 ---help---
52 Currently supports the LAN83C185 PHY
53
48endmenu 54endmenu
49 55
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index e4116a5fbb4c..d9614134cc06 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_DAVICOM_PHY) += davicom.o
8obj-$(CONFIG_CICADA_PHY) += cicada.o 8obj-$(CONFIG_CICADA_PHY) += cicada.o
9obj-$(CONFIG_LXT_PHY) += lxt.o 9obj-$(CONFIG_LXT_PHY) += lxt.o
10obj-$(CONFIG_QSEMI_PHY) += qsemi.o 10obj-$(CONFIG_QSEMI_PHY) += qsemi.o
11obj-$(CONFIG_SMSC_PHY) += smsc.o
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
new file mode 100644
index 000000000000..25e31fb5cb31
--- /dev/null
+++ b/drivers/net/phy/smsc.c
@@ -0,0 +1,101 @@
1/*
2 * drivers/net/phy/smsc.c
3 *
4 * Driver for SMSC PHYs
5 *
6 * Author: Herbert Valerio Riedel
7 *
8 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/mii.h>
21#include <linux/ethtool.h>
22#include <linux/phy.h>
23#include <linux/netdevice.h>
24
25#define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */
26#define MII_LAN83C185_IM 30 /* Interrupt Mask */
27
28#define MII_LAN83C185_ISF_INT1 (1<<1) /* Auto-Negotiation Page Received */
29#define MII_LAN83C185_ISF_INT2 (1<<2) /* Parallel Detection Fault */
30#define MII_LAN83C185_ISF_INT3 (1<<3) /* Auto-Negotiation LP Ack */
31#define MII_LAN83C185_ISF_INT4 (1<<4) /* Link Down */
32#define MII_LAN83C185_ISF_INT5 (1<<5) /* Remote Fault Detected */
33#define MII_LAN83C185_ISF_INT6 (1<<6) /* Auto-Negotiation complete */
34#define MII_LAN83C185_ISF_INT7 (1<<7) /* ENERGYON */
35
36#define MII_LAN83C185_ISF_INT_ALL (0x0e)
37
38#define MII_LAN83C185_ISF_INT_PHYLIB_EVENTS \
39 (MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4)
40
41
42static int lan83c185_config_intr(struct phy_device *phydev)
43{
44 int rc = phy_write (phydev, MII_LAN83C185_IM,
45 ((PHY_INTERRUPT_ENABLED == phydev->interrupts)
46 ? MII_LAN83C185_ISF_INT_PHYLIB_EVENTS
47 : 0));
48
49 return rc < 0 ? rc : 0;
50}
51
52static int lan83c185_ack_interrupt(struct phy_device *phydev)
53{
54 int rc = phy_read (phydev, MII_LAN83C185_ISF);
55
56 return rc < 0 ? rc : 0;
57}
58
59static int lan83c185_config_init(struct phy_device *phydev)
60{
61 return lan83c185_ack_interrupt (phydev);
62}
63
64
65static struct phy_driver lan83c185_driver = {
66 .phy_id = 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
67 .phy_id_mask = 0xfffffff0,
68 .name = "SMSC LAN83C185",
69
70 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
71 | SUPPORTED_Asym_Pause),
72 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
73
74 /* basic functions */
75 .config_aneg = genphy_config_aneg,
76 .read_status = genphy_read_status,
77 .config_init = lan83c185_config_init,
78
79 /* IRQ related */
80 .ack_interrupt = lan83c185_ack_interrupt,
81 .config_intr = lan83c185_config_intr,
82
83 .driver = { .owner = THIS_MODULE, }
84};
85
86static int __init smsc_init(void)
87{
88 return phy_driver_register (&lan83c185_driver);
89}
90
91static void __exit smsc_exit(void)
92{
93 phy_driver_unregister (&lan83c185_driver);
94}
95
96MODULE_DESCRIPTION("SMSC PHY driver");
97MODULE_AUTHOR("Herbert Valerio Riedel");
98MODULE_LICENSE("GPL");
99
100module_init(smsc_init);
101module_exit(smsc_exit);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index b2073fce8216..01cd8ec751ea 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1609,8 +1609,6 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1609 kfree_skb(skb); 1609 kfree_skb(skb);
1610 skb = ns; 1610 skb = ns;
1611 } 1611 }
1612 else if (!pskb_may_pull(skb, skb->len))
1613 goto err;
1614 else 1612 else
1615 skb->ip_summed = CHECKSUM_NONE; 1613 skb->ip_summed = CHECKSUM_NONE;
1616 1614
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 0ad3310290f1..9945cc6b8d90 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -184,6 +184,7 @@ static const struct {
184 184
185static struct pci_device_id rtl8169_pci_tbl[] = { 185static struct pci_device_id rtl8169_pci_tbl[] = {
186 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), }, 186 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), },
187 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), },
187 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), }, 188 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), },
188 { PCI_DEVICE(0x16ec, 0x0116), }, 189 { PCI_DEVICE(0x16ec, 0x0116), },
189 { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0024, }, 190 { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0024, },
diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h
index 00179bc3437f..0ef525899566 100644
--- a/drivers/net/s2io-regs.h
+++ b/drivers/net/s2io-regs.h
@@ -167,6 +167,7 @@ typedef struct _XENA_dev_config {
167 u8 unused4[0x08]; 167 u8 unused4[0x08];
168 168
169 u64 gpio_int_reg; 169 u64 gpio_int_reg;
170#define GPIO_INT_REG_DP_ERR_INT BIT(0)
170#define GPIO_INT_REG_LINK_DOWN BIT(1) 171#define GPIO_INT_REG_LINK_DOWN BIT(1)
171#define GPIO_INT_REG_LINK_UP BIT(2) 172#define GPIO_INT_REG_LINK_UP BIT(2)
172 u64 gpio_int_mask; 173 u64 gpio_int_mask;
@@ -187,7 +188,7 @@ typedef struct _XENA_dev_config {
187/* PIC Control registers */ 188/* PIC Control registers */
188 u64 pic_control; 189 u64 pic_control;
189#define PIC_CNTL_RX_ALARM_MAP_1 BIT(0) 190#define PIC_CNTL_RX_ALARM_MAP_1 BIT(0)
190#define PIC_CNTL_SHARED_SPLITS(n) vBIT(n,11,4) 191#define PIC_CNTL_SHARED_SPLITS(n) vBIT(n,11,5)
191 192
192 u64 swapper_ctrl; 193 u64 swapper_ctrl;
193#define SWAPPER_CTRL_PIF_R_FE BIT(0) 194#define SWAPPER_CTRL_PIF_R_FE BIT(0)
@@ -267,6 +268,21 @@ typedef struct _XENA_dev_config {
267 268
268 /* General Configuration */ 269 /* General Configuration */
269 u64 mdio_control; 270 u64 mdio_control;
271#define MDIO_MMD_INDX_ADDR(val) vBIT(val, 0, 16)
272#define MDIO_MMD_DEV_ADDR(val) vBIT(val, 19, 5)
273#define MDIO_MMD_PMA_DEV_ADDR 0x1
274#define MDIO_MMD_PMD_DEV_ADDR 0x1
275#define MDIO_MMD_WIS_DEV_ADDR 0x2
276#define MDIO_MMD_PCS_DEV_ADDR 0x3
277#define MDIO_MMD_PHYXS_DEV_ADDR 0x4
278#define MDIO_MMS_PRT_ADDR(val) vBIT(val, 27, 5)
279#define MDIO_CTRL_START_TRANS(val) vBIT(val, 56, 4)
280#define MDIO_OP(val) vBIT(val, 60, 2)
281#define MDIO_OP_ADDR_TRANS 0x0
282#define MDIO_OP_WRITE_TRANS 0x1
283#define MDIO_OP_READ_POST_INC_TRANS 0x2
284#define MDIO_OP_READ_TRANS 0x3
285#define MDIO_MDIO_DATA(val) vBIT(val, 32, 16)
270 286
271 u64 dtx_control; 287 u64 dtx_control;
272 288
@@ -284,9 +300,13 @@ typedef struct _XENA_dev_config {
284 u64 gpio_control; 300 u64 gpio_control;
285#define GPIO_CTRL_GPIO_0 BIT(8) 301#define GPIO_CTRL_GPIO_0 BIT(8)
286 u64 misc_control; 302 u64 misc_control;
303#define EXT_REQ_EN BIT(1)
287#define MISC_LINK_STABILITY_PRD(val) vBIT(val,29,3) 304#define MISC_LINK_STABILITY_PRD(val) vBIT(val,29,3)
288 305
289 u8 unused7_1[0x240 - 0x208]; 306 u8 unused7_1[0x230 - 0x208];
307
308 u64 pic_control2;
309 u64 ini_dperr_ctrl;
290 310
291 u64 wreq_split_mask; 311 u64 wreq_split_mask;
292#define WREQ_SPLIT_MASK_SET_MASK(val) vBIT(val, 52, 12) 312#define WREQ_SPLIT_MASK_SET_MASK(val) vBIT(val, 52, 12)
@@ -493,6 +513,7 @@ typedef struct _XENA_dev_config {
493#define PRC_CTRL_NO_SNOOP_DESC BIT(22) 513#define PRC_CTRL_NO_SNOOP_DESC BIT(22)
494#define PRC_CTRL_NO_SNOOP_BUFF BIT(23) 514#define PRC_CTRL_NO_SNOOP_BUFF BIT(23)
495#define PRC_CTRL_BIMODAL_INTERRUPT BIT(37) 515#define PRC_CTRL_BIMODAL_INTERRUPT BIT(37)
516#define PRC_CTRL_GROUP_READS BIT(38)
496#define PRC_CTRL_RXD_BACKOFF_INTERVAL(val) vBIT(val,40,24) 517#define PRC_CTRL_RXD_BACKOFF_INTERVAL(val) vBIT(val,40,24)
497 518
498 u64 prc_alarm_action; 519 u64 prc_alarm_action;
@@ -541,7 +562,12 @@ typedef struct _XENA_dev_config {
541#define RX_PA_CFG_IGNORE_LLC_CTRL BIT(3) 562#define RX_PA_CFG_IGNORE_LLC_CTRL BIT(3)
542#define RX_PA_CFG_IGNORE_L2_ERR BIT(6) 563#define RX_PA_CFG_IGNORE_L2_ERR BIT(6)
543 564
544 u8 unused12[0x700 - 0x1D8]; 565 u64 unused_11_1;
566
567 u64 ring_bump_counter1;
568 u64 ring_bump_counter2;
569
570 u8 unused12[0x700 - 0x1F0];
545 571
546 u64 rxdma_debug_ctrl; 572 u64 rxdma_debug_ctrl;
547 573
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 79208f434ac1..cac9fdd2e1d5 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -26,15 +26,22 @@
26 * 26 *
27 * The module loadable parameters that are supported by the driver and a brief 27 * The module loadable parameters that are supported by the driver and a brief
28 * explaination of all the variables. 28 * explaination of all the variables.
29 *
29 * rx_ring_num : This can be used to program the number of receive rings used 30 * rx_ring_num : This can be used to program the number of receive rings used
30 * in the driver. 31 * in the driver.
31 * rx_ring_sz: This defines the number of descriptors each ring can have. This 32 * rx_ring_sz: This defines the number of receive blocks each ring can have.
32 * is also an array of size 8. 33 * This is also an array of size 8.
33 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid 34 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid
34 * values are 1, 2 and 3. 35 * values are 1, 2 and 3.
35 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver. 36 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver.
36 * tx_fifo_len: This too is an array of 8. Each element defines the number of 37 * tx_fifo_len: This too is an array of 8. Each element defines the number of
37 * Tx descriptors that can be associated with each corresponding FIFO. 38 * Tx descriptors that can be associated with each corresponding FIFO.
39 * intr_type: This defines the type of interrupt. The values can be 0(INTA),
40 * 1(MSI), 2(MSI_X). Default value is '0(INTA)'
41 * lro: Specifies whether to enable Large Receive Offload (LRO) or not.
42 * Possible values '1' for enable '0' for disable. Default is '0'
43 * lro_max_pkts: This parameter defines maximum number of packets can be
44 * aggregated as a single large packet
38 ************************************************************************/ 45 ************************************************************************/
39 46
40#include <linux/config.h> 47#include <linux/config.h>
@@ -70,7 +77,7 @@
70#include "s2io.h" 77#include "s2io.h"
71#include "s2io-regs.h" 78#include "s2io-regs.h"
72 79
73#define DRV_VERSION "2.0.11.2" 80#define DRV_VERSION "2.0.14.2"
74 81
75/* S2io Driver name & version. */ 82/* S2io Driver name & version. */
76static char s2io_driver_name[] = "Neterion"; 83static char s2io_driver_name[] = "Neterion";
@@ -106,18 +113,14 @@ static inline int RXD_IS_UP2DT(RxD_t *rxdp)
106#define LOW 2 113#define LOW 2
107static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring) 114static inline int rx_buffer_level(nic_t * sp, int rxb_size, int ring)
108{ 115{
109 int level = 0;
110 mac_info_t *mac_control; 116 mac_info_t *mac_control;
111 117
112 mac_control = &sp->mac_control; 118 mac_control = &sp->mac_control;
113 if ((mac_control->rings[ring].pkt_cnt - rxb_size) > 16) { 119 if (rxb_size <= rxd_count[sp->rxd_mode])
114 level = LOW; 120 return PANIC;
115 if (rxb_size <= rxd_count[sp->rxd_mode]) { 121 else if ((mac_control->rings[ring].pkt_cnt - rxb_size) > 16)
116 level = PANIC; 122 return LOW;
117 } 123 return 0;
118 }
119
120 return level;
121} 124}
122 125
123/* Ethtool related variables and Macros. */ 126/* Ethtool related variables and Macros. */
@@ -136,7 +139,11 @@ static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
136 {"tmac_mcst_frms"}, 139 {"tmac_mcst_frms"},
137 {"tmac_bcst_frms"}, 140 {"tmac_bcst_frms"},
138 {"tmac_pause_ctrl_frms"}, 141 {"tmac_pause_ctrl_frms"},
142 {"tmac_ttl_octets"},
143 {"tmac_ucst_frms"},
144 {"tmac_nucst_frms"},
139 {"tmac_any_err_frms"}, 145 {"tmac_any_err_frms"},
146 {"tmac_ttl_less_fb_octets"},
140 {"tmac_vld_ip_octets"}, 147 {"tmac_vld_ip_octets"},
141 {"tmac_vld_ip"}, 148 {"tmac_vld_ip"},
142 {"tmac_drop_ip"}, 149 {"tmac_drop_ip"},
@@ -151,13 +158,27 @@ static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
151 {"rmac_vld_mcst_frms"}, 158 {"rmac_vld_mcst_frms"},
152 {"rmac_vld_bcst_frms"}, 159 {"rmac_vld_bcst_frms"},
153 {"rmac_in_rng_len_err_frms"}, 160 {"rmac_in_rng_len_err_frms"},
161 {"rmac_out_rng_len_err_frms"},
154 {"rmac_long_frms"}, 162 {"rmac_long_frms"},
155 {"rmac_pause_ctrl_frms"}, 163 {"rmac_pause_ctrl_frms"},
164 {"rmac_unsup_ctrl_frms"},
165 {"rmac_ttl_octets"},
166 {"rmac_accepted_ucst_frms"},
167 {"rmac_accepted_nucst_frms"},
156 {"rmac_discarded_frms"}, 168 {"rmac_discarded_frms"},
169 {"rmac_drop_events"},
170 {"rmac_ttl_less_fb_octets"},
171 {"rmac_ttl_frms"},
157 {"rmac_usized_frms"}, 172 {"rmac_usized_frms"},
158 {"rmac_osized_frms"}, 173 {"rmac_osized_frms"},
159 {"rmac_frag_frms"}, 174 {"rmac_frag_frms"},
160 {"rmac_jabber_frms"}, 175 {"rmac_jabber_frms"},
176 {"rmac_ttl_64_frms"},
177 {"rmac_ttl_65_127_frms"},
178 {"rmac_ttl_128_255_frms"},
179 {"rmac_ttl_256_511_frms"},
180 {"rmac_ttl_512_1023_frms"},
181 {"rmac_ttl_1024_1518_frms"},
161 {"rmac_ip"}, 182 {"rmac_ip"},
162 {"rmac_ip_octets"}, 183 {"rmac_ip_octets"},
163 {"rmac_hdr_err_ip"}, 184 {"rmac_hdr_err_ip"},
@@ -166,12 +187,82 @@ static char ethtool_stats_keys[][ETH_GSTRING_LEN] = {
166 {"rmac_tcp"}, 187 {"rmac_tcp"},
167 {"rmac_udp"}, 188 {"rmac_udp"},
168 {"rmac_err_drp_udp"}, 189 {"rmac_err_drp_udp"},
190 {"rmac_xgmii_err_sym"},
191 {"rmac_frms_q0"},
192 {"rmac_frms_q1"},
193 {"rmac_frms_q2"},
194 {"rmac_frms_q3"},
195 {"rmac_frms_q4"},
196 {"rmac_frms_q5"},
197 {"rmac_frms_q6"},
198 {"rmac_frms_q7"},
199 {"rmac_full_q0"},
200 {"rmac_full_q1"},
201 {"rmac_full_q2"},
202 {"rmac_full_q3"},
203 {"rmac_full_q4"},
204 {"rmac_full_q5"},
205 {"rmac_full_q6"},
206 {"rmac_full_q7"},
169 {"rmac_pause_cnt"}, 207 {"rmac_pause_cnt"},
208 {"rmac_xgmii_data_err_cnt"},
209 {"rmac_xgmii_ctrl_err_cnt"},
170 {"rmac_accepted_ip"}, 210 {"rmac_accepted_ip"},
171 {"rmac_err_tcp"}, 211 {"rmac_err_tcp"},
212 {"rd_req_cnt"},
213 {"new_rd_req_cnt"},
214 {"new_rd_req_rtry_cnt"},
215 {"rd_rtry_cnt"},
216 {"wr_rtry_rd_ack_cnt"},
217 {"wr_req_cnt"},
218 {"new_wr_req_cnt"},
219 {"new_wr_req_rtry_cnt"},
220 {"wr_rtry_cnt"},
221 {"wr_disc_cnt"},
222 {"rd_rtry_wr_ack_cnt"},
223 {"txp_wr_cnt"},
224 {"txd_rd_cnt"},
225 {"txd_wr_cnt"},
226 {"rxd_rd_cnt"},
227 {"rxd_wr_cnt"},
228 {"txf_rd_cnt"},
229 {"rxf_wr_cnt"},
230 {"rmac_ttl_1519_4095_frms"},
231 {"rmac_ttl_4096_8191_frms"},
232 {"rmac_ttl_8192_max_frms"},
233 {"rmac_ttl_gt_max_frms"},
234 {"rmac_osized_alt_frms"},
235 {"rmac_jabber_alt_frms"},
236 {"rmac_gt_max_alt_frms"},
237 {"rmac_vlan_frms"},
238 {"rmac_len_discard"},
239 {"rmac_fcs_discard"},
240 {"rmac_pf_discard"},
241 {"rmac_da_discard"},
242 {"rmac_red_discard"},
243 {"rmac_rts_discard"},
244 {"rmac_ingm_full_discard"},
245 {"link_fault_cnt"},
172 {"\n DRIVER STATISTICS"}, 246 {"\n DRIVER STATISTICS"},
173 {"single_bit_ecc_errs"}, 247 {"single_bit_ecc_errs"},
174 {"double_bit_ecc_errs"}, 248 {"double_bit_ecc_errs"},
249 {"parity_err_cnt"},
250 {"serious_err_cnt"},
251 {"soft_reset_cnt"},
252 {"fifo_full_cnt"},
253 {"ring_full_cnt"},
254 ("alarm_transceiver_temp_high"),
255 ("alarm_transceiver_temp_low"),
256 ("alarm_laser_bias_current_high"),
257 ("alarm_laser_bias_current_low"),
258 ("alarm_laser_output_power_high"),
259 ("alarm_laser_output_power_low"),
260 ("warn_transceiver_temp_high"),
261 ("warn_transceiver_temp_low"),
262 ("warn_laser_bias_current_high"),
263 ("warn_laser_bias_current_low"),
264 ("warn_laser_output_power_high"),
265 ("warn_laser_output_power_low"),
175 ("lro_aggregated_pkts"), 266 ("lro_aggregated_pkts"),
176 ("lro_flush_both_count"), 267 ("lro_flush_both_count"),
177 ("lro_out_of_sequence_pkts"), 268 ("lro_out_of_sequence_pkts"),
@@ -220,9 +311,7 @@ static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)
220 * the XAUI. 311 * the XAUI.
221 */ 312 */
222 313
223#define SWITCH_SIGN 0xA5A5A5A5A5A5A5A5ULL
224#define END_SIGN 0x0 314#define END_SIGN 0x0
225
226static const u64 herc_act_dtx_cfg[] = { 315static const u64 herc_act_dtx_cfg[] = {
227 /* Set address */ 316 /* Set address */
228 0x8000051536750000ULL, 0x80000515367500E0ULL, 317 0x8000051536750000ULL, 0x80000515367500E0ULL,
@@ -244,37 +333,19 @@ static const u64 herc_act_dtx_cfg[] = {
244 END_SIGN 333 END_SIGN
245}; 334};
246 335
247static const u64 xena_mdio_cfg[] = {
248 /* Reset PMA PLL */
249 0xC001010000000000ULL, 0xC0010100000000E0ULL,
250 0xC0010100008000E4ULL,
251 /* Remove Reset from PMA PLL */
252 0xC001010000000000ULL, 0xC0010100000000E0ULL,
253 0xC0010100000000E4ULL,
254 END_SIGN
255};
256
257static const u64 xena_dtx_cfg[] = { 336static const u64 xena_dtx_cfg[] = {
337 /* Set address */
258 0x8000051500000000ULL, 0x80000515000000E0ULL, 338 0x8000051500000000ULL, 0x80000515000000E0ULL,
259 0x80000515D93500E4ULL, 0x8001051500000000ULL, 339 /* Write data */
260 0x80010515000000E0ULL, 0x80010515001E00E4ULL, 340 0x80000515D9350004ULL, 0x80000515D93500E4ULL,
261 0x8002051500000000ULL, 0x80020515000000E0ULL, 341 /* Set address */
262 0x80020515F21000E4ULL, 342 0x8001051500000000ULL, 0x80010515000000E0ULL,
263 /* Set PADLOOPBACKN */ 343 /* Write data */
264 0x8002051500000000ULL, 0x80020515000000E0ULL, 344 0x80010515001E0004ULL, 0x80010515001E00E4ULL,
265 0x80020515B20000E4ULL, 0x8003051500000000ULL, 345 /* Set address */
266 0x80030515000000E0ULL, 0x80030515B20000E4ULL,
267 0x8004051500000000ULL, 0x80040515000000E0ULL,
268 0x80040515B20000E4ULL, 0x8005051500000000ULL,
269 0x80050515000000E0ULL, 0x80050515B20000E4ULL,
270 SWITCH_SIGN,
271 /* Remove PADLOOPBACKN */
272 0x8002051500000000ULL, 0x80020515000000E0ULL, 346 0x8002051500000000ULL, 0x80020515000000E0ULL,
273 0x80020515F20000E4ULL, 0x8003051500000000ULL, 347 /* Write data */
274 0x80030515000000E0ULL, 0x80030515F20000E4ULL, 348 0x80020515F2100004ULL, 0x80020515F21000E4ULL,
275 0x8004051500000000ULL, 0x80040515000000E0ULL,
276 0x80040515F20000E4ULL, 0x8005051500000000ULL,
277 0x80050515000000E0ULL, 0x80050515F20000E4ULL,
278 END_SIGN 349 END_SIGN
279}; 350};
280 351
@@ -303,15 +374,15 @@ static const u64 fix_mac[] = {
303/* Module Loadable parameters. */ 374/* Module Loadable parameters. */
304static unsigned int tx_fifo_num = 1; 375static unsigned int tx_fifo_num = 1;
305static unsigned int tx_fifo_len[MAX_TX_FIFOS] = 376static unsigned int tx_fifo_len[MAX_TX_FIFOS] =
306 {[0 ...(MAX_TX_FIFOS - 1)] = 0 }; 377 {DEFAULT_FIFO_0_LEN, [1 ...(MAX_TX_FIFOS - 1)] = DEFAULT_FIFO_1_7_LEN};
307static unsigned int rx_ring_num = 1; 378static unsigned int rx_ring_num = 1;
308static unsigned int rx_ring_sz[MAX_RX_RINGS] = 379static unsigned int rx_ring_sz[MAX_RX_RINGS] =
309 {[0 ...(MAX_RX_RINGS - 1)] = 0 }; 380 {[0 ...(MAX_RX_RINGS - 1)] = SMALL_BLK_CNT};
310static unsigned int rts_frm_len[MAX_RX_RINGS] = 381static unsigned int rts_frm_len[MAX_RX_RINGS] =
311 {[0 ...(MAX_RX_RINGS - 1)] = 0 }; 382 {[0 ...(MAX_RX_RINGS - 1)] = 0 };
312static unsigned int rx_ring_mode = 1; 383static unsigned int rx_ring_mode = 1;
313static unsigned int use_continuous_tx_intrs = 1; 384static unsigned int use_continuous_tx_intrs = 1;
314static unsigned int rmac_pause_time = 65535; 385static unsigned int rmac_pause_time = 0x100;
315static unsigned int mc_pause_threshold_q0q3 = 187; 386static unsigned int mc_pause_threshold_q0q3 = 187;
316static unsigned int mc_pause_threshold_q4q7 = 187; 387static unsigned int mc_pause_threshold_q4q7 = 187;
317static unsigned int shared_splits; 388static unsigned int shared_splits;
@@ -549,11 +620,6 @@ static int init_shared_mem(struct s2io_nic *nic)
549 rx_blocks->block_dma_addr + 620 rx_blocks->block_dma_addr +
550 (rxd_size[nic->rxd_mode] * l); 621 (rxd_size[nic->rxd_mode] * l);
551 } 622 }
552
553 mac_control->rings[i].rx_blocks[j].block_virt_addr =
554 tmp_v_addr;
555 mac_control->rings[i].rx_blocks[j].block_dma_addr =
556 tmp_p_addr;
557 } 623 }
558 /* Interlinking all Rx Blocks */ 624 /* Interlinking all Rx Blocks */
559 for (j = 0; j < blk_cnt; j++) { 625 for (j = 0; j < blk_cnt; j++) {
@@ -772,7 +838,21 @@ static int s2io_verify_pci_mode(nic_t *nic)
772 return mode; 838 return mode;
773} 839}
774 840
841#define NEC_VENID 0x1033
842#define NEC_DEVID 0x0125
843static int s2io_on_nec_bridge(struct pci_dev *s2io_pdev)
844{
845 struct pci_dev *tdev = NULL;
846 while ((tdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, tdev)) != NULL) {
847 if ((tdev->vendor == NEC_VENID) && (tdev->device == NEC_DEVID)){
848 if (tdev->bus == s2io_pdev->bus->parent)
849 return 1;
850 }
851 }
852 return 0;
853}
775 854
855static int bus_speed[8] = {33, 133, 133, 200, 266, 133, 200, 266};
776/** 856/**
777 * s2io_print_pci_mode - 857 * s2io_print_pci_mode -
778 */ 858 */
@@ -789,6 +869,14 @@ static int s2io_print_pci_mode(nic_t *nic)
789 if ( val64 & PCI_MODE_UNKNOWN_MODE) 869 if ( val64 & PCI_MODE_UNKNOWN_MODE)
790 return -1; /* Unknown PCI mode */ 870 return -1; /* Unknown PCI mode */
791 871
872 config->bus_speed = bus_speed[mode];
873
874 if (s2io_on_nec_bridge(nic->pdev)) {
875 DBG_PRINT(ERR_DBG, "%s: Device is on PCI-E bus\n",
876 nic->dev->name);
877 return mode;
878 }
879
792 if (val64 & PCI_MODE_32_BITS) { 880 if (val64 & PCI_MODE_32_BITS) {
793 DBG_PRINT(ERR_DBG, "%s: Device is on 32 bit ", nic->dev->name); 881 DBG_PRINT(ERR_DBG, "%s: Device is on 32 bit ", nic->dev->name);
794 } else { 882 } else {
@@ -798,35 +886,27 @@ static int s2io_print_pci_mode(nic_t *nic)
798 switch(mode) { 886 switch(mode) {
799 case PCI_MODE_PCI_33: 887 case PCI_MODE_PCI_33:
800 DBG_PRINT(ERR_DBG, "33MHz PCI bus\n"); 888 DBG_PRINT(ERR_DBG, "33MHz PCI bus\n");
801 config->bus_speed = 33;
802 break; 889 break;
803 case PCI_MODE_PCI_66: 890 case PCI_MODE_PCI_66:
804 DBG_PRINT(ERR_DBG, "66MHz PCI bus\n"); 891 DBG_PRINT(ERR_DBG, "66MHz PCI bus\n");
805 config->bus_speed = 133;
806 break; 892 break;
807 case PCI_MODE_PCIX_M1_66: 893 case PCI_MODE_PCIX_M1_66:
808 DBG_PRINT(ERR_DBG, "66MHz PCIX(M1) bus\n"); 894 DBG_PRINT(ERR_DBG, "66MHz PCIX(M1) bus\n");
809 config->bus_speed = 133; /* Herc doubles the clock rate */
810 break; 895 break;
811 case PCI_MODE_PCIX_M1_100: 896 case PCI_MODE_PCIX_M1_100:
812 DBG_PRINT(ERR_DBG, "100MHz PCIX(M1) bus\n"); 897 DBG_PRINT(ERR_DBG, "100MHz PCIX(M1) bus\n");
813 config->bus_speed = 200;
814 break; 898 break;
815 case PCI_MODE_PCIX_M1_133: 899 case PCI_MODE_PCIX_M1_133:
816 DBG_PRINT(ERR_DBG, "133MHz PCIX(M1) bus\n"); 900 DBG_PRINT(ERR_DBG, "133MHz PCIX(M1) bus\n");
817 config->bus_speed = 266;
818 break; 901 break;
819 case PCI_MODE_PCIX_M2_66: 902 case PCI_MODE_PCIX_M2_66:
820 DBG_PRINT(ERR_DBG, "133MHz PCIX(M2) bus\n"); 903 DBG_PRINT(ERR_DBG, "133MHz PCIX(M2) bus\n");
821 config->bus_speed = 133;
822 break; 904 break;
823 case PCI_MODE_PCIX_M2_100: 905 case PCI_MODE_PCIX_M2_100:
824 DBG_PRINT(ERR_DBG, "200MHz PCIX(M2) bus\n"); 906 DBG_PRINT(ERR_DBG, "200MHz PCIX(M2) bus\n");
825 config->bus_speed = 200;
826 break; 907 break;
827 case PCI_MODE_PCIX_M2_133: 908 case PCI_MODE_PCIX_M2_133:
828 DBG_PRINT(ERR_DBG, "266MHz PCIX(M2) bus\n"); 909 DBG_PRINT(ERR_DBG, "266MHz PCIX(M2) bus\n");
829 config->bus_speed = 266;
830 break; 910 break;
831 default: 911 default:
832 return -1; /* Unsupported bus speed */ 912 return -1; /* Unsupported bus speed */
@@ -854,7 +934,7 @@ static int init_nic(struct s2io_nic *nic)
854 int i, j; 934 int i, j;
855 mac_info_t *mac_control; 935 mac_info_t *mac_control;
856 struct config_param *config; 936 struct config_param *config;
857 int mdio_cnt = 0, dtx_cnt = 0; 937 int dtx_cnt = 0;
858 unsigned long long mem_share; 938 unsigned long long mem_share;
859 int mem_size; 939 int mem_size;
860 940
@@ -901,20 +981,6 @@ static int init_nic(struct s2io_nic *nic)
901 val64 = dev->mtu; 981 val64 = dev->mtu;
902 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len); 982 writeq(vBIT(val64, 2, 14), &bar0->rmac_max_pyld_len);
903 983
904 /*
905 * Configuring the XAUI Interface of Xena.
906 * ***************************************
907 * To Configure the Xena's XAUI, one has to write a series
908 * of 64 bit values into two registers in a particular
909 * sequence. Hence a macro 'SWITCH_SIGN' has been defined
910 * which will be defined in the array of configuration values
911 * (xena_dtx_cfg & xena_mdio_cfg) at appropriate places
912 * to switch writing from one regsiter to another. We continue
913 * writing these values until we encounter the 'END_SIGN' macro.
914 * For example, After making a series of 21 writes into
915 * dtx_control register the 'SWITCH_SIGN' appears and hence we
916 * start writing into mdio_control until we encounter END_SIGN.
917 */
918 if (nic->device_type & XFRAME_II_DEVICE) { 984 if (nic->device_type & XFRAME_II_DEVICE) {
919 while (herc_act_dtx_cfg[dtx_cnt] != END_SIGN) { 985 while (herc_act_dtx_cfg[dtx_cnt] != END_SIGN) {
920 SPECIAL_REG_WRITE(herc_act_dtx_cfg[dtx_cnt], 986 SPECIAL_REG_WRITE(herc_act_dtx_cfg[dtx_cnt],
@@ -924,35 +990,11 @@ static int init_nic(struct s2io_nic *nic)
924 dtx_cnt++; 990 dtx_cnt++;
925 } 991 }
926 } else { 992 } else {
927 while (1) { 993 while (xena_dtx_cfg[dtx_cnt] != END_SIGN) {
928 dtx_cfg: 994 SPECIAL_REG_WRITE(xena_dtx_cfg[dtx_cnt],
929 while (xena_dtx_cfg[dtx_cnt] != END_SIGN) { 995 &bar0->dtx_control, UF);
930 if (xena_dtx_cfg[dtx_cnt] == SWITCH_SIGN) { 996 val64 = readq(&bar0->dtx_control);
931 dtx_cnt++; 997 dtx_cnt++;
932 goto mdio_cfg;
933 }
934 SPECIAL_REG_WRITE(xena_dtx_cfg[dtx_cnt],
935 &bar0->dtx_control, UF);
936 val64 = readq(&bar0->dtx_control);
937 dtx_cnt++;
938 }
939 mdio_cfg:
940 while (xena_mdio_cfg[mdio_cnt] != END_SIGN) {
941 if (xena_mdio_cfg[mdio_cnt] == SWITCH_SIGN) {
942 mdio_cnt++;
943 goto dtx_cfg;
944 }
945 SPECIAL_REG_WRITE(xena_mdio_cfg[mdio_cnt],
946 &bar0->mdio_control, UF);
947 val64 = readq(&bar0->mdio_control);
948 mdio_cnt++;
949 }
950 if ((xena_dtx_cfg[dtx_cnt] == END_SIGN) &&
951 (xena_mdio_cfg[mdio_cnt] == END_SIGN)) {
952 break;
953 } else {
954 goto dtx_cfg;
955 }
956 } 998 }
957 } 999 }
958 1000
@@ -994,11 +1036,6 @@ static int init_nic(struct s2io_nic *nic)
994 } 1036 }
995 } 1037 }
996 1038
997 /* Enable Tx FIFO partition 0. */
998 val64 = readq(&bar0->tx_fifo_partition_0);
999 val64 |= BIT(0); /* To enable the FIFO partition. */
1000 writeq(val64, &bar0->tx_fifo_partition_0);
1001
1002 /* 1039 /*
1003 * Disable 4 PCCs for Xena1, 2 and 3 as per H/W bug 1040 * Disable 4 PCCs for Xena1, 2 and 3 as per H/W bug
1004 * SXE-008 TRANSMIT DMA ARBITRATION ISSUE. 1041 * SXE-008 TRANSMIT DMA ARBITRATION ISSUE.
@@ -1177,6 +1214,11 @@ static int init_nic(struct s2io_nic *nic)
1177 break; 1214 break;
1178 } 1215 }
1179 1216
1217 /* Enable Tx FIFO partition 0. */
1218 val64 = readq(&bar0->tx_fifo_partition_0);
1219 val64 |= (TX_FIFO_PARTITION_EN);
1220 writeq(val64, &bar0->tx_fifo_partition_0);
1221
1180 /* Filling the Rx round robin registers as per the 1222 /* Filling the Rx round robin registers as per the
1181 * number of Rings and steering based on QoS. 1223 * number of Rings and steering based on QoS.
1182 */ 1224 */
@@ -1545,19 +1587,26 @@ static int init_nic(struct s2io_nic *nic)
1545 val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits); 1587 val64 |= PIC_CNTL_SHARED_SPLITS(shared_splits);
1546 writeq(val64, &bar0->pic_control); 1588 writeq(val64, &bar0->pic_control);
1547 1589
1590 if (nic->config.bus_speed == 266) {
1591 writeq(TXREQTO_VAL(0x7f) | TXREQTO_EN, &bar0->txreqtimeout);
1592 writeq(0x0, &bar0->read_retry_delay);
1593 writeq(0x0, &bar0->write_retry_delay);
1594 }
1595
1548 /* 1596 /*
1549 * Programming the Herc to split every write transaction 1597 * Programming the Herc to split every write transaction
1550 * that does not start on an ADB to reduce disconnects. 1598 * that does not start on an ADB to reduce disconnects.
1551 */ 1599 */
1552 if (nic->device_type == XFRAME_II_DEVICE) { 1600 if (nic->device_type == XFRAME_II_DEVICE) {
1553 val64 = WREQ_SPLIT_MASK_SET_MASK(255); 1601 val64 = EXT_REQ_EN | MISC_LINK_STABILITY_PRD(3);
1554 writeq(val64, &bar0->wreq_split_mask);
1555 }
1556
1557 /* Setting Link stability period to 64 ms */
1558 if (nic->device_type == XFRAME_II_DEVICE) {
1559 val64 = MISC_LINK_STABILITY_PRD(3);
1560 writeq(val64, &bar0->misc_control); 1602 writeq(val64, &bar0->misc_control);
1603 val64 = readq(&bar0->pic_control2);
1604 val64 &= ~(BIT(13)|BIT(14)|BIT(15));
1605 writeq(val64, &bar0->pic_control2);
1606 }
1607 if (strstr(nic->product_name, "CX4")) {
1608 val64 = TMAC_AVG_IPG(0x17);
1609 writeq(val64, &bar0->tmac_avg_ipg);
1561 } 1610 }
1562 1611
1563 return SUCCESS; 1612 return SUCCESS;
@@ -1948,6 +1997,10 @@ static int start_nic(struct s2io_nic *nic)
1948 val64 |= PRC_CTRL_RC_ENABLED; 1997 val64 |= PRC_CTRL_RC_ENABLED;
1949 else 1998 else
1950 val64 |= PRC_CTRL_RC_ENABLED | PRC_CTRL_RING_MODE_3; 1999 val64 |= PRC_CTRL_RC_ENABLED | PRC_CTRL_RING_MODE_3;
2000 if (nic->device_type == XFRAME_II_DEVICE)
2001 val64 |= PRC_CTRL_GROUP_READS;
2002 val64 &= ~PRC_CTRL_RXD_BACKOFF_INTERVAL(0xFFFFFF);
2003 val64 |= PRC_CTRL_RXD_BACKOFF_INTERVAL(0x1000);
1951 writeq(val64, &bar0->prc_ctrl_n[i]); 2004 writeq(val64, &bar0->prc_ctrl_n[i]);
1952 } 2005 }
1953 2006
@@ -2018,6 +2071,13 @@ static int start_nic(struct s2io_nic *nic)
2018 val64 |= ADAPTER_EOI_TX_ON; 2071 val64 |= ADAPTER_EOI_TX_ON;
2019 writeq(val64, &bar0->adapter_control); 2072 writeq(val64, &bar0->adapter_control);
2020 2073
2074 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
2075 /*
2076 * Dont see link state interrupts initally on some switches,
2077 * so directly scheduling the link state task here.
2078 */
2079 schedule_work(&nic->set_link_task);
2080 }
2021 /* SXE-002: Initialize link and activity LED */ 2081 /* SXE-002: Initialize link and activity LED */
2022 subid = nic->pdev->subsystem_device; 2082 subid = nic->pdev->subsystem_device;
2023 if (((subid & 0xFF) >= 0x07) && 2083 if (((subid & 0xFF) >= 0x07) &&
@@ -2029,12 +2089,6 @@ static int start_nic(struct s2io_nic *nic)
2029 writeq(val64, (void __iomem *)bar0 + 0x2700); 2089 writeq(val64, (void __iomem *)bar0 + 0x2700);
2030 } 2090 }
2031 2091
2032 /*
2033 * Don't see link state interrupts on certain switches, so
2034 * directly scheduling a link state task from here.
2035 */
2036 schedule_work(&nic->set_link_task);
2037
2038 return SUCCESS; 2092 return SUCCESS;
2039} 2093}
2040/** 2094/**
@@ -2134,7 +2188,7 @@ static void stop_nic(struct s2io_nic *nic)
2134{ 2188{
2135 XENA_dev_config_t __iomem *bar0 = nic->bar0; 2189 XENA_dev_config_t __iomem *bar0 = nic->bar0;
2136 register u64 val64 = 0; 2190 register u64 val64 = 0;
2137 u16 interruptible, i; 2191 u16 interruptible;
2138 mac_info_t *mac_control; 2192 mac_info_t *mac_control;
2139 struct config_param *config; 2193 struct config_param *config;
2140 2194
@@ -2147,12 +2201,10 @@ static void stop_nic(struct s2io_nic *nic)
2147 interruptible |= TX_MAC_INTR | RX_MAC_INTR; 2201 interruptible |= TX_MAC_INTR | RX_MAC_INTR;
2148 en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS); 2202 en_dis_able_nic_intrs(nic, interruptible, DISABLE_INTRS);
2149 2203
2150 /* Disable PRCs */ 2204 /* Clearing Adapter_En bit of ADAPTER_CONTROL Register */
2151 for (i = 0; i < config->rx_ring_num; i++) { 2205 val64 = readq(&bar0->adapter_control);
2152 val64 = readq(&bar0->prc_ctrl_n[i]); 2206 val64 &= ~(ADAPTER_CNTL_EN);
2153 val64 &= ~((u64) PRC_CTRL_RC_ENABLED); 2207 writeq(val64, &bar0->adapter_control);
2154 writeq(val64, &bar0->prc_ctrl_n[i]);
2155 }
2156} 2208}
2157 2209
2158static int fill_rxd_3buf(nic_t *nic, RxD_t *rxdp, struct sk_buff *skb) 2210static int fill_rxd_3buf(nic_t *nic, RxD_t *rxdp, struct sk_buff *skb)
@@ -2231,13 +2283,12 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2231 alloc_cnt = mac_control->rings[ring_no].pkt_cnt - 2283 alloc_cnt = mac_control->rings[ring_no].pkt_cnt -
2232 atomic_read(&nic->rx_bufs_left[ring_no]); 2284 atomic_read(&nic->rx_bufs_left[ring_no]);
2233 2285
2286 block_no1 = mac_control->rings[ring_no].rx_curr_get_info.block_index;
2287 off1 = mac_control->rings[ring_no].rx_curr_get_info.offset;
2234 while (alloc_tab < alloc_cnt) { 2288 while (alloc_tab < alloc_cnt) {
2235 block_no = mac_control->rings[ring_no].rx_curr_put_info. 2289 block_no = mac_control->rings[ring_no].rx_curr_put_info.
2236 block_index; 2290 block_index;
2237 block_no1 = mac_control->rings[ring_no].rx_curr_get_info.
2238 block_index;
2239 off = mac_control->rings[ring_no].rx_curr_put_info.offset; 2291 off = mac_control->rings[ring_no].rx_curr_put_info.offset;
2240 off1 = mac_control->rings[ring_no].rx_curr_get_info.offset;
2241 2292
2242 rxdp = mac_control->rings[ring_no]. 2293 rxdp = mac_control->rings[ring_no].
2243 rx_blocks[block_no].rxds[off].virt_addr; 2294 rx_blocks[block_no].rxds[off].virt_addr;
@@ -2307,9 +2358,9 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2307 memset(rxdp, 0, sizeof(RxD1_t)); 2358 memset(rxdp, 0, sizeof(RxD1_t));
2308 skb_reserve(skb, NET_IP_ALIGN); 2359 skb_reserve(skb, NET_IP_ALIGN);
2309 ((RxD1_t*)rxdp)->Buffer0_ptr = pci_map_single 2360 ((RxD1_t*)rxdp)->Buffer0_ptr = pci_map_single
2310 (nic->pdev, skb->data, size, PCI_DMA_FROMDEVICE); 2361 (nic->pdev, skb->data, size - NET_IP_ALIGN,
2311 rxdp->Control_2 &= (~MASK_BUFFER0_SIZE_1); 2362 PCI_DMA_FROMDEVICE);
2312 rxdp->Control_2 |= SET_BUFFER0_SIZE_1(size); 2363 rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
2313 2364
2314 } else if (nic->rxd_mode >= RXD_MODE_3A) { 2365 } else if (nic->rxd_mode >= RXD_MODE_3A) {
2315 /* 2366 /*
@@ -2516,7 +2567,7 @@ static int s2io_poll(struct net_device *dev, int *budget)
2516 mac_info_t *mac_control; 2567 mac_info_t *mac_control;
2517 struct config_param *config; 2568 struct config_param *config;
2518 XENA_dev_config_t __iomem *bar0 = nic->bar0; 2569 XENA_dev_config_t __iomem *bar0 = nic->bar0;
2519 u64 val64; 2570 u64 val64 = 0xFFFFFFFFFFFFFFFFULL;
2520 int i; 2571 int i;
2521 2572
2522 atomic_inc(&nic->isr_cnt); 2573 atomic_inc(&nic->isr_cnt);
@@ -2528,8 +2579,8 @@ static int s2io_poll(struct net_device *dev, int *budget)
2528 nic->pkts_to_process = dev->quota; 2579 nic->pkts_to_process = dev->quota;
2529 org_pkts_to_process = nic->pkts_to_process; 2580 org_pkts_to_process = nic->pkts_to_process;
2530 2581
2531 val64 = readq(&bar0->rx_traffic_int);
2532 writeq(val64, &bar0->rx_traffic_int); 2582 writeq(val64, &bar0->rx_traffic_int);
2583 val64 = readl(&bar0->rx_traffic_int);
2533 2584
2534 for (i = 0; i < config->rx_ring_num; i++) { 2585 for (i = 0; i < config->rx_ring_num; i++) {
2535 rx_intr_handler(&mac_control->rings[i]); 2586 rx_intr_handler(&mac_control->rings[i]);
@@ -2554,7 +2605,8 @@ static int s2io_poll(struct net_device *dev, int *budget)
2554 } 2605 }
2555 } 2606 }
2556 /* Re enable the Rx interrupts. */ 2607 /* Re enable the Rx interrupts. */
2557 en_dis_able_nic_intrs(nic, RX_TRAFFIC_INTR, ENABLE_INTRS); 2608 writeq(0x0, &bar0->rx_traffic_mask);
2609 val64 = readl(&bar0->rx_traffic_mask);
2558 atomic_dec(&nic->isr_cnt); 2610 atomic_dec(&nic->isr_cnt);
2559 return 0; 2611 return 0;
2560 2612
@@ -2666,6 +2718,7 @@ static void rx_intr_handler(ring_info_t *ring_data)
2666 ((RxD3_t*)rxdp)->Buffer2_ptr, 2718 ((RxD3_t*)rxdp)->Buffer2_ptr,
2667 dev->mtu, PCI_DMA_FROMDEVICE); 2719 dev->mtu, PCI_DMA_FROMDEVICE);
2668 } 2720 }
2721 prefetch(skb->data);
2669 rx_osm_handler(ring_data, rxdp); 2722 rx_osm_handler(ring_data, rxdp);
2670 get_info.offset++; 2723 get_info.offset++;
2671 ring_data->rx_curr_get_info.offset = get_info.offset; 2724 ring_data->rx_curr_get_info.offset = get_info.offset;
@@ -2737,6 +2790,10 @@ static void tx_intr_handler(fifo_info_t *fifo_data)
2737 if (txdlp->Control_1 & TXD_T_CODE) { 2790 if (txdlp->Control_1 & TXD_T_CODE) {
2738 unsigned long long err; 2791 unsigned long long err;
2739 err = txdlp->Control_1 & TXD_T_CODE; 2792 err = txdlp->Control_1 & TXD_T_CODE;
2793 if (err & 0x1) {
2794 nic->mac_control.stats_info->sw_stat.
2795 parity_err_cnt++;
2796 }
2740 if ((err >> 48) == 0xA) { 2797 if ((err >> 48) == 0xA) {
2741 DBG_PRINT(TX_DBG, "TxD returned due \ 2798 DBG_PRINT(TX_DBG, "TxD returned due \
2742to loss of link\n"); 2799to loss of link\n");
@@ -2760,7 +2817,8 @@ to loss of link\n");
2760 dev_kfree_skb_irq(skb); 2817 dev_kfree_skb_irq(skb);
2761 2818
2762 get_info.offset++; 2819 get_info.offset++;
2763 get_info.offset %= get_info.fifo_len + 1; 2820 if (get_info.offset == get_info.fifo_len + 1)
2821 get_info.offset = 0;
2764 txdlp = (TxD_t *) fifo_data->list_info 2822 txdlp = (TxD_t *) fifo_data->list_info
2765 [get_info.offset].list_virt_addr; 2823 [get_info.offset].list_virt_addr;
2766 fifo_data->tx_curr_get_info.offset = 2824 fifo_data->tx_curr_get_info.offset =
@@ -2774,6 +2832,256 @@ to loss of link\n");
2774} 2832}
2775 2833
2776/** 2834/**
2835 * s2io_mdio_write - Function to write in to MDIO registers
2836 * @mmd_type : MMD type value (PMA/PMD/WIS/PCS/PHYXS)
2837 * @addr : address value
2838 * @value : data value
2839 * @dev : pointer to net_device structure
2840 * Description:
2841 * This function is used to write values to the MDIO registers
2842 * NONE
2843 */
2844static void s2io_mdio_write(u32 mmd_type, u64 addr, u16 value, struct net_device *dev)
2845{
2846 u64 val64 = 0x0;
2847 nic_t *sp = dev->priv;
2848 XENA_dev_config_t *bar0 = (XENA_dev_config_t *)sp->bar0;
2849
2850 //address transaction
2851 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
2852 | MDIO_MMD_DEV_ADDR(mmd_type)
2853 | MDIO_MMS_PRT_ADDR(0x0);
2854 writeq(val64, &bar0->mdio_control);
2855 val64 = val64 | MDIO_CTRL_START_TRANS(0xE);
2856 writeq(val64, &bar0->mdio_control);
2857 udelay(100);
2858
2859 //Data transaction
2860 val64 = 0x0;
2861 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
2862 | MDIO_MMD_DEV_ADDR(mmd_type)
2863 | MDIO_MMS_PRT_ADDR(0x0)
2864 | MDIO_MDIO_DATA(value)
2865 | MDIO_OP(MDIO_OP_WRITE_TRANS);
2866 writeq(val64, &bar0->mdio_control);
2867 val64 = val64 | MDIO_CTRL_START_TRANS(0xE);
2868 writeq(val64, &bar0->mdio_control);
2869 udelay(100);
2870
2871 val64 = 0x0;
2872 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
2873 | MDIO_MMD_DEV_ADDR(mmd_type)
2874 | MDIO_MMS_PRT_ADDR(0x0)
2875 | MDIO_OP(MDIO_OP_READ_TRANS);
2876 writeq(val64, &bar0->mdio_control);
2877 val64 = val64 | MDIO_CTRL_START_TRANS(0xE);
2878 writeq(val64, &bar0->mdio_control);
2879 udelay(100);
2880
2881}
2882
2883/**
2884 * s2io_mdio_read - Function to write in to MDIO registers
2885 * @mmd_type : MMD type value (PMA/PMD/WIS/PCS/PHYXS)
2886 * @addr : address value
2887 * @dev : pointer to net_device structure
2888 * Description:
2889 * This function is used to read values to the MDIO registers
2890 * NONE
2891 */
2892static u64 s2io_mdio_read(u32 mmd_type, u64 addr, struct net_device *dev)
2893{
2894 u64 val64 = 0x0;
2895 u64 rval64 = 0x0;
2896 nic_t *sp = dev->priv;
2897 XENA_dev_config_t *bar0 = (XENA_dev_config_t *)sp->bar0;
2898
2899 /* address transaction */
2900 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
2901 | MDIO_MMD_DEV_ADDR(mmd_type)
2902 | MDIO_MMS_PRT_ADDR(0x0);
2903 writeq(val64, &bar0->mdio_control);
2904 val64 = val64 | MDIO_CTRL_START_TRANS(0xE);
2905 writeq(val64, &bar0->mdio_control);
2906 udelay(100);
2907
2908 /* Data transaction */
2909 val64 = 0x0;
2910 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
2911 | MDIO_MMD_DEV_ADDR(mmd_type)
2912 | MDIO_MMS_PRT_ADDR(0x0)
2913 | MDIO_OP(MDIO_OP_READ_TRANS);
2914 writeq(val64, &bar0->mdio_control);
2915 val64 = val64 | MDIO_CTRL_START_TRANS(0xE);
2916 writeq(val64, &bar0->mdio_control);
2917 udelay(100);
2918
2919 /* Read the value from regs */
2920 rval64 = readq(&bar0->mdio_control);
2921 rval64 = rval64 & 0xFFFF0000;
2922 rval64 = rval64 >> 16;
2923 return rval64;
2924}
2925/**
2926 * s2io_chk_xpak_counter - Function to check the status of the xpak counters
2927 * @counter : couter value to be updated
2928 * @flag : flag to indicate the status
2929 * @type : counter type
2930 * Description:
2931 * This function is to check the status of the xpak counters value
2932 * NONE
2933 */
2934
2935static void s2io_chk_xpak_counter(u64 *counter, u64 * regs_stat, u32 index, u16 flag, u16 type)
2936{
2937 u64 mask = 0x3;
2938 u64 val64;
2939 int i;
2940 for(i = 0; i <index; i++)
2941 mask = mask << 0x2;
2942
2943 if(flag > 0)
2944 {
2945 *counter = *counter + 1;
2946 val64 = *regs_stat & mask;
2947 val64 = val64 >> (index * 0x2);
2948 val64 = val64 + 1;
2949 if(val64 == 3)
2950 {
2951 switch(type)
2952 {
2953 case 1:
2954 DBG_PRINT(ERR_DBG, "Take Xframe NIC out of "
2955 "service. Excessive temperatures may "
2956 "result in premature transceiver "
2957 "failure \n");
2958 break;
2959 case 2:
2960 DBG_PRINT(ERR_DBG, "Take Xframe NIC out of "
2961 "service Excessive bias currents may "
2962 "indicate imminent laser diode "
2963 "failure \n");
2964 break;
2965 case 3:
2966 DBG_PRINT(ERR_DBG, "Take Xframe NIC out of "
2967 "service Excessive laser output "
2968 "power may saturate far-end "
2969 "receiver\n");
2970 break;
2971 default:
2972 DBG_PRINT(ERR_DBG, "Incorrect XPAK Alarm "
2973 "type \n");
2974 }
2975 val64 = 0x0;
2976 }
2977 val64 = val64 << (index * 0x2);
2978 *regs_stat = (*regs_stat & (~mask)) | (val64);
2979
2980 } else {
2981 *regs_stat = *regs_stat & (~mask);
2982 }
2983}
2984
2985/**
2986 * s2io_updt_xpak_counter - Function to update the xpak counters
2987 * @dev : pointer to net_device struct
2988 * Description:
2989 * This function is to upate the status of the xpak counters value
2990 * NONE
2991 */
2992static void s2io_updt_xpak_counter(struct net_device *dev)
2993{
2994 u16 flag = 0x0;
2995 u16 type = 0x0;
2996 u16 val16 = 0x0;
2997 u64 val64 = 0x0;
2998 u64 addr = 0x0;
2999
3000 nic_t *sp = dev->priv;
3001 StatInfo_t *stat_info = sp->mac_control.stats_info;
3002
3003 /* Check the communication with the MDIO slave */
3004 addr = 0x0000;
3005 val64 = 0x0;
3006 val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
3007 if((val64 == 0xFFFF) || (val64 == 0x0000))
3008 {
3009 DBG_PRINT(ERR_DBG, "ERR: MDIO slave access failed - "
3010 "Returned %llx\n", (unsigned long long)val64);
3011 return;
3012 }
3013
3014 /* Check for the expecte value of 2040 at PMA address 0x0000 */
3015 if(val64 != 0x2040)
3016 {
3017 DBG_PRINT(ERR_DBG, "Incorrect value at PMA address 0x0000 - ");
3018 DBG_PRINT(ERR_DBG, "Returned: %llx- Expected: 0x2040\n",
3019 (unsigned long long)val64);
3020 return;
3021 }
3022
3023 /* Loading the DOM register to MDIO register */
3024 addr = 0xA100;
3025 s2io_mdio_write(MDIO_MMD_PMA_DEV_ADDR, addr, val16, dev);
3026 val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
3027
3028 /* Reading the Alarm flags */
3029 addr = 0xA070;
3030 val64 = 0x0;
3031 val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
3032
3033 flag = CHECKBIT(val64, 0x7);
3034 type = 1;
3035 s2io_chk_xpak_counter(&stat_info->xpak_stat.alarm_transceiver_temp_high,
3036 &stat_info->xpak_stat.xpak_regs_stat,
3037 0x0, flag, type);
3038
3039 if(CHECKBIT(val64, 0x6))
3040 stat_info->xpak_stat.alarm_transceiver_temp_low++;
3041
3042 flag = CHECKBIT(val64, 0x3);
3043 type = 2;
3044 s2io_chk_xpak_counter(&stat_info->xpak_stat.alarm_laser_bias_current_high,
3045 &stat_info->xpak_stat.xpak_regs_stat,
3046 0x2, flag, type);
3047
3048 if(CHECKBIT(val64, 0x2))
3049 stat_info->xpak_stat.alarm_laser_bias_current_low++;
3050
3051 flag = CHECKBIT(val64, 0x1);
3052 type = 3;
3053 s2io_chk_xpak_counter(&stat_info->xpak_stat.alarm_laser_output_power_high,
3054 &stat_info->xpak_stat.xpak_regs_stat,
3055 0x4, flag, type);
3056
3057 if(CHECKBIT(val64, 0x0))
3058 stat_info->xpak_stat.alarm_laser_output_power_low++;
3059
3060 /* Reading the Warning flags */
3061 addr = 0xA074;
3062 val64 = 0x0;
3063 val64 = s2io_mdio_read(MDIO_MMD_PMA_DEV_ADDR, addr, dev);
3064
3065 if(CHECKBIT(val64, 0x7))
3066 stat_info->xpak_stat.warn_transceiver_temp_high++;
3067
3068 if(CHECKBIT(val64, 0x6))
3069 stat_info->xpak_stat.warn_transceiver_temp_low++;
3070
3071 if(CHECKBIT(val64, 0x3))
3072 stat_info->xpak_stat.warn_laser_bias_current_high++;
3073
3074 if(CHECKBIT(val64, 0x2))
3075 stat_info->xpak_stat.warn_laser_bias_current_low++;
3076
3077 if(CHECKBIT(val64, 0x1))
3078 stat_info->xpak_stat.warn_laser_output_power_high++;
3079
3080 if(CHECKBIT(val64, 0x0))
3081 stat_info->xpak_stat.warn_laser_output_power_low++;
3082}
3083
3084/**
2777 * alarm_intr_handler - Alarm Interrrupt handler 3085 * alarm_intr_handler - Alarm Interrrupt handler
2778 * @nic: device private variable 3086 * @nic: device private variable
2779 * Description: If the interrupt was neither because of Rx packet or Tx 3087 * Description: If the interrupt was neither because of Rx packet or Tx
@@ -2790,6 +3098,18 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2790 struct net_device *dev = (struct net_device *) nic->dev; 3098 struct net_device *dev = (struct net_device *) nic->dev;
2791 XENA_dev_config_t __iomem *bar0 = nic->bar0; 3099 XENA_dev_config_t __iomem *bar0 = nic->bar0;
2792 register u64 val64 = 0, err_reg = 0; 3100 register u64 val64 = 0, err_reg = 0;
3101 u64 cnt;
3102 int i;
3103 nic->mac_control.stats_info->sw_stat.ring_full_cnt = 0;
3104 /* Handling the XPAK counters update */
3105 if(nic->mac_control.stats_info->xpak_stat.xpak_timer_count < 72000) {
3106 /* waiting for an hour */
3107 nic->mac_control.stats_info->xpak_stat.xpak_timer_count++;
3108 } else {
3109 s2io_updt_xpak_counter(dev);
3110 /* reset the count to zero */
3111 nic->mac_control.stats_info->xpak_stat.xpak_timer_count = 0;
3112 }
2793 3113
2794 /* Handling link status change error Intr */ 3114 /* Handling link status change error Intr */
2795 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) { 3115 if (s2io_link_fault_indication(nic) == MAC_RMAC_ERR_TIMER) {
@@ -2816,6 +3136,8 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2816 MC_ERR_REG_MIRI_ECC_DB_ERR_1)) { 3136 MC_ERR_REG_MIRI_ECC_DB_ERR_1)) {
2817 netif_stop_queue(dev); 3137 netif_stop_queue(dev);
2818 schedule_work(&nic->rst_timer_task); 3138 schedule_work(&nic->rst_timer_task);
3139 nic->mac_control.stats_info->sw_stat.
3140 soft_reset_cnt++;
2819 } 3141 }
2820 } 3142 }
2821 } else { 3143 } else {
@@ -2827,11 +3149,13 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2827 /* In case of a serious error, the device will be Reset. */ 3149 /* In case of a serious error, the device will be Reset. */
2828 val64 = readq(&bar0->serr_source); 3150 val64 = readq(&bar0->serr_source);
2829 if (val64 & SERR_SOURCE_ANY) { 3151 if (val64 & SERR_SOURCE_ANY) {
3152 nic->mac_control.stats_info->sw_stat.serious_err_cnt++;
2830 DBG_PRINT(ERR_DBG, "%s: Device indicates ", dev->name); 3153 DBG_PRINT(ERR_DBG, "%s: Device indicates ", dev->name);
2831 DBG_PRINT(ERR_DBG, "serious error %llx!!\n", 3154 DBG_PRINT(ERR_DBG, "serious error %llx!!\n",
2832 (unsigned long long)val64); 3155 (unsigned long long)val64);
2833 netif_stop_queue(dev); 3156 netif_stop_queue(dev);
2834 schedule_work(&nic->rst_timer_task); 3157 schedule_work(&nic->rst_timer_task);
3158 nic->mac_control.stats_info->sw_stat.soft_reset_cnt++;
2835 } 3159 }
2836 3160
2837 /* 3161 /*
@@ -2849,6 +3173,35 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2849 ac = readq(&bar0->adapter_control); 3173 ac = readq(&bar0->adapter_control);
2850 schedule_work(&nic->set_link_task); 3174 schedule_work(&nic->set_link_task);
2851 } 3175 }
3176 /* Check for data parity error */
3177 val64 = readq(&bar0->pic_int_status);
3178 if (val64 & PIC_INT_GPIO) {
3179 val64 = readq(&bar0->gpio_int_reg);
3180 if (val64 & GPIO_INT_REG_DP_ERR_INT) {
3181 nic->mac_control.stats_info->sw_stat.parity_err_cnt++;
3182 schedule_work(&nic->rst_timer_task);
3183 nic->mac_control.stats_info->sw_stat.soft_reset_cnt++;
3184 }
3185 }
3186
3187 /* Check for ring full counter */
3188 if (nic->device_type & XFRAME_II_DEVICE) {
3189 val64 = readq(&bar0->ring_bump_counter1);
3190 for (i=0; i<4; i++) {
3191 cnt = ( val64 & vBIT(0xFFFF,(i*16),16));
3192 cnt >>= 64 - ((i+1)*16);
3193 nic->mac_control.stats_info->sw_stat.ring_full_cnt
3194 += cnt;
3195 }
3196
3197 val64 = readq(&bar0->ring_bump_counter2);
3198 for (i=0; i<4; i++) {
3199 cnt = ( val64 & vBIT(0xFFFF,(i*16),16));
3200 cnt >>= 64 - ((i+1)*16);
3201 nic->mac_control.stats_info->sw_stat.ring_full_cnt
3202 += cnt;
3203 }
3204 }
2852 3205
2853 /* Other type of interrupts are not being handled now, TODO */ 3206 /* Other type of interrupts are not being handled now, TODO */
2854} 3207}
@@ -2864,23 +3217,26 @@ static void alarm_intr_handler(struct s2io_nic *nic)
2864 * SUCCESS on success and FAILURE on failure. 3217 * SUCCESS on success and FAILURE on failure.
2865 */ 3218 */
2866 3219
2867static int wait_for_cmd_complete(nic_t * sp) 3220static int wait_for_cmd_complete(void *addr, u64 busy_bit)
2868{ 3221{
2869 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2870 int ret = FAILURE, cnt = 0; 3222 int ret = FAILURE, cnt = 0;
2871 u64 val64; 3223 u64 val64;
2872 3224
2873 while (TRUE) { 3225 while (TRUE) {
2874 val64 = readq(&bar0->rmac_addr_cmd_mem); 3226 val64 = readq(addr);
2875 if (!(val64 & RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING)) { 3227 if (!(val64 & busy_bit)) {
2876 ret = SUCCESS; 3228 ret = SUCCESS;
2877 break; 3229 break;
2878 } 3230 }
2879 msleep(50); 3231
3232 if(in_interrupt())
3233 mdelay(50);
3234 else
3235 msleep(50);
3236
2880 if (cnt++ > 10) 3237 if (cnt++ > 10)
2881 break; 3238 break;
2882 } 3239 }
2883
2884 return ret; 3240 return ret;
2885} 3241}
2886 3242
@@ -2919,6 +3275,9 @@ static void s2io_reset(nic_t * sp)
2919 * PCI write to sw_reset register is done by this time. 3275 * PCI write to sw_reset register is done by this time.
2920 */ 3276 */
2921 msleep(250); 3277 msleep(250);
3278 if (strstr(sp->product_name, "CX4")) {
3279 msleep(750);
3280 }
2922 3281
2923 /* Restore the PCI state saved during initialization. */ 3282 /* Restore the PCI state saved during initialization. */
2924 pci_restore_state(sp->pdev); 3283 pci_restore_state(sp->pdev);
@@ -3137,7 +3496,7 @@ static void restore_xmsi_data(nic_t *nic)
3137 u64 val64; 3496 u64 val64;
3138 int i; 3497 int i;
3139 3498
3140 for (i=0; i< MAX_REQUESTED_MSI_X; i++) { 3499 for (i=0; i< nic->avail_msix_vectors; i++) {
3141 writeq(nic->msix_info[i].addr, &bar0->xmsi_address); 3500 writeq(nic->msix_info[i].addr, &bar0->xmsi_address);
3142 writeq(nic->msix_info[i].data, &bar0->xmsi_data); 3501 writeq(nic->msix_info[i].data, &bar0->xmsi_data);
3143 val64 = (BIT(7) | BIT(15) | vBIT(i, 26, 6)); 3502 val64 = (BIT(7) | BIT(15) | vBIT(i, 26, 6));
@@ -3156,7 +3515,7 @@ static void store_xmsi_data(nic_t *nic)
3156 int i; 3515 int i;
3157 3516
3158 /* Store and display */ 3517 /* Store and display */
3159 for (i=0; i< MAX_REQUESTED_MSI_X; i++) { 3518 for (i=0; i< nic->avail_msix_vectors; i++) {
3160 val64 = (BIT(15) | vBIT(i, 26, 6)); 3519 val64 = (BIT(15) | vBIT(i, 26, 6));
3161 writeq(val64, &bar0->xmsi_access); 3520 writeq(val64, &bar0->xmsi_access);
3162 if (wait_for_msix_trans(nic, i)) { 3521 if (wait_for_msix_trans(nic, i)) {
@@ -3284,15 +3643,24 @@ static int s2io_enable_msi_x(nic_t *nic)
3284 writeq(tx_mat, &bar0->tx_mat0_n[7]); 3643 writeq(tx_mat, &bar0->tx_mat0_n[7]);
3285 } 3644 }
3286 3645
3646 nic->avail_msix_vectors = 0;
3287 ret = pci_enable_msix(nic->pdev, nic->entries, MAX_REQUESTED_MSI_X); 3647 ret = pci_enable_msix(nic->pdev, nic->entries, MAX_REQUESTED_MSI_X);
3648 /* We fail init if error or we get less vectors than min required */
3649 if (ret >= (nic->config.tx_fifo_num + nic->config.rx_ring_num + 1)) {
3650 nic->avail_msix_vectors = ret;
3651 ret = pci_enable_msix(nic->pdev, nic->entries, ret);
3652 }
3288 if (ret) { 3653 if (ret) {
3289 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); 3654 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name);
3290 kfree(nic->entries); 3655 kfree(nic->entries);
3291 kfree(nic->s2io_entries); 3656 kfree(nic->s2io_entries);
3292 nic->entries = NULL; 3657 nic->entries = NULL;
3293 nic->s2io_entries = NULL; 3658 nic->s2io_entries = NULL;
3659 nic->avail_msix_vectors = 0;
3294 return -ENOMEM; 3660 return -ENOMEM;
3295 } 3661 }
3662 if (!nic->avail_msix_vectors)
3663 nic->avail_msix_vectors = MAX_REQUESTED_MSI_X;
3296 3664
3297 /* 3665 /*
3298 * To enable MSI-X, MSI also needs to be enabled, due to a bug 3666 * To enable MSI-X, MSI also needs to be enabled, due to a bug
@@ -3325,8 +3693,6 @@ static int s2io_open(struct net_device *dev)
3325{ 3693{
3326 nic_t *sp = dev->priv; 3694 nic_t *sp = dev->priv;
3327 int err = 0; 3695 int err = 0;
3328 int i;
3329 u16 msi_control; /* Temp variable */
3330 3696
3331 /* 3697 /*
3332 * Make sure you have link off by default every time 3698 * Make sure you have link off by default every time
@@ -3336,11 +3702,14 @@ static int s2io_open(struct net_device *dev)
3336 sp->last_link_state = 0; 3702 sp->last_link_state = 0;
3337 3703
3338 /* Initialize H/W and enable interrupts */ 3704 /* Initialize H/W and enable interrupts */
3339 if (s2io_card_up(sp)) { 3705 err = s2io_card_up(sp);
3706 if (err) {
3340 DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n", 3707 DBG_PRINT(ERR_DBG, "%s: H/W initialization failed\n",
3341 dev->name); 3708 dev->name);
3342 err = -ENODEV; 3709 if (err == -ENODEV)
3343 goto hw_init_failed; 3710 goto hw_init_failed;
3711 else
3712 goto hw_enable_failed;
3344 } 3713 }
3345 3714
3346 /* Store the values of the MSIX table in the nic_t structure */ 3715 /* Store the values of the MSIX table in the nic_t structure */
@@ -3357,6 +3726,8 @@ failed\n", dev->name);
3357 } 3726 }
3358 } 3727 }
3359 if (sp->intr_type == MSI_X) { 3728 if (sp->intr_type == MSI_X) {
3729 int i;
3730
3360 for (i=1; (sp->s2io_entries[i].in_use == MSIX_FLG); i++) { 3731 for (i=1; (sp->s2io_entries[i].in_use == MSIX_FLG); i++) {
3361 if (sp->s2io_entries[i].type == MSIX_FIFO_TYPE) { 3732 if (sp->s2io_entries[i].type == MSIX_FIFO_TYPE) {
3362 sprintf(sp->desc1, "%s:MSI-X-%d-TX", 3733 sprintf(sp->desc1, "%s:MSI-X-%d-TX",
@@ -3409,24 +3780,26 @@ setting_mac_address_failed:
3409isr_registration_failed: 3780isr_registration_failed:
3410 del_timer_sync(&sp->alarm_timer); 3781 del_timer_sync(&sp->alarm_timer);
3411 if (sp->intr_type == MSI_X) { 3782 if (sp->intr_type == MSI_X) {
3412 if (sp->device_type == XFRAME_II_DEVICE) { 3783 int i;
3413 for (i=1; (sp->s2io_entries[i].in_use == 3784 u16 msi_control; /* Temp variable */
3414 MSIX_REGISTERED_SUCCESS); i++) {
3415 int vector = sp->entries[i].vector;
3416 void *arg = sp->s2io_entries[i].arg;
3417 3785
3418 free_irq(vector, arg); 3786 for (i=1; (sp->s2io_entries[i].in_use ==
3419 } 3787 MSIX_REGISTERED_SUCCESS); i++) {
3420 pci_disable_msix(sp->pdev); 3788 int vector = sp->entries[i].vector;
3789 void *arg = sp->s2io_entries[i].arg;
3421 3790
3422 /* Temp */ 3791 free_irq(vector, arg);
3423 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3424 msi_control &= 0xFFFE; /* Disable MSI */
3425 pci_write_config_word(sp->pdev, 0x42, msi_control);
3426 } 3792 }
3793 pci_disable_msix(sp->pdev);
3794
3795 /* Temp */
3796 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3797 msi_control &= 0xFFFE; /* Disable MSI */
3798 pci_write_config_word(sp->pdev, 0x42, msi_control);
3427 } 3799 }
3428 else if (sp->intr_type == MSI) 3800 else if (sp->intr_type == MSI)
3429 pci_disable_msi(sp->pdev); 3801 pci_disable_msi(sp->pdev);
3802hw_enable_failed:
3430 s2io_reset(sp); 3803 s2io_reset(sp);
3431hw_init_failed: 3804hw_init_failed:
3432 if (sp->intr_type == MSI_X) { 3805 if (sp->intr_type == MSI_X) {
@@ -3454,35 +3827,12 @@ hw_init_failed:
3454static int s2io_close(struct net_device *dev) 3827static int s2io_close(struct net_device *dev)
3455{ 3828{
3456 nic_t *sp = dev->priv; 3829 nic_t *sp = dev->priv;
3457 int i;
3458 u16 msi_control;
3459 3830
3460 flush_scheduled_work(); 3831 flush_scheduled_work();
3461 netif_stop_queue(dev); 3832 netif_stop_queue(dev);
3462 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3833 /* Reset card, kill tasklet and free Tx and Rx buffers. */
3463 s2io_card_down(sp); 3834 s2io_card_down(sp, 1);
3464
3465 if (sp->intr_type == MSI_X) {
3466 if (sp->device_type == XFRAME_II_DEVICE) {
3467 for (i=1; (sp->s2io_entries[i].in_use ==
3468 MSIX_REGISTERED_SUCCESS); i++) {
3469 int vector = sp->entries[i].vector;
3470 void *arg = sp->s2io_entries[i].arg;
3471 3835
3472 free_irq(vector, arg);
3473 }
3474 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3475 msi_control &= 0xFFFE; /* Disable MSI */
3476 pci_write_config_word(sp->pdev, 0x42, msi_control);
3477
3478 pci_disable_msix(sp->pdev);
3479 }
3480 }
3481 else {
3482 free_irq(sp->pdev->irq, dev);
3483 if (sp->intr_type == MSI)
3484 pci_disable_msi(sp->pdev);
3485 }
3486 sp->device_close_flag = TRUE; /* Device is shut down. */ 3836 sp->device_close_flag = TRUE; /* Device is shut down. */
3487 return 0; 3837 return 0;
3488} 3838}
@@ -3545,7 +3895,8 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3545 3895
3546 queue_len = mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1; 3896 queue_len = mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1;
3547 /* Avoid "put" pointer going beyond "get" pointer */ 3897 /* Avoid "put" pointer going beyond "get" pointer */
3548 if (txdp->Host_Control || (((put_off + 1) % queue_len) == get_off)) { 3898 if (txdp->Host_Control ||
3899 ((put_off+1) == queue_len ? 0 : (put_off+1)) == get_off) {
3549 DBG_PRINT(TX_DBG, "Error in xmit, No free TXDs.\n"); 3900 DBG_PRINT(TX_DBG, "Error in xmit, No free TXDs.\n");
3550 netif_stop_queue(dev); 3901 netif_stop_queue(dev);
3551 dev_kfree_skb(skb); 3902 dev_kfree_skb(skb);
@@ -3655,11 +4006,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3655 mmiowb(); 4006 mmiowb();
3656 4007
3657 put_off++; 4008 put_off++;
3658 put_off %= mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1; 4009 if (put_off == mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1)
4010 put_off = 0;
3659 mac_control->fifos[queue].tx_curr_put_info.offset = put_off; 4011 mac_control->fifos[queue].tx_curr_put_info.offset = put_off;
3660 4012
3661 /* Avoid "put" pointer going beyond "get" pointer */ 4013 /* Avoid "put" pointer going beyond "get" pointer */
3662 if (((put_off + 1) % queue_len) == get_off) { 4014 if (((put_off+1) == queue_len ? 0 : (put_off+1)) == get_off) {
4015 sp->mac_control.stats_info->sw_stat.fifo_full_cnt++;
3663 DBG_PRINT(TX_DBG, 4016 DBG_PRINT(TX_DBG,
3664 "No free TxDs for xmit, Put: 0x%x Get:0x%x\n", 4017 "No free TxDs for xmit, Put: 0x%x Get:0x%x\n",
3665 put_off, get_off); 4018 put_off, get_off);
@@ -3795,7 +4148,6 @@ s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs)
3795 atomic_dec(&sp->isr_cnt); 4148 atomic_dec(&sp->isr_cnt);
3796 return IRQ_HANDLED; 4149 return IRQ_HANDLED;
3797} 4150}
3798
3799static void s2io_txpic_intr_handle(nic_t *sp) 4151static void s2io_txpic_intr_handle(nic_t *sp)
3800{ 4152{
3801 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4153 XENA_dev_config_t __iomem *bar0 = sp->bar0;
@@ -3806,41 +4158,56 @@ static void s2io_txpic_intr_handle(nic_t *sp)
3806 val64 = readq(&bar0->gpio_int_reg); 4158 val64 = readq(&bar0->gpio_int_reg);
3807 if ((val64 & GPIO_INT_REG_LINK_DOWN) && 4159 if ((val64 & GPIO_INT_REG_LINK_DOWN) &&
3808 (val64 & GPIO_INT_REG_LINK_UP)) { 4160 (val64 & GPIO_INT_REG_LINK_UP)) {
4161 /*
4162 * This is unstable state so clear both up/down
4163 * interrupt and adapter to re-evaluate the link state.
4164 */
3809 val64 |= GPIO_INT_REG_LINK_DOWN; 4165 val64 |= GPIO_INT_REG_LINK_DOWN;
3810 val64 |= GPIO_INT_REG_LINK_UP; 4166 val64 |= GPIO_INT_REG_LINK_UP;
3811 writeq(val64, &bar0->gpio_int_reg); 4167 writeq(val64, &bar0->gpio_int_reg);
3812 goto masking;
3813 }
3814
3815 if (((sp->last_link_state == LINK_UP) &&
3816 (val64 & GPIO_INT_REG_LINK_DOWN)) ||
3817 ((sp->last_link_state == LINK_DOWN) &&
3818 (val64 & GPIO_INT_REG_LINK_UP))) {
3819 val64 = readq(&bar0->gpio_int_mask); 4168 val64 = readq(&bar0->gpio_int_mask);
3820 val64 |= GPIO_INT_MASK_LINK_DOWN; 4169 val64 &= ~(GPIO_INT_MASK_LINK_UP |
3821 val64 |= GPIO_INT_MASK_LINK_UP; 4170 GPIO_INT_MASK_LINK_DOWN);
3822 writeq(val64, &bar0->gpio_int_mask); 4171 writeq(val64, &bar0->gpio_int_mask);
3823 s2io_set_link((unsigned long)sp);
3824 } 4172 }
3825masking: 4173 else if (val64 & GPIO_INT_REG_LINK_UP) {
3826 if (sp->last_link_state == LINK_UP) { 4174 val64 = readq(&bar0->adapter_status);
3827 /*enable down interrupt */ 4175 if (verify_xena_quiescence(sp, val64,
3828 val64 = readq(&bar0->gpio_int_mask); 4176 sp->device_enabled_once)) {
3829 /* unmasks link down intr */ 4177 /* Enable Adapter */
3830 val64 &= ~GPIO_INT_MASK_LINK_DOWN; 4178 val64 = readq(&bar0->adapter_control);
3831 /* masks link up intr */ 4179 val64 |= ADAPTER_CNTL_EN;
3832 val64 |= GPIO_INT_MASK_LINK_UP; 4180 writeq(val64, &bar0->adapter_control);
3833 writeq(val64, &bar0->gpio_int_mask); 4181 val64 |= ADAPTER_LED_ON;
3834 } else { 4182 writeq(val64, &bar0->adapter_control);
3835 /*enable UP Interrupt */ 4183 if (!sp->device_enabled_once)
3836 val64 = readq(&bar0->gpio_int_mask); 4184 sp->device_enabled_once = 1;
3837 /* unmasks link up interrupt */ 4185
3838 val64 &= ~GPIO_INT_MASK_LINK_UP; 4186 s2io_link(sp, LINK_UP);
3839 /* masks link down interrupt */ 4187 /*
3840 val64 |= GPIO_INT_MASK_LINK_DOWN; 4188 * unmask link down interrupt and mask link-up
3841 writeq(val64, &bar0->gpio_int_mask); 4189 * intr
4190 */
4191 val64 = readq(&bar0->gpio_int_mask);
4192 val64 &= ~GPIO_INT_MASK_LINK_DOWN;
4193 val64 |= GPIO_INT_MASK_LINK_UP;
4194 writeq(val64, &bar0->gpio_int_mask);
4195
4196 }
4197 }else if (val64 & GPIO_INT_REG_LINK_DOWN) {
4198 val64 = readq(&bar0->adapter_status);
4199 if (verify_xena_quiescence(sp, val64,
4200 sp->device_enabled_once)) {
4201 s2io_link(sp, LINK_DOWN);
4202 /* Link is down so unmaks link up interrupt */
4203 val64 = readq(&bar0->gpio_int_mask);
4204 val64 &= ~GPIO_INT_MASK_LINK_UP;
4205 val64 |= GPIO_INT_MASK_LINK_DOWN;
4206 writeq(val64, &bar0->gpio_int_mask);
4207 }
3842 } 4208 }
3843 } 4209 }
4210 val64 = readq(&bar0->gpio_int_mask);
3844} 4211}
3845 4212
3846/** 4213/**
@@ -3863,7 +4230,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
3863 nic_t *sp = dev->priv; 4230 nic_t *sp = dev->priv;
3864 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4231 XENA_dev_config_t __iomem *bar0 = sp->bar0;
3865 int i; 4232 int i;
3866 u64 reason = 0, val64; 4233 u64 reason = 0, val64, org_mask;
3867 mac_info_t *mac_control; 4234 mac_info_t *mac_control;
3868 struct config_param *config; 4235 struct config_param *config;
3869 4236
@@ -3887,43 +4254,41 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
3887 return IRQ_NONE; 4254 return IRQ_NONE;
3888 } 4255 }
3889 4256
4257 val64 = 0xFFFFFFFFFFFFFFFFULL;
4258 /* Store current mask before masking all interrupts */
4259 org_mask = readq(&bar0->general_int_mask);
4260 writeq(val64, &bar0->general_int_mask);
4261
3890#ifdef CONFIG_S2IO_NAPI 4262#ifdef CONFIG_S2IO_NAPI
3891 if (reason & GEN_INTR_RXTRAFFIC) { 4263 if (reason & GEN_INTR_RXTRAFFIC) {
3892 if (netif_rx_schedule_prep(dev)) { 4264 if (netif_rx_schedule_prep(dev)) {
3893 en_dis_able_nic_intrs(sp, RX_TRAFFIC_INTR, 4265 writeq(val64, &bar0->rx_traffic_mask);
3894 DISABLE_INTRS);
3895 __netif_rx_schedule(dev); 4266 __netif_rx_schedule(dev);
3896 } 4267 }
3897 } 4268 }
3898#else 4269#else
3899 /* If Intr is because of Rx Traffic */ 4270 /*
3900 if (reason & GEN_INTR_RXTRAFFIC) { 4271 * Rx handler is called by default, without checking for the
3901 /* 4272 * cause of interrupt.
3902 * rx_traffic_int reg is an R1 register, writing all 1's 4273 * rx_traffic_int reg is an R1 register, writing all 1's
3903 * will ensure that the actual interrupt causing bit get's 4274 * will ensure that the actual interrupt causing bit get's
3904 * cleared and hence a read can be avoided. 4275 * cleared and hence a read can be avoided.
3905 */ 4276 */
3906 val64 = 0xFFFFFFFFFFFFFFFFULL; 4277 writeq(val64, &bar0->rx_traffic_int);
3907 writeq(val64, &bar0->rx_traffic_int); 4278 for (i = 0; i < config->rx_ring_num; i++) {
3908 for (i = 0; i < config->rx_ring_num; i++) { 4279 rx_intr_handler(&mac_control->rings[i]);
3909 rx_intr_handler(&mac_control->rings[i]);
3910 }
3911 } 4280 }
3912#endif 4281#endif
3913 4282
3914 /* If Intr is because of Tx Traffic */ 4283 /*
3915 if (reason & GEN_INTR_TXTRAFFIC) { 4284 * tx_traffic_int reg is an R1 register, writing all 1's
3916 /* 4285 * will ensure that the actual interrupt causing bit get's
3917 * tx_traffic_int reg is an R1 register, writing all 1's 4286 * cleared and hence a read can be avoided.
3918 * will ensure that the actual interrupt causing bit get's 4287 */
3919 * cleared and hence a read can be avoided. 4288 writeq(val64, &bar0->tx_traffic_int);
3920 */
3921 val64 = 0xFFFFFFFFFFFFFFFFULL;
3922 writeq(val64, &bar0->tx_traffic_int);
3923 4289
3924 for (i = 0; i < config->tx_fifo_num; i++) 4290 for (i = 0; i < config->tx_fifo_num; i++)
3925 tx_intr_handler(&mac_control->fifos[i]); 4291 tx_intr_handler(&mac_control->fifos[i]);
3926 }
3927 4292
3928 if (reason & GEN_INTR_TXPIC) 4293 if (reason & GEN_INTR_TXPIC)
3929 s2io_txpic_intr_handle(sp); 4294 s2io_txpic_intr_handle(sp);
@@ -3949,6 +4314,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
3949 DBG_PRINT(ERR_DBG, " in ISR!!\n"); 4314 DBG_PRINT(ERR_DBG, " in ISR!!\n");
3950 clear_bit(0, (&sp->tasklet_status)); 4315 clear_bit(0, (&sp->tasklet_status));
3951 atomic_dec(&sp->isr_cnt); 4316 atomic_dec(&sp->isr_cnt);
4317 writeq(org_mask, &bar0->general_int_mask);
3952 return IRQ_HANDLED; 4318 return IRQ_HANDLED;
3953 } 4319 }
3954 clear_bit(0, (&sp->tasklet_status)); 4320 clear_bit(0, (&sp->tasklet_status));
@@ -3964,7 +4330,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs)
3964 } 4330 }
3965 } 4331 }
3966#endif 4332#endif
3967 4333 writeq(org_mask, &bar0->general_int_mask);
3968 atomic_dec(&sp->isr_cnt); 4334 atomic_dec(&sp->isr_cnt);
3969 return IRQ_HANDLED; 4335 return IRQ_HANDLED;
3970} 4336}
@@ -4067,7 +4433,8 @@ static void s2io_set_multicast(struct net_device *dev)
4067 RMAC_ADDR_CMD_MEM_OFFSET(MAC_MC_ALL_MC_ADDR_OFFSET); 4433 RMAC_ADDR_CMD_MEM_OFFSET(MAC_MC_ALL_MC_ADDR_OFFSET);
4068 writeq(val64, &bar0->rmac_addr_cmd_mem); 4434 writeq(val64, &bar0->rmac_addr_cmd_mem);
4069 /* Wait till command completes */ 4435 /* Wait till command completes */
4070 wait_for_cmd_complete(sp); 4436 wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem,
4437 RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING);
4071 4438
4072 sp->m_cast_flg = 1; 4439 sp->m_cast_flg = 1;
4073 sp->all_multi_pos = MAC_MC_ALL_MC_ADDR_OFFSET; 4440 sp->all_multi_pos = MAC_MC_ALL_MC_ADDR_OFFSET;
@@ -4082,7 +4449,8 @@ static void s2io_set_multicast(struct net_device *dev)
4082 RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos); 4449 RMAC_ADDR_CMD_MEM_OFFSET(sp->all_multi_pos);
4083 writeq(val64, &bar0->rmac_addr_cmd_mem); 4450 writeq(val64, &bar0->rmac_addr_cmd_mem);
4084 /* Wait till command completes */ 4451 /* Wait till command completes */
4085 wait_for_cmd_complete(sp); 4452 wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem,
4453 RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING);
4086 4454
4087 sp->m_cast_flg = 0; 4455 sp->m_cast_flg = 0;
4088 sp->all_multi_pos = 0; 4456 sp->all_multi_pos = 0;
@@ -4147,7 +4515,8 @@ static void s2io_set_multicast(struct net_device *dev)
4147 writeq(val64, &bar0->rmac_addr_cmd_mem); 4515 writeq(val64, &bar0->rmac_addr_cmd_mem);
4148 4516
4149 /* Wait for command completes */ 4517 /* Wait for command completes */
4150 if (wait_for_cmd_complete(sp)) { 4518 if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem,
4519 RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING)) {
4151 DBG_PRINT(ERR_DBG, "%s: Adding ", 4520 DBG_PRINT(ERR_DBG, "%s: Adding ",
4152 dev->name); 4521 dev->name);
4153 DBG_PRINT(ERR_DBG, "Multicasts failed\n"); 4522 DBG_PRINT(ERR_DBG, "Multicasts failed\n");
@@ -4177,7 +4546,8 @@ static void s2io_set_multicast(struct net_device *dev)
4177 writeq(val64, &bar0->rmac_addr_cmd_mem); 4546 writeq(val64, &bar0->rmac_addr_cmd_mem);
4178 4547
4179 /* Wait for command completes */ 4548 /* Wait for command completes */
4180 if (wait_for_cmd_complete(sp)) { 4549 if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem,
4550 RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING)) {
4181 DBG_PRINT(ERR_DBG, "%s: Adding ", 4551 DBG_PRINT(ERR_DBG, "%s: Adding ",
4182 dev->name); 4552 dev->name);
4183 DBG_PRINT(ERR_DBG, "Multicasts failed\n"); 4553 DBG_PRINT(ERR_DBG, "Multicasts failed\n");
@@ -4222,7 +4592,8 @@ static int s2io_set_mac_addr(struct net_device *dev, u8 * addr)
4222 RMAC_ADDR_CMD_MEM_OFFSET(0); 4592 RMAC_ADDR_CMD_MEM_OFFSET(0);
4223 writeq(val64, &bar0->rmac_addr_cmd_mem); 4593 writeq(val64, &bar0->rmac_addr_cmd_mem);
4224 /* Wait till command completes */ 4594 /* Wait till command completes */
4225 if (wait_for_cmd_complete(sp)) { 4595 if (wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem,
4596 RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING)) {
4226 DBG_PRINT(ERR_DBG, "%s: set_mac_addr failed\n", dev->name); 4597 DBG_PRINT(ERR_DBG, "%s: set_mac_addr failed\n", dev->name);
4227 return FAILURE; 4598 return FAILURE;
4228 } 4599 }
@@ -4619,6 +4990,44 @@ static int write_eeprom(nic_t * sp, int off, u64 data, int cnt)
4619 } 4990 }
4620 return ret; 4991 return ret;
4621} 4992}
4993static void s2io_vpd_read(nic_t *nic)
4994{
4995 u8 vpd_data[256],data;
4996 int i=0, cnt, fail = 0;
4997 int vpd_addr = 0x80;
4998
4999 if (nic->device_type == XFRAME_II_DEVICE) {
5000 strcpy(nic->product_name, "Xframe II 10GbE network adapter");
5001 vpd_addr = 0x80;
5002 }
5003 else {
5004 strcpy(nic->product_name, "Xframe I 10GbE network adapter");
5005 vpd_addr = 0x50;
5006 }
5007
5008 for (i = 0; i < 256; i +=4 ) {
5009 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i);
5010 pci_read_config_byte(nic->pdev, (vpd_addr + 2), &data);
5011 pci_write_config_byte(nic->pdev, (vpd_addr + 3), 0);
5012 for (cnt = 0; cnt <5; cnt++) {
5013 msleep(2);
5014 pci_read_config_byte(nic->pdev, (vpd_addr + 3), &data);
5015 if (data == 0x80)
5016 break;
5017 }
5018 if (cnt >= 5) {
5019 DBG_PRINT(ERR_DBG, "Read of VPD data failed\n");
5020 fail = 1;
5021 break;
5022 }
5023 pci_read_config_dword(nic->pdev, (vpd_addr + 4),
5024 (u32 *)&vpd_data[i]);
5025 }
5026 if ((!fail) && (vpd_data[1] < VPD_PRODUCT_NAME_LEN)) {
5027 memset(nic->product_name, 0, vpd_data[1]);
5028 memcpy(nic->product_name, &vpd_data[3], vpd_data[1]);
5029 }
5030}
4622 5031
4623/** 5032/**
4624 * s2io_ethtool_geeprom - reads the value stored in the Eeprom. 5033 * s2io_ethtool_geeprom - reads the value stored in the Eeprom.
@@ -4931,8 +5340,10 @@ static int s2io_link_test(nic_t * sp, uint64_t * data)
4931 u64 val64; 5340 u64 val64;
4932 5341
4933 val64 = readq(&bar0->adapter_status); 5342 val64 = readq(&bar0->adapter_status);
4934 if (val64 & ADAPTER_STATUS_RMAC_LOCAL_FAULT) 5343 if(!(LINK_IS_UP(val64)))
4935 *data = 1; 5344 *data = 1;
5345 else
5346 *data = 0;
4936 5347
4937 return 0; 5348 return 0;
4938} 5349}
@@ -5112,7 +5523,6 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5112 int i = 0; 5523 int i = 0;
5113 nic_t *sp = dev->priv; 5524 nic_t *sp = dev->priv;
5114 StatInfo_t *stat_info = sp->mac_control.stats_info; 5525 StatInfo_t *stat_info = sp->mac_control.stats_info;
5115 u64 tmp;
5116 5526
5117 s2io_updt_stats(sp); 5527 s2io_updt_stats(sp);
5118 tmp_stats[i++] = 5528 tmp_stats[i++] =
@@ -5129,9 +5539,19 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5129 (u64)le32_to_cpu(stat_info->tmac_bcst_frms_oflow) << 32 | 5539 (u64)le32_to_cpu(stat_info->tmac_bcst_frms_oflow) << 32 |
5130 le32_to_cpu(stat_info->tmac_bcst_frms); 5540 le32_to_cpu(stat_info->tmac_bcst_frms);
5131 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_pause_ctrl_frms); 5541 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_pause_ctrl_frms);
5542 tmp_stats[i++] =
5543 (u64)le32_to_cpu(stat_info->tmac_ttl_octets_oflow) << 32 |
5544 le32_to_cpu(stat_info->tmac_ttl_octets);
5545 tmp_stats[i++] =
5546 (u64)le32_to_cpu(stat_info->tmac_ucst_frms_oflow) << 32 |
5547 le32_to_cpu(stat_info->tmac_ucst_frms);
5548 tmp_stats[i++] =
5549 (u64)le32_to_cpu(stat_info->tmac_nucst_frms_oflow) << 32 |
5550 le32_to_cpu(stat_info->tmac_nucst_frms);
5132 tmp_stats[i++] = 5551 tmp_stats[i++] =
5133 (u64)le32_to_cpu(stat_info->tmac_any_err_frms_oflow) << 32 | 5552 (u64)le32_to_cpu(stat_info->tmac_any_err_frms_oflow) << 32 |
5134 le32_to_cpu(stat_info->tmac_any_err_frms); 5553 le32_to_cpu(stat_info->tmac_any_err_frms);
5554 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_ttl_less_fb_octets);
5135 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_vld_ip_octets); 5555 tmp_stats[i++] = le64_to_cpu(stat_info->tmac_vld_ip_octets);
5136 tmp_stats[i++] = 5556 tmp_stats[i++] =
5137 (u64)le32_to_cpu(stat_info->tmac_vld_ip_oflow) << 32 | 5557 (u64)le32_to_cpu(stat_info->tmac_vld_ip_oflow) << 32 |
@@ -5163,11 +5583,27 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5163 (u64)le32_to_cpu(stat_info->rmac_vld_bcst_frms_oflow) << 32 | 5583 (u64)le32_to_cpu(stat_info->rmac_vld_bcst_frms_oflow) << 32 |
5164 le32_to_cpu(stat_info->rmac_vld_bcst_frms); 5584 le32_to_cpu(stat_info->rmac_vld_bcst_frms);
5165 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_in_rng_len_err_frms); 5585 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_in_rng_len_err_frms);
5586 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_out_rng_len_err_frms);
5166 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_long_frms); 5587 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_long_frms);
5167 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_pause_ctrl_frms); 5588 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_pause_ctrl_frms);
5589 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_unsup_ctrl_frms);
5590 tmp_stats[i++] =
5591 (u64)le32_to_cpu(stat_info->rmac_ttl_octets_oflow) << 32 |
5592 le32_to_cpu(stat_info->rmac_ttl_octets);
5593 tmp_stats[i++] =
5594 (u64)le32_to_cpu(stat_info->rmac_accepted_ucst_frms_oflow)
5595 << 32 | le32_to_cpu(stat_info->rmac_accepted_ucst_frms);
5596 tmp_stats[i++] =
5597 (u64)le32_to_cpu(stat_info->rmac_accepted_nucst_frms_oflow)
5598 << 32 | le32_to_cpu(stat_info->rmac_accepted_nucst_frms);
5168 tmp_stats[i++] = 5599 tmp_stats[i++] =
5169 (u64)le32_to_cpu(stat_info->rmac_discarded_frms_oflow) << 32 | 5600 (u64)le32_to_cpu(stat_info->rmac_discarded_frms_oflow) << 32 |
5170 le32_to_cpu(stat_info->rmac_discarded_frms); 5601 le32_to_cpu(stat_info->rmac_discarded_frms);
5602 tmp_stats[i++] =
5603 (u64)le32_to_cpu(stat_info->rmac_drop_events_oflow)
5604 << 32 | le32_to_cpu(stat_info->rmac_drop_events);
5605 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_less_fb_octets);
5606 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_frms);
5171 tmp_stats[i++] = 5607 tmp_stats[i++] =
5172 (u64)le32_to_cpu(stat_info->rmac_usized_frms_oflow) << 32 | 5608 (u64)le32_to_cpu(stat_info->rmac_usized_frms_oflow) << 32 |
5173 le32_to_cpu(stat_info->rmac_usized_frms); 5609 le32_to_cpu(stat_info->rmac_usized_frms);
@@ -5180,40 +5616,129 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5180 tmp_stats[i++] = 5616 tmp_stats[i++] =
5181 (u64)le32_to_cpu(stat_info->rmac_jabber_frms_oflow) << 32 | 5617 (u64)le32_to_cpu(stat_info->rmac_jabber_frms_oflow) << 32 |
5182 le32_to_cpu(stat_info->rmac_jabber_frms); 5618 le32_to_cpu(stat_info->rmac_jabber_frms);
5183 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_ip_oflow) << 32 | 5619 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_64_frms);
5620 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_65_127_frms);
5621 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_128_255_frms);
5622 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_256_511_frms);
5623 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_512_1023_frms);
5624 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_1024_1518_frms);
5625 tmp_stats[i++] =
5626 (u64)le32_to_cpu(stat_info->rmac_ip_oflow) << 32 |
5184 le32_to_cpu(stat_info->rmac_ip); 5627 le32_to_cpu(stat_info->rmac_ip);
5185 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ip_octets); 5628 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ip_octets);
5186 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_hdr_err_ip); 5629 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_hdr_err_ip);
5187 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_drop_ip_oflow) << 32 | 5630 tmp_stats[i++] =
5631 (u64)le32_to_cpu(stat_info->rmac_drop_ip_oflow) << 32 |
5188 le32_to_cpu(stat_info->rmac_drop_ip); 5632 le32_to_cpu(stat_info->rmac_drop_ip);
5189 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_icmp_oflow) << 32 | 5633 tmp_stats[i++] =
5634 (u64)le32_to_cpu(stat_info->rmac_icmp_oflow) << 32 |
5190 le32_to_cpu(stat_info->rmac_icmp); 5635 le32_to_cpu(stat_info->rmac_icmp);
5191 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_tcp); 5636 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_tcp);
5192 tmp_stats[i++] = (u64)le32_to_cpu(stat_info->rmac_udp_oflow) << 32 | 5637 tmp_stats[i++] =
5638 (u64)le32_to_cpu(stat_info->rmac_udp_oflow) << 32 |
5193 le32_to_cpu(stat_info->rmac_udp); 5639 le32_to_cpu(stat_info->rmac_udp);
5194 tmp_stats[i++] = 5640 tmp_stats[i++] =
5195 (u64)le32_to_cpu(stat_info->rmac_err_drp_udp_oflow) << 32 | 5641 (u64)le32_to_cpu(stat_info->rmac_err_drp_udp_oflow) << 32 |
5196 le32_to_cpu(stat_info->rmac_err_drp_udp); 5642 le32_to_cpu(stat_info->rmac_err_drp_udp);
5643 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_xgmii_err_sym);
5644 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q0);
5645 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q1);
5646 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q2);
5647 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q3);
5648 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q4);
5649 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q5);
5650 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q6);
5651 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_frms_q7);
5652 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q0);
5653 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q1);
5654 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q2);
5655 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q3);
5656 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q4);
5657 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q5);
5658 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q6);
5659 tmp_stats[i++] = le16_to_cpu(stat_info->rmac_full_q7);
5197 tmp_stats[i++] = 5660 tmp_stats[i++] =
5198 (u64)le32_to_cpu(stat_info->rmac_pause_cnt_oflow) << 32 | 5661 (u64)le32_to_cpu(stat_info->rmac_pause_cnt_oflow) << 32 |
5199 le32_to_cpu(stat_info->rmac_pause_cnt); 5662 le32_to_cpu(stat_info->rmac_pause_cnt);
5663 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_xgmii_data_err_cnt);
5664 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_xgmii_ctrl_err_cnt);
5200 tmp_stats[i++] = 5665 tmp_stats[i++] =
5201 (u64)le32_to_cpu(stat_info->rmac_accepted_ip_oflow) << 32 | 5666 (u64)le32_to_cpu(stat_info->rmac_accepted_ip_oflow) << 32 |
5202 le32_to_cpu(stat_info->rmac_accepted_ip); 5667 le32_to_cpu(stat_info->rmac_accepted_ip);
5203 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_err_tcp); 5668 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_err_tcp);
5669 tmp_stats[i++] = le32_to_cpu(stat_info->rd_req_cnt);
5670 tmp_stats[i++] = le32_to_cpu(stat_info->new_rd_req_cnt);
5671 tmp_stats[i++] = le32_to_cpu(stat_info->new_rd_req_rtry_cnt);
5672 tmp_stats[i++] = le32_to_cpu(stat_info->rd_rtry_cnt);
5673 tmp_stats[i++] = le32_to_cpu(stat_info->wr_rtry_rd_ack_cnt);
5674 tmp_stats[i++] = le32_to_cpu(stat_info->wr_req_cnt);
5675 tmp_stats[i++] = le32_to_cpu(stat_info->new_wr_req_cnt);
5676 tmp_stats[i++] = le32_to_cpu(stat_info->new_wr_req_rtry_cnt);
5677 tmp_stats[i++] = le32_to_cpu(stat_info->wr_rtry_cnt);
5678 tmp_stats[i++] = le32_to_cpu(stat_info->wr_disc_cnt);
5679 tmp_stats[i++] = le32_to_cpu(stat_info->rd_rtry_wr_ack_cnt);
5680 tmp_stats[i++] = le32_to_cpu(stat_info->txp_wr_cnt);
5681 tmp_stats[i++] = le32_to_cpu(stat_info->txd_rd_cnt);
5682 tmp_stats[i++] = le32_to_cpu(stat_info->txd_wr_cnt);
5683 tmp_stats[i++] = le32_to_cpu(stat_info->rxd_rd_cnt);
5684 tmp_stats[i++] = le32_to_cpu(stat_info->rxd_wr_cnt);
5685 tmp_stats[i++] = le32_to_cpu(stat_info->txf_rd_cnt);
5686 tmp_stats[i++] = le32_to_cpu(stat_info->rxf_wr_cnt);
5687 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_1519_4095_frms);
5688 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_4096_8191_frms);
5689 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_8192_max_frms);
5690 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_ttl_gt_max_frms);
5691 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_osized_alt_frms);
5692 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_jabber_alt_frms);
5693 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_gt_max_alt_frms);
5694 tmp_stats[i++] = le64_to_cpu(stat_info->rmac_vlan_frms);
5695 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_len_discard);
5696 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_fcs_discard);
5697 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_pf_discard);
5698 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_da_discard);
5699 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_red_discard);
5700 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_rts_discard);
5701 tmp_stats[i++] = le32_to_cpu(stat_info->rmac_ingm_full_discard);
5702 tmp_stats[i++] = le32_to_cpu(stat_info->link_fault_cnt);
5204 tmp_stats[i++] = 0; 5703 tmp_stats[i++] = 0;
5205 tmp_stats[i++] = stat_info->sw_stat.single_ecc_errs; 5704 tmp_stats[i++] = stat_info->sw_stat.single_ecc_errs;
5206 tmp_stats[i++] = stat_info->sw_stat.double_ecc_errs; 5705 tmp_stats[i++] = stat_info->sw_stat.double_ecc_errs;
5706 tmp_stats[i++] = stat_info->sw_stat.parity_err_cnt;
5707 tmp_stats[i++] = stat_info->sw_stat.serious_err_cnt;
5708 tmp_stats[i++] = stat_info->sw_stat.soft_reset_cnt;
5709 tmp_stats[i++] = stat_info->sw_stat.fifo_full_cnt;
5710 tmp_stats[i++] = stat_info->sw_stat.ring_full_cnt;
5711 tmp_stats[i++] = stat_info->xpak_stat.alarm_transceiver_temp_high;
5712 tmp_stats[i++] = stat_info->xpak_stat.alarm_transceiver_temp_low;
5713 tmp_stats[i++] = stat_info->xpak_stat.alarm_laser_bias_current_high;
5714 tmp_stats[i++] = stat_info->xpak_stat.alarm_laser_bias_current_low;
5715 tmp_stats[i++] = stat_info->xpak_stat.alarm_laser_output_power_high;
5716 tmp_stats[i++] = stat_info->xpak_stat.alarm_laser_output_power_low;
5717 tmp_stats[i++] = stat_info->xpak_stat.warn_transceiver_temp_high;
5718 tmp_stats[i++] = stat_info->xpak_stat.warn_transceiver_temp_low;
5719 tmp_stats[i++] = stat_info->xpak_stat.warn_laser_bias_current_high;
5720 tmp_stats[i++] = stat_info->xpak_stat.warn_laser_bias_current_low;
5721 tmp_stats[i++] = stat_info->xpak_stat.warn_laser_output_power_high;
5722 tmp_stats[i++] = stat_info->xpak_stat.warn_laser_output_power_low;
5207 tmp_stats[i++] = stat_info->sw_stat.clubbed_frms_cnt; 5723 tmp_stats[i++] = stat_info->sw_stat.clubbed_frms_cnt;
5208 tmp_stats[i++] = stat_info->sw_stat.sending_both; 5724 tmp_stats[i++] = stat_info->sw_stat.sending_both;
5209 tmp_stats[i++] = stat_info->sw_stat.outof_sequence_pkts; 5725 tmp_stats[i++] = stat_info->sw_stat.outof_sequence_pkts;
5210 tmp_stats[i++] = stat_info->sw_stat.flush_max_pkts; 5726 tmp_stats[i++] = stat_info->sw_stat.flush_max_pkts;
5211 tmp = 0;
5212 if (stat_info->sw_stat.num_aggregations) { 5727 if (stat_info->sw_stat.num_aggregations) {
5213 tmp = stat_info->sw_stat.sum_avg_pkts_aggregated; 5728 u64 tmp = stat_info->sw_stat.sum_avg_pkts_aggregated;
5214 do_div(tmp, stat_info->sw_stat.num_aggregations); 5729 int count = 0;
5730 /*
5731 * Since 64-bit divide does not work on all platforms,
5732 * do repeated subtraction.
5733 */
5734 while (tmp >= stat_info->sw_stat.num_aggregations) {
5735 tmp -= stat_info->sw_stat.num_aggregations;
5736 count++;
5737 }
5738 tmp_stats[i++] = count;
5215 } 5739 }
5216 tmp_stats[i++] = tmp; 5740 else
5741 tmp_stats[i++] = 0;
5217} 5742}
5218 5743
5219static int s2io_ethtool_get_regs_len(struct net_device *dev) 5744static int s2io_ethtool_get_regs_len(struct net_device *dev)
@@ -5351,7 +5876,7 @@ static int s2io_change_mtu(struct net_device *dev, int new_mtu)
5351 5876
5352 dev->mtu = new_mtu; 5877 dev->mtu = new_mtu;
5353 if (netif_running(dev)) { 5878 if (netif_running(dev)) {
5354 s2io_card_down(sp); 5879 s2io_card_down(sp, 0);
5355 netif_stop_queue(dev); 5880 netif_stop_queue(dev);
5356 if (s2io_card_up(sp)) { 5881 if (s2io_card_up(sp)) {
5357 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n", 5882 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
@@ -5489,12 +6014,172 @@ static void s2io_set_link(unsigned long data)
5489 clear_bit(0, &(nic->link_state)); 6014 clear_bit(0, &(nic->link_state));
5490} 6015}
5491 6016
5492static void s2io_card_down(nic_t * sp) 6017static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
6018 struct sk_buff **skb, u64 *temp0, u64 *temp1,
6019 u64 *temp2, int size)
6020{
6021 struct net_device *dev = sp->dev;
6022 struct sk_buff *frag_list;
6023
6024 if ((sp->rxd_mode == RXD_MODE_1) && (rxdp->Host_Control == 0)) {
6025 /* allocate skb */
6026 if (*skb) {
6027 DBG_PRINT(INFO_DBG, "SKB is not NULL\n");
6028 /*
6029 * As Rx frame are not going to be processed,
6030 * using same mapped address for the Rxd
6031 * buffer pointer
6032 */
6033 ((RxD1_t*)rxdp)->Buffer0_ptr = *temp0;
6034 } else {
6035 *skb = dev_alloc_skb(size);
6036 if (!(*skb)) {
6037 DBG_PRINT(ERR_DBG, "%s: Out of ", dev->name);
6038 DBG_PRINT(ERR_DBG, "memory to allocate SKBs\n");
6039 return -ENOMEM ;
6040 }
6041 /* storing the mapped addr in a temp variable
6042 * such it will be used for next rxd whose
6043 * Host Control is NULL
6044 */
6045 ((RxD1_t*)rxdp)->Buffer0_ptr = *temp0 =
6046 pci_map_single( sp->pdev, (*skb)->data,
6047 size - NET_IP_ALIGN,
6048 PCI_DMA_FROMDEVICE);
6049 rxdp->Host_Control = (unsigned long) (*skb);
6050 }
6051 } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) {
6052 /* Two buffer Mode */
6053 if (*skb) {
6054 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
6055 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0;
6056 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
6057 } else {
6058 *skb = dev_alloc_skb(size);
6059 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
6060 pci_map_single(sp->pdev, (*skb)->data,
6061 dev->mtu + 4,
6062 PCI_DMA_FROMDEVICE);
6063 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
6064 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN,
6065 PCI_DMA_FROMDEVICE);
6066 rxdp->Host_Control = (unsigned long) (*skb);
6067
6068 /* Buffer-1 will be dummy buffer not used */
6069 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1 =
6070 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN,
6071 PCI_DMA_FROMDEVICE);
6072 }
6073 } else if ((rxdp->Host_Control == 0)) {
6074 /* Three buffer mode */
6075 if (*skb) {
6076 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0;
6077 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
6078 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
6079 } else {
6080 *skb = dev_alloc_skb(size);
6081
6082 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
6083 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6084 PCI_DMA_FROMDEVICE);
6085 /* Buffer-1 receives L3/L4 headers */
6086 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1 =
6087 pci_map_single( sp->pdev, (*skb)->data,
6088 l3l4hdr_size + 4,
6089 PCI_DMA_FROMDEVICE);
6090 /*
6091 * skb_shinfo(skb)->frag_list will have L4
6092 * data payload
6093 */
6094 skb_shinfo(*skb)->frag_list = dev_alloc_skb(dev->mtu +
6095 ALIGN_SIZE);
6096 if (skb_shinfo(*skb)->frag_list == NULL) {
6097 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \
6098 failed\n ", dev->name);
6099 return -ENOMEM ;
6100 }
6101 frag_list = skb_shinfo(*skb)->frag_list;
6102 frag_list->next = NULL;
6103 /*
6104 * Buffer-2 receives L4 data payload
6105 */
6106 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
6107 pci_map_single( sp->pdev, frag_list->data,
6108 dev->mtu, PCI_DMA_FROMDEVICE);
6109 }
6110 }
6111 return 0;
6112}
6113static void set_rxd_buffer_size(nic_t *sp, RxD_t *rxdp, int size)
6114{
6115 struct net_device *dev = sp->dev;
6116 if (sp->rxd_mode == RXD_MODE_1) {
6117 rxdp->Control_2 = SET_BUFFER0_SIZE_1( size - NET_IP_ALIGN);
6118 } else if (sp->rxd_mode == RXD_MODE_3B) {
6119 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
6120 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1);
6121 rxdp->Control_2 |= SET_BUFFER2_SIZE_3( dev->mtu + 4);
6122 } else {
6123 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
6124 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(l3l4hdr_size + 4);
6125 rxdp->Control_2 |= SET_BUFFER2_SIZE_3(dev->mtu);
6126 }
6127}
6128
6129static int rxd_owner_bit_reset(nic_t *sp)
6130{
6131 int i, j, k, blk_cnt = 0, size;
6132 mac_info_t * mac_control = &sp->mac_control;
6133 struct config_param *config = &sp->config;
6134 struct net_device *dev = sp->dev;
6135 RxD_t *rxdp = NULL;
6136 struct sk_buff *skb = NULL;
6137 buffAdd_t *ba = NULL;
6138 u64 temp0_64 = 0, temp1_64 = 0, temp2_64 = 0;
6139
6140 /* Calculate the size based on ring mode */
6141 size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE +
6142 HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
6143 if (sp->rxd_mode == RXD_MODE_1)
6144 size += NET_IP_ALIGN;
6145 else if (sp->rxd_mode == RXD_MODE_3B)
6146 size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4;
6147 else
6148 size = l3l4hdr_size + ALIGN_SIZE + BUF0_LEN + 4;
6149
6150 for (i = 0; i < config->rx_ring_num; i++) {
6151 blk_cnt = config->rx_cfg[i].num_rxd /
6152 (rxd_count[sp->rxd_mode] +1);
6153
6154 for (j = 0; j < blk_cnt; j++) {
6155 for (k = 0; k < rxd_count[sp->rxd_mode]; k++) {
6156 rxdp = mac_control->rings[i].
6157 rx_blocks[j].rxds[k].virt_addr;
6158 if(sp->rxd_mode >= RXD_MODE_3A)
6159 ba = &mac_control->rings[i].ba[j][k];
6160 set_rxd_buffer_pointer(sp, rxdp, ba,
6161 &skb,(u64 *)&temp0_64,
6162 (u64 *)&temp1_64,
6163 (u64 *)&temp2_64, size);
6164
6165 set_rxd_buffer_size(sp, rxdp, size);
6166 wmb();
6167 /* flip the Ownership bit to Hardware */
6168 rxdp->Control_1 |= RXD_OWN_XENA;
6169 }
6170 }
6171 }
6172 return 0;
6173
6174}
6175
6176static void s2io_card_down(nic_t * sp, int flag)
5493{ 6177{
5494 int cnt = 0; 6178 int cnt = 0;
5495 XENA_dev_config_t __iomem *bar0 = sp->bar0; 6179 XENA_dev_config_t __iomem *bar0 = sp->bar0;
5496 unsigned long flags; 6180 unsigned long flags;
5497 register u64 val64 = 0; 6181 register u64 val64 = 0;
6182 struct net_device *dev = sp->dev;
5498 6183
5499 del_timer_sync(&sp->alarm_timer); 6184 del_timer_sync(&sp->alarm_timer);
5500 /* If s2io_set_link task is executing, wait till it completes. */ 6185 /* If s2io_set_link task is executing, wait till it completes. */
@@ -5505,12 +6190,51 @@ static void s2io_card_down(nic_t * sp)
5505 6190
5506 /* disable Tx and Rx traffic on the NIC */ 6191 /* disable Tx and Rx traffic on the NIC */
5507 stop_nic(sp); 6192 stop_nic(sp);
6193 if (flag) {
6194 if (sp->intr_type == MSI_X) {
6195 int i;
6196 u16 msi_control;
6197
6198 for (i=1; (sp->s2io_entries[i].in_use ==
6199 MSIX_REGISTERED_SUCCESS); i++) {
6200 int vector = sp->entries[i].vector;
6201 void *arg = sp->s2io_entries[i].arg;
6202
6203 free_irq(vector, arg);
6204 }
6205 pci_read_config_word(sp->pdev, 0x42, &msi_control);
6206 msi_control &= 0xFFFE; /* Disable MSI */
6207 pci_write_config_word(sp->pdev, 0x42, msi_control);
6208 pci_disable_msix(sp->pdev);
6209 } else {
6210 free_irq(sp->pdev->irq, dev);
6211 if (sp->intr_type == MSI)
6212 pci_disable_msi(sp->pdev);
6213 }
6214 }
6215 /* Waiting till all Interrupt handlers are complete */
6216 cnt = 0;
6217 do {
6218 msleep(10);
6219 if (!atomic_read(&sp->isr_cnt))
6220 break;
6221 cnt++;
6222 } while(cnt < 5);
5508 6223
5509 /* Kill tasklet. */ 6224 /* Kill tasklet. */
5510 tasklet_kill(&sp->task); 6225 tasklet_kill(&sp->task);
5511 6226
5512 /* Check if the device is Quiescent and then Reset the NIC */ 6227 /* Check if the device is Quiescent and then Reset the NIC */
5513 do { 6228 do {
6229 /* As per the HW requirement we need to replenish the
6230 * receive buffer to avoid the ring bump. Since there is
6231 * no intention of processing the Rx frame at this pointwe are
6232 * just settting the ownership bit of rxd in Each Rx
6233 * ring to HW and set the appropriate buffer size
6234 * based on the ring mode
6235 */
6236 rxd_owner_bit_reset(sp);
6237
5514 val64 = readq(&bar0->adapter_status); 6238 val64 = readq(&bar0->adapter_status);
5515 if (verify_xena_quiescence(sp, val64, sp->device_enabled_once)) { 6239 if (verify_xena_quiescence(sp, val64, sp->device_enabled_once)) {
5516 break; 6240 break;
@@ -5528,15 +6252,6 @@ static void s2io_card_down(nic_t * sp)
5528 } while (1); 6252 } while (1);
5529 s2io_reset(sp); 6253 s2io_reset(sp);
5530 6254
5531 /* Waiting till all Interrupt handlers are complete */
5532 cnt = 0;
5533 do {
5534 msleep(10);
5535 if (!atomic_read(&sp->isr_cnt))
5536 break;
5537 cnt++;
5538 } while(cnt < 5);
5539
5540 spin_lock_irqsave(&sp->tx_lock, flags); 6255 spin_lock_irqsave(&sp->tx_lock, flags);
5541 /* Free all Tx buffers */ 6256 /* Free all Tx buffers */
5542 free_tx_buffers(sp); 6257 free_tx_buffers(sp);
@@ -5637,7 +6352,7 @@ static void s2io_restart_nic(unsigned long data)
5637 struct net_device *dev = (struct net_device *) data; 6352 struct net_device *dev = (struct net_device *) data;
5638 nic_t *sp = dev->priv; 6353 nic_t *sp = dev->priv;
5639 6354
5640 s2io_card_down(sp); 6355 s2io_card_down(sp, 0);
5641 if (s2io_card_up(sp)) { 6356 if (s2io_card_up(sp)) {
5642 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n", 6357 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",
5643 dev->name); 6358 dev->name);
@@ -5667,6 +6382,7 @@ static void s2io_tx_watchdog(struct net_device *dev)
5667 6382
5668 if (netif_carrier_ok(dev)) { 6383 if (netif_carrier_ok(dev)) {
5669 schedule_work(&sp->rst_timer_task); 6384 schedule_work(&sp->rst_timer_task);
6385 sp->mac_control.stats_info->sw_stat.soft_reset_cnt++;
5670 } 6386 }
5671} 6387}
5672 6388
@@ -5695,18 +6411,33 @@ static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp)
5695 ((unsigned long) rxdp->Host_Control); 6411 ((unsigned long) rxdp->Host_Control);
5696 int ring_no = ring_data->ring_no; 6412 int ring_no = ring_data->ring_no;
5697 u16 l3_csum, l4_csum; 6413 u16 l3_csum, l4_csum;
6414 unsigned long long err = rxdp->Control_1 & RXD_T_CODE;
5698 lro_t *lro; 6415 lro_t *lro;
5699 6416
5700 skb->dev = dev; 6417 skb->dev = dev;
5701 if (rxdp->Control_1 & RXD_T_CODE) { 6418
5702 unsigned long long err = rxdp->Control_1 & RXD_T_CODE; 6419 if (err) {
5703 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", 6420 /* Check for parity error */
5704 dev->name, err); 6421 if (err & 0x1) {
5705 dev_kfree_skb(skb); 6422 sp->mac_control.stats_info->sw_stat.parity_err_cnt++;
5706 sp->stats.rx_crc_errors++; 6423 }
5707 atomic_dec(&sp->rx_bufs_left[ring_no]); 6424
5708 rxdp->Host_Control = 0; 6425 /*
5709 return 0; 6426 * Drop the packet if bad transfer code. Exception being
6427 * 0x5, which could be due to unsupported IPv6 extension header.
6428 * In this case, we let stack handle the packet.
6429 * Note that in this case, since checksum will be incorrect,
6430 * stack will validate the same.
6431 */
6432 if (err && ((err >> 48) != 0x5)) {
6433 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
6434 dev->name, err);
6435 sp->stats.rx_crc_errors++;
6436 dev_kfree_skb(skb);
6437 atomic_dec(&sp->rx_bufs_left[ring_no]);
6438 rxdp->Host_Control = 0;
6439 return 0;
6440 }
5710 } 6441 }
5711 6442
5712 /* Updating statistics */ 6443 /* Updating statistics */
@@ -5792,6 +6523,9 @@ static int rx_osm_handler(ring_info_t *ring_data, RxD_t * rxdp)
5792 clear_lro_session(lro); 6523 clear_lro_session(lro);
5793 goto send_up; 6524 goto send_up;
5794 case 0: /* sessions exceeded */ 6525 case 0: /* sessions exceeded */
6526 case -1: /* non-TCP or not
6527 * L2 aggregatable
6528 */
5795 case 5: /* 6529 case 5: /*
5796 * First pkt in session not 6530 * First pkt in session not
5797 * L3/L4 aggregatable 6531 * L3/L4 aggregatable
@@ -5918,13 +6652,6 @@ static void s2io_init_pci(nic_t * sp)
5918 pci_write_config_word(sp->pdev, PCI_COMMAND, 6652 pci_write_config_word(sp->pdev, PCI_COMMAND,
5919 (pci_cmd | PCI_COMMAND_PARITY)); 6653 (pci_cmd | PCI_COMMAND_PARITY));
5920 pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd); 6654 pci_read_config_word(sp->pdev, PCI_COMMAND, &pci_cmd);
5921
5922 /* Forcibly disabling relaxed ordering capability of the card. */
5923 pcix_cmd &= 0xfffd;
5924 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5925 pcix_cmd);
5926 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER,
5927 &(pcix_cmd));
5928} 6655}
5929 6656
5930MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>"); 6657MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>");
@@ -5954,6 +6681,55 @@ module_param(intr_type, int, 0);
5954module_param(lro, int, 0); 6681module_param(lro, int, 0);
5955module_param(lro_max_pkts, int, 0); 6682module_param(lro_max_pkts, int, 0);
5956 6683
6684static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type)
6685{
6686 if ( tx_fifo_num > 8) {
6687 DBG_PRINT(ERR_DBG, "s2io: Requested number of Tx fifos not "
6688 "supported\n");
6689 DBG_PRINT(ERR_DBG, "s2io: Default to 8 Tx fifos\n");
6690 tx_fifo_num = 8;
6691 }
6692 if ( rx_ring_num > 8) {
6693 DBG_PRINT(ERR_DBG, "s2io: Requested number of Rx rings not "
6694 "supported\n");
6695 DBG_PRINT(ERR_DBG, "s2io: Default to 8 Rx rings\n");
6696 rx_ring_num = 8;
6697 }
6698#ifdef CONFIG_S2IO_NAPI
6699 if (*dev_intr_type != INTA) {
6700 DBG_PRINT(ERR_DBG, "s2io: NAPI cannot be enabled when "
6701 "MSI/MSI-X is enabled. Defaulting to INTA\n");
6702 *dev_intr_type = INTA;
6703 }
6704#endif
6705#ifndef CONFIG_PCI_MSI
6706 if (*dev_intr_type != INTA) {
6707 DBG_PRINT(ERR_DBG, "s2io: This kernel does not support"
6708 "MSI/MSI-X. Defaulting to INTA\n");
6709 *dev_intr_type = INTA;
6710 }
6711#else
6712 if (*dev_intr_type > MSI_X) {
6713 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. "
6714 "Defaulting to INTA\n");
6715 *dev_intr_type = INTA;
6716 }
6717#endif
6718 if ((*dev_intr_type == MSI_X) &&
6719 ((pdev->device != PCI_DEVICE_ID_HERC_WIN) &&
6720 (pdev->device != PCI_DEVICE_ID_HERC_UNI))) {
6721 DBG_PRINT(ERR_DBG, "s2io: Xframe I does not support MSI_X. "
6722 "Defaulting to INTA\n");
6723 *dev_intr_type = INTA;
6724 }
6725 if (rx_ring_mode > 3) {
6726 DBG_PRINT(ERR_DBG, "s2io: Requested ring mode not supported\n");
6727 DBG_PRINT(ERR_DBG, "s2io: Defaulting to 3-buffer mode\n");
6728 rx_ring_mode = 3;
6729 }
6730 return SUCCESS;
6731}
6732
5957/** 6733/**
5958 * s2io_init_nic - Initialization of the adapter . 6734 * s2io_init_nic - Initialization of the adapter .
5959 * @pdev : structure containing the PCI related information of the device. 6735 * @pdev : structure containing the PCI related information of the device.
@@ -5984,15 +6760,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5984 int mode; 6760 int mode;
5985 u8 dev_intr_type = intr_type; 6761 u8 dev_intr_type = intr_type;
5986 6762
5987#ifdef CONFIG_S2IO_NAPI 6763 if ((ret = s2io_verify_parm(pdev, &dev_intr_type)))
5988 if (dev_intr_type != INTA) { 6764 return ret;
5989 DBG_PRINT(ERR_DBG, "NAPI cannot be enabled when MSI/MSI-X \
5990is enabled. Defaulting to INTA\n");
5991 dev_intr_type = INTA;
5992 }
5993 else
5994 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n");
5995#endif
5996 6765
5997 if ((ret = pci_enable_device(pdev))) { 6766 if ((ret = pci_enable_device(pdev))) {
5998 DBG_PRINT(ERR_DBG, 6767 DBG_PRINT(ERR_DBG,
@@ -6017,14 +6786,6 @@ is enabled. Defaulting to INTA\n");
6017 pci_disable_device(pdev); 6786 pci_disable_device(pdev);
6018 return -ENOMEM; 6787 return -ENOMEM;
6019 } 6788 }
6020
6021 if ((dev_intr_type == MSI_X) &&
6022 ((pdev->device != PCI_DEVICE_ID_HERC_WIN) &&
6023 (pdev->device != PCI_DEVICE_ID_HERC_UNI))) {
6024 DBG_PRINT(ERR_DBG, "Xframe I does not support MSI_X. \
6025Defaulting to INTA\n");
6026 dev_intr_type = INTA;
6027 }
6028 if (dev_intr_type != MSI_X) { 6789 if (dev_intr_type != MSI_X) {
6029 if (pci_request_regions(pdev, s2io_driver_name)) { 6790 if (pci_request_regions(pdev, s2io_driver_name)) {
6030 DBG_PRINT(ERR_DBG, "Request Regions failed\n"), 6791 DBG_PRINT(ERR_DBG, "Request Regions failed\n"),
@@ -6100,8 +6861,6 @@ Defaulting to INTA\n");
6100 config = &sp->config; 6861 config = &sp->config;
6101 6862
6102 /* Tx side parameters. */ 6863 /* Tx side parameters. */
6103 if (tx_fifo_len[0] == 0)
6104 tx_fifo_len[0] = DEFAULT_FIFO_LEN; /* Default value. */
6105 config->tx_fifo_num = tx_fifo_num; 6864 config->tx_fifo_num = tx_fifo_num;
6106 for (i = 0; i < MAX_TX_FIFOS; i++) { 6865 for (i = 0; i < MAX_TX_FIFOS; i++) {
6107 config->tx_cfg[i].fifo_len = tx_fifo_len[i]; 6866 config->tx_cfg[i].fifo_len = tx_fifo_len[i];
@@ -6125,8 +6884,6 @@ Defaulting to INTA\n");
6125 config->max_txds = MAX_SKB_FRAGS + 2; 6884 config->max_txds = MAX_SKB_FRAGS + 2;
6126 6885
6127 /* Rx side parameters. */ 6886 /* Rx side parameters. */
6128 if (rx_ring_sz[0] == 0)
6129 rx_ring_sz[0] = SMALL_BLK_CNT; /* Default value. */
6130 config->rx_ring_num = rx_ring_num; 6887 config->rx_ring_num = rx_ring_num;
6131 for (i = 0; i < MAX_RX_RINGS; i++) { 6888 for (i = 0; i < MAX_RX_RINGS; i++) {
6132 config->rx_cfg[i].num_rxd = rx_ring_sz[i] * 6889 config->rx_cfg[i].num_rxd = rx_ring_sz[i] *
@@ -6267,8 +7024,8 @@ Defaulting to INTA\n");
6267 val64 = RMAC_ADDR_CMD_MEM_RD | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD | 7024 val64 = RMAC_ADDR_CMD_MEM_RD | RMAC_ADDR_CMD_MEM_STROBE_NEW_CMD |
6268 RMAC_ADDR_CMD_MEM_OFFSET(0 + MAC_MAC_ADDR_START_OFFSET); 7025 RMAC_ADDR_CMD_MEM_OFFSET(0 + MAC_MAC_ADDR_START_OFFSET);
6269 writeq(val64, &bar0->rmac_addr_cmd_mem); 7026 writeq(val64, &bar0->rmac_addr_cmd_mem);
6270 wait_for_cmd_complete(sp); 7027 wait_for_cmd_complete(&bar0->rmac_addr_cmd_mem,
6271 7028 RMAC_ADDR_CMD_MEM_STROBE_CMD_EXECUTING);
6272 tmp64 = readq(&bar0->rmac_addr_data0_mem); 7029 tmp64 = readq(&bar0->rmac_addr_data0_mem);
6273 mac_down = (u32) tmp64; 7030 mac_down = (u32) tmp64;
6274 mac_up = (u32) (tmp64 >> 32); 7031 mac_up = (u32) (tmp64 >> 32);
@@ -6322,82 +7079,63 @@ Defaulting to INTA\n");
6322 ret = -ENODEV; 7079 ret = -ENODEV;
6323 goto register_failed; 7080 goto register_failed;
6324 } 7081 }
6325 7082 s2io_vpd_read(sp);
6326 if (sp->device_type & XFRAME_II_DEVICE) { 7083 DBG_PRINT(ERR_DBG, "%s: Neterion %s",dev->name, sp->product_name);
6327 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ", 7084 DBG_PRINT(ERR_DBG, "(rev %d), Driver version %s\n",
6328 dev->name);
6329 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
6330 get_xena_rev_id(sp->pdev), 7085 get_xena_rev_id(sp->pdev),
6331 s2io_driver_version); 7086 s2io_driver_version);
6332 switch(sp->intr_type) { 7087 DBG_PRINT(ERR_DBG, "Copyright(c) 2002-2005 Neterion Inc.\n");
6333 case INTA: 7088 DBG_PRINT(ERR_DBG, "%s: MAC ADDR: "
6334 DBG_PRINT(ERR_DBG, ", Intr type INTA"); 7089 "%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
6335 break;
6336 case MSI:
6337 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6338 break;
6339 case MSI_X:
6340 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6341 break;
6342 }
6343
6344 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
6345 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
6346 sp->def_mac_addr[0].mac_addr[0], 7090 sp->def_mac_addr[0].mac_addr[0],
6347 sp->def_mac_addr[0].mac_addr[1], 7091 sp->def_mac_addr[0].mac_addr[1],
6348 sp->def_mac_addr[0].mac_addr[2], 7092 sp->def_mac_addr[0].mac_addr[2],
6349 sp->def_mac_addr[0].mac_addr[3], 7093 sp->def_mac_addr[0].mac_addr[3],
6350 sp->def_mac_addr[0].mac_addr[4], 7094 sp->def_mac_addr[0].mac_addr[4],
6351 sp->def_mac_addr[0].mac_addr[5]); 7095 sp->def_mac_addr[0].mac_addr[5]);
7096 if (sp->device_type & XFRAME_II_DEVICE) {
6352 mode = s2io_print_pci_mode(sp); 7097 mode = s2io_print_pci_mode(sp);
6353 if (mode < 0) { 7098 if (mode < 0) {
6354 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode "); 7099 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode\n");
6355 ret = -EBADSLT; 7100 ret = -EBADSLT;
7101 unregister_netdev(dev);
6356 goto set_swap_failed; 7102 goto set_swap_failed;
6357 } 7103 }
6358 } else {
6359 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ",
6360 dev->name);
6361 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
6362 get_xena_rev_id(sp->pdev),
6363 s2io_driver_version);
6364 switch(sp->intr_type) {
6365 case INTA:
6366 DBG_PRINT(ERR_DBG, ", Intr type INTA");
6367 break;
6368 case MSI:
6369 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6370 break;
6371 case MSI_X:
6372 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6373 break;
6374 }
6375 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
6376 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
6377 sp->def_mac_addr[0].mac_addr[0],
6378 sp->def_mac_addr[0].mac_addr[1],
6379 sp->def_mac_addr[0].mac_addr[2],
6380 sp->def_mac_addr[0].mac_addr[3],
6381 sp->def_mac_addr[0].mac_addr[4],
6382 sp->def_mac_addr[0].mac_addr[5]);
6383 } 7104 }
6384 if (sp->rxd_mode == RXD_MODE_3B) 7105 switch(sp->rxd_mode) {
6385 DBG_PRINT(ERR_DBG, "%s: 2-Buffer mode support has been " 7106 case RXD_MODE_1:
6386 "enabled\n",dev->name); 7107 DBG_PRINT(ERR_DBG, "%s: 1-Buffer receive mode enabled\n",
6387 if (sp->rxd_mode == RXD_MODE_3A) 7108 dev->name);
6388 DBG_PRINT(ERR_DBG, "%s: 3-Buffer mode support has been " 7109 break;
6389 "enabled\n",dev->name); 7110 case RXD_MODE_3B:
6390 7111 DBG_PRINT(ERR_DBG, "%s: 2-Buffer receive mode enabled\n",
7112 dev->name);
7113 break;
7114 case RXD_MODE_3A:
7115 DBG_PRINT(ERR_DBG, "%s: 3-Buffer receive mode enabled\n",
7116 dev->name);
7117 break;
7118 }
7119#ifdef CONFIG_S2IO_NAPI
7120 DBG_PRINT(ERR_DBG, "%s: NAPI enabled\n", dev->name);
7121#endif
7122 switch(sp->intr_type) {
7123 case INTA:
7124 DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name);
7125 break;
7126 case MSI:
7127 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI\n", dev->name);
7128 break;
7129 case MSI_X:
7130 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI-X\n", dev->name);
7131 break;
7132 }
6391 if (sp->lro) 7133 if (sp->lro)
6392 DBG_PRINT(ERR_DBG, "%s: Large receive offload enabled\n", 7134 DBG_PRINT(ERR_DBG, "%s: Large receive offload enabled\n",
6393 dev->name); 7135 dev->name);
6394 7136
6395 /* Initialize device name */ 7137 /* Initialize device name */
6396 strcpy(sp->name, dev->name); 7138 sprintf(sp->name, "%s Neterion %s", dev->name, sp->product_name);
6397 if (sp->device_type & XFRAME_II_DEVICE)
6398 strcat(sp->name, ": Neterion Xframe II 10GbE adapter");
6399 else
6400 strcat(sp->name, ": Neterion Xframe I 10GbE adapter");
6401 7139
6402 /* Initialize bimodal Interrupts */ 7140 /* Initialize bimodal Interrupts */
6403 sp->config.bimodal = bimodal; 7141 sp->config.bimodal = bimodal;
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 0a0b5b29d81e..3203732a668d 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -31,6 +31,8 @@
31#define SUCCESS 0 31#define SUCCESS 0
32#define FAILURE -1 32#define FAILURE -1
33 33
34#define CHECKBIT(value, nbit) (value & (1 << nbit))
35
34/* Maximum time to flicker LED when asked to identify NIC using ethtool */ 36/* Maximum time to flicker LED when asked to identify NIC using ethtool */
35#define MAX_FLICKER_TIME 60000 /* 60 Secs */ 37#define MAX_FLICKER_TIME 60000 /* 60 Secs */
36 38
@@ -78,6 +80,11 @@ static int debug_level = ERR_DBG;
78typedef struct { 80typedef struct {
79 unsigned long long single_ecc_errs; 81 unsigned long long single_ecc_errs;
80 unsigned long long double_ecc_errs; 82 unsigned long long double_ecc_errs;
83 unsigned long long parity_err_cnt;
84 unsigned long long serious_err_cnt;
85 unsigned long long soft_reset_cnt;
86 unsigned long long fifo_full_cnt;
87 unsigned long long ring_full_cnt;
81 /* LRO statistics */ 88 /* LRO statistics */
82 unsigned long long clubbed_frms_cnt; 89 unsigned long long clubbed_frms_cnt;
83 unsigned long long sending_both; 90 unsigned long long sending_both;
@@ -87,6 +94,25 @@ typedef struct {
87 unsigned long long num_aggregations; 94 unsigned long long num_aggregations;
88} swStat_t; 95} swStat_t;
89 96
97/* Xpak releated alarm and warnings */
98typedef struct {
99 u64 alarm_transceiver_temp_high;
100 u64 alarm_transceiver_temp_low;
101 u64 alarm_laser_bias_current_high;
102 u64 alarm_laser_bias_current_low;
103 u64 alarm_laser_output_power_high;
104 u64 alarm_laser_output_power_low;
105 u64 warn_transceiver_temp_high;
106 u64 warn_transceiver_temp_low;
107 u64 warn_laser_bias_current_high;
108 u64 warn_laser_bias_current_low;
109 u64 warn_laser_output_power_high;
110 u64 warn_laser_output_power_low;
111 u64 xpak_regs_stat;
112 u32 xpak_timer_count;
113} xpakStat_t;
114
115
90/* The statistics block of Xena */ 116/* The statistics block of Xena */
91typedef struct stat_block { 117typedef struct stat_block {
92/* Tx MAC statistics counters. */ 118/* Tx MAC statistics counters. */
@@ -263,7 +289,9 @@ typedef struct stat_block {
263 u32 rmac_accepted_ip_oflow; 289 u32 rmac_accepted_ip_oflow;
264 u32 reserved_14; 290 u32 reserved_14;
265 u32 link_fault_cnt; 291 u32 link_fault_cnt;
292 u8 buffer[20];
266 swStat_t sw_stat; 293 swStat_t sw_stat;
294 xpakStat_t xpak_stat;
267} StatInfo_t; 295} StatInfo_t;
268 296
269/* 297/*
@@ -659,7 +687,8 @@ typedef struct {
659} usr_addr_t; 687} usr_addr_t;
660 688
661/* Default Tunable parameters of the NIC. */ 689/* Default Tunable parameters of the NIC. */
662#define DEFAULT_FIFO_LEN 4096 690#define DEFAULT_FIFO_0_LEN 4096
691#define DEFAULT_FIFO_1_7_LEN 512
663#define SMALL_BLK_CNT 30 692#define SMALL_BLK_CNT 30
664#define LARGE_BLK_CNT 100 693#define LARGE_BLK_CNT 100
665 694
@@ -732,7 +761,7 @@ struct s2io_nic {
732 int device_close_flag; 761 int device_close_flag;
733 int device_enabled_once; 762 int device_enabled_once;
734 763
735 char name[50]; 764 char name[60];
736 struct tasklet_struct task; 765 struct tasklet_struct task;
737 volatile unsigned long tasklet_status; 766 volatile unsigned long tasklet_status;
738 767
@@ -803,6 +832,8 @@ struct s2io_nic {
803 char desc1[35]; 832 char desc1[35];
804 char desc2[35]; 833 char desc2[35];
805 834
835 int avail_msix_vectors; /* No. of MSI-X vectors granted by system */
836
806 struct msix_info_st msix_info[0x3f]; 837 struct msix_info_st msix_info[0x3f];
807 838
808#define XFRAME_I_DEVICE 1 839#define XFRAME_I_DEVICE 1
@@ -824,6 +855,8 @@ struct s2io_nic {
824 spinlock_t rx_lock; 855 spinlock_t rx_lock;
825 atomic_t isr_cnt; 856 atomic_t isr_cnt;
826 u64 *ufo_in_band_v; 857 u64 *ufo_in_band_v;
858#define VPD_PRODUCT_NAME_LEN 50
859 u8 product_name[VPD_PRODUCT_NAME_LEN];
827}; 860};
828 861
829#define RESET_ERROR 1; 862#define RESET_ERROR 1;
@@ -848,28 +881,32 @@ static inline void writeq(u64 val, void __iomem *addr)
848 writel((u32) (val), addr); 881 writel((u32) (val), addr);
849 writel((u32) (val >> 32), (addr + 4)); 882 writel((u32) (val >> 32), (addr + 4));
850} 883}
884#endif
851 885
852/* In 32 bit modes, some registers have to be written in a 886/*
853 * particular order to expect correct hardware operation. The 887 * Some registers have to be written in a particular order to
854 * macro SPECIAL_REG_WRITE is used to perform such ordered 888 * expect correct hardware operation. The macro SPECIAL_REG_WRITE
855 * writes. Defines UF (Upper First) and LF (Lower First) will 889 * is used to perform such ordered writes. Defines UF (Upper First)
856 * be used to specify the required write order. 890 * and LF (Lower First) will be used to specify the required write order.
857 */ 891 */
858#define UF 1 892#define UF 1
859#define LF 2 893#define LF 2
860static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order) 894static inline void SPECIAL_REG_WRITE(u64 val, void __iomem *addr, int order)
861{ 895{
896 u32 ret;
897
862 if (order == LF) { 898 if (order == LF) {
863 writel((u32) (val), addr); 899 writel((u32) (val), addr);
900 ret = readl(addr);
864 writel((u32) (val >> 32), (addr + 4)); 901 writel((u32) (val >> 32), (addr + 4));
902 ret = readl(addr + 4);
865 } else { 903 } else {
866 writel((u32) (val >> 32), (addr + 4)); 904 writel((u32) (val >> 32), (addr + 4));
905 ret = readl(addr + 4);
867 writel((u32) (val), addr); 906 writel((u32) (val), addr);
907 ret = readl(addr);
868 } 908 }
869} 909}
870#else
871#define SPECIAL_REG_WRITE(val, addr, dummy) writeq(val, addr)
872#endif
873 910
874/* Interrupt related values of Xena */ 911/* Interrupt related values of Xena */
875 912
@@ -965,7 +1002,7 @@ static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
965static struct ethtool_ops netdev_ethtool_ops; 1002static struct ethtool_ops netdev_ethtool_ops;
966static void s2io_set_link(unsigned long data); 1003static void s2io_set_link(unsigned long data);
967static int s2io_set_swapper(nic_t * sp); 1004static int s2io_set_swapper(nic_t * sp);
968static void s2io_card_down(nic_t *nic); 1005static void s2io_card_down(nic_t *nic, int flag);
969static int s2io_card_up(nic_t *nic); 1006static int s2io_card_up(nic_t *nic);
970static int get_xena_rev_id(struct pci_dev *pdev); 1007static int get_xena_rev_id(struct pci_dev *pdev);
971static void restore_xmsi_data(nic_t *nic); 1008static void restore_xmsi_data(nic_t *nic);
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index f5a3bf4d959a..d05874172209 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1,6 +1,6 @@
1/* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux. 1/* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux.
2 Copyright 1999 Silicon Integrated System Corporation 2 Copyright 1999 Silicon Integrated System Corporation
3 Revision: 1.08.09 Sep. 19 2005 3 Revision: 1.08.10 Apr. 2 2006
4 4
5 Modified from the driver which is originally written by Donald Becker. 5 Modified from the driver which is originally written by Donald Becker.
6 6
@@ -17,9 +17,10 @@
17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution, 17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
18 preliminary Rev. 1.0 Jan. 18, 1998 18 preliminary Rev. 1.0 Jan. 18, 1998
19 19
20 Rev 1.08.10 Apr. 2 2006 Daniele Venzano add vlan (jumbo packets) support
20 Rev 1.08.09 Sep. 19 2005 Daniele Venzano add Wake on LAN support 21 Rev 1.08.09 Sep. 19 2005 Daniele Venzano add Wake on LAN support
21 Rev 1.08.08 Jan. 22 2005 Daniele Venzano use netif_msg for debugging messages 22 Rev 1.08.08 Jan. 22 2005 Daniele Venzano use netif_msg for debugging messages
22 Rev 1.08.07 Nov. 2 2003 Daniele Venzano <webvenza@libero.it> add suspend/resume support 23 Rev 1.08.07 Nov. 2 2003 Daniele Venzano <venza@brownhat.org> add suspend/resume support
23 Rev 1.08.06 Sep. 24 2002 Mufasa Yang bug fix for Tx timeout & add SiS963 support 24 Rev 1.08.06 Sep. 24 2002 Mufasa Yang bug fix for Tx timeout & add SiS963 support
24 Rev 1.08.05 Jun. 6 2002 Mufasa Yang bug fix for read_eeprom & Tx descriptor over-boundary 25 Rev 1.08.05 Jun. 6 2002 Mufasa Yang bug fix for read_eeprom & Tx descriptor over-boundary
25 Rev 1.08.04 Apr. 25 2002 Mufasa Yang <mufasa@sis.com.tw> added SiS962 support 26 Rev 1.08.04 Apr. 25 2002 Mufasa Yang <mufasa@sis.com.tw> added SiS962 support
@@ -77,7 +78,7 @@
77#include "sis900.h" 78#include "sis900.h"
78 79
79#define SIS900_MODULE_NAME "sis900" 80#define SIS900_MODULE_NAME "sis900"
80#define SIS900_DRV_VERSION "v1.08.09 Sep. 19 2005" 81#define SIS900_DRV_VERSION "v1.08.10 Apr. 2 2006"
81 82
82static char version[] __devinitdata = 83static char version[] __devinitdata =
83KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n"; 84KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n";
@@ -1402,6 +1403,11 @@ static void sis900_set_mode (long ioaddr, int speed, int duplex)
1402 rx_flags |= RxATX; 1403 rx_flags |= RxATX;
1403 } 1404 }
1404 1405
1406#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
1407 /* Can accept Jumbo packet */
1408 rx_flags |= RxAJAB;
1409#endif
1410
1405 outl (tx_flags, ioaddr + txcfg); 1411 outl (tx_flags, ioaddr + txcfg);
1406 outl (rx_flags, ioaddr + rxcfg); 1412 outl (rx_flags, ioaddr + rxcfg);
1407} 1413}
@@ -1714,18 +1720,26 @@ static int sis900_rx(struct net_device *net_dev)
1714 1720
1715 while (rx_status & OWN) { 1721 while (rx_status & OWN) {
1716 unsigned int rx_size; 1722 unsigned int rx_size;
1723 unsigned int data_size;
1717 1724
1718 if (--rx_work_limit < 0) 1725 if (--rx_work_limit < 0)
1719 break; 1726 break;
1720 1727
1721 rx_size = (rx_status & DSIZE) - CRC_SIZE; 1728 data_size = rx_status & DSIZE;
1729 rx_size = data_size - CRC_SIZE;
1730
1731#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
1732 /* ``TOOLONG'' flag means jumbo packet recived. */
1733 if ((rx_status & TOOLONG) && data_size <= MAX_FRAME_SIZE)
1734 rx_status &= (~ ((unsigned int)TOOLONG));
1735#endif
1722 1736
1723 if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) { 1737 if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) {
1724 /* corrupted packet received */ 1738 /* corrupted packet received */
1725 if (netif_msg_rx_err(sis_priv)) 1739 if (netif_msg_rx_err(sis_priv))
1726 printk(KERN_DEBUG "%s: Corrupted packet " 1740 printk(KERN_DEBUG "%s: Corrupted packet "
1727 "received, buffer status = 0x%8.8x.\n", 1741 "received, buffer status = 0x%8.8x/%d.\n",
1728 net_dev->name, rx_status); 1742 net_dev->name, rx_status, data_size);
1729 sis_priv->stats.rx_errors++; 1743 sis_priv->stats.rx_errors++;
1730 if (rx_status & OVERRUN) 1744 if (rx_status & OVERRUN)
1731 sis_priv->stats.rx_over_errors++; 1745 sis_priv->stats.rx_over_errors++;
diff --git a/drivers/net/sis900.h b/drivers/net/sis900.h
index 50323941e3c0..4834e3a15694 100644
--- a/drivers/net/sis900.h
+++ b/drivers/net/sis900.h
@@ -310,8 +310,14 @@ enum sis630_revision_id {
310#define CRC_SIZE 4 310#define CRC_SIZE 4
311#define MAC_HEADER_SIZE 14 311#define MAC_HEADER_SIZE 14
312 312
313#define TX_BUF_SIZE 1536 313#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
314#define RX_BUF_SIZE 1536 314#define MAX_FRAME_SIZE (1518 + 4)
315#else
316#define MAX_FRAME_SIZE 1518
317#endif /* CONFIG_VLAN_802_1Q */
318
319#define TX_BUF_SIZE (MAX_FRAME_SIZE+18)
320#define RX_BUF_SIZE (MAX_FRAME_SIZE+18)
315 321
316#define NUM_TX_DESC 16 /* Number of Tx descriptor registers. */ 322#define NUM_TX_DESC 16 /* Number of Tx descriptor registers. */
317#define NUM_RX_DESC 16 /* Number of Rx descriptor registers. */ 323#define NUM_RX_DESC 16 /* Number of Rx descriptor registers. */
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 5ca5a1b546a1..536dd1cf7f79 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -44,12 +44,13 @@
44#include "skge.h" 44#include "skge.h"
45 45
46#define DRV_NAME "skge" 46#define DRV_NAME "skge"
47#define DRV_VERSION "1.5" 47#define DRV_VERSION "1.6"
48#define PFX DRV_NAME " " 48#define PFX DRV_NAME " "
49 49
50#define DEFAULT_TX_RING_SIZE 128 50#define DEFAULT_TX_RING_SIZE 128
51#define DEFAULT_RX_RING_SIZE 512 51#define DEFAULT_RX_RING_SIZE 512
52#define MAX_TX_RING_SIZE 1024 52#define MAX_TX_RING_SIZE 1024
53#define TX_LOW_WATER (MAX_SKB_FRAGS + 1)
53#define MAX_RX_RING_SIZE 4096 54#define MAX_RX_RING_SIZE 4096
54#define RX_COPY_THRESHOLD 128 55#define RX_COPY_THRESHOLD 128
55#define RX_BUF_SIZE 1536 56#define RX_BUF_SIZE 1536
@@ -401,7 +402,7 @@ static int skge_set_ring_param(struct net_device *dev,
401 int err; 402 int err;
402 403
403 if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE || 404 if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE ||
404 p->tx_pending < MAX_SKB_FRAGS+1 || p->tx_pending > MAX_TX_RING_SIZE) 405 p->tx_pending < TX_LOW_WATER || p->tx_pending > MAX_TX_RING_SIZE)
405 return -EINVAL; 406 return -EINVAL;
406 407
407 skge->rx_ring.count = p->rx_pending; 408 skge->rx_ring.count = p->rx_pending;
@@ -603,7 +604,7 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
603 struct skge_hw *hw = skge->hw; 604 struct skge_hw *hw = skge->hw;
604 int port = skge->port; 605 int port = skge->port;
605 606
606 spin_lock_bh(&hw->phy_lock); 607 mutex_lock(&hw->phy_mutex);
607 if (hw->chip_id == CHIP_ID_GENESIS) { 608 if (hw->chip_id == CHIP_ID_GENESIS) {
608 switch (mode) { 609 switch (mode) {
609 case LED_MODE_OFF: 610 case LED_MODE_OFF:
@@ -663,7 +664,7 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
663 PHY_M_LED_MO_RX(MO_LED_ON)); 664 PHY_M_LED_MO_RX(MO_LED_ON));
664 } 665 }
665 } 666 }
666 spin_unlock_bh(&hw->phy_lock); 667 mutex_unlock(&hw->phy_mutex);
667} 668}
668 669
669/* blink LED's for finding board */ 670/* blink LED's for finding board */
@@ -2038,7 +2039,7 @@ static void skge_phy_reset(struct skge_port *skge)
2038 netif_stop_queue(skge->netdev); 2039 netif_stop_queue(skge->netdev);
2039 netif_carrier_off(skge->netdev); 2040 netif_carrier_off(skge->netdev);
2040 2041
2041 spin_lock_bh(&hw->phy_lock); 2042 mutex_lock(&hw->phy_mutex);
2042 if (hw->chip_id == CHIP_ID_GENESIS) { 2043 if (hw->chip_id == CHIP_ID_GENESIS) {
2043 genesis_reset(hw, port); 2044 genesis_reset(hw, port);
2044 genesis_mac_init(hw, port); 2045 genesis_mac_init(hw, port);
@@ -2046,7 +2047,7 @@ static void skge_phy_reset(struct skge_port *skge)
2046 yukon_reset(hw, port); 2047 yukon_reset(hw, port);
2047 yukon_init(hw, port); 2048 yukon_init(hw, port);
2048 } 2049 }
2049 spin_unlock_bh(&hw->phy_lock); 2050 mutex_unlock(&hw->phy_mutex);
2050} 2051}
2051 2052
2052/* Basic MII support */ 2053/* Basic MII support */
@@ -2067,12 +2068,12 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2067 /* fallthru */ 2068 /* fallthru */
2068 case SIOCGMIIREG: { 2069 case SIOCGMIIREG: {
2069 u16 val = 0; 2070 u16 val = 0;
2070 spin_lock_bh(&hw->phy_lock); 2071 mutex_lock(&hw->phy_mutex);
2071 if (hw->chip_id == CHIP_ID_GENESIS) 2072 if (hw->chip_id == CHIP_ID_GENESIS)
2072 err = __xm_phy_read(hw, skge->port, data->reg_num & 0x1f, &val); 2073 err = __xm_phy_read(hw, skge->port, data->reg_num & 0x1f, &val);
2073 else 2074 else
2074 err = __gm_phy_read(hw, skge->port, data->reg_num & 0x1f, &val); 2075 err = __gm_phy_read(hw, skge->port, data->reg_num & 0x1f, &val);
2075 spin_unlock_bh(&hw->phy_lock); 2076 mutex_unlock(&hw->phy_mutex);
2076 data->val_out = val; 2077 data->val_out = val;
2077 break; 2078 break;
2078 } 2079 }
@@ -2081,14 +2082,14 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2081 if (!capable(CAP_NET_ADMIN)) 2082 if (!capable(CAP_NET_ADMIN))
2082 return -EPERM; 2083 return -EPERM;
2083 2084
2084 spin_lock_bh(&hw->phy_lock); 2085 mutex_lock(&hw->phy_mutex);
2085 if (hw->chip_id == CHIP_ID_GENESIS) 2086 if (hw->chip_id == CHIP_ID_GENESIS)
2086 err = xm_phy_write(hw, skge->port, data->reg_num & 0x1f, 2087 err = xm_phy_write(hw, skge->port, data->reg_num & 0x1f,
2087 data->val_in); 2088 data->val_in);
2088 else 2089 else
2089 err = gm_phy_write(hw, skge->port, data->reg_num & 0x1f, 2090 err = gm_phy_write(hw, skge->port, data->reg_num & 0x1f,
2090 data->val_in); 2091 data->val_in);
2091 spin_unlock_bh(&hw->phy_lock); 2092 mutex_unlock(&hw->phy_mutex);
2092 break; 2093 break;
2093 } 2094 }
2094 return err; 2095 return err;
@@ -2191,12 +2192,12 @@ static int skge_up(struct net_device *dev)
2191 goto free_rx_ring; 2192 goto free_rx_ring;
2192 2193
2193 /* Initialize MAC */ 2194 /* Initialize MAC */
2194 spin_lock_bh(&hw->phy_lock); 2195 mutex_lock(&hw->phy_mutex);
2195 if (hw->chip_id == CHIP_ID_GENESIS) 2196 if (hw->chip_id == CHIP_ID_GENESIS)
2196 genesis_mac_init(hw, port); 2197 genesis_mac_init(hw, port);
2197 else 2198 else
2198 yukon_mac_init(hw, port); 2199 yukon_mac_init(hw, port);
2199 spin_unlock_bh(&hw->phy_lock); 2200 mutex_unlock(&hw->phy_mutex);
2200 2201
2201 /* Configure RAMbuffers */ 2202 /* Configure RAMbuffers */
2202 chunk = hw->ram_size / ((hw->ports + 1)*2); 2203 chunk = hw->ram_size / ((hw->ports + 1)*2);
@@ -2302,21 +2303,20 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2302{ 2303{
2303 struct skge_port *skge = netdev_priv(dev); 2304 struct skge_port *skge = netdev_priv(dev);
2304 struct skge_hw *hw = skge->hw; 2305 struct skge_hw *hw = skge->hw;
2305 struct skge_ring *ring = &skge->tx_ring;
2306 struct skge_element *e; 2306 struct skge_element *e;
2307 struct skge_tx_desc *td; 2307 struct skge_tx_desc *td;
2308 int i; 2308 int i;
2309 u32 control, len; 2309 u32 control, len;
2310 u64 map; 2310 u64 map;
2311 unsigned long flags;
2311 2312
2312 skb = skb_padto(skb, ETH_ZLEN); 2313 skb = skb_padto(skb, ETH_ZLEN);
2313 if (!skb) 2314 if (!skb)
2314 return NETDEV_TX_OK; 2315 return NETDEV_TX_OK;
2315 2316
2316 if (!spin_trylock(&skge->tx_lock)) { 2317 if (!spin_trylock_irqsave(&skge->tx_lock, flags))
2317 /* Collision - tell upper layer to requeue */ 2318 /* Collision - tell upper layer to requeue */
2318 return NETDEV_TX_LOCKED; 2319 return NETDEV_TX_LOCKED;
2319 }
2320 2320
2321 if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1)) { 2321 if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1)) {
2322 if (!netif_queue_stopped(dev)) { 2322 if (!netif_queue_stopped(dev)) {
@@ -2325,12 +2325,13 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2325 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", 2325 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n",
2326 dev->name); 2326 dev->name);
2327 } 2327 }
2328 spin_unlock(&skge->tx_lock); 2328 spin_unlock_irqrestore(&skge->tx_lock, flags);
2329 return NETDEV_TX_BUSY; 2329 return NETDEV_TX_BUSY;
2330 } 2330 }
2331 2331
2332 e = ring->to_use; 2332 e = skge->tx_ring.to_use;
2333 td = e->desc; 2333 td = e->desc;
2334 BUG_ON(td->control & BMU_OWN);
2334 e->skb = skb; 2335 e->skb = skb;
2335 len = skb_headlen(skb); 2336 len = skb_headlen(skb);
2336 map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE); 2337 map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
@@ -2371,8 +2372,10 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2371 frag->size, PCI_DMA_TODEVICE); 2372 frag->size, PCI_DMA_TODEVICE);
2372 2373
2373 e = e->next; 2374 e = e->next;
2374 e->skb = NULL; 2375 e->skb = skb;
2375 tf = e->desc; 2376 tf = e->desc;
2377 BUG_ON(tf->control & BMU_OWN);
2378
2376 tf->dma_lo = map; 2379 tf->dma_lo = map;
2377 tf->dma_hi = (u64) map >> 32; 2380 tf->dma_hi = (u64) map >> 32;
2378 pci_unmap_addr_set(e, mapaddr, map); 2381 pci_unmap_addr_set(e, mapaddr, map);
@@ -2389,56 +2392,68 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2389 2392
2390 skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START); 2393 skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START);
2391 2394
2392 if (netif_msg_tx_queued(skge)) 2395 if (unlikely(netif_msg_tx_queued(skge)))
2393 printk(KERN_DEBUG "%s: tx queued, slot %td, len %d\n", 2396 printk(KERN_DEBUG "%s: tx queued, slot %td, len %d\n",
2394 dev->name, e - ring->start, skb->len); 2397 dev->name, e - skge->tx_ring.start, skb->len);
2395 2398
2396 ring->to_use = e->next; 2399 skge->tx_ring.to_use = e->next;
2397 if (skge_avail(&skge->tx_ring) <= MAX_SKB_FRAGS + 1) { 2400 if (skge_avail(&skge->tx_ring) <= TX_LOW_WATER) {
2398 pr_debug("%s: transmit queue full\n", dev->name); 2401 pr_debug("%s: transmit queue full\n", dev->name);
2399 netif_stop_queue(dev); 2402 netif_stop_queue(dev);
2400 } 2403 }
2401 2404
2402 mmiowb(); 2405 spin_unlock_irqrestore(&skge->tx_lock, flags);
2403 spin_unlock(&skge->tx_lock);
2404 2406
2405 dev->trans_start = jiffies; 2407 dev->trans_start = jiffies;
2406 2408
2407 return NETDEV_TX_OK; 2409 return NETDEV_TX_OK;
2408} 2410}
2409 2411
2410static void skge_tx_complete(struct skge_port *skge, struct skge_element *last) 2412
2413/* Free resources associated with this reing element */
2414static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
2415 u32 control)
2411{ 2416{
2412 struct pci_dev *pdev = skge->hw->pdev; 2417 struct pci_dev *pdev = skge->hw->pdev;
2413 struct skge_element *e;
2414 2418
2415 for (e = skge->tx_ring.to_clean; e != last; e = e->next) { 2419 BUG_ON(!e->skb);
2416 struct sk_buff *skb = e->skb;
2417 int i;
2418 2420
2419 e->skb = NULL; 2421 /* skb header vs. fragment */
2422 if (control & BMU_STF)
2420 pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr), 2423 pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr),
2421 skb_headlen(skb), PCI_DMA_TODEVICE); 2424 pci_unmap_len(e, maplen),
2425 PCI_DMA_TODEVICE);
2426 else
2427 pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr),
2428 pci_unmap_len(e, maplen),
2429 PCI_DMA_TODEVICE);
2422 2430
2423 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 2431 if (control & BMU_EOF) {
2424 e = e->next; 2432 if (unlikely(netif_msg_tx_done(skge)))
2425 pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr), 2433 printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
2426 skb_shinfo(skb)->frags[i].size, 2434 skge->netdev->name, e - skge->tx_ring.start);
2427 PCI_DMA_TODEVICE);
2428 }
2429 2435
2430 dev_kfree_skb(skb); 2436 dev_kfree_skb_any(e->skb);
2431 } 2437 }
2432 skge->tx_ring.to_clean = e; 2438 e->skb = NULL;
2433} 2439}
2434 2440
2441/* Free all buffers in transmit ring */
2435static void skge_tx_clean(struct skge_port *skge) 2442static void skge_tx_clean(struct skge_port *skge)
2436{ 2443{
2444 struct skge_element *e;
2445 unsigned long flags;
2446
2447 spin_lock_irqsave(&skge->tx_lock, flags);
2448 for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
2449 struct skge_tx_desc *td = e->desc;
2450 skge_tx_free(skge, e, td->control);
2451 td->control = 0;
2452 }
2437 2453
2438 spin_lock_bh(&skge->tx_lock); 2454 skge->tx_ring.to_clean = e;
2439 skge_tx_complete(skge, skge->tx_ring.to_use);
2440 netif_wake_queue(skge->netdev); 2455 netif_wake_queue(skge->netdev);
2441 spin_unlock_bh(&skge->tx_lock); 2456 spin_unlock_irqrestore(&skge->tx_lock, flags);
2442} 2457}
2443 2458
2444static void skge_tx_timeout(struct net_device *dev) 2459static void skge_tx_timeout(struct net_device *dev)
@@ -2664,32 +2679,28 @@ resubmit:
2664 return NULL; 2679 return NULL;
2665} 2680}
2666 2681
2667static void skge_tx_done(struct skge_port *skge) 2682/* Free all buffers in Tx ring which are no longer owned by device */
2683static void skge_txirq(struct net_device *dev)
2668{ 2684{
2685 struct skge_port *skge = netdev_priv(dev);
2669 struct skge_ring *ring = &skge->tx_ring; 2686 struct skge_ring *ring = &skge->tx_ring;
2670 struct skge_element *e, *last; 2687 struct skge_element *e;
2688
2689 rmb();
2671 2690
2672 spin_lock(&skge->tx_lock); 2691 spin_lock(&skge->tx_lock);
2673 last = ring->to_clean;
2674 for (e = ring->to_clean; e != ring->to_use; e = e->next) { 2692 for (e = ring->to_clean; e != ring->to_use; e = e->next) {
2675 struct skge_tx_desc *td = e->desc; 2693 struct skge_tx_desc *td = e->desc;
2676 2694
2677 if (td->control & BMU_OWN) 2695 if (td->control & BMU_OWN)
2678 break; 2696 break;
2679 2697
2680 if (td->control & BMU_EOF) { 2698 skge_tx_free(skge, e, td->control);
2681 last = e->next;
2682 if (unlikely(netif_msg_tx_done(skge)))
2683 printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
2684 skge->netdev->name, e - ring->start);
2685 }
2686 } 2699 }
2700 skge->tx_ring.to_clean = e;
2687 2701
2688 skge_tx_complete(skge, last); 2702 if (netif_queue_stopped(skge->netdev)
2689 2703 && skge_avail(&skge->tx_ring) > TX_LOW_WATER)
2690 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
2691
2692 if (skge_avail(&skge->tx_ring) > MAX_SKB_FRAGS + 1)
2693 netif_wake_queue(skge->netdev); 2704 netif_wake_queue(skge->netdev);
2694 2705
2695 spin_unlock(&skge->tx_lock); 2706 spin_unlock(&skge->tx_lock);
@@ -2704,8 +2715,6 @@ static int skge_poll(struct net_device *dev, int *budget)
2704 int to_do = min(dev->quota, *budget); 2715 int to_do = min(dev->quota, *budget);
2705 int work_done = 0; 2716 int work_done = 0;
2706 2717
2707 skge_tx_done(skge);
2708
2709 for (e = ring->to_clean; prefetch(e->next), work_done < to_do; e = e->next) { 2718 for (e = ring->to_clean; prefetch(e->next), work_done < to_do; e = e->next) {
2710 struct skge_rx_desc *rd = e->desc; 2719 struct skge_rx_desc *rd = e->desc;
2711 struct sk_buff *skb; 2720 struct sk_buff *skb;
@@ -2737,10 +2746,12 @@ static int skge_poll(struct net_device *dev, int *budget)
2737 return 1; /* not done */ 2746 return 1; /* not done */
2738 2747
2739 netif_rx_complete(dev); 2748 netif_rx_complete(dev);
2740 mmiowb();
2741 2749
2742 hw->intr_mask |= skge->port == 0 ? (IS_R1_F|IS_XA1_F) : (IS_R2_F|IS_XA2_F); 2750 spin_lock_irq(&hw->hw_lock);
2751 hw->intr_mask |= rxirqmask[skge->port];
2743 skge_write32(hw, B0_IMSK, hw->intr_mask); 2752 skge_write32(hw, B0_IMSK, hw->intr_mask);
2753 mmiowb();
2754 spin_unlock_irq(&hw->hw_lock);
2744 2755
2745 return 0; 2756 return 0;
2746} 2757}
@@ -2847,16 +2858,16 @@ static void skge_error_irq(struct skge_hw *hw)
2847} 2858}
2848 2859
2849/* 2860/*
2850 * Interrupt from PHY are handled in tasklet (soft irq) 2861 * Interrupt from PHY are handled in work queue
2851 * because accessing phy registers requires spin wait which might 2862 * because accessing phy registers requires spin wait which might
2852 * cause excess interrupt latency. 2863 * cause excess interrupt latency.
2853 */ 2864 */
2854static void skge_extirq(unsigned long data) 2865static void skge_extirq(void *arg)
2855{ 2866{
2856 struct skge_hw *hw = (struct skge_hw *) data; 2867 struct skge_hw *hw = arg;
2857 int port; 2868 int port;
2858 2869
2859 spin_lock(&hw->phy_lock); 2870 mutex_lock(&hw->phy_mutex);
2860 for (port = 0; port < hw->ports; port++) { 2871 for (port = 0; port < hw->ports; port++) {
2861 struct net_device *dev = hw->dev[port]; 2872 struct net_device *dev = hw->dev[port];
2862 struct skge_port *skge = netdev_priv(dev); 2873 struct skge_port *skge = netdev_priv(dev);
@@ -2868,10 +2879,12 @@ static void skge_extirq(unsigned long data)
2868 bcom_phy_intr(skge); 2879 bcom_phy_intr(skge);
2869 } 2880 }
2870 } 2881 }
2871 spin_unlock(&hw->phy_lock); 2882 mutex_unlock(&hw->phy_mutex);
2872 2883
2884 spin_lock_irq(&hw->hw_lock);
2873 hw->intr_mask |= IS_EXT_REG; 2885 hw->intr_mask |= IS_EXT_REG;
2874 skge_write32(hw, B0_IMSK, hw->intr_mask); 2886 skge_write32(hw, B0_IMSK, hw->intr_mask);
2887 spin_unlock_irq(&hw->hw_lock);
2875} 2888}
2876 2889
2877static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs) 2890static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
@@ -2884,54 +2897,68 @@ static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
2884 if (status == 0) 2897 if (status == 0)
2885 return IRQ_NONE; 2898 return IRQ_NONE;
2886 2899
2900 spin_lock(&hw->hw_lock);
2901 status &= hw->intr_mask;
2887 if (status & IS_EXT_REG) { 2902 if (status & IS_EXT_REG) {
2888 hw->intr_mask &= ~IS_EXT_REG; 2903 hw->intr_mask &= ~IS_EXT_REG;
2889 tasklet_schedule(&hw->ext_tasklet); 2904 schedule_work(&hw->phy_work);
2890 } 2905 }
2891 2906
2892 if (status & (IS_R1_F|IS_XA1_F)) { 2907 if (status & IS_XA1_F) {
2893 skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F); 2908 skge_write8(hw, Q_ADDR(Q_XA1, Q_CSR), CSR_IRQ_CL_F);
2894 hw->intr_mask &= ~(IS_R1_F|IS_XA1_F); 2909 skge_txirq(hw->dev[0]);
2895 netif_rx_schedule(hw->dev[0]);
2896 } 2910 }
2897 2911
2898 if (status & (IS_R2_F|IS_XA2_F)) { 2912 if (status & IS_R1_F) {
2899 skge_write8(hw, Q_ADDR(Q_R2, Q_CSR), CSR_IRQ_CL_F); 2913 skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F);
2900 hw->intr_mask &= ~(IS_R2_F|IS_XA2_F); 2914 hw->intr_mask &= ~IS_R1_F;
2901 netif_rx_schedule(hw->dev[1]); 2915 netif_rx_schedule(hw->dev[0]);
2902 } 2916 }
2903 2917
2904 if (likely((status & hw->intr_mask) == 0)) 2918 if (status & IS_PA_TO_TX1)
2905 return IRQ_HANDLED; 2919 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX1);
2906 2920
2907 if (status & IS_PA_TO_RX1) { 2921 if (status & IS_PA_TO_RX1) {
2908 struct skge_port *skge = netdev_priv(hw->dev[0]); 2922 struct skge_port *skge = netdev_priv(hw->dev[0]);
2909 ++skge->net_stats.rx_over_errors;
2910 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX1);
2911 }
2912 2923
2913 if (status & IS_PA_TO_RX2) {
2914 struct skge_port *skge = netdev_priv(hw->dev[1]);
2915 ++skge->net_stats.rx_over_errors; 2924 ++skge->net_stats.rx_over_errors;
2916 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX2); 2925 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX1);
2917 } 2926 }
2918 2927
2919 if (status & IS_PA_TO_TX1)
2920 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX1);
2921
2922 if (status & IS_PA_TO_TX2)
2923 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX2);
2924 2928
2925 if (status & IS_MAC1) 2929 if (status & IS_MAC1)
2926 skge_mac_intr(hw, 0); 2930 skge_mac_intr(hw, 0);
2927 2931
2928 if (status & IS_MAC2) 2932 if (hw->dev[1]) {
2929 skge_mac_intr(hw, 1); 2933 if (status & IS_XA2_F) {
2934 skge_write8(hw, Q_ADDR(Q_XA2, Q_CSR), CSR_IRQ_CL_F);
2935 skge_txirq(hw->dev[1]);
2936 }
2937
2938 if (status & IS_R2_F) {
2939 skge_write8(hw, Q_ADDR(Q_R2, Q_CSR), CSR_IRQ_CL_F);
2940 hw->intr_mask &= ~IS_R2_F;
2941 netif_rx_schedule(hw->dev[1]);
2942 }
2943
2944 if (status & IS_PA_TO_RX2) {
2945 struct skge_port *skge = netdev_priv(hw->dev[1]);
2946 ++skge->net_stats.rx_over_errors;
2947 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_RX2);
2948 }
2949
2950 if (status & IS_PA_TO_TX2)
2951 skge_write16(hw, B3_PA_CTRL, PA_CLR_TO_TX2);
2952
2953 if (status & IS_MAC2)
2954 skge_mac_intr(hw, 1);
2955 }
2930 2956
2931 if (status & IS_HW_ERR) 2957 if (status & IS_HW_ERR)
2932 skge_error_irq(hw); 2958 skge_error_irq(hw);
2933 2959
2934 skge_write32(hw, B0_IMSK, hw->intr_mask); 2960 skge_write32(hw, B0_IMSK, hw->intr_mask);
2961 spin_unlock(&hw->hw_lock);
2935 2962
2936 return IRQ_HANDLED; 2963 return IRQ_HANDLED;
2937} 2964}
@@ -2957,7 +2984,7 @@ static int skge_set_mac_address(struct net_device *dev, void *p)
2957 if (!is_valid_ether_addr(addr->sa_data)) 2984 if (!is_valid_ether_addr(addr->sa_data))
2958 return -EADDRNOTAVAIL; 2985 return -EADDRNOTAVAIL;
2959 2986
2960 spin_lock_bh(&hw->phy_lock); 2987 mutex_lock(&hw->phy_mutex);
2961 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 2988 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
2962 memcpy_toio(hw->regs + B2_MAC_1 + port*8, 2989 memcpy_toio(hw->regs + B2_MAC_1 + port*8,
2963 dev->dev_addr, ETH_ALEN); 2990 dev->dev_addr, ETH_ALEN);
@@ -2970,7 +2997,7 @@ static int skge_set_mac_address(struct net_device *dev, void *p)
2970 gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr); 2997 gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
2971 gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr); 2998 gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
2972 } 2999 }
2973 spin_unlock_bh(&hw->phy_lock); 3000 mutex_unlock(&hw->phy_mutex);
2974 3001
2975 return 0; 3002 return 0;
2976} 3003}
@@ -3082,6 +3109,7 @@ static int skge_reset(struct skge_hw *hw)
3082 else 3109 else
3083 hw->ram_size = t8 * 4096; 3110 hw->ram_size = t8 * 4096;
3084 3111
3112 spin_lock_init(&hw->hw_lock);
3085 hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1; 3113 hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1;
3086 if (hw->ports > 1) 3114 if (hw->ports > 1)
3087 hw->intr_mask |= IS_PORT_2; 3115 hw->intr_mask |= IS_PORT_2;
@@ -3150,14 +3178,14 @@ static int skge_reset(struct skge_hw *hw)
3150 3178
3151 skge_write32(hw, B0_IMSK, hw->intr_mask); 3179 skge_write32(hw, B0_IMSK, hw->intr_mask);
3152 3180
3153 spin_lock_bh(&hw->phy_lock); 3181 mutex_lock(&hw->phy_mutex);
3154 for (i = 0; i < hw->ports; i++) { 3182 for (i = 0; i < hw->ports; i++) {
3155 if (hw->chip_id == CHIP_ID_GENESIS) 3183 if (hw->chip_id == CHIP_ID_GENESIS)
3156 genesis_reset(hw, i); 3184 genesis_reset(hw, i);
3157 else 3185 else
3158 yukon_reset(hw, i); 3186 yukon_reset(hw, i);
3159 } 3187 }
3160 spin_unlock_bh(&hw->phy_lock); 3188 mutex_unlock(&hw->phy_mutex);
3161 3189
3162 return 0; 3190 return 0;
3163} 3191}
@@ -3305,8 +3333,8 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3305 } 3333 }
3306 3334
3307 hw->pdev = pdev; 3335 hw->pdev = pdev;
3308 spin_lock_init(&hw->phy_lock); 3336 mutex_init(&hw->phy_mutex);
3309 tasklet_init(&hw->ext_tasklet, skge_extirq, (unsigned long) hw); 3337 INIT_WORK(&hw->phy_work, skge_extirq, hw);
3310 3338
3311 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); 3339 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
3312 if (!hw->regs) { 3340 if (!hw->regs) {
@@ -3334,6 +3362,14 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3334 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL) 3362 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL)
3335 goto err_out_led_off; 3363 goto err_out_led_off;
3336 3364
3365 if (!is_valid_ether_addr(dev->dev_addr)) {
3366 printk(KERN_ERR PFX "%s: bad (zero?) ethernet address in rom\n",
3367 pci_name(pdev));
3368 err = -EIO;
3369 goto err_out_free_netdev;
3370 }
3371
3372
3337 err = register_netdev(dev); 3373 err = register_netdev(dev);
3338 if (err) { 3374 if (err) {
3339 printk(KERN_ERR PFX "%s: cannot register net device\n", 3375 printk(KERN_ERR PFX "%s: cannot register net device\n",
@@ -3388,11 +3424,15 @@ static void __devexit skge_remove(struct pci_dev *pdev)
3388 dev0 = hw->dev[0]; 3424 dev0 = hw->dev[0];
3389 unregister_netdev(dev0); 3425 unregister_netdev(dev0);
3390 3426
3427 spin_lock_irq(&hw->hw_lock);
3428 hw->intr_mask = 0;
3391 skge_write32(hw, B0_IMSK, 0); 3429 skge_write32(hw, B0_IMSK, 0);
3430 spin_unlock_irq(&hw->hw_lock);
3431
3392 skge_write16(hw, B0_LED, LED_STAT_OFF); 3432 skge_write16(hw, B0_LED, LED_STAT_OFF);
3393 skge_write8(hw, B0_CTST, CS_RST_SET); 3433 skge_write8(hw, B0_CTST, CS_RST_SET);
3394 3434
3395 tasklet_kill(&hw->ext_tasklet); 3435 flush_scheduled_work();
3396 3436
3397 free_irq(pdev->irq, hw); 3437 free_irq(pdev->irq, hw);
3398 pci_release_regions(pdev); 3438 pci_release_regions(pdev);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 1f1ce88c8186..ed19ff47ce11 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2388,6 +2388,7 @@ struct skge_ring {
2388struct skge_hw { 2388struct skge_hw {
2389 void __iomem *regs; 2389 void __iomem *regs;
2390 struct pci_dev *pdev; 2390 struct pci_dev *pdev;
2391 spinlock_t hw_lock;
2391 u32 intr_mask; 2392 u32 intr_mask;
2392 struct net_device *dev[2]; 2393 struct net_device *dev[2];
2393 2394
@@ -2399,9 +2400,8 @@ struct skge_hw {
2399 u32 ram_size; 2400 u32 ram_size;
2400 u32 ram_offset; 2401 u32 ram_offset;
2401 u16 phy_addr; 2402 u16 phy_addr;
2402 2403 struct work_struct phy_work;
2403 struct tasklet_struct ext_tasklet; 2404 struct mutex phy_mutex;
2404 spinlock_t phy_lock;
2405}; 2405};
2406 2406
2407enum { 2407enum {
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 959109609d85..fba1e4d4d83d 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -187,12 +187,11 @@ static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
187 return v; 187 return v;
188} 188}
189 189
190static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state) 190static void sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
191{ 191{
192 u16 power_control; 192 u16 power_control;
193 u32 reg1; 193 u32 reg1;
194 int vaux; 194 int vaux;
195 int ret = 0;
196 195
197 pr_debug("sky2_set_power_state %d\n", state); 196 pr_debug("sky2_set_power_state %d\n", state);
198 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 197 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
@@ -275,12 +274,10 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
275 break; 274 break;
276 default: 275 default:
277 printk(KERN_ERR PFX "Unknown power state %d\n", state); 276 printk(KERN_ERR PFX "Unknown power state %d\n", state);
278 ret = -1;
279 } 277 }
280 278
281 sky2_pci_write16(hw, hw->pm_cap + PCI_PM_CTRL, power_control); 279 sky2_pci_write16(hw, hw->pm_cap + PCI_PM_CTRL, power_control);
282 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 280 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
283 return ret;
284} 281}
285 282
286static void sky2_phy_reset(struct sky2_hw *hw, unsigned port) 283static void sky2_phy_reset(struct sky2_hw *hw, unsigned port)
@@ -2164,6 +2161,13 @@ static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port,
2164/* If idle then force a fake soft NAPI poll once a second 2161/* If idle then force a fake soft NAPI poll once a second
2165 * to work around cases where sharing an edge triggered interrupt. 2162 * to work around cases where sharing an edge triggered interrupt.
2166 */ 2163 */
2164static inline void sky2_idle_start(struct sky2_hw *hw)
2165{
2166 if (idle_timeout > 0)
2167 mod_timer(&hw->idle_timer,
2168 jiffies + msecs_to_jiffies(idle_timeout));
2169}
2170
2167static void sky2_idle(unsigned long arg) 2171static void sky2_idle(unsigned long arg)
2168{ 2172{
2169 struct sky2_hw *hw = (struct sky2_hw *) arg; 2173 struct sky2_hw *hw = (struct sky2_hw *) arg;
@@ -2183,6 +2187,9 @@ static int sky2_poll(struct net_device *dev0, int *budget)
2183 int work_done = 0; 2187 int work_done = 0;
2184 u32 status = sky2_read32(hw, B0_Y2_SP_EISR); 2188 u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
2185 2189
2190 if (!~status)
2191 goto out;
2192
2186 if (status & Y2_IS_HW_ERR) 2193 if (status & Y2_IS_HW_ERR)
2187 sky2_hw_intr(hw); 2194 sky2_hw_intr(hw);
2188 2195
@@ -2219,7 +2226,7 @@ static int sky2_poll(struct net_device *dev0, int *budget)
2219 2226
2220 if (sky2_more_work(hw)) 2227 if (sky2_more_work(hw))
2221 return 1; 2228 return 1;
2222 2229out:
2223 netif_rx_complete(dev0); 2230 netif_rx_complete(dev0);
2224 2231
2225 sky2_read32(hw, B0_Y2_SP_LISR); 2232 sky2_read32(hw, B0_Y2_SP_LISR);
@@ -2248,8 +2255,10 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs)
2248static void sky2_netpoll(struct net_device *dev) 2255static void sky2_netpoll(struct net_device *dev)
2249{ 2256{
2250 struct sky2_port *sky2 = netdev_priv(dev); 2257 struct sky2_port *sky2 = netdev_priv(dev);
2258 struct net_device *dev0 = sky2->hw->dev[0];
2251 2259
2252 sky2_intr(sky2->hw->pdev->irq, sky2->hw, NULL); 2260 if (netif_running(dev) && __netif_rx_schedule_prep(dev0))
2261 __netif_rx_schedule(dev0);
2253} 2262}
2254#endif 2263#endif
2255 2264
@@ -3350,9 +3359,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3350 sky2_write32(hw, B0_IMSK, Y2_IS_BASE); 3359 sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
3351 3360
3352 setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); 3361 setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw);
3353 if (idle_timeout > 0) 3362 sky2_idle_start(hw);
3354 mod_timer(&hw->idle_timer,
3355 jiffies + msecs_to_jiffies(idle_timeout));
3356 3363
3357 pci_set_drvdata(pdev, hw); 3364 pci_set_drvdata(pdev, hw);
3358 3365
@@ -3425,8 +3432,14 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3425{ 3432{
3426 struct sky2_hw *hw = pci_get_drvdata(pdev); 3433 struct sky2_hw *hw = pci_get_drvdata(pdev);
3427 int i; 3434 int i;
3435 pci_power_t pstate = pci_choose_state(pdev, state);
3436
3437 if (!(pstate == PCI_D3hot || pstate == PCI_D3cold))
3438 return -EINVAL;
3439
3440 del_timer_sync(&hw->idle_timer);
3428 3441
3429 for (i = 0; i < 2; i++) { 3442 for (i = 0; i < hw->ports; i++) {
3430 struct net_device *dev = hw->dev[i]; 3443 struct net_device *dev = hw->dev[i];
3431 3444
3432 if (dev) { 3445 if (dev) {
@@ -3435,10 +3448,14 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3435 3448
3436 sky2_down(dev); 3449 sky2_down(dev);
3437 netif_device_detach(dev); 3450 netif_device_detach(dev);
3451 netif_poll_disable(dev);
3438 } 3452 }
3439 } 3453 }
3440 3454
3441 return sky2_set_power_state(hw, pci_choose_state(pdev, state)); 3455 sky2_write32(hw, B0_IMSK, 0);
3456 pci_save_state(pdev);
3457 sky2_set_power_state(hw, pstate);
3458 return 0;
3442} 3459}
3443 3460
3444static int sky2_resume(struct pci_dev *pdev) 3461static int sky2_resume(struct pci_dev *pdev)
@@ -3448,27 +3465,31 @@ static int sky2_resume(struct pci_dev *pdev)
3448 3465
3449 pci_restore_state(pdev); 3466 pci_restore_state(pdev);
3450 pci_enable_wake(pdev, PCI_D0, 0); 3467 pci_enable_wake(pdev, PCI_D0, 0);
3451 err = sky2_set_power_state(hw, PCI_D0); 3468 sky2_set_power_state(hw, PCI_D0);
3452 if (err)
3453 goto out;
3454 3469
3455 err = sky2_reset(hw); 3470 err = sky2_reset(hw);
3456 if (err) 3471 if (err)
3457 goto out; 3472 goto out;
3458 3473
3459 for (i = 0; i < 2; i++) { 3474 sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
3475
3476 for (i = 0; i < hw->ports; i++) {
3460 struct net_device *dev = hw->dev[i]; 3477 struct net_device *dev = hw->dev[i];
3461 if (dev && netif_running(dev)) { 3478 if (dev && netif_running(dev)) {
3462 netif_device_attach(dev); 3479 netif_device_attach(dev);
3480 netif_poll_enable(dev);
3481
3463 err = sky2_up(dev); 3482 err = sky2_up(dev);
3464 if (err) { 3483 if (err) {
3465 printk(KERN_ERR PFX "%s: could not up: %d\n", 3484 printk(KERN_ERR PFX "%s: could not up: %d\n",
3466 dev->name, err); 3485 dev->name, err);
3467 dev_close(dev); 3486 dev_close(dev);
3468 break; 3487 goto out;
3469 } 3488 }
3470 } 3489 }
3471 } 3490 }
3491
3492 sky2_idle_start(hw);
3472out: 3493out:
3473 return err; 3494 return err;
3474} 3495}
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index 3db30cd0625e..5b4e8529d4ab 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -553,7 +553,7 @@ MODULE_LICENSE("GPL");
553 553
554/* This is set up so that only a single autoprobe takes place per call. 554/* This is set up so that only a single autoprobe takes place per call.
555ISA device autoprobes on a running machine are not recommended. */ 555ISA device autoprobes on a running machine are not recommended. */
556int 556int __init
557init_module(void) 557init_module(void)
558{ 558{
559 struct net_device *dev; 559 struct net_device *dev;
diff --git a/drivers/net/smc-ultra32.c b/drivers/net/smc-ultra32.c
index b3e397d7ca85..ff9bd97746dc 100644
--- a/drivers/net/smc-ultra32.c
+++ b/drivers/net/smc-ultra32.c
@@ -421,7 +421,7 @@ static struct net_device *dev_ultra[MAX_ULTRA32_CARDS];
421MODULE_DESCRIPTION("SMC Ultra32 EISA ethernet driver"); 421MODULE_DESCRIPTION("SMC Ultra32 EISA ethernet driver");
422MODULE_LICENSE("GPL"); 422MODULE_LICENSE("GPL");
423 423
424int init_module(void) 424int __init init_module(void)
425{ 425{
426 int this_dev, found = 0; 426 int this_dev, found = 0;
427 427
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
new file mode 100644
index 000000000000..bdd8702ead54
--- /dev/null
+++ b/drivers/net/smc911x.c
@@ -0,0 +1,2307 @@
1/*
2 * smc911x.c
3 * This is a driver for SMSC's LAN911{5,6,7,8} single-chip Ethernet devices.
4 *
5 * Copyright (C) 2005 Sensoria Corp
6 * Derived from the unified SMC91x driver by Nicolas Pitre
7 * and the smsc911x.c reference driver by SMSC
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Arguments:
24 * watchdog = TX watchdog timeout
25 * tx_fifo_kb = Size of TX FIFO in KB
26 *
27 * History:
28 * 04/16/05 Dustin McIntire Initial version
29 */
30static const char version[] =
31 "smc911x.c: v1.0 04-16-2005 by Dustin McIntire <dustin@sensoria.com>\n";
32
33/* Debugging options */
34#define ENABLE_SMC_DEBUG_RX 0
35#define ENABLE_SMC_DEBUG_TX 0
36#define ENABLE_SMC_DEBUG_DMA 0
37#define ENABLE_SMC_DEBUG_PKTS 0
38#define ENABLE_SMC_DEBUG_MISC 0
39#define ENABLE_SMC_DEBUG_FUNC 0
40
41#define SMC_DEBUG_RX ((ENABLE_SMC_DEBUG_RX ? 1 : 0) << 0)
42#define SMC_DEBUG_TX ((ENABLE_SMC_DEBUG_TX ? 1 : 0) << 1)
43#define SMC_DEBUG_DMA ((ENABLE_SMC_DEBUG_DMA ? 1 : 0) << 2)
44#define SMC_DEBUG_PKTS ((ENABLE_SMC_DEBUG_PKTS ? 1 : 0) << 3)
45#define SMC_DEBUG_MISC ((ENABLE_SMC_DEBUG_MISC ? 1 : 0) << 4)
46#define SMC_DEBUG_FUNC ((ENABLE_SMC_DEBUG_FUNC ? 1 : 0) << 5)
47
48#ifndef SMC_DEBUG
49#define SMC_DEBUG ( SMC_DEBUG_RX | \
50 SMC_DEBUG_TX | \
51 SMC_DEBUG_DMA | \
52 SMC_DEBUG_PKTS | \
53 SMC_DEBUG_MISC | \
54 SMC_DEBUG_FUNC \
55 )
56#endif
57
58
59#include <linux/config.h>
60#include <linux/init.h>
61#include <linux/module.h>
62#include <linux/kernel.h>
63#include <linux/sched.h>
64#include <linux/slab.h>
65#include <linux/delay.h>
66#include <linux/interrupt.h>
67#include <linux/errno.h>
68#include <linux/ioport.h>
69#include <linux/crc32.h>
70#include <linux/device.h>
71#include <linux/platform_device.h>
72#include <linux/spinlock.h>
73#include <linux/ethtool.h>
74#include <linux/mii.h>
75#include <linux/workqueue.h>
76
77#include <linux/netdevice.h>
78#include <linux/etherdevice.h>
79#include <linux/skbuff.h>
80
81#include <asm/io.h>
82#include <asm/irq.h>
83
84#include "smc911x.h"
85
86/*
87 * Transmit timeout, default 5 seconds.
88 */
89static int watchdog = 5000;
90module_param(watchdog, int, 0400);
91MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
92
93static int tx_fifo_kb=8;
94module_param(tx_fifo_kb, int, 0400);
95MODULE_PARM_DESC(tx_fifo_kb,"transmit FIFO size in KB (1<x<15)(default=8)");
96
97MODULE_LICENSE("GPL");
98
99/*
100 * The internal workings of the driver. If you are changing anything
101 * here with the SMC stuff, you should have the datasheet and know
102 * what you are doing.
103 */
104#define CARDNAME "smc911x"
105
106/*
107 * Use power-down feature of the chip
108 */
109#define POWER_DOWN 1
110
111
112/* store this information for the driver.. */
113struct smc911x_local {
114 /*
115 * If I have to wait until the DMA is finished and ready to reload a
116 * packet, I will store the skbuff here. Then, the DMA will send it
117 * out and free it.
118 */
119 struct sk_buff *pending_tx_skb;
120
121 /*
122 * these are things that the kernel wants me to keep, so users
123 * can find out semi-useless statistics of how well the card is
124 * performing
125 */
126 struct net_device_stats stats;
127
128 /* version/revision of the SMC911x chip */
129 u16 version;
130 u16 revision;
131
132 /* FIFO sizes */
133 int tx_fifo_kb;
134 int tx_fifo_size;
135 int rx_fifo_size;
136 int afc_cfg;
137
138 /* Contains the current active receive/phy mode */
139 int ctl_rfduplx;
140 int ctl_rspeed;
141
142 u32 msg_enable;
143 u32 phy_type;
144 struct mii_if_info mii;
145
146 /* work queue */
147 struct work_struct phy_configure;
148 int work_pending;
149
150 int tx_throttle;
151 spinlock_t lock;
152
153#ifdef SMC_USE_DMA
154 /* DMA needs the physical address of the chip */
155 u_long physaddr;
156 int rxdma;
157 int txdma;
158 int rxdma_active;
159 int txdma_active;
160 struct sk_buff *current_rx_skb;
161 struct sk_buff *current_tx_skb;
162 struct device *dev;
163#endif
164};
165
166#if SMC_DEBUG > 0
167#define DBG(n, args...) \
168 do { \
169 if (SMC_DEBUG & (n)) \
170 printk(args); \
171 } while (0)
172
173#define PRINTK(args...) printk(args)
174#else
175#define DBG(n, args...) do { } while (0)
176#define PRINTK(args...) printk(KERN_DEBUG args)
177#endif
178
179#if SMC_DEBUG_PKTS > 0
180static void PRINT_PKT(u_char *buf, int length)
181{
182 int i;
183 int remainder;
184 int lines;
185
186 lines = length / 16;
187 remainder = length % 16;
188
189 for (i = 0; i < lines ; i ++) {
190 int cur;
191 for (cur = 0; cur < 8; cur++) {
192 u_char a, b;
193 a = *buf++;
194 b = *buf++;
195 printk("%02x%02x ", a, b);
196 }
197 printk("\n");
198 }
199 for (i = 0; i < remainder/2 ; i++) {
200 u_char a, b;
201 a = *buf++;
202 b = *buf++;
203 printk("%02x%02x ", a, b);
204 }
205 printk("\n");
206}
207#else
208#define PRINT_PKT(x...) do { } while (0)
209#endif
210
211
212/* this enables an interrupt in the interrupt mask register */
213#define SMC_ENABLE_INT(x) do { \
214 unsigned int __mask; \
215 unsigned long __flags; \
216 spin_lock_irqsave(&lp->lock, __flags); \
217 __mask = SMC_GET_INT_EN(); \
218 __mask |= (x); \
219 SMC_SET_INT_EN(__mask); \
220 spin_unlock_irqrestore(&lp->lock, __flags); \
221} while (0)
222
223/* this disables an interrupt from the interrupt mask register */
224#define SMC_DISABLE_INT(x) do { \
225 unsigned int __mask; \
226 unsigned long __flags; \
227 spin_lock_irqsave(&lp->lock, __flags); \
228 __mask = SMC_GET_INT_EN(); \
229 __mask &= ~(x); \
230 SMC_SET_INT_EN(__mask); \
231 spin_unlock_irqrestore(&lp->lock, __flags); \
232} while (0)
233
234/*
235 * this does a soft reset on the device
236 */
237static void smc911x_reset(struct net_device *dev)
238{
239 unsigned long ioaddr = dev->base_addr;
240 struct smc911x_local *lp = netdev_priv(dev);
241 unsigned int reg, timeout=0, resets=1;
242 unsigned long flags;
243
244 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
245
246 /* Take out of PM setting first */
247 if ((SMC_GET_PMT_CTRL() & PMT_CTRL_READY_) == 0) {
248 /* Write to the bytetest will take out of powerdown */
249 SMC_SET_BYTE_TEST(0);
250 timeout=10;
251 do {
252 udelay(10);
253 reg = SMC_GET_PMT_CTRL() & PMT_CTRL_READY_;
254 } while ( timeout-- && !reg);
255 if (timeout == 0) {
256 PRINTK("%s: smc911x_reset timeout waiting for PM restore\n", dev->name);
257 return;
258 }
259 }
260
261 /* Disable all interrupts */
262 spin_lock_irqsave(&lp->lock, flags);
263 SMC_SET_INT_EN(0);
264 spin_unlock_irqrestore(&lp->lock, flags);
265
266 while (resets--) {
267 SMC_SET_HW_CFG(HW_CFG_SRST_);
268 timeout=10;
269 do {
270 udelay(10);
271 reg = SMC_GET_HW_CFG();
272 /* If chip indicates reset timeout then try again */
273 if (reg & HW_CFG_SRST_TO_) {
274 PRINTK("%s: chip reset timeout, retrying...\n", dev->name);
275 resets++;
276 break;
277 }
278 } while ( timeout-- && (reg & HW_CFG_SRST_));
279 }
280 if (timeout == 0) {
281 PRINTK("%s: smc911x_reset timeout waiting for reset\n", dev->name);
282 return;
283 }
284
285 /* make sure EEPROM has finished loading before setting GPIO_CFG */
286 timeout=1000;
287 while ( timeout-- && (SMC_GET_E2P_CMD() & E2P_CMD_EPC_BUSY_)) {
288 udelay(10);
289 }
290 if (timeout == 0){
291 PRINTK("%s: smc911x_reset timeout waiting for EEPROM busy\n", dev->name);
292 return;
293 }
294
295 /* Initialize interrupts */
296 SMC_SET_INT_EN(0);
297 SMC_ACK_INT(-1);
298
299 /* Reset the FIFO level and flow control settings */
300 SMC_SET_HW_CFG((lp->tx_fifo_kb & 0xF) << 16);
301//TODO: Figure out what appropriate pause time is
302 SMC_SET_FLOW(FLOW_FCPT_ | FLOW_FCEN_);
303 SMC_SET_AFC_CFG(lp->afc_cfg);
304
305
306 /* Set to LED outputs */
307 SMC_SET_GPIO_CFG(0x70070000);
308
309 /*
310 * Deassert IRQ for 1*10us for edge type interrupts
311 * and drive IRQ pin push-pull
312 */
313 SMC_SET_IRQ_CFG( (1 << 24) | INT_CFG_IRQ_EN_ | INT_CFG_IRQ_TYPE_ );
314
315 /* clear anything saved */
316 if (lp->pending_tx_skb != NULL) {
317 dev_kfree_skb (lp->pending_tx_skb);
318 lp->pending_tx_skb = NULL;
319 lp->stats.tx_errors++;
320 lp->stats.tx_aborted_errors++;
321 }
322}
323
324/*
325 * Enable Interrupts, Receive, and Transmit
326 */
327static void smc911x_enable(struct net_device *dev)
328{
329 unsigned long ioaddr = dev->base_addr;
330 struct smc911x_local *lp = netdev_priv(dev);
331 unsigned mask, cfg, cr;
332 unsigned long flags;
333
334 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
335
336 SMC_SET_MAC_ADDR(dev->dev_addr);
337
338 /* Enable TX */
339 cfg = SMC_GET_HW_CFG();
340 cfg &= HW_CFG_TX_FIF_SZ_ | 0xFFF;
341 cfg |= HW_CFG_SF_;
342 SMC_SET_HW_CFG(cfg);
343 SMC_SET_FIFO_TDA(0xFF);
344 /* Update TX stats on every 64 packets received or every 1 sec */
345 SMC_SET_FIFO_TSL(64);
346 SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000);
347
348 spin_lock_irqsave(&lp->lock, flags);
349 SMC_GET_MAC_CR(cr);
350 cr |= MAC_CR_TXEN_ | MAC_CR_HBDIS_;
351 SMC_SET_MAC_CR(cr);
352 SMC_SET_TX_CFG(TX_CFG_TX_ON_);
353 spin_unlock_irqrestore(&lp->lock, flags);
354
355 /* Add 2 byte padding to start of packets */
356 SMC_SET_RX_CFG((2<<8) & RX_CFG_RXDOFF_);
357
358 /* Turn on receiver and enable RX */
359 if (cr & MAC_CR_RXEN_)
360 DBG(SMC_DEBUG_RX, "%s: Receiver already enabled\n", dev->name);
361
362 spin_lock_irqsave(&lp->lock, flags);
363 SMC_SET_MAC_CR( cr | MAC_CR_RXEN_ );
364 spin_unlock_irqrestore(&lp->lock, flags);
365
366 /* Interrupt on every received packet */
367 SMC_SET_FIFO_RSA(0x01);
368 SMC_SET_FIFO_RSL(0x00);
369
370 /* now, enable interrupts */
371 mask = INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_ | INT_EN_RSFL_EN_ |
372 INT_EN_GPT_INT_EN_ | INT_EN_RXDFH_INT_EN_ | INT_EN_RXE_EN_ |
373 INT_EN_PHY_INT_EN_;
374 if (IS_REV_A(lp->revision))
375 mask|=INT_EN_RDFL_EN_;
376 else {
377 mask|=INT_EN_RDFO_EN_;
378 }
379 SMC_ENABLE_INT(mask);
380}
381
382/*
383 * this puts the device in an inactive state
384 */
385static void smc911x_shutdown(struct net_device *dev)
386{
387 unsigned long ioaddr = dev->base_addr;
388 struct smc911x_local *lp = netdev_priv(dev);
389 unsigned cr;
390 unsigned long flags;
391
392 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", CARDNAME, __FUNCTION__);
393
394 /* Disable IRQ's */
395 SMC_SET_INT_EN(0);
396
397 /* Turn of Rx and TX */
398 spin_lock_irqsave(&lp->lock, flags);
399 SMC_GET_MAC_CR(cr);
400 cr &= ~(MAC_CR_TXEN_ | MAC_CR_RXEN_ | MAC_CR_HBDIS_);
401 SMC_SET_MAC_CR(cr);
402 SMC_SET_TX_CFG(TX_CFG_STOP_TX_);
403 spin_unlock_irqrestore(&lp->lock, flags);
404}
405
406static inline void smc911x_drop_pkt(struct net_device *dev)
407{
408 unsigned long ioaddr = dev->base_addr;
409 unsigned int fifo_count, timeout, reg;
410
411 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", CARDNAME, __FUNCTION__);
412 fifo_count = SMC_GET_RX_FIFO_INF() & 0xFFFF;
413 if (fifo_count <= 4) {
414 /* Manually dump the packet data */
415 while (fifo_count--)
416 SMC_GET_RX_FIFO();
417 } else {
418 /* Fast forward through the bad packet */
419 SMC_SET_RX_DP_CTRL(RX_DP_CTRL_FFWD_BUSY_);
420 timeout=50;
421 do {
422 udelay(10);
423 reg = SMC_GET_RX_DP_CTRL() & RX_DP_CTRL_FFWD_BUSY_;
424 } while ( timeout-- && reg);
425 if (timeout == 0) {
426 PRINTK("%s: timeout waiting for RX fast forward\n", dev->name);
427 }
428 }
429}
430
431/*
432 * This is the procedure to handle the receipt of a packet.
433 * It should be called after checking for packet presence in
434 * the RX status FIFO. It must be called with the spin lock
435 * already held.
436 */
437static inline void smc911x_rcv(struct net_device *dev)
438{
439 struct smc911x_local *lp = netdev_priv(dev);
440 unsigned long ioaddr = dev->base_addr;
441 unsigned int pkt_len, status;
442 struct sk_buff *skb;
443 unsigned char *data;
444
445 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n",
446 dev->name, __FUNCTION__);
447 status = SMC_GET_RX_STS_FIFO();
448 DBG(SMC_DEBUG_RX, "%s: Rx pkt len %d status 0x%08x \n",
449 dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff);
450 pkt_len = (status & RX_STS_PKT_LEN_) >> 16;
451 if (status & RX_STS_ES_) {
452 /* Deal with a bad packet */
453 lp->stats.rx_errors++;
454 if (status & RX_STS_CRC_ERR_)
455 lp->stats.rx_crc_errors++;
456 else {
457 if (status & RX_STS_LEN_ERR_)
458 lp->stats.rx_length_errors++;
459 if (status & RX_STS_MCAST_)
460 lp->stats.multicast++;
461 }
462 /* Remove the bad packet data from the RX FIFO */
463 smc911x_drop_pkt(dev);
464 } else {
465 /* Receive a valid packet */
466 /* Alloc a buffer with extra room for DMA alignment */
467 skb=dev_alloc_skb(pkt_len+32);
468 if (unlikely(skb == NULL)) {
469 PRINTK( "%s: Low memory, rcvd packet dropped.\n",
470 dev->name);
471 lp->stats.rx_dropped++;
472 smc911x_drop_pkt(dev);
473 return;
474 }
475 /* Align IP header to 32 bits
476 * Note that the device is configured to add a 2
477 * byte padding to the packet start, so we really
478 * want to write to the orignal data pointer */
479 data = skb->data;
480 skb_reserve(skb, 2);
481 skb_put(skb,pkt_len-4);
482#ifdef SMC_USE_DMA
483 {
484 unsigned int fifo;
485 /* Lower the FIFO threshold if possible */
486 fifo = SMC_GET_FIFO_INT();
487 if (fifo & 0xFF) fifo--;
488 DBG(SMC_DEBUG_RX, "%s: Setting RX stat FIFO threshold to %d\n",
489 dev->name, fifo & 0xff);
490 SMC_SET_FIFO_INT(fifo);
491 /* Setup RX DMA */
492 SMC_SET_RX_CFG(RX_CFG_RX_END_ALGN16_ | ((2<<8) & RX_CFG_RXDOFF_));
493 lp->rxdma_active = 1;
494 lp->current_rx_skb = skb;
495 SMC_PULL_DATA(data, (pkt_len+2+15) & ~15);
496 /* Packet processing deferred to DMA RX interrupt */
497 }
498#else
499 SMC_SET_RX_CFG(RX_CFG_RX_END_ALGN4_ | ((2<<8) & RX_CFG_RXDOFF_));
500 SMC_PULL_DATA(data, pkt_len+2+3);
501
502 DBG(SMC_DEBUG_PKTS, "%s: Received packet\n", dev->name,);
503 PRINT_PKT(data, ((pkt_len - 4) <= 64) ? pkt_len - 4 : 64);
504 dev->last_rx = jiffies;
505 skb->dev = dev;
506 skb->protocol = eth_type_trans(skb, dev);
507 netif_rx(skb);
508 lp->stats.rx_packets++;
509 lp->stats.rx_bytes += pkt_len-4;
510#endif
511 }
512}
513
514/*
515 * This is called to actually send a packet to the chip.
516 */
517static void smc911x_hardware_send_pkt(struct net_device *dev)
518{
519 struct smc911x_local *lp = netdev_priv(dev);
520 unsigned long ioaddr = dev->base_addr;
521 struct sk_buff *skb;
522 unsigned int cmdA, cmdB, len;
523 unsigned char *buf;
524 unsigned long flags;
525
526 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_TX, "%s: --> %s\n", dev->name, __FUNCTION__);
527 BUG_ON(lp->pending_tx_skb == NULL);
528
529 skb = lp->pending_tx_skb;
530 lp->pending_tx_skb = NULL;
531
532 /* cmdA {25:24] data alignment [20:16] start offset [10:0] buffer length */
533 /* cmdB {31:16] pkt tag [10:0] length */
534#ifdef SMC_USE_DMA
535 /* 16 byte buffer alignment mode */
536 buf = (char*)((u32)(skb->data) & ~0xF);
537 len = (skb->len + 0xF + ((u32)skb->data & 0xF)) & ~0xF;
538 cmdA = (1<<24) | (((u32)skb->data & 0xF)<<16) |
539 TX_CMD_A_INT_FIRST_SEG_ | TX_CMD_A_INT_LAST_SEG_ |
540 skb->len;
541#else
542 buf = (char*)((u32)skb->data & ~0x3);
543 len = (skb->len + 3 + ((u32)skb->data & 3)) & ~0x3;
544 cmdA = (((u32)skb->data & 0x3) << 16) |
545 TX_CMD_A_INT_FIRST_SEG_ | TX_CMD_A_INT_LAST_SEG_ |
546 skb->len;
547#endif
548 /* tag is packet length so we can use this in stats update later */
549 cmdB = (skb->len << 16) | (skb->len & 0x7FF);
550
551 DBG(SMC_DEBUG_TX, "%s: TX PKT LENGTH 0x%04x (%d) BUF 0x%p CMDA 0x%08x CMDB 0x%08x\n",
552 dev->name, len, len, buf, cmdA, cmdB);
553 SMC_SET_TX_FIFO(cmdA);
554 SMC_SET_TX_FIFO(cmdB);
555
556 DBG(SMC_DEBUG_PKTS, "%s: Transmitted packet\n", dev->name);
557 PRINT_PKT(buf, len <= 64 ? len : 64);
558
559 /* Send pkt via PIO or DMA */
560#ifdef SMC_USE_DMA
561 lp->current_tx_skb = skb;
562 SMC_PUSH_DATA(buf, len);
563 /* DMA complete IRQ will free buffer and set jiffies */
564#else
565 SMC_PUSH_DATA(buf, len);
566 dev->trans_start = jiffies;
567 dev_kfree_skb(skb);
568#endif
569 spin_lock_irqsave(&lp->lock, flags);
570 if (!lp->tx_throttle) {
571 netif_wake_queue(dev);
572 }
573 spin_unlock_irqrestore(&lp->lock, flags);
574 SMC_ENABLE_INT(INT_EN_TDFA_EN_ | INT_EN_TSFL_EN_);
575}
576
577/*
578 * Since I am not sure if I will have enough room in the chip's ram
579 * to store the packet, I call this routine which either sends it
580 * now, or set the card to generates an interrupt when ready
581 * for the packet.
582 */
583static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
584{
585 struct smc911x_local *lp = netdev_priv(dev);
586 unsigned long ioaddr = dev->base_addr;
587 unsigned int free;
588 unsigned long flags;
589
590 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_TX, "%s: --> %s\n",
591 dev->name, __FUNCTION__);
592
593 BUG_ON(lp->pending_tx_skb != NULL);
594
595 free = SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TDFREE_;
596 DBG(SMC_DEBUG_TX, "%s: TX free space %d\n", dev->name, free);
597
598 /* Turn off the flow when running out of space in FIFO */
599 if (free <= SMC911X_TX_FIFO_LOW_THRESHOLD) {
600 DBG(SMC_DEBUG_TX, "%s: Disabling data flow due to low FIFO space (%d)\n",
601 dev->name, free);
602 spin_lock_irqsave(&lp->lock, flags);
603 /* Reenable when at least 1 packet of size MTU present */
604 SMC_SET_FIFO_TDA((SMC911X_TX_FIFO_LOW_THRESHOLD)/64);
605 lp->tx_throttle = 1;
606 netif_stop_queue(dev);
607 spin_unlock_irqrestore(&lp->lock, flags);
608 }
609
610 /* Drop packets when we run out of space in TX FIFO
611 * Account for overhead required for:
612 *
613 * Tx command words 8 bytes
614 * Start offset 15 bytes
615 * End padding 15 bytes
616 */
617 if (unlikely(free < (skb->len + 8 + 15 + 15))) {
618 printk("%s: No Tx free space %d < %d\n",
619 dev->name, free, skb->len);
620 lp->pending_tx_skb = NULL;
621 lp->stats.tx_errors++;
622 lp->stats.tx_dropped++;
623 dev_kfree_skb(skb);
624 return 0;
625 }
626
627#ifdef SMC_USE_DMA
628 {
629 /* If the DMA is already running then defer this packet Tx until
630 * the DMA IRQ starts it
631 */
632 spin_lock_irqsave(&lp->lock, flags);
633 if (lp->txdma_active) {
634 DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, "%s: Tx DMA running, deferring packet\n", dev->name);
635 lp->pending_tx_skb = skb;
636 netif_stop_queue(dev);
637 spin_unlock_irqrestore(&lp->lock, flags);
638 return 0;
639 } else {
640 DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, "%s: Activating Tx DMA\n", dev->name);
641 lp->txdma_active = 1;
642 }
643 spin_unlock_irqrestore(&lp->lock, flags);
644 }
645#endif
646 lp->pending_tx_skb = skb;
647 smc911x_hardware_send_pkt(dev);
648
649 return 0;
650}
651
652/*
653 * This handles a TX status interrupt, which is only called when:
654 * - a TX error occurred, or
655 * - TX of a packet completed.
656 */
657static void smc911x_tx(struct net_device *dev)
658{
659 unsigned long ioaddr = dev->base_addr;
660 struct smc911x_local *lp = netdev_priv(dev);
661 unsigned int tx_status;
662
663 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_TX, "%s: --> %s\n",
664 dev->name, __FUNCTION__);
665
666 /* Collect the TX status */
667 while (((SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TSUSED_) >> 16) != 0) {
668 DBG(SMC_DEBUG_TX, "%s: Tx stat FIFO used 0x%04x\n",
669 dev->name,
670 (SMC_GET_TX_FIFO_INF() & TX_FIFO_INF_TSUSED_) >> 16);
671 tx_status = SMC_GET_TX_STS_FIFO();
672 lp->stats.tx_packets++;
673 lp->stats.tx_bytes+=tx_status>>16;
674 DBG(SMC_DEBUG_TX, "%s: Tx FIFO tag 0x%04x status 0x%04x\n",
675 dev->name, (tx_status & 0xffff0000) >> 16,
676 tx_status & 0x0000ffff);
677 /* count Tx errors, but ignore lost carrier errors when in
678 * full-duplex mode */
679 if ((tx_status & TX_STS_ES_) && !(lp->ctl_rfduplx &&
680 !(tx_status & 0x00000306))) {
681 lp->stats.tx_errors++;
682 }
683 if (tx_status & TX_STS_MANY_COLL_) {
684 lp->stats.collisions+=16;
685 lp->stats.tx_aborted_errors++;
686 } else {
687 lp->stats.collisions+=(tx_status & TX_STS_COLL_CNT_) >> 3;
688 }
689 /* carrier error only has meaning for half-duplex communication */
690 if ((tx_status & (TX_STS_LOC_ | TX_STS_NO_CARR_)) &&
691 !lp->ctl_rfduplx) {
692 lp->stats.tx_carrier_errors++;
693 }
694 if (tx_status & TX_STS_LATE_COLL_) {
695 lp->stats.collisions++;
696 lp->stats.tx_aborted_errors++;
697 }
698 }
699}
700
701
702/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
703/*
704 * Reads a register from the MII Management serial interface
705 */
706
707static int smc911x_phy_read(struct net_device *dev, int phyaddr, int phyreg)
708{
709 unsigned long ioaddr = dev->base_addr;
710 unsigned int phydata;
711
712 SMC_GET_MII(phyreg, phyaddr, phydata);
713
714 DBG(SMC_DEBUG_MISC, "%s: phyaddr=0x%x, phyreg=0x%02x, phydata=0x%04x\n",
715 __FUNCTION__, phyaddr, phyreg, phydata);
716 return phydata;
717}
718
719
720/*
721 * Writes a register to the MII Management serial interface
722 */
723static void smc911x_phy_write(struct net_device *dev, int phyaddr, int phyreg,
724 int phydata)
725{
726 unsigned long ioaddr = dev->base_addr;
727
728 DBG(SMC_DEBUG_MISC, "%s: phyaddr=0x%x, phyreg=0x%x, phydata=0x%x\n",
729 __FUNCTION__, phyaddr, phyreg, phydata);
730
731 SMC_SET_MII(phyreg, phyaddr, phydata);
732}
733
734/*
735 * Finds and reports the PHY address (115 and 117 have external
736 * PHY interface 118 has internal only
737 */
738static void smc911x_phy_detect(struct net_device *dev)
739{
740 unsigned long ioaddr = dev->base_addr;
741 struct smc911x_local *lp = netdev_priv(dev);
742 int phyaddr;
743 unsigned int cfg, id1, id2;
744
745 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
746
747 lp->phy_type = 0;
748
749 /*
750 * Scan all 32 PHY addresses if necessary, starting at
751 * PHY#1 to PHY#31, and then PHY#0 last.
752 */
753 switch(lp->version) {
754 case 0x115:
755 case 0x117:
756 cfg = SMC_GET_HW_CFG();
757 if (cfg & HW_CFG_EXT_PHY_DET_) {
758 cfg &= ~HW_CFG_PHY_CLK_SEL_;
759 cfg |= HW_CFG_PHY_CLK_SEL_CLK_DIS_;
760 SMC_SET_HW_CFG(cfg);
761 udelay(10); /* Wait for clocks to stop */
762
763 cfg |= HW_CFG_EXT_PHY_EN_;
764 SMC_SET_HW_CFG(cfg);
765 udelay(10); /* Wait for clocks to stop */
766
767 cfg &= ~HW_CFG_PHY_CLK_SEL_;
768 cfg |= HW_CFG_PHY_CLK_SEL_EXT_PHY_;
769 SMC_SET_HW_CFG(cfg);
770 udelay(10); /* Wait for clocks to stop */
771
772 cfg |= HW_CFG_SMI_SEL_;
773 SMC_SET_HW_CFG(cfg);
774
775 for (phyaddr = 1; phyaddr < 32; ++phyaddr) {
776
777 /* Read the PHY identifiers */
778 SMC_GET_PHY_ID1(phyaddr & 31, id1);
779 SMC_GET_PHY_ID2(phyaddr & 31, id2);
780
781 /* Make sure it is a valid identifier */
782 if (id1 != 0x0000 && id1 != 0xffff &&
783 id1 != 0x8000 && id2 != 0x0000 &&
784 id2 != 0xffff && id2 != 0x8000) {
785 /* Save the PHY's address */
786 lp->mii.phy_id = phyaddr & 31;
787 lp->phy_type = id1 << 16 | id2;
788 break;
789 }
790 }
791 }
792 default:
793 /* Internal media only */
794 SMC_GET_PHY_ID1(1, id1);
795 SMC_GET_PHY_ID2(1, id2);
796 /* Save the PHY's address */
797 lp->mii.phy_id = 1;
798 lp->phy_type = id1 << 16 | id2;
799 }
800
801 DBG(SMC_DEBUG_MISC, "%s: phy_id1=0x%x, phy_id2=0x%x phyaddr=0x%d\n",
802 dev->name, id1, id2, lp->mii.phy_id);
803}
804
805/*
806 * Sets the PHY to a configuration as determined by the user.
807 * Called with spin_lock held.
808 */
809static int smc911x_phy_fixed(struct net_device *dev)
810{
811 struct smc911x_local *lp = netdev_priv(dev);
812 unsigned long ioaddr = dev->base_addr;
813 int phyaddr = lp->mii.phy_id;
814 int bmcr;
815
816 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
817
818 /* Enter Link Disable state */
819 SMC_GET_PHY_BMCR(phyaddr, bmcr);
820 bmcr |= BMCR_PDOWN;
821 SMC_SET_PHY_BMCR(phyaddr, bmcr);
822
823 /*
824 * Set our fixed capabilities
825 * Disable auto-negotiation
826 */
827 bmcr &= ~BMCR_ANENABLE;
828 if (lp->ctl_rfduplx)
829 bmcr |= BMCR_FULLDPLX;
830
831 if (lp->ctl_rspeed == 100)
832 bmcr |= BMCR_SPEED100;
833
834 /* Write our capabilities to the phy control register */
835 SMC_SET_PHY_BMCR(phyaddr, bmcr);
836
837 /* Re-Configure the Receive/Phy Control register */
838 bmcr &= ~BMCR_PDOWN;
839 SMC_SET_PHY_BMCR(phyaddr, bmcr);
840
841 return 1;
842}
843
844/*
845 * smc911x_phy_reset - reset the phy
846 * @dev: net device
847 * @phy: phy address
848 *
849 * Issue a software reset for the specified PHY and
850 * wait up to 100ms for the reset to complete. We should
851 * not access the PHY for 50ms after issuing the reset.
852 *
853 * The time to wait appears to be dependent on the PHY.
854 *
855 */
856static int smc911x_phy_reset(struct net_device *dev, int phy)
857{
858 struct smc911x_local *lp = netdev_priv(dev);
859 unsigned long ioaddr = dev->base_addr;
860 int timeout;
861 unsigned long flags;
862 unsigned int reg;
863
864 DBG(SMC_DEBUG_FUNC, "%s: --> %s()\n", dev->name, __FUNCTION__);
865
866 spin_lock_irqsave(&lp->lock, flags);
867 reg = SMC_GET_PMT_CTRL();
868 reg &= ~0xfffff030;
869 reg |= PMT_CTRL_PHY_RST_;
870 SMC_SET_PMT_CTRL(reg);
871 spin_unlock_irqrestore(&lp->lock, flags);
872 for (timeout = 2; timeout; timeout--) {
873 msleep(50);
874 spin_lock_irqsave(&lp->lock, flags);
875 reg = SMC_GET_PMT_CTRL();
876 spin_unlock_irqrestore(&lp->lock, flags);
877 if (!(reg & PMT_CTRL_PHY_RST_)) {
878 /* extra delay required because the phy may
879 * not be completed with its reset
880 * when PHY_BCR_RESET_ is cleared. 256us
881 * should suffice, but use 500us to be safe
882 */
883 udelay(500);
884 break;
885 }
886 }
887
888 return reg & PMT_CTRL_PHY_RST_;
889}
890
891/*
892 * smc911x_phy_powerdown - powerdown phy
893 * @dev: net device
894 * @phy: phy address
895 *
896 * Power down the specified PHY
897 */
898static void smc911x_phy_powerdown(struct net_device *dev, int phy)
899{
900 unsigned long ioaddr = dev->base_addr;
901 unsigned int bmcr;
902
903 /* Enter Link Disable state */
904 SMC_GET_PHY_BMCR(phy, bmcr);
905 bmcr |= BMCR_PDOWN;
906 SMC_SET_PHY_BMCR(phy, bmcr);
907}
908
909/*
910 * smc911x_phy_check_media - check the media status and adjust BMCR
911 * @dev: net device
912 * @init: set true for initialisation
913 *
914 * Select duplex mode depending on negotiation state. This
915 * also updates our carrier state.
916 */
917static void smc911x_phy_check_media(struct net_device *dev, int init)
918{
919 struct smc911x_local *lp = netdev_priv(dev);
920 unsigned long ioaddr = dev->base_addr;
921 int phyaddr = lp->mii.phy_id;
922 unsigned int bmcr, cr;
923
924 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
925
926 if (mii_check_media(&lp->mii, netif_msg_link(lp), init)) {
927 /* duplex state has changed */
928 SMC_GET_PHY_BMCR(phyaddr, bmcr);
929 SMC_GET_MAC_CR(cr);
930 if (lp->mii.full_duplex) {
931 DBG(SMC_DEBUG_MISC, "%s: Configuring for full-duplex mode\n", dev->name);
932 bmcr |= BMCR_FULLDPLX;
933 cr |= MAC_CR_RCVOWN_;
934 } else {
935 DBG(SMC_DEBUG_MISC, "%s: Configuring for half-duplex mode\n", dev->name);
936 bmcr &= ~BMCR_FULLDPLX;
937 cr &= ~MAC_CR_RCVOWN_;
938 }
939 SMC_SET_PHY_BMCR(phyaddr, bmcr);
940 SMC_SET_MAC_CR(cr);
941 }
942}
943
944/*
945 * Configures the specified PHY through the MII management interface
946 * using Autonegotiation.
947 * Calls smc911x_phy_fixed() if the user has requested a certain config.
948 * If RPC ANEG bit is set, the media selection is dependent purely on
949 * the selection by the MII (either in the MII BMCR reg or the result
950 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection
951 * is controlled by the RPC SPEED and RPC DPLX bits.
952 */
953static void smc911x_phy_configure(void *data)
954{
955 struct net_device *dev = data;
956 struct smc911x_local *lp = netdev_priv(dev);
957 unsigned long ioaddr = dev->base_addr;
958 int phyaddr = lp->mii.phy_id;
959 int my_phy_caps; /* My PHY capabilities */
960 int my_ad_caps; /* My Advertised capabilities */
961 int status;
962 unsigned long flags;
963
964 DBG(SMC_DEBUG_FUNC, "%s: --> %s()\n", dev->name, __FUNCTION__);
965
966 /*
967 * We should not be called if phy_type is zero.
968 */
969 if (lp->phy_type == 0)
970 goto smc911x_phy_configure_exit;
971
972 if (smc911x_phy_reset(dev, phyaddr)) {
973 printk("%s: PHY reset timed out\n", dev->name);
974 goto smc911x_phy_configure_exit;
975 }
976 spin_lock_irqsave(&lp->lock, flags);
977
978 /*
979 * Enable PHY Interrupts (for register 18)
980 * Interrupts listed here are enabled
981 */
982 SMC_SET_PHY_INT_MASK(phyaddr, PHY_INT_MASK_ENERGY_ON_ |
983 PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_REMOTE_FAULT_ |
984 PHY_INT_MASK_LINK_DOWN_);
985
986 /* If the user requested no auto neg, then go set his request */
987 if (lp->mii.force_media) {
988 smc911x_phy_fixed(dev);
989 goto smc911x_phy_configure_exit;
990 }
991
992 /* Copy our capabilities from MII_BMSR to MII_ADVERTISE */
993 SMC_GET_PHY_BMSR(phyaddr, my_phy_caps);
994 if (!(my_phy_caps & BMSR_ANEGCAPABLE)) {
995 printk(KERN_INFO "Auto negotiation NOT supported\n");
996 smc911x_phy_fixed(dev);
997 goto smc911x_phy_configure_exit;
998 }
999
1000 /* CSMA capable w/ both pauses */
1001 my_ad_caps = ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
1002
1003 if (my_phy_caps & BMSR_100BASE4)
1004 my_ad_caps |= ADVERTISE_100BASE4;
1005 if (my_phy_caps & BMSR_100FULL)
1006 my_ad_caps |= ADVERTISE_100FULL;
1007 if (my_phy_caps & BMSR_100HALF)
1008 my_ad_caps |= ADVERTISE_100HALF;
1009 if (my_phy_caps & BMSR_10FULL)
1010 my_ad_caps |= ADVERTISE_10FULL;
1011 if (my_phy_caps & BMSR_10HALF)
1012 my_ad_caps |= ADVERTISE_10HALF;
1013
1014 /* Disable capabilities not selected by our user */
1015 if (lp->ctl_rspeed != 100)
1016 my_ad_caps &= ~(ADVERTISE_100BASE4|ADVERTISE_100FULL|ADVERTISE_100HALF);
1017
1018 if (!lp->ctl_rfduplx)
1019 my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL);
1020
1021 /* Update our Auto-Neg Advertisement Register */
1022 SMC_SET_PHY_MII_ADV(phyaddr, my_ad_caps);
1023 lp->mii.advertising = my_ad_caps;
1024
1025 /*
1026 * Read the register back. Without this, it appears that when
1027 * auto-negotiation is restarted, sometimes it isn't ready and
1028 * the link does not come up.
1029 */
1030 udelay(10);
1031 SMC_GET_PHY_MII_ADV(phyaddr, status);
1032
1033 DBG(SMC_DEBUG_MISC, "%s: phy caps=0x%04x\n", dev->name, my_phy_caps);
1034 DBG(SMC_DEBUG_MISC, "%s: phy advertised caps=0x%04x\n", dev->name, my_ad_caps);
1035
1036 /* Restart auto-negotiation process in order to advertise my caps */
1037 SMC_SET_PHY_BMCR(phyaddr, BMCR_ANENABLE | BMCR_ANRESTART);
1038
1039 smc911x_phy_check_media(dev, 1);
1040
1041smc911x_phy_configure_exit:
1042 spin_unlock_irqrestore(&lp->lock, flags);
1043 lp->work_pending = 0;
1044}
1045
1046/*
1047 * smc911x_phy_interrupt
1048 *
1049 * Purpose: Handle interrupts relating to PHY register 18. This is
1050 * called from the "hard" interrupt handler under our private spinlock.
1051 */
1052static void smc911x_phy_interrupt(struct net_device *dev)
1053{
1054 struct smc911x_local *lp = netdev_priv(dev);
1055 unsigned long ioaddr = dev->base_addr;
1056 int phyaddr = lp->mii.phy_id;
1057 int status;
1058
1059 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1060
1061 if (lp->phy_type == 0)
1062 return;
1063
1064 smc911x_phy_check_media(dev, 0);
1065 /* read to clear status bits */
1066 SMC_GET_PHY_INT_SRC(phyaddr,status);
1067 DBG(SMC_DEBUG_MISC, "%s: PHY interrupt status 0x%04x\n",
1068 dev->name, status & 0xffff);
1069 DBG(SMC_DEBUG_MISC, "%s: AFC_CFG 0x%08x\n",
1070 dev->name, SMC_GET_AFC_CFG());
1071}
1072
1073/*--- END PHY CONTROL AND CONFIGURATION-------------------------------------*/
1074
1075/*
1076 * This is the main routine of the driver, to handle the device when
1077 * it needs some attention.
1078 */
1079static irqreturn_t smc911x_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1080{
1081 struct net_device *dev = dev_id;
1082 unsigned long ioaddr = dev->base_addr;
1083 struct smc911x_local *lp = netdev_priv(dev);
1084 unsigned int status, mask, timeout;
1085 unsigned int rx_overrun=0, cr, pkts;
1086 unsigned long flags;
1087
1088 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1089
1090 spin_lock_irqsave(&lp->lock, flags);
1091
1092 /* Spurious interrupt check */
1093 if ((SMC_GET_IRQ_CFG() & (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) !=
1094 (INT_CFG_IRQ_INT_ | INT_CFG_IRQ_EN_)) {
1095 return IRQ_NONE;
1096 }
1097
1098 mask = SMC_GET_INT_EN();
1099 SMC_SET_INT_EN(0);
1100
1101 /* set a timeout value, so I don't stay here forever */
1102 timeout = 8;
1103
1104
1105 do {
1106 status = SMC_GET_INT();
1107
1108 DBG(SMC_DEBUG_MISC, "%s: INT 0x%08x MASK 0x%08x OUTSIDE MASK 0x%08x\n",
1109 dev->name, status, mask, status & ~mask);
1110
1111 status &= mask;
1112 if (!status)
1113 break;
1114
1115 /* Handle SW interrupt condition */
1116 if (status & INT_STS_SW_INT_) {
1117 SMC_ACK_INT(INT_STS_SW_INT_);
1118 mask &= ~INT_EN_SW_INT_EN_;
1119 }
1120 /* Handle various error conditions */
1121 if (status & INT_STS_RXE_) {
1122 SMC_ACK_INT(INT_STS_RXE_);
1123 lp->stats.rx_errors++;
1124 }
1125 if (status & INT_STS_RXDFH_INT_) {
1126 SMC_ACK_INT(INT_STS_RXDFH_INT_);
1127 lp->stats.rx_dropped+=SMC_GET_RX_DROP();
1128 }
1129 /* Undocumented interrupt-what is the right thing to do here? */
1130 if (status & INT_STS_RXDF_INT_) {
1131 SMC_ACK_INT(INT_STS_RXDF_INT_);
1132 }
1133
1134 /* Rx Data FIFO exceeds set level */
1135 if (status & INT_STS_RDFL_) {
1136 if (IS_REV_A(lp->revision)) {
1137 rx_overrun=1;
1138 SMC_GET_MAC_CR(cr);
1139 cr &= ~MAC_CR_RXEN_;
1140 SMC_SET_MAC_CR(cr);
1141 DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name);
1142 lp->stats.rx_errors++;
1143 lp->stats.rx_fifo_errors++;
1144 }
1145 SMC_ACK_INT(INT_STS_RDFL_);
1146 }
1147 if (status & INT_STS_RDFO_) {
1148 if (!IS_REV_A(lp->revision)) {
1149 SMC_GET_MAC_CR(cr);
1150 cr &= ~MAC_CR_RXEN_;
1151 SMC_SET_MAC_CR(cr);
1152 rx_overrun=1;
1153 DBG(SMC_DEBUG_RX, "%s: RX overrun\n", dev->name);
1154 lp->stats.rx_errors++;
1155 lp->stats.rx_fifo_errors++;
1156 }
1157 SMC_ACK_INT(INT_STS_RDFO_);
1158 }
1159 /* Handle receive condition */
1160 if ((status & INT_STS_RSFL_) || rx_overrun) {
1161 unsigned int fifo;
1162 DBG(SMC_DEBUG_RX, "%s: RX irq\n", dev->name);
1163 fifo = SMC_GET_RX_FIFO_INF();
1164 pkts = (fifo & RX_FIFO_INF_RXSUSED_) >> 16;
1165 DBG(SMC_DEBUG_RX, "%s: Rx FIFO pkts %d, bytes %d\n",
1166 dev->name, pkts, fifo & 0xFFFF );
1167 if (pkts != 0) {
1168#ifdef SMC_USE_DMA
1169 unsigned int fifo;
1170 if (lp->rxdma_active){
1171 DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA,
1172 "%s: RX DMA active\n", dev->name);
1173 /* The DMA is already running so up the IRQ threshold */
1174 fifo = SMC_GET_FIFO_INT() & ~0xFF;
1175 fifo |= pkts & 0xFF;
1176 DBG(SMC_DEBUG_RX,
1177 "%s: Setting RX stat FIFO threshold to %d\n",
1178 dev->name, fifo & 0xff);
1179 SMC_SET_FIFO_INT(fifo);
1180 } else
1181#endif
1182 smc911x_rcv(dev);
1183 }
1184 SMC_ACK_INT(INT_STS_RSFL_);
1185 }
1186 /* Handle transmit FIFO available */
1187 if (status & INT_STS_TDFA_) {
1188 DBG(SMC_DEBUG_TX, "%s: TX data FIFO space available irq\n", dev->name);
1189 SMC_SET_FIFO_TDA(0xFF);
1190 lp->tx_throttle = 0;
1191#ifdef SMC_USE_DMA
1192 if (!lp->txdma_active)
1193#endif
1194 netif_wake_queue(dev);
1195 SMC_ACK_INT(INT_STS_TDFA_);
1196 }
1197 /* Handle transmit done condition */
1198#if 1
1199 if (status & (INT_STS_TSFL_ | INT_STS_GPT_INT_)) {
1200 DBG(SMC_DEBUG_TX | SMC_DEBUG_MISC,
1201 "%s: Tx stat FIFO limit (%d) /GPT irq\n",
1202 dev->name, (SMC_GET_FIFO_INT() & 0x00ff0000) >> 16);
1203 smc911x_tx(dev);
1204 SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000);
1205 SMC_ACK_INT(INT_STS_TSFL_);
1206 SMC_ACK_INT(INT_STS_TSFL_ | INT_STS_GPT_INT_);
1207 }
1208#else
1209 if (status & INT_STS_TSFL_) {
1210 DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq \n", dev->name, );
1211 smc911x_tx(dev);
1212 SMC_ACK_INT(INT_STS_TSFL_);
1213 }
1214
1215 if (status & INT_STS_GPT_INT_) {
1216 DBG(SMC_DEBUG_RX, "%s: IRQ_CFG 0x%08x FIFO_INT 0x%08x RX_CFG 0x%08x\n",
1217 dev->name,
1218 SMC_GET_IRQ_CFG(),
1219 SMC_GET_FIFO_INT(),
1220 SMC_GET_RX_CFG());
1221 DBG(SMC_DEBUG_RX, "%s: Rx Stat FIFO Used 0x%02x "
1222 "Data FIFO Used 0x%04x Stat FIFO 0x%08x\n",
1223 dev->name,
1224 (SMC_GET_RX_FIFO_INF() & 0x00ff0000) >> 16,
1225 SMC_GET_RX_FIFO_INF() & 0xffff,
1226 SMC_GET_RX_STS_FIFO_PEEK());
1227 SMC_SET_GPT_CFG(GPT_CFG_TIMER_EN_ | 10000);
1228 SMC_ACK_INT(INT_STS_GPT_INT_);
1229 }
1230#endif
1231
1232 /* Handle PHY interupt condition */
1233 if (status & INT_STS_PHY_INT_) {
1234 DBG(SMC_DEBUG_MISC, "%s: PHY irq\n", dev->name);
1235 smc911x_phy_interrupt(dev);
1236 SMC_ACK_INT(INT_STS_PHY_INT_);
1237 }
1238 } while (--timeout);
1239
1240 /* restore mask state */
1241 SMC_SET_INT_EN(mask);
1242
1243 DBG(SMC_DEBUG_MISC, "%s: Interrupt done (%d loops)\n",
1244 dev->name, 8-timeout);
1245
1246 spin_unlock_irqrestore(&lp->lock, flags);
1247
1248 DBG(3, "%s: Interrupt done (%d loops)\n", dev->name, 8-timeout);
1249
1250 return IRQ_HANDLED;
1251}
1252
1253#ifdef SMC_USE_DMA
1254static void
1255smc911x_tx_dma_irq(int dma, void *data, struct pt_regs *regs)
1256{
1257 struct net_device *dev = (struct net_device *)data;
1258 struct smc911x_local *lp = netdev_priv(dev);
1259 struct sk_buff *skb = lp->current_tx_skb;
1260 unsigned long flags;
1261
1262 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1263
1264 DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, "%s: TX DMA irq handler\n", dev->name);
1265 /* Clear the DMA interrupt sources */
1266 SMC_DMA_ACK_IRQ(dev, dma);
1267 BUG_ON(skb == NULL);
1268 dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE);
1269 dev->trans_start = jiffies;
1270 dev_kfree_skb_irq(skb);
1271 lp->current_tx_skb = NULL;
1272 if (lp->pending_tx_skb != NULL)
1273 smc911x_hardware_send_pkt(dev);
1274 else {
1275 DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA,
1276 "%s: No pending Tx packets. DMA disabled\n", dev->name);
1277 spin_lock_irqsave(&lp->lock, flags);
1278 lp->txdma_active = 0;
1279 if (!lp->tx_throttle) {
1280 netif_wake_queue(dev);
1281 }
1282 spin_unlock_irqrestore(&lp->lock, flags);
1283 }
1284
1285 DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA,
1286 "%s: TX DMA irq completed\n", dev->name);
1287}
1288static void
1289smc911x_rx_dma_irq(int dma, void *data, struct pt_regs *regs)
1290{
1291 struct net_device *dev = (struct net_device *)data;
1292 unsigned long ioaddr = dev->base_addr;
1293 struct smc911x_local *lp = netdev_priv(dev);
1294 struct sk_buff *skb = lp->current_rx_skb;
1295 unsigned long flags;
1296 unsigned int pkts;
1297
1298 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1299 DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, "%s: RX DMA irq handler\n", dev->name);
1300 /* Clear the DMA interrupt sources */
1301 SMC_DMA_ACK_IRQ(dev, dma);
1302 dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE);
1303 BUG_ON(skb == NULL);
1304 lp->current_rx_skb = NULL;
1305 PRINT_PKT(skb->data, skb->len);
1306 dev->last_rx = jiffies;
1307 skb->dev = dev;
1308 skb->protocol = eth_type_trans(skb, dev);
1309 netif_rx(skb);
1310 lp->stats.rx_packets++;
1311 lp->stats.rx_bytes += skb->len;
1312
1313 spin_lock_irqsave(&lp->lock, flags);
1314 pkts = (SMC_GET_RX_FIFO_INF() & RX_FIFO_INF_RXSUSED_) >> 16;
1315 if (pkts != 0) {
1316 smc911x_rcv(dev);
1317 }else {
1318 lp->rxdma_active = 0;
1319 }
1320 spin_unlock_irqrestore(&lp->lock, flags);
1321 DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA,
1322 "%s: RX DMA irq completed. DMA RX FIFO PKTS %d\n",
1323 dev->name, pkts);
1324}
1325#endif /* SMC_USE_DMA */
1326
1327#ifdef CONFIG_NET_POLL_CONTROLLER
1328/*
1329 * Polling receive - used by netconsole and other diagnostic tools
1330 * to allow network i/o with interrupts disabled.
1331 */
1332static void smc911x_poll_controller(struct net_device *dev)
1333{
1334 disable_irq(dev->irq);
1335 smc911x_interrupt(dev->irq, dev, NULL);
1336 enable_irq(dev->irq);
1337}
1338#endif
1339
1340/* Our watchdog timed out. Called by the networking layer */
1341static void smc911x_timeout(struct net_device *dev)
1342{
1343 struct smc911x_local *lp = netdev_priv(dev);
1344 unsigned long ioaddr = dev->base_addr;
1345 int status, mask;
1346 unsigned long flags;
1347
1348 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1349
1350 spin_lock_irqsave(&lp->lock, flags);
1351 status = SMC_GET_INT();
1352 mask = SMC_GET_INT_EN();
1353 spin_unlock_irqrestore(&lp->lock, flags);
1354 DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x \n",
1355 dev->name, status, mask);
1356
1357 /* Dump the current TX FIFO contents and restart */
1358 mask = SMC_GET_TX_CFG();
1359 SMC_SET_TX_CFG(mask | TX_CFG_TXS_DUMP_ | TX_CFG_TXD_DUMP_);
1360 /*
1361 * Reconfiguring the PHY doesn't seem like a bad idea here, but
1362 * smc911x_phy_configure() calls msleep() which calls schedule_timeout()
1363 * which calls schedule(). Hence we use a work queue.
1364 */
1365 if (lp->phy_type != 0) {
1366 if (schedule_work(&lp->phy_configure)) {
1367 lp->work_pending = 1;
1368 }
1369 }
1370
1371 /* We can accept TX packets again */
1372 dev->trans_start = jiffies;
1373 netif_wake_queue(dev);
1374}
1375
1376/*
1377 * This routine will, depending on the values passed to it,
1378 * either make it accept multicast packets, go into
1379 * promiscuous mode (for TCPDUMP and cousins) or accept
1380 * a select set of multicast packets
1381 */
1382static void smc911x_set_multicast_list(struct net_device *dev)
1383{
1384 struct smc911x_local *lp = netdev_priv(dev);
1385 unsigned long ioaddr = dev->base_addr;
1386 unsigned int multicast_table[2];
1387 unsigned int mcr, update_multicast = 0;
1388 unsigned long flags;
1389 /* table for flipping the order of 5 bits */
1390 static const unsigned char invert5[] =
1391 {0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0C, 0x1C,
1392 0x02, 0x12, 0x0A, 0x1A, 0x06, 0x16, 0x0E, 0x1E,
1393 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0D, 0x1D,
1394 0x03, 0x13, 0x0B, 0x1B, 0x07, 0x17, 0x0F, 0x1F};
1395
1396
1397 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1398
1399 spin_lock_irqsave(&lp->lock, flags);
1400 SMC_GET_MAC_CR(mcr);
1401 spin_unlock_irqrestore(&lp->lock, flags);
1402
1403 if (dev->flags & IFF_PROMISC) {
1404
1405 DBG(SMC_DEBUG_MISC, "%s: RCR_PRMS\n", dev->name);
1406 mcr |= MAC_CR_PRMS_;
1407 }
1408 /*
1409 * Here, I am setting this to accept all multicast packets.
1410 * I don't need to zero the multicast table, because the flag is
1411 * checked before the table is
1412 */
1413 else if (dev->flags & IFF_ALLMULTI || dev->mc_count > 16) {
1414 DBG(SMC_DEBUG_MISC, "%s: RCR_ALMUL\n", dev->name);
1415 mcr |= MAC_CR_MCPAS_;
1416 }
1417
1418 /*
1419 * This sets the internal hardware table to filter out unwanted
1420 * multicast packets before they take up memory.
1421 *
1422 * The SMC chip uses a hash table where the high 6 bits of the CRC of
1423 * address are the offset into the table. If that bit is 1, then the
1424 * multicast packet is accepted. Otherwise, it's dropped silently.
1425 *
1426 * To use the 6 bits as an offset into the table, the high 1 bit is
1427 * the number of the 32 bit register, while the low 5 bits are the bit
1428 * within that register.
1429 */
1430 else if (dev->mc_count) {
1431 int i;
1432 struct dev_mc_list *cur_addr;
1433
1434 /* Set the Hash perfec mode */
1435 mcr |= MAC_CR_HPFILT_;
1436
1437 /* start with a table of all zeros: reject all */
1438 memset(multicast_table, 0, sizeof(multicast_table));
1439
1440 cur_addr = dev->mc_list;
1441 for (i = 0; i < dev->mc_count; i++, cur_addr = cur_addr->next) {
1442 int position;
1443
1444 /* do we have a pointer here? */
1445 if (!cur_addr)
1446 break;
1447 /* make sure this is a multicast address -
1448 shouldn't this be a given if we have it here ? */
1449 if (!(*cur_addr->dmi_addr & 1))
1450 continue;
1451
1452 /* only use the low order bits */
1453 position = crc32_le(~0, cur_addr->dmi_addr, 6) & 0x3f;
1454
1455 /* do some messy swapping to put the bit in the right spot */
1456 multicast_table[invert5[position&0x1F]&0x1] |=
1457 (1<<invert5[(position>>1)&0x1F]);
1458 }
1459
1460 /* be sure I get rid of flags I might have set */
1461 mcr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_);
1462
1463 /* now, the table can be loaded into the chipset */
1464 update_multicast = 1;
1465 } else {
1466 DBG(SMC_DEBUG_MISC, "%s: ~(MAC_CR_PRMS_|MAC_CR_MCPAS_)\n",
1467 dev->name);
1468 mcr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_);
1469
1470 /*
1471 * since I'm disabling all multicast entirely, I need to
1472 * clear the multicast list
1473 */
1474 memset(multicast_table, 0, sizeof(multicast_table));
1475 update_multicast = 1;
1476 }
1477
1478 spin_lock_irqsave(&lp->lock, flags);
1479 SMC_SET_MAC_CR(mcr);
1480 if (update_multicast) {
1481 DBG(SMC_DEBUG_MISC,
1482 "%s: update mcast hash table 0x%08x 0x%08x\n",
1483 dev->name, multicast_table[0], multicast_table[1]);
1484 SMC_SET_HASHL(multicast_table[0]);
1485 SMC_SET_HASHH(multicast_table[1]);
1486 }
1487 spin_unlock_irqrestore(&lp->lock, flags);
1488}
1489
1490
1491/*
1492 * Open and Initialize the board
1493 *
1494 * Set up everything, reset the card, etc..
1495 */
1496static int
1497smc911x_open(struct net_device *dev)
1498{
1499 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1500
1501 /*
1502 * Check that the address is valid. If its not, refuse
1503 * to bring the device up. The user must specify an
1504 * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
1505 */
1506 if (!is_valid_ether_addr(dev->dev_addr)) {
1507 PRINTK("%s: no valid ethernet hw addr\n", __FUNCTION__);
1508 return -EINVAL;
1509 }
1510
1511 /* reset the hardware */
1512 smc911x_reset(dev);
1513
1514 /* Configure the PHY, initialize the link state */
1515 smc911x_phy_configure(dev);
1516
1517 /* Turn on Tx + Rx */
1518 smc911x_enable(dev);
1519
1520 netif_start_queue(dev);
1521
1522 return 0;
1523}
1524
1525/*
1526 * smc911x_close
1527 *
1528 * this makes the board clean up everything that it can
1529 * and not talk to the outside world. Caused by
1530 * an 'ifconfig ethX down'
1531 */
1532static int smc911x_close(struct net_device *dev)
1533{
1534 struct smc911x_local *lp = netdev_priv(dev);
1535
1536 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1537
1538 netif_stop_queue(dev);
1539 netif_carrier_off(dev);
1540
1541 /* clear everything */
1542 smc911x_shutdown(dev);
1543
1544 if (lp->phy_type != 0) {
1545 /* We need to ensure that no calls to
1546 * smc911x_phy_configure are pending.
1547
1548 * flush_scheduled_work() cannot be called because we
1549 * are running with the netlink semaphore held (from
1550 * devinet_ioctl()) and the pending work queue
1551 * contains linkwatch_event() (scheduled by
1552 * netif_carrier_off() above). linkwatch_event() also
1553 * wants the netlink semaphore.
1554 */
1555 while (lp->work_pending)
1556 schedule();
1557 smc911x_phy_powerdown(dev, lp->mii.phy_id);
1558 }
1559
1560 if (lp->pending_tx_skb) {
1561 dev_kfree_skb(lp->pending_tx_skb);
1562 lp->pending_tx_skb = NULL;
1563 }
1564
1565 return 0;
1566}
1567
1568/*
1569 * Get the current statistics.
1570 * This may be called with the card open or closed.
1571 */
1572static struct net_device_stats *smc911x_query_statistics(struct net_device *dev)
1573{
1574 struct smc911x_local *lp = netdev_priv(dev);
1575 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1576
1577
1578 return &lp->stats;
1579}
1580
1581/*
1582 * Ethtool support
1583 */
1584static int
1585smc911x_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
1586{
1587 struct smc911x_local *lp = netdev_priv(dev);
1588 unsigned long ioaddr = dev->base_addr;
1589 int ret, status;
1590 unsigned long flags;
1591
1592 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1593 cmd->maxtxpkt = 1;
1594 cmd->maxrxpkt = 1;
1595
1596 if (lp->phy_type != 0) {
1597 spin_lock_irqsave(&lp->lock, flags);
1598 ret = mii_ethtool_gset(&lp->mii, cmd);
1599 spin_unlock_irqrestore(&lp->lock, flags);
1600 } else {
1601 cmd->supported = SUPPORTED_10baseT_Half |
1602 SUPPORTED_10baseT_Full |
1603 SUPPORTED_TP | SUPPORTED_AUI;
1604
1605 if (lp->ctl_rspeed == 10)
1606 cmd->speed = SPEED_10;
1607 else if (lp->ctl_rspeed == 100)
1608 cmd->speed = SPEED_100;
1609
1610 cmd->autoneg = AUTONEG_DISABLE;
1611 if (lp->mii.phy_id==1)
1612 cmd->transceiver = XCVR_INTERNAL;
1613 else
1614 cmd->transceiver = XCVR_EXTERNAL;
1615 cmd->port = 0;
1616 SMC_GET_PHY_SPECIAL(lp->mii.phy_id, status);
1617 cmd->duplex =
1618 (status & (PHY_SPECIAL_SPD_10FULL_ | PHY_SPECIAL_SPD_100FULL_)) ?
1619 DUPLEX_FULL : DUPLEX_HALF;
1620 ret = 0;
1621 }
1622
1623 return ret;
1624}
1625
1626static int
1627smc911x_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
1628{
1629 struct smc911x_local *lp = netdev_priv(dev);
1630 int ret;
1631 unsigned long flags;
1632
1633 if (lp->phy_type != 0) {
1634 spin_lock_irqsave(&lp->lock, flags);
1635 ret = mii_ethtool_sset(&lp->mii, cmd);
1636 spin_unlock_irqrestore(&lp->lock, flags);
1637 } else {
1638 if (cmd->autoneg != AUTONEG_DISABLE ||
1639 cmd->speed != SPEED_10 ||
1640 (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL) ||
1641 (cmd->port != PORT_TP && cmd->port != PORT_AUI))
1642 return -EINVAL;
1643
1644 lp->ctl_rfduplx = cmd->duplex == DUPLEX_FULL;
1645
1646 ret = 0;
1647 }
1648
1649 return ret;
1650}
1651
1652static void
1653smc911x_ethtool_getdrvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1654{
1655 strncpy(info->driver, CARDNAME, sizeof(info->driver));
1656 strncpy(info->version, version, sizeof(info->version));
1657 strncpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info));
1658}
1659
1660static int smc911x_ethtool_nwayreset(struct net_device *dev)
1661{
1662 struct smc911x_local *lp = netdev_priv(dev);
1663 int ret = -EINVAL;
1664 unsigned long flags;
1665
1666 if (lp->phy_type != 0) {
1667 spin_lock_irqsave(&lp->lock, flags);
1668 ret = mii_nway_restart(&lp->mii);
1669 spin_unlock_irqrestore(&lp->lock, flags);
1670 }
1671
1672 return ret;
1673}
1674
1675static u32 smc911x_ethtool_getmsglevel(struct net_device *dev)
1676{
1677 struct smc911x_local *lp = netdev_priv(dev);
1678 return lp->msg_enable;
1679}
1680
1681static void smc911x_ethtool_setmsglevel(struct net_device *dev, u32 level)
1682{
1683 struct smc911x_local *lp = netdev_priv(dev);
1684 lp->msg_enable = level;
1685}
1686
1687static int smc911x_ethtool_getregslen(struct net_device *dev)
1688{
1689 /* System regs + MAC regs + PHY regs */
1690 return (((E2P_CMD - ID_REV)/4 + 1) +
1691 (WUCSR - MAC_CR)+1 + 32) * sizeof(u32);
1692}
1693
1694static void smc911x_ethtool_getregs(struct net_device *dev,
1695 struct ethtool_regs* regs, void *buf)
1696{
1697 unsigned long ioaddr = dev->base_addr;
1698 struct smc911x_local *lp = netdev_priv(dev);
1699 unsigned long flags;
1700 u32 reg,i,j=0;
1701 u32 *data = (u32*)buf;
1702
1703 regs->version = lp->version;
1704 for(i=ID_REV;i<=E2P_CMD;i+=4) {
1705 data[j++] = SMC_inl(ioaddr,i);
1706 }
1707 for(i=MAC_CR;i<=WUCSR;i++) {
1708 spin_lock_irqsave(&lp->lock, flags);
1709 SMC_GET_MAC_CSR(i, reg);
1710 spin_unlock_irqrestore(&lp->lock, flags);
1711 data[j++] = reg;
1712 }
1713 for(i=0;i<=31;i++) {
1714 spin_lock_irqsave(&lp->lock, flags);
1715 SMC_GET_MII(i, lp->mii.phy_id, reg);
1716 spin_unlock_irqrestore(&lp->lock, flags);
1717 data[j++] = reg & 0xFFFF;
1718 }
1719}
1720
1721static int smc911x_ethtool_wait_eeprom_ready(struct net_device *dev)
1722{
1723 unsigned long ioaddr = dev->base_addr;
1724 unsigned int timeout;
1725 int e2p_cmd;
1726
1727 e2p_cmd = SMC_GET_E2P_CMD();
1728 for(timeout=10;(e2p_cmd & E2P_CMD_EPC_BUSY_) && timeout; timeout--) {
1729 if (e2p_cmd & E2P_CMD_EPC_TIMEOUT_) {
1730 PRINTK("%s: %s timeout waiting for EEPROM to respond\n",
1731 dev->name, __FUNCTION__);
1732 return -EFAULT;
1733 }
1734 mdelay(1);
1735 e2p_cmd = SMC_GET_E2P_CMD();
1736 }
1737 if (timeout == 0) {
1738 PRINTK("%s: %s timeout waiting for EEPROM CMD not busy\n",
1739 dev->name, __FUNCTION__);
1740 return -ETIMEDOUT;
1741 }
1742 return 0;
1743}
1744
1745static inline int smc911x_ethtool_write_eeprom_cmd(struct net_device *dev,
1746 int cmd, int addr)
1747{
1748 unsigned long ioaddr = dev->base_addr;
1749 int ret;
1750
1751 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0)
1752 return ret;
1753 SMC_SET_E2P_CMD(E2P_CMD_EPC_BUSY_ |
1754 ((cmd) & (0x7<<28)) |
1755 ((addr) & 0xFF));
1756 return 0;
1757}
1758
1759static inline int smc911x_ethtool_read_eeprom_byte(struct net_device *dev,
1760 u8 *data)
1761{
1762 unsigned long ioaddr = dev->base_addr;
1763 int ret;
1764
1765 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0)
1766 return ret;
1767 *data = SMC_GET_E2P_DATA();
1768 return 0;
1769}
1770
1771static inline int smc911x_ethtool_write_eeprom_byte(struct net_device *dev,
1772 u8 data)
1773{
1774 unsigned long ioaddr = dev->base_addr;
1775 int ret;
1776
1777 if ((ret = smc911x_ethtool_wait_eeprom_ready(dev))!=0)
1778 return ret;
1779 SMC_SET_E2P_DATA(data);
1780 return 0;
1781}
1782
1783static int smc911x_ethtool_geteeprom(struct net_device *dev,
1784 struct ethtool_eeprom *eeprom, u8 *data)
1785{
1786 u8 eebuf[SMC911X_EEPROM_LEN];
1787 int i, ret;
1788
1789 for(i=0;i<SMC911X_EEPROM_LEN;i++) {
1790 if ((ret=smc911x_ethtool_write_eeprom_cmd(dev, E2P_CMD_EPC_CMD_READ_, i ))!=0)
1791 return ret;
1792 if ((ret=smc911x_ethtool_read_eeprom_byte(dev, &eebuf[i]))!=0)
1793 return ret;
1794 }
1795 memcpy(data, eebuf+eeprom->offset, eeprom->len);
1796 return 0;
1797}
1798
1799static int smc911x_ethtool_seteeprom(struct net_device *dev,
1800 struct ethtool_eeprom *eeprom, u8 *data)
1801{
1802 int i, ret;
1803
1804 /* Enable erase */
1805 if ((ret=smc911x_ethtool_write_eeprom_cmd(dev, E2P_CMD_EPC_CMD_EWEN_, 0 ))!=0)
1806 return ret;
1807 for(i=eeprom->offset;i<(eeprom->offset+eeprom->len);i++) {
1808 /* erase byte */
1809 if ((ret=smc911x_ethtool_write_eeprom_cmd(dev, E2P_CMD_EPC_CMD_ERASE_, i ))!=0)
1810 return ret;
1811 /* write byte */
1812 if ((ret=smc911x_ethtool_write_eeprom_byte(dev, *data))!=0)
1813 return ret;
1814 if ((ret=smc911x_ethtool_write_eeprom_cmd(dev, E2P_CMD_EPC_CMD_WRITE_, i ))!=0)
1815 return ret;
1816 }
1817 return 0;
1818}
1819
1820static int smc911x_ethtool_geteeprom_len(struct net_device *dev)
1821{
1822 return SMC911X_EEPROM_LEN;
1823}
1824
1825static struct ethtool_ops smc911x_ethtool_ops = {
1826 .get_settings = smc911x_ethtool_getsettings,
1827 .set_settings = smc911x_ethtool_setsettings,
1828 .get_drvinfo = smc911x_ethtool_getdrvinfo,
1829 .get_msglevel = smc911x_ethtool_getmsglevel,
1830 .set_msglevel = smc911x_ethtool_setmsglevel,
1831 .nway_reset = smc911x_ethtool_nwayreset,
1832 .get_link = ethtool_op_get_link,
1833 .get_regs_len = smc911x_ethtool_getregslen,
1834 .get_regs = smc911x_ethtool_getregs,
1835 .get_eeprom_len = smc911x_ethtool_geteeprom_len,
1836 .get_eeprom = smc911x_ethtool_geteeprom,
1837 .set_eeprom = smc911x_ethtool_seteeprom,
1838};
1839
1840/*
1841 * smc911x_findirq
1842 *
1843 * This routine has a simple purpose -- make the SMC chip generate an
1844 * interrupt, so an auto-detect routine can detect it, and find the IRQ,
1845 */
1846static int __init smc911x_findirq(unsigned long ioaddr)
1847{
1848 int timeout = 20;
1849 unsigned long cookie;
1850
1851 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
1852
1853 cookie = probe_irq_on();
1854
1855 /*
1856 * Force a SW interrupt
1857 */
1858
1859 SMC_SET_INT_EN(INT_EN_SW_INT_EN_);
1860
1861 /*
1862 * Wait until positive that the interrupt has been generated
1863 */
1864 do {
1865 int int_status;
1866 udelay(10);
1867 int_status = SMC_GET_INT_EN();
1868 if (int_status & INT_EN_SW_INT_EN_)
1869 break; /* got the interrupt */
1870 } while (--timeout);
1871
1872 /*
1873 * there is really nothing that I can do here if timeout fails,
1874 * as autoirq_report will return a 0 anyway, which is what I
1875 * want in this case. Plus, the clean up is needed in both
1876 * cases.
1877 */
1878
1879 /* and disable all interrupts again */
1880 SMC_SET_INT_EN(0);
1881
1882 /* and return what I found */
1883 return probe_irq_off(cookie);
1884}
1885
1886/*
1887 * Function: smc911x_probe(unsigned long ioaddr)
1888 *
1889 * Purpose:
1890 * Tests to see if a given ioaddr points to an SMC911x chip.
1891 * Returns a 0 on success
1892 *
1893 * Algorithm:
1894 * (1) see if the endian word is OK
1895 * (1) see if I recognize the chip ID in the appropriate register
1896 *
1897 * Here I do typical initialization tasks.
1898 *
1899 * o Initialize the structure if needed
1900 * o print out my vanity message if not done so already
1901 * o print out what type of hardware is detected
1902 * o print out the ethernet address
1903 * o find the IRQ
1904 * o set up my private data
1905 * o configure the dev structure with my subroutines
1906 * o actually GRAB the irq.
1907 * o GRAB the region
1908 */
1909static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
1910{
1911 struct smc911x_local *lp = netdev_priv(dev);
1912 int i, retval;
1913 unsigned int val, chip_id, revision;
1914 const char *version_string;
1915
1916 DBG(SMC_DEBUG_FUNC, "%s: --> %s\n", dev->name, __FUNCTION__);
1917
1918 /* First, see if the endian word is recognized */
1919 val = SMC_GET_BYTE_TEST();
1920 DBG(SMC_DEBUG_MISC, "%s: endian probe returned 0x%04x\n", CARDNAME, val);
1921 if (val != 0x87654321) {
1922 printk(KERN_ERR "Invalid chip endian 0x08%x\n",val);
1923 retval = -ENODEV;
1924 goto err_out;
1925 }
1926
1927 /*
1928 * check if the revision register is something that I
1929 * recognize. These might need to be added to later,
1930 * as future revisions could be added.
1931 */
1932 chip_id = SMC_GET_PN();
1933 DBG(SMC_DEBUG_MISC, "%s: id probe returned 0x%04x\n", CARDNAME, chip_id);
1934 for(i=0;chip_ids[i].id != 0; i++) {
1935 if (chip_ids[i].id == chip_id) break;
1936 }
1937 if (!chip_ids[i].id) {
1938 printk(KERN_ERR "Unknown chip ID %04x\n", chip_id);
1939 retval = -ENODEV;
1940 goto err_out;
1941 }
1942 version_string = chip_ids[i].name;
1943
1944 revision = SMC_GET_REV();
1945 DBG(SMC_DEBUG_MISC, "%s: revision = 0x%04x\n", CARDNAME, revision);
1946
1947 /* At this point I'll assume that the chip is an SMC911x. */
1948 DBG(SMC_DEBUG_MISC, "%s: Found a %s\n", CARDNAME, chip_ids[i].name);
1949
1950 /* Validate the TX FIFO size requested */
1951 if ((tx_fifo_kb < 2) || (tx_fifo_kb > 14)) {
1952 printk(KERN_ERR "Invalid TX FIFO size requested %d\n", tx_fifo_kb);
1953 retval = -EINVAL;
1954 goto err_out;
1955 }
1956
1957 /* fill in some of the fields */
1958 dev->base_addr = ioaddr;
1959 lp->version = chip_ids[i].id;
1960 lp->revision = revision;
1961 lp->tx_fifo_kb = tx_fifo_kb;
1962 /* Reverse calculate the RX FIFO size from the TX */
1963 lp->tx_fifo_size=(lp->tx_fifo_kb<<10) - 512;
1964 lp->rx_fifo_size= ((0x4000 - 512 - lp->tx_fifo_size) / 16) * 15;
1965
1966 /* Set the automatic flow control values */
1967 switch(lp->tx_fifo_kb) {
1968 /*
1969 * AFC_HI is about ((Rx Data Fifo Size)*2/3)/64
1970 * AFC_LO is AFC_HI/2
1971 * BACK_DUR is about 5uS*(AFC_LO) rounded down
1972 */
1973 case 2:/* 13440 Rx Data Fifo Size */
1974 lp->afc_cfg=0x008C46AF;break;
1975 case 3:/* 12480 Rx Data Fifo Size */
1976 lp->afc_cfg=0x0082419F;break;
1977 case 4:/* 11520 Rx Data Fifo Size */
1978 lp->afc_cfg=0x00783C9F;break;
1979 case 5:/* 10560 Rx Data Fifo Size */
1980 lp->afc_cfg=0x006E374F;break;
1981 case 6:/* 9600 Rx Data Fifo Size */
1982 lp->afc_cfg=0x0064328F;break;
1983 case 7:/* 8640 Rx Data Fifo Size */
1984 lp->afc_cfg=0x005A2D7F;break;
1985 case 8:/* 7680 Rx Data Fifo Size */
1986 lp->afc_cfg=0x0050287F;break;
1987 case 9:/* 6720 Rx Data Fifo Size */
1988 lp->afc_cfg=0x0046236F;break;
1989 case 10:/* 5760 Rx Data Fifo Size */
1990 lp->afc_cfg=0x003C1E6F;break;
1991 case 11:/* 4800 Rx Data Fifo Size */
1992 lp->afc_cfg=0x0032195F;break;
1993 /*
1994 * AFC_HI is ~1520 bytes less than RX Data Fifo Size
1995 * AFC_LO is AFC_HI/2
1996 * BACK_DUR is about 5uS*(AFC_LO) rounded down
1997 */
1998 case 12:/* 3840 Rx Data Fifo Size */
1999 lp->afc_cfg=0x0024124F;break;
2000 case 13:/* 2880 Rx Data Fifo Size */
2001 lp->afc_cfg=0x0015073F;break;
2002 case 14:/* 1920 Rx Data Fifo Size */
2003 lp->afc_cfg=0x0006032F;break;
2004 default:
2005 PRINTK("%s: ERROR -- no AFC_CFG setting found",
2006 dev->name);
2007 break;
2008 }
2009
2010 DBG(SMC_DEBUG_MISC | SMC_DEBUG_TX | SMC_DEBUG_RX,
2011 "%s: tx_fifo %d rx_fifo %d afc_cfg 0x%08x\n", CARDNAME,
2012 lp->tx_fifo_size, lp->rx_fifo_size, lp->afc_cfg);
2013
2014 spin_lock_init(&lp->lock);
2015
2016 /* Get the MAC address */
2017 SMC_GET_MAC_ADDR(dev->dev_addr);
2018
2019 /* now, reset the chip, and put it into a known state */
2020 smc911x_reset(dev);
2021
2022 /*
2023 * If dev->irq is 0, then the device has to be banged on to see
2024 * what the IRQ is.
2025 *
2026 * Specifying an IRQ is done with the assumption that the user knows
2027 * what (s)he is doing. No checking is done!!!!
2028 */
2029 if (dev->irq < 1) {
2030 int trials;
2031
2032 trials = 3;
2033 while (trials--) {
2034 dev->irq = smc911x_findirq(ioaddr);
2035 if (dev->irq)
2036 break;
2037 /* kick the card and try again */
2038 smc911x_reset(dev);
2039 }
2040 }
2041 if (dev->irq == 0) {
2042 printk("%s: Couldn't autodetect your IRQ. Use irq=xx.\n",
2043 dev->name);
2044 retval = -ENODEV;
2045 goto err_out;
2046 }
2047 dev->irq = irq_canonicalize(dev->irq);
2048
2049 /* Fill in the fields of the device structure with ethernet values. */
2050 ether_setup(dev);
2051
2052 dev->open = smc911x_open;
2053 dev->stop = smc911x_close;
2054 dev->hard_start_xmit = smc911x_hard_start_xmit;
2055 dev->tx_timeout = smc911x_timeout;
2056 dev->watchdog_timeo = msecs_to_jiffies(watchdog);
2057 dev->get_stats = smc911x_query_statistics;
2058 dev->set_multicast_list = smc911x_set_multicast_list;
2059 dev->ethtool_ops = &smc911x_ethtool_ops;
2060#ifdef CONFIG_NET_POLL_CONTROLLER
2061 dev->poll_controller = smc911x_poll_controller;
2062#endif
2063
2064 INIT_WORK(&lp->phy_configure, smc911x_phy_configure, dev);
2065 lp->mii.phy_id_mask = 0x1f;
2066 lp->mii.reg_num_mask = 0x1f;
2067 lp->mii.force_media = 0;
2068 lp->mii.full_duplex = 0;
2069 lp->mii.dev = dev;
2070 lp->mii.mdio_read = smc911x_phy_read;
2071 lp->mii.mdio_write = smc911x_phy_write;
2072
2073 /*
2074 * Locate the phy, if any.
2075 */
2076 smc911x_phy_detect(dev);
2077
2078 /* Set default parameters */
2079 lp->msg_enable = NETIF_MSG_LINK;
2080 lp->ctl_rfduplx = 1;
2081 lp->ctl_rspeed = 100;
2082
2083 /* Grab the IRQ */
2084 retval = request_irq(dev->irq, &smc911x_interrupt, SA_SHIRQ, dev->name, dev);
2085 if (retval)
2086 goto err_out;
2087
2088 set_irq_type(dev->irq, IRQT_FALLING);
2089
2090#ifdef SMC_USE_DMA
2091 lp->rxdma = SMC_DMA_REQUEST(dev, smc911x_rx_dma_irq);
2092 lp->txdma = SMC_DMA_REQUEST(dev, smc911x_tx_dma_irq);
2093 lp->rxdma_active = 0;
2094 lp->txdma_active = 0;
2095 dev->dma = lp->rxdma;
2096#endif
2097
2098 retval = register_netdev(dev);
2099 if (retval == 0) {
2100 /* now, print out the card info, in a short format.. */
2101 printk("%s: %s (rev %d) at %#lx IRQ %d",
2102 dev->name, version_string, lp->revision,
2103 dev->base_addr, dev->irq);
2104
2105#ifdef SMC_USE_DMA
2106 if (lp->rxdma != -1)
2107 printk(" RXDMA %d ", lp->rxdma);
2108
2109 if (lp->txdma != -1)
2110 printk("TXDMA %d", lp->txdma);
2111#endif
2112 printk("\n");
2113 if (!is_valid_ether_addr(dev->dev_addr)) {
2114 printk("%s: Invalid ethernet MAC address. Please "
2115 "set using ifconfig\n", dev->name);
2116 } else {
2117 /* Print the Ethernet address */
2118 printk("%s: Ethernet addr: ", dev->name);
2119 for (i = 0; i < 5; i++)
2120 printk("%2.2x:", dev->dev_addr[i]);
2121 printk("%2.2x\n", dev->dev_addr[5]);
2122 }
2123
2124 if (lp->phy_type == 0) {
2125 PRINTK("%s: No PHY found\n", dev->name);
2126 } else if ((lp->phy_type & ~0xff) == LAN911X_INTERNAL_PHY_ID) {
2127 PRINTK("%s: LAN911x Internal PHY\n", dev->name);
2128 } else {
2129 PRINTK("%s: External PHY 0x%08x\n", dev->name, lp->phy_type);
2130 }
2131 }
2132
2133err_out:
2134#ifdef SMC_USE_DMA
2135 if (retval) {
2136 if (lp->rxdma != -1) {
2137 SMC_DMA_FREE(dev, lp->rxdma);
2138 }
2139 if (lp->txdma != -1) {
2140 SMC_DMA_FREE(dev, lp->txdma);
2141 }
2142 }
2143#endif
2144 return retval;
2145}
2146
2147/*
2148 * smc911x_init(void)
2149 *
2150 * Output:
2151 * 0 --> there is a device
2152 * anything else, error
2153 */
2154static int smc911x_drv_probe(struct platform_device *pdev)
2155{
2156 struct net_device *ndev;
2157 struct resource *res;
2158 unsigned int *addr;
2159 int ret;
2160
2161 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
2162 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2163 if (!res) {
2164 ret = -ENODEV;
2165 goto out;
2166 }
2167
2168 /*
2169 * Request the regions.
2170 */
2171 if (!request_mem_region(res->start, SMC911X_IO_EXTENT, CARDNAME)) {
2172 ret = -EBUSY;
2173 goto out;
2174 }
2175
2176 ndev = alloc_etherdev(sizeof(struct smc911x_local));
2177 if (!ndev) {
2178 printk("%s: could not allocate device.\n", CARDNAME);
2179 ret = -ENOMEM;
2180 goto release_1;
2181 }
2182 SET_MODULE_OWNER(ndev);
2183 SET_NETDEV_DEV(ndev, &pdev->dev);
2184
2185 ndev->dma = (unsigned char)-1;
2186 ndev->irq = platform_get_irq(pdev, 0);
2187
2188 addr = ioremap(res->start, SMC911X_IO_EXTENT);
2189 if (!addr) {
2190 ret = -ENOMEM;
2191 goto release_both;
2192 }
2193
2194 platform_set_drvdata(pdev, ndev);
2195 ret = smc911x_probe(ndev, (unsigned long)addr);
2196 if (ret != 0) {
2197 platform_set_drvdata(pdev, NULL);
2198 iounmap(addr);
2199release_both:
2200 free_netdev(ndev);
2201release_1:
2202 release_mem_region(res->start, SMC911X_IO_EXTENT);
2203out:
2204 printk("%s: not found (%d).\n", CARDNAME, ret);
2205 }
2206#ifdef SMC_USE_DMA
2207 else {
2208 struct smc911x_local *lp = netdev_priv(ndev);
2209 lp->physaddr = res->start;
2210 lp->dev = &pdev->dev;
2211 }
2212#endif
2213
2214 return ret;
2215}
2216
2217static int smc911x_drv_remove(struct platform_device *pdev)
2218{
2219 struct net_device *ndev = platform_get_drvdata(pdev);
2220 struct resource *res;
2221
2222 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
2223 platform_set_drvdata(pdev, NULL);
2224
2225 unregister_netdev(ndev);
2226
2227 free_irq(ndev->irq, ndev);
2228
2229#ifdef SMC_USE_DMA
2230 {
2231 struct smc911x_local *lp = netdev_priv(ndev);
2232 if (lp->rxdma != -1) {
2233 SMC_DMA_FREE(dev, lp->rxdma);
2234 }
2235 if (lp->txdma != -1) {
2236 SMC_DMA_FREE(dev, lp->txdma);
2237 }
2238 }
2239#endif
2240 iounmap((void *)ndev->base_addr);
2241 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2242 release_mem_region(res->start, SMC911X_IO_EXTENT);
2243
2244 free_netdev(ndev);
2245 return 0;
2246}
2247
2248static int smc911x_drv_suspend(struct platform_device *dev, pm_message_t state)
2249{
2250 struct net_device *ndev = platform_get_drvdata(dev);
2251 unsigned long ioaddr = ndev->base_addr;
2252
2253 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
2254 if (ndev) {
2255 if (netif_running(ndev)) {
2256 netif_device_detach(ndev);
2257 smc911x_shutdown(ndev);
2258#if POWER_DOWN
2259 /* Set D2 - Energy detect only setting */
2260 SMC_SET_PMT_CTRL(2<<12);
2261#endif
2262 }
2263 }
2264 return 0;
2265}
2266
2267static int smc911x_drv_resume(struct platform_device *dev)
2268{
2269 struct net_device *ndev = platform_get_drvdata(dev);
2270
2271 DBG(SMC_DEBUG_FUNC, "--> %s\n", __FUNCTION__);
2272 if (ndev) {
2273 struct smc911x_local *lp = netdev_priv(ndev);
2274
2275 if (netif_running(ndev)) {
2276 smc911x_reset(ndev);
2277 smc911x_enable(ndev);
2278 if (lp->phy_type != 0)
2279 smc911x_phy_configure(ndev);
2280 netif_device_attach(ndev);
2281 }
2282 }
2283 return 0;
2284}
2285
2286static struct platform_driver smc911x_driver = {
2287 .probe = smc911x_drv_probe,
2288 .remove = smc911x_drv_remove,
2289 .suspend = smc911x_drv_suspend,
2290 .resume = smc911x_drv_resume,
2291 .driver = {
2292 .name = CARDNAME,
2293 },
2294};
2295
2296static int __init smc911x_init(void)
2297{
2298 return platform_driver_register(&smc911x_driver);
2299}
2300
2301static void __exit smc911x_cleanup(void)
2302{
2303 platform_driver_unregister(&smc911x_driver);
2304}
2305
2306module_init(smc911x_init);
2307module_exit(smc911x_cleanup);
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
new file mode 100644
index 000000000000..962a710459fc
--- /dev/null
+++ b/drivers/net/smc911x.h
@@ -0,0 +1,835 @@
1/*------------------------------------------------------------------------
2 . smc911x.h - macros for SMSC's LAN911{5,6,7,8} single-chip Ethernet device.
3 .
4 . Copyright (C) 2005 Sensoria Corp.
5 . Derived from the unified SMC91x driver by Nicolas Pitre
6 .
7 . This program is free software; you can redistribute it and/or modify
8 . it under the terms of the GNU General Public License as published by
9 . the Free Software Foundation; either version 2 of the License, or
10 . (at your option) any later version.
11 .
12 . This program is distributed in the hope that it will be useful,
13 . but WITHOUT ANY WARRANTY; without even the implied warranty of
14 . MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 . GNU General Public License for more details.
16 .
17 . You should have received a copy of the GNU General Public License
18 . along with this program; if not, write to the Free Software
19 . Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 .
21 . Information contained in this file was obtained from the LAN9118
22 . manual from SMC. To get a copy, if you really want one, you can find
23 . information under www.smsc.com.
24 .
25 . Authors
26 . Dustin McIntire <dustin@sensoria.com>
27 .
28 ---------------------------------------------------------------------------*/
29#ifndef _SMC911X_H_
30#define _SMC911X_H_
31
32/*
33 * Use the DMA feature on PXA chips
34 */
35#ifdef CONFIG_ARCH_PXA
36 #define SMC_USE_PXA_DMA 1
37 #define SMC_USE_16BIT 0
38 #define SMC_USE_32BIT 1
39#endif
40
41
42/*
43 * Define the bus width specific IO macros
44 */
45
46#if SMC_USE_16BIT
47#define SMC_inb(a, r) readb((a) + (r))
48#define SMC_inw(a, r) readw((a) + (r))
49#define SMC_inl(a, r) ((SMC_inw(a, r) & 0xFFFF)+(SMC_inw(a+2, r)<<16))
50#define SMC_outb(v, a, r) writeb(v, (a) + (r))
51#define SMC_outw(v, a, r) writew(v, (a) + (r))
52#define SMC_outl(v, a, r) \
53 do{ \
54 writel(v & 0xFFFF, (a) + (r)); \
55 writel(v >> 16, (a) + (r) + 2); \
56 } while (0)
57#define SMC_insl(a, r, p, l) readsw((short*)((a) + (r)), p, l*2)
58#define SMC_outsl(a, r, p, l) writesw((short*)((a) + (r)), p, l*2)
59
60#elif SMC_USE_32BIT
61#define SMC_inb(a, r) readb((a) + (r))
62#define SMC_inw(a, r) readw((a) + (r))
63#define SMC_inl(a, r) readl((a) + (r))
64#define SMC_outb(v, a, r) writeb(v, (a) + (r))
65#define SMC_outl(v, a, r) writel(v, (a) + (r))
66#define SMC_insl(a, r, p, l) readsl((int*)((a) + (r)), p, l)
67#define SMC_outsl(a, r, p, l) writesl((int*)((a) + (r)), p, l)
68
69#endif /* SMC_USE_16BIT */
70
71
72
73#if SMC_USE_PXA_DMA
74#define SMC_USE_DMA
75
76/*
77 * Define the request and free functions
78 * These are unfortunately architecture specific as no generic allocation
79 * mechanism exits
80 */
81#define SMC_DMA_REQUEST(dev, handler) \
82 pxa_request_dma(dev->name, DMA_PRIO_LOW, handler, dev)
83
84#define SMC_DMA_FREE(dev, dma) \
85 pxa_free_dma(dma)
86
87#define SMC_DMA_ACK_IRQ(dev, dma) \
88{ \
89 if (DCSR(dma) & DCSR_BUSERR) { \
90 printk("%s: DMA %d bus error!\n", dev->name, dma); \
91 } \
92 DCSR(dma) = DCSR_STARTINTR|DCSR_ENDINTR|DCSR_BUSERR; \
93}
94
95/*
96 * Use a DMA for RX and TX packets.
97 */
98#include <linux/dma-mapping.h>
99#include <asm/dma.h>
100#include <asm/arch/pxa-regs.h>
101
102static dma_addr_t rx_dmabuf, tx_dmabuf;
103static int rx_dmalen, tx_dmalen;
104
105#ifdef SMC_insl
106#undef SMC_insl
107#define SMC_insl(a, r, p, l) \
108 smc_pxa_dma_insl(lp->dev, a, lp->physaddr, r, lp->rxdma, p, l)
109
110static inline void
111smc_pxa_dma_insl(struct device *dev, u_long ioaddr, u_long physaddr,
112 int reg, int dma, u_char *buf, int len)
113{
114 /* 64 bit alignment is required for memory to memory DMA */
115 if ((long)buf & 4) {
116 *((u32 *)buf) = SMC_inl(ioaddr, reg);
117 buf += 4;
118 len--;
119 }
120
121 len *= 4;
122 rx_dmabuf = dma_map_single(dev, buf, len, DMA_FROM_DEVICE);
123 rx_dmalen = len;
124 DCSR(dma) = DCSR_NODESC;
125 DTADR(dma) = rx_dmabuf;
126 DSADR(dma) = physaddr + reg;
127 DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 |
128 DCMD_WIDTH4 | DCMD_ENDIRQEN | (DCMD_LENGTH & rx_dmalen));
129 DCSR(dma) = DCSR_NODESC | DCSR_RUN;
130}
131#endif
132
133#ifdef SMC_insw
134#undef SMC_insw
135#define SMC_insw(a, r, p, l) \
136 smc_pxa_dma_insw(lp->dev, a, lp->physaddr, r, lp->rxdma, p, l)
137
138static inline void
139smc_pxa_dma_insw(struct device *dev, u_long ioaddr, u_long physaddr,
140 int reg, int dma, u_char *buf, int len)
141{
142 /* 64 bit alignment is required for memory to memory DMA */
143 while ((long)buf & 6) {
144 *((u16 *)buf) = SMC_inw(ioaddr, reg);
145 buf += 2;
146 len--;
147 }
148
149 len *= 2;
150 rx_dmabuf = dma_map_single(dev, buf, len, DMA_FROM_DEVICE);
151 rx_dmalen = len;
152 DCSR(dma) = DCSR_NODESC;
153 DTADR(dma) = rx_dmabuf;
154 DSADR(dma) = physaddr + reg;
155 DCMD(dma) = (DCMD_INCTRGADDR | DCMD_BURST32 |
156 DCMD_WIDTH2 | DCMD_ENDIRQEN | (DCMD_LENGTH & rx_dmalen));
157 DCSR(dma) = DCSR_NODESC | DCSR_RUN;
158}
159#endif
160
161#ifdef SMC_outsl
162#undef SMC_outsl
163#define SMC_outsl(a, r, p, l) \
164 smc_pxa_dma_outsl(lp->dev, a, lp->physaddr, r, lp->txdma, p, l)
165
166static inline void
167smc_pxa_dma_outsl(struct device *dev, u_long ioaddr, u_long physaddr,
168 int reg, int dma, u_char *buf, int len)
169{
170 /* 64 bit alignment is required for memory to memory DMA */
171 if ((long)buf & 4) {
172 SMC_outl(*((u32 *)buf), ioaddr, reg);
173 buf += 4;
174 len--;
175 }
176
177 len *= 4;
178 tx_dmabuf = dma_map_single(dev, buf, len, DMA_TO_DEVICE);
179 tx_dmalen = len;
180 DCSR(dma) = DCSR_NODESC;
181 DSADR(dma) = tx_dmabuf;
182 DTADR(dma) = physaddr + reg;
183 DCMD(dma) = (DCMD_INCSRCADDR | DCMD_BURST32 |
184 DCMD_WIDTH4 | DCMD_ENDIRQEN | (DCMD_LENGTH & tx_dmalen));
185 DCSR(dma) = DCSR_NODESC | DCSR_RUN;
186}
187#endif
188
189#ifdef SMC_outsw
190#undef SMC_outsw
191#define SMC_outsw(a, r, p, l) \
192 smc_pxa_dma_outsw(lp->dev, a, lp->physaddr, r, lp->txdma, p, l)
193
194static inline void
195smc_pxa_dma_outsw(struct device *dev, u_long ioaddr, u_long physaddr,
196 int reg, int dma, u_char *buf, int len)
197{
198 /* 64 bit alignment is required for memory to memory DMA */
199 while ((long)buf & 6) {
200 SMC_outw(*((u16 *)buf), ioaddr, reg);
201 buf += 2;
202 len--;
203 }
204
205 len *= 2;
206 tx_dmabuf = dma_map_single(dev, buf, len, DMA_TO_DEVICE);
207 tx_dmalen = len;
208 DCSR(dma) = DCSR_NODESC;
209 DSADR(dma) = tx_dmabuf;
210 DTADR(dma) = physaddr + reg;
211 DCMD(dma) = (DCMD_INCSRCADDR | DCMD_BURST32 |
212 DCMD_WIDTH2 | DCMD_ENDIRQEN | (DCMD_LENGTH & tx_dmalen));
213 DCSR(dma) = DCSR_NODESC | DCSR_RUN;
214}
215#endif
216
217#endif /* SMC_USE_PXA_DMA */
218
219
220/* Chip Parameters and Register Definitions */
221
222#define SMC911X_TX_FIFO_LOW_THRESHOLD (1536*2)
223
224#define SMC911X_IO_EXTENT 0x100
225
226#define SMC911X_EEPROM_LEN 7
227
228/* Below are the register offsets and bit definitions
229 * of the Lan911x memory space
230 */
231#define RX_DATA_FIFO (0x00)
232
233#define TX_DATA_FIFO (0x20)
234#define TX_CMD_A_INT_ON_COMP_ (0x80000000)
235#define TX_CMD_A_INT_BUF_END_ALGN_ (0x03000000)
236#define TX_CMD_A_INT_4_BYTE_ALGN_ (0x00000000)
237#define TX_CMD_A_INT_16_BYTE_ALGN_ (0x01000000)
238#define TX_CMD_A_INT_32_BYTE_ALGN_ (0x02000000)
239#define TX_CMD_A_INT_DATA_OFFSET_ (0x001F0000)
240#define TX_CMD_A_INT_FIRST_SEG_ (0x00002000)
241#define TX_CMD_A_INT_LAST_SEG_ (0x00001000)
242#define TX_CMD_A_BUF_SIZE_ (0x000007FF)
243#define TX_CMD_B_PKT_TAG_ (0xFFFF0000)
244#define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000)
245#define TX_CMD_B_DISABLE_PADDING_ (0x00001000)
246#define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FF)
247
248#define RX_STATUS_FIFO (0x40)
249#define RX_STS_PKT_LEN_ (0x3FFF0000)
250#define RX_STS_ES_ (0x00008000)
251#define RX_STS_BCST_ (0x00002000)
252#define RX_STS_LEN_ERR_ (0x00001000)
253#define RX_STS_RUNT_ERR_ (0x00000800)
254#define RX_STS_MCAST_ (0x00000400)
255#define RX_STS_TOO_LONG_ (0x00000080)
256#define RX_STS_COLL_ (0x00000040)
257#define RX_STS_ETH_TYPE_ (0x00000020)
258#define RX_STS_WDOG_TMT_ (0x00000010)
259#define RX_STS_MII_ERR_ (0x00000008)
260#define RX_STS_DRIBBLING_ (0x00000004)
261#define RX_STS_CRC_ERR_ (0x00000002)
262#define RX_STATUS_FIFO_PEEK (0x44)
263#define TX_STATUS_FIFO (0x48)
264#define TX_STS_TAG_ (0xFFFF0000)
265#define TX_STS_ES_ (0x00008000)
266#define TX_STS_LOC_ (0x00000800)
267#define TX_STS_NO_CARR_ (0x00000400)
268#define TX_STS_LATE_COLL_ (0x00000200)
269#define TX_STS_MANY_COLL_ (0x00000100)
270#define TX_STS_COLL_CNT_ (0x00000078)
271#define TX_STS_MANY_DEFER_ (0x00000004)
272#define TX_STS_UNDERRUN_ (0x00000002)
273#define TX_STS_DEFERRED_ (0x00000001)
274#define TX_STATUS_FIFO_PEEK (0x4C)
275#define ID_REV (0x50)
276#define ID_REV_CHIP_ID_ (0xFFFF0000) /* RO */
277#define ID_REV_REV_ID_ (0x0000FFFF) /* RO */
278
279#define INT_CFG (0x54)
280#define INT_CFG_INT_DEAS_ (0xFF000000) /* R/W */
281#define INT_CFG_INT_DEAS_CLR_ (0x00004000)
282#define INT_CFG_INT_DEAS_STS_ (0x00002000)
283#define INT_CFG_IRQ_INT_ (0x00001000) /* RO */
284#define INT_CFG_IRQ_EN_ (0x00000100) /* R/W */
285#define INT_CFG_IRQ_POL_ (0x00000010) /* R/W Not Affected by SW Reset */
286#define INT_CFG_IRQ_TYPE_ (0x00000001) /* R/W Not Affected by SW Reset */
287
288#define INT_STS (0x58)
289#define INT_STS_SW_INT_ (0x80000000) /* R/WC */
290#define INT_STS_TXSTOP_INT_ (0x02000000) /* R/WC */
291#define INT_STS_RXSTOP_INT_ (0x01000000) /* R/WC */
292#define INT_STS_RXDFH_INT_ (0x00800000) /* R/WC */
293#define INT_STS_RXDF_INT_ (0x00400000) /* R/WC */
294#define INT_STS_TX_IOC_ (0x00200000) /* R/WC */
295#define INT_STS_RXD_INT_ (0x00100000) /* R/WC */
296#define INT_STS_GPT_INT_ (0x00080000) /* R/WC */
297#define INT_STS_PHY_INT_ (0x00040000) /* RO */
298#define INT_STS_PME_INT_ (0x00020000) /* R/WC */
299#define INT_STS_TXSO_ (0x00010000) /* R/WC */
300#define INT_STS_RWT_ (0x00008000) /* R/WC */
301#define INT_STS_RXE_ (0x00004000) /* R/WC */
302#define INT_STS_TXE_ (0x00002000) /* R/WC */
303//#define INT_STS_ERX_ (0x00001000) /* R/WC */
304#define INT_STS_TDFU_ (0x00000800) /* R/WC */
305#define INT_STS_TDFO_ (0x00000400) /* R/WC */
306#define INT_STS_TDFA_ (0x00000200) /* R/WC */
307#define INT_STS_TSFF_ (0x00000100) /* R/WC */
308#define INT_STS_TSFL_ (0x00000080) /* R/WC */
309//#define INT_STS_RXDF_ (0x00000040) /* R/WC */
310#define INT_STS_RDFO_ (0x00000040) /* R/WC */
311#define INT_STS_RDFL_ (0x00000020) /* R/WC */
312#define INT_STS_RSFF_ (0x00000010) /* R/WC */
313#define INT_STS_RSFL_ (0x00000008) /* R/WC */
314#define INT_STS_GPIO2_INT_ (0x00000004) /* R/WC */
315#define INT_STS_GPIO1_INT_ (0x00000002) /* R/WC */
316#define INT_STS_GPIO0_INT_ (0x00000001) /* R/WC */
317
318#define INT_EN (0x5C)
319#define INT_EN_SW_INT_EN_ (0x80000000) /* R/W */
320#define INT_EN_TXSTOP_INT_EN_ (0x02000000) /* R/W */
321#define INT_EN_RXSTOP_INT_EN_ (0x01000000) /* R/W */
322#define INT_EN_RXDFH_INT_EN_ (0x00800000) /* R/W */
323//#define INT_EN_RXDF_INT_EN_ (0x00400000) /* R/W */
324#define INT_EN_TIOC_INT_EN_ (0x00200000) /* R/W */
325#define INT_EN_RXD_INT_EN_ (0x00100000) /* R/W */
326#define INT_EN_GPT_INT_EN_ (0x00080000) /* R/W */
327#define INT_EN_PHY_INT_EN_ (0x00040000) /* R/W */
328#define INT_EN_PME_INT_EN_ (0x00020000) /* R/W */
329#define INT_EN_TXSO_EN_ (0x00010000) /* R/W */
330#define INT_EN_RWT_EN_ (0x00008000) /* R/W */
331#define INT_EN_RXE_EN_ (0x00004000) /* R/W */
332#define INT_EN_TXE_EN_ (0x00002000) /* R/W */
333//#define INT_EN_ERX_EN_ (0x00001000) /* R/W */
334#define INT_EN_TDFU_EN_ (0x00000800) /* R/W */
335#define INT_EN_TDFO_EN_ (0x00000400) /* R/W */
336#define INT_EN_TDFA_EN_ (0x00000200) /* R/W */
337#define INT_EN_TSFF_EN_ (0x00000100) /* R/W */
338#define INT_EN_TSFL_EN_ (0x00000080) /* R/W */
339//#define INT_EN_RXDF_EN_ (0x00000040) /* R/W */
340#define INT_EN_RDFO_EN_ (0x00000040) /* R/W */
341#define INT_EN_RDFL_EN_ (0x00000020) /* R/W */
342#define INT_EN_RSFF_EN_ (0x00000010) /* R/W */
343#define INT_EN_RSFL_EN_ (0x00000008) /* R/W */
344#define INT_EN_GPIO2_INT_ (0x00000004) /* R/W */
345#define INT_EN_GPIO1_INT_ (0x00000002) /* R/W */
346#define INT_EN_GPIO0_INT_ (0x00000001) /* R/W */
347
348#define BYTE_TEST (0x64)
349#define FIFO_INT (0x68)
350#define FIFO_INT_TX_AVAIL_LEVEL_ (0xFF000000) /* R/W */
351#define FIFO_INT_TX_STS_LEVEL_ (0x00FF0000) /* R/W */
352#define FIFO_INT_RX_AVAIL_LEVEL_ (0x0000FF00) /* R/W */
353#define FIFO_INT_RX_STS_LEVEL_ (0x000000FF) /* R/W */
354
355#define RX_CFG (0x6C)
356#define RX_CFG_RX_END_ALGN_ (0xC0000000) /* R/W */
357#define RX_CFG_RX_END_ALGN4_ (0x00000000) /* R/W */
358#define RX_CFG_RX_END_ALGN16_ (0x40000000) /* R/W */
359#define RX_CFG_RX_END_ALGN32_ (0x80000000) /* R/W */
360#define RX_CFG_RX_DMA_CNT_ (0x0FFF0000) /* R/W */
361#define RX_CFG_RX_DUMP_ (0x00008000) /* R/W */
362#define RX_CFG_RXDOFF_ (0x00001F00) /* R/W */
363//#define RX_CFG_RXBAD_ (0x00000001) /* R/W */
364
365#define TX_CFG (0x70)
366//#define TX_CFG_TX_DMA_LVL_ (0xE0000000) /* R/W */
367//#define TX_CFG_TX_DMA_CNT_ (0x0FFF0000) /* R/W Self Clearing */
368#define TX_CFG_TXS_DUMP_ (0x00008000) /* Self Clearing */
369#define TX_CFG_TXD_DUMP_ (0x00004000) /* Self Clearing */
370#define TX_CFG_TXSAO_ (0x00000004) /* R/W */
371#define TX_CFG_TX_ON_ (0x00000002) /* R/W */
372#define TX_CFG_STOP_TX_ (0x00000001) /* Self Clearing */
373
374#define HW_CFG (0x74)
375#define HW_CFG_TTM_ (0x00200000) /* R/W */
376#define HW_CFG_SF_ (0x00100000) /* R/W */
377#define HW_CFG_TX_FIF_SZ_ (0x000F0000) /* R/W */
378#define HW_CFG_TR_ (0x00003000) /* R/W */
379#define HW_CFG_PHY_CLK_SEL_ (0x00000060) /* R/W */
380#define HW_CFG_PHY_CLK_SEL_INT_PHY_ (0x00000000) /* R/W */
381#define HW_CFG_PHY_CLK_SEL_EXT_PHY_ (0x00000020) /* R/W */
382#define HW_CFG_PHY_CLK_SEL_CLK_DIS_ (0x00000040) /* R/W */
383#define HW_CFG_SMI_SEL_ (0x00000010) /* R/W */
384#define HW_CFG_EXT_PHY_DET_ (0x00000008) /* RO */
385#define HW_CFG_EXT_PHY_EN_ (0x00000004) /* R/W */
386#define HW_CFG_32_16_BIT_MODE_ (0x00000004) /* RO */
387#define HW_CFG_SRST_TO_ (0x00000002) /* RO */
388#define HW_CFG_SRST_ (0x00000001) /* Self Clearing */
389
390#define RX_DP_CTRL (0x78)
391#define RX_DP_CTRL_RX_FFWD_ (0x80000000) /* R/W */
392#define RX_DP_CTRL_FFWD_BUSY_ (0x80000000) /* RO */
393
394#define RX_FIFO_INF (0x7C)
395#define RX_FIFO_INF_RXSUSED_ (0x00FF0000) /* RO */
396#define RX_FIFO_INF_RXDUSED_ (0x0000FFFF) /* RO */
397
398#define TX_FIFO_INF (0x80)
399#define TX_FIFO_INF_TSUSED_ (0x00FF0000) /* RO */
400#define TX_FIFO_INF_TDFREE_ (0x0000FFFF) /* RO */
401
402#define PMT_CTRL (0x84)
403#define PMT_CTRL_PM_MODE_ (0x00003000) /* Self Clearing */
404#define PMT_CTRL_PHY_RST_ (0x00000400) /* Self Clearing */
405#define PMT_CTRL_WOL_EN_ (0x00000200) /* R/W */
406#define PMT_CTRL_ED_EN_ (0x00000100) /* R/W */
407#define PMT_CTRL_PME_TYPE_ (0x00000040) /* R/W Not Affected by SW Reset */
408#define PMT_CTRL_WUPS_ (0x00000030) /* R/WC */
409#define PMT_CTRL_WUPS_NOWAKE_ (0x00000000) /* R/WC */
410#define PMT_CTRL_WUPS_ED_ (0x00000010) /* R/WC */
411#define PMT_CTRL_WUPS_WOL_ (0x00000020) /* R/WC */
412#define PMT_CTRL_WUPS_MULTI_ (0x00000030) /* R/WC */
413#define PMT_CTRL_PME_IND_ (0x00000008) /* R/W */
414#define PMT_CTRL_PME_POL_ (0x00000004) /* R/W */
415#define PMT_CTRL_PME_EN_ (0x00000002) /* R/W Not Affected by SW Reset */
416#define PMT_CTRL_READY_ (0x00000001) /* RO */
417
418#define GPIO_CFG (0x88)
419#define GPIO_CFG_LED3_EN_ (0x40000000) /* R/W */
420#define GPIO_CFG_LED2_EN_ (0x20000000) /* R/W */
421#define GPIO_CFG_LED1_EN_ (0x10000000) /* R/W */
422#define GPIO_CFG_GPIO2_INT_POL_ (0x04000000) /* R/W */
423#define GPIO_CFG_GPIO1_INT_POL_ (0x02000000) /* R/W */
424#define GPIO_CFG_GPIO0_INT_POL_ (0x01000000) /* R/W */
425#define GPIO_CFG_EEPR_EN_ (0x00700000) /* R/W */
426#define GPIO_CFG_GPIOBUF2_ (0x00040000) /* R/W */
427#define GPIO_CFG_GPIOBUF1_ (0x00020000) /* R/W */
428#define GPIO_CFG_GPIOBUF0_ (0x00010000) /* R/W */
429#define GPIO_CFG_GPIODIR2_ (0x00000400) /* R/W */
430#define GPIO_CFG_GPIODIR1_ (0x00000200) /* R/W */
431#define GPIO_CFG_GPIODIR0_ (0x00000100) /* R/W */
432#define GPIO_CFG_GPIOD4_ (0x00000010) /* R/W */
433#define GPIO_CFG_GPIOD3_ (0x00000008) /* R/W */
434#define GPIO_CFG_GPIOD2_ (0x00000004) /* R/W */
435#define GPIO_CFG_GPIOD1_ (0x00000002) /* R/W */
436#define GPIO_CFG_GPIOD0_ (0x00000001) /* R/W */
437
438#define GPT_CFG (0x8C)
439#define GPT_CFG_TIMER_EN_ (0x20000000) /* R/W */
440#define GPT_CFG_GPT_LOAD_ (0x0000FFFF) /* R/W */
441
442#define GPT_CNT (0x90)
443#define GPT_CNT_GPT_CNT_ (0x0000FFFF) /* RO */
444
445#define ENDIAN (0x98)
446#define FREE_RUN (0x9C)
447#define RX_DROP (0xA0)
448#define MAC_CSR_CMD (0xA4)
449#define MAC_CSR_CMD_CSR_BUSY_ (0x80000000) /* Self Clearing */
450#define MAC_CSR_CMD_R_NOT_W_ (0x40000000) /* R/W */
451#define MAC_CSR_CMD_CSR_ADDR_ (0x000000FF) /* R/W */
452
453#define MAC_CSR_DATA (0xA8)
454#define AFC_CFG (0xAC)
455#define AFC_CFG_AFC_HI_ (0x00FF0000) /* R/W */
456#define AFC_CFG_AFC_LO_ (0x0000FF00) /* R/W */
457#define AFC_CFG_BACK_DUR_ (0x000000F0) /* R/W */
458#define AFC_CFG_FCMULT_ (0x00000008) /* R/W */
459#define AFC_CFG_FCBRD_ (0x00000004) /* R/W */
460#define AFC_CFG_FCADD_ (0x00000002) /* R/W */
461#define AFC_CFG_FCANY_ (0x00000001) /* R/W */
462
463#define E2P_CMD (0xB0)
464#define E2P_CMD_EPC_BUSY_ (0x80000000) /* Self Clearing */
465#define E2P_CMD_EPC_CMD_ (0x70000000) /* R/W */
466#define E2P_CMD_EPC_CMD_READ_ (0x00000000) /* R/W */
467#define E2P_CMD_EPC_CMD_EWDS_ (0x10000000) /* R/W */
468#define E2P_CMD_EPC_CMD_EWEN_ (0x20000000) /* R/W */
469#define E2P_CMD_EPC_CMD_WRITE_ (0x30000000) /* R/W */
470#define E2P_CMD_EPC_CMD_WRAL_ (0x40000000) /* R/W */
471#define E2P_CMD_EPC_CMD_ERASE_ (0x50000000) /* R/W */
472#define E2P_CMD_EPC_CMD_ERAL_ (0x60000000) /* R/W */
473#define E2P_CMD_EPC_CMD_RELOAD_ (0x70000000) /* R/W */
474#define E2P_CMD_EPC_TIMEOUT_ (0x00000200) /* RO */
475#define E2P_CMD_MAC_ADDR_LOADED_ (0x00000100) /* RO */
476#define E2P_CMD_EPC_ADDR_ (0x000000FF) /* R/W */
477
478#define E2P_DATA (0xB4)
479#define E2P_DATA_EEPROM_DATA_ (0x000000FF) /* R/W */
480/* end of LAN register offsets and bit definitions */
481
482/*
483 ****************************************************************************
484 ****************************************************************************
485 * MAC Control and Status Register (Indirect Address)
486 * Offset (through the MAC_CSR CMD and DATA port)
487 ****************************************************************************
488 ****************************************************************************
489 *
490 */
491#define MAC_CR (0x01) /* R/W */
492
493/* MAC_CR - MAC Control Register */
494#define MAC_CR_RXALL_ (0x80000000)
495// TODO: delete this bit? It is not described in the data sheet.
496#define MAC_CR_HBDIS_ (0x10000000)
497#define MAC_CR_RCVOWN_ (0x00800000)
498#define MAC_CR_LOOPBK_ (0x00200000)
499#define MAC_CR_FDPX_ (0x00100000)
500#define MAC_CR_MCPAS_ (0x00080000)
501#define MAC_CR_PRMS_ (0x00040000)
502#define MAC_CR_INVFILT_ (0x00020000)
503#define MAC_CR_PASSBAD_ (0x00010000)
504#define MAC_CR_HFILT_ (0x00008000)
505#define MAC_CR_HPFILT_ (0x00002000)
506#define MAC_CR_LCOLL_ (0x00001000)
507#define MAC_CR_BCAST_ (0x00000800)
508#define MAC_CR_DISRTY_ (0x00000400)
509#define MAC_CR_PADSTR_ (0x00000100)
510#define MAC_CR_BOLMT_MASK_ (0x000000C0)
511#define MAC_CR_DFCHK_ (0x00000020)
512#define MAC_CR_TXEN_ (0x00000008)
513#define MAC_CR_RXEN_ (0x00000004)
514
515#define ADDRH (0x02) /* R/W mask 0x0000FFFFUL */
516#define ADDRL (0x03) /* R/W mask 0xFFFFFFFFUL */
517#define HASHH (0x04) /* R/W */
518#define HASHL (0x05) /* R/W */
519
520#define MII_ACC (0x06) /* R/W */
521#define MII_ACC_PHY_ADDR_ (0x0000F800)
522#define MII_ACC_MIIRINDA_ (0x000007C0)
523#define MII_ACC_MII_WRITE_ (0x00000002)
524#define MII_ACC_MII_BUSY_ (0x00000001)
525
526#define MII_DATA (0x07) /* R/W mask 0x0000FFFFUL */
527
528#define FLOW (0x08) /* R/W */
529#define FLOW_FCPT_ (0xFFFF0000)
530#define FLOW_FCPASS_ (0x00000004)
531#define FLOW_FCEN_ (0x00000002)
532#define FLOW_FCBSY_ (0x00000001)
533
534#define VLAN1 (0x09) /* R/W mask 0x0000FFFFUL */
535#define VLAN1_VTI1_ (0x0000ffff)
536
537#define VLAN2 (0x0A) /* R/W mask 0x0000FFFFUL */
538#define VLAN2_VTI2_ (0x0000ffff)
539
540#define WUFF (0x0B) /* WO */
541
542#define WUCSR (0x0C) /* R/W */
543#define WUCSR_GUE_ (0x00000200)
544#define WUCSR_WUFR_ (0x00000040)
545#define WUCSR_MPR_ (0x00000020)
546#define WUCSR_WAKE_EN_ (0x00000004)
547#define WUCSR_MPEN_ (0x00000002)
548
549/*
550 ****************************************************************************
551 * Chip Specific MII Defines
552 ****************************************************************************
553 *
554 * Phy register offsets and bit definitions
555 *
556 */
557
558#define PHY_MODE_CTRL_STS ((u32)17) /* Mode Control/Status Register */
559//#define MODE_CTRL_STS_FASTRIP_ ((u16)0x4000)
560#define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000)
561//#define MODE_CTRL_STS_LOWSQEN_ ((u16)0x0800)
562//#define MODE_CTRL_STS_MDPREBP_ ((u16)0x0400)
563//#define MODE_CTRL_STS_FARLOOPBACK_ ((u16)0x0200)
564//#define MODE_CTRL_STS_FASTEST_ ((u16)0x0100)
565//#define MODE_CTRL_STS_REFCLKEN_ ((u16)0x0010)
566//#define MODE_CTRL_STS_PHYADBP_ ((u16)0x0008)
567//#define MODE_CTRL_STS_FORCE_G_LINK_ ((u16)0x0004)
568#define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002)
569
570#define PHY_INT_SRC ((u32)29)
571#define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080)
572#define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040)
573#define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020)
574#define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010)
575#define PHY_INT_SRC_ANEG_LP_ACK_ ((u16)0x0008)
576#define PHY_INT_SRC_PAR_DET_FAULT_ ((u16)0x0004)
577#define PHY_INT_SRC_ANEG_PGRX_ ((u16)0x0002)
578
579#define PHY_INT_MASK ((u32)30)
580#define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080)
581#define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040)
582#define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020)
583#define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010)
584#define PHY_INT_MASK_ANEG_LP_ACK_ ((u16)0x0008)
585#define PHY_INT_MASK_PAR_DET_FAULT_ ((u16)0x0004)
586#define PHY_INT_MASK_ANEG_PGRX_ ((u16)0x0002)
587
588#define PHY_SPECIAL ((u32)31)
589#define PHY_SPECIAL_ANEG_DONE_ ((u16)0x1000)
590#define PHY_SPECIAL_RES_ ((u16)0x0040)
591#define PHY_SPECIAL_RES_MASK_ ((u16)0x0FE1)
592#define PHY_SPECIAL_SPD_ ((u16)0x001C)
593#define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004)
594#define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014)
595#define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008)
596#define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018)
597
598#define LAN911X_INTERNAL_PHY_ID (0x0007C000)
599
600/* Chip ID values */
601#define CHIP_9115 0x115
602#define CHIP_9116 0x116
603#define CHIP_9117 0x117
604#define CHIP_9118 0x118
605
606struct chip_id {
607 u16 id;
608 char *name;
609};
610
611static const struct chip_id chip_ids[] = {
612 { CHIP_9115, "LAN9115" },
613 { CHIP_9116, "LAN9116" },
614 { CHIP_9117, "LAN9117" },
615 { CHIP_9118, "LAN9118" },
616 { 0, NULL },
617};
618
619#define IS_REV_A(x) ((x & 0xFFFF)==0)
620
621/*
622 * Macros to abstract register access according to the data bus
623 * capabilities. Please use those and not the in/out primitives.
624 */
625/* FIFO read/write macros */
626#define SMC_PUSH_DATA(p, l) SMC_outsl( ioaddr, TX_DATA_FIFO, p, (l) >> 2 )
627#define SMC_PULL_DATA(p, l) SMC_insl ( ioaddr, RX_DATA_FIFO, p, (l) >> 2 )
628#define SMC_SET_TX_FIFO(x) SMC_outl( x, ioaddr, TX_DATA_FIFO )
629#define SMC_GET_RX_FIFO() SMC_inl( ioaddr, RX_DATA_FIFO )
630
631
632/* I/O mapped register read/write macros */
633#define SMC_GET_TX_STS_FIFO() SMC_inl( ioaddr, TX_STATUS_FIFO )
634#define SMC_GET_RX_STS_FIFO() SMC_inl( ioaddr, RX_STATUS_FIFO )
635#define SMC_GET_RX_STS_FIFO_PEEK() SMC_inl( ioaddr, RX_STATUS_FIFO_PEEK )
636#define SMC_GET_PN() (SMC_inl( ioaddr, ID_REV ) >> 16)
637#define SMC_GET_REV() (SMC_inl( ioaddr, ID_REV ) & 0xFFFF)
638#define SMC_GET_IRQ_CFG() SMC_inl( ioaddr, INT_CFG )
639#define SMC_SET_IRQ_CFG(x) SMC_outl( x, ioaddr, INT_CFG )
640#define SMC_GET_INT() SMC_inl( ioaddr, INT_STS )
641#define SMC_ACK_INT(x) SMC_outl( x, ioaddr, INT_STS )
642#define SMC_GET_INT_EN() SMC_inl( ioaddr, INT_EN )
643#define SMC_SET_INT_EN(x) SMC_outl( x, ioaddr, INT_EN )
644#define SMC_GET_BYTE_TEST() SMC_inl( ioaddr, BYTE_TEST )
645#define SMC_SET_BYTE_TEST(x) SMC_outl( x, ioaddr, BYTE_TEST )
646#define SMC_GET_FIFO_INT() SMC_inl( ioaddr, FIFO_INT )
647#define SMC_SET_FIFO_INT(x) SMC_outl( x, ioaddr, FIFO_INT )
648#define SMC_SET_FIFO_TDA(x) \
649 do { \
650 unsigned long __flags; \
651 int __mask; \
652 local_irq_save(__flags); \
653 __mask = SMC_GET_FIFO_INT() & ~(0xFF<<24); \
654 SMC_SET_FIFO_INT( __mask | (x)<<24 ); \
655 local_irq_restore(__flags); \
656 } while (0)
657#define SMC_SET_FIFO_TSL(x) \
658 do { \
659 unsigned long __flags; \
660 int __mask; \
661 local_irq_save(__flags); \
662 __mask = SMC_GET_FIFO_INT() & ~(0xFF<<16); \
663 SMC_SET_FIFO_INT( __mask | (((x) & 0xFF)<<16)); \
664 local_irq_restore(__flags); \
665 } while (0)
666#define SMC_SET_FIFO_RSA(x) \
667 do { \
668 unsigned long __flags; \
669 int __mask; \
670 local_irq_save(__flags); \
671 __mask = SMC_GET_FIFO_INT() & ~(0xFF<<8); \
672 SMC_SET_FIFO_INT( __mask | (((x) & 0xFF)<<8)); \
673 local_irq_restore(__flags); \
674 } while (0)
675#define SMC_SET_FIFO_RSL(x) \
676 do { \
677 unsigned long __flags; \
678 int __mask; \
679 local_irq_save(__flags); \
680 __mask = SMC_GET_FIFO_INT() & ~0xFF; \
681 SMC_SET_FIFO_INT( __mask | ((x) & 0xFF)); \
682 local_irq_restore(__flags); \
683 } while (0)
684#define SMC_GET_RX_CFG() SMC_inl( ioaddr, RX_CFG )
685#define SMC_SET_RX_CFG(x) SMC_outl( x, ioaddr, RX_CFG )
686#define SMC_GET_TX_CFG() SMC_inl( ioaddr, TX_CFG )
687#define SMC_SET_TX_CFG(x) SMC_outl( x, ioaddr, TX_CFG )
688#define SMC_GET_HW_CFG() SMC_inl( ioaddr, HW_CFG )
689#define SMC_SET_HW_CFG(x) SMC_outl( x, ioaddr, HW_CFG )
690#define SMC_GET_RX_DP_CTRL() SMC_inl( ioaddr, RX_DP_CTRL )
691#define SMC_SET_RX_DP_CTRL(x) SMC_outl( x, ioaddr, RX_DP_CTRL )
692#define SMC_GET_PMT_CTRL() SMC_inl( ioaddr, PMT_CTRL )
693#define SMC_SET_PMT_CTRL(x) SMC_outl( x, ioaddr, PMT_CTRL )
694#define SMC_GET_GPIO_CFG() SMC_inl( ioaddr, GPIO_CFG )
695#define SMC_SET_GPIO_CFG(x) SMC_outl( x, ioaddr, GPIO_CFG )
696#define SMC_GET_RX_FIFO_INF() SMC_inl( ioaddr, RX_FIFO_INF )
697#define SMC_SET_RX_FIFO_INF(x) SMC_outl( x, ioaddr, RX_FIFO_INF )
698#define SMC_GET_TX_FIFO_INF() SMC_inl( ioaddr, TX_FIFO_INF )
699#define SMC_SET_TX_FIFO_INF(x) SMC_outl( x, ioaddr, TX_FIFO_INF )
700#define SMC_GET_GPT_CFG() SMC_inl( ioaddr, GPT_CFG )
701#define SMC_SET_GPT_CFG(x) SMC_outl( x, ioaddr, GPT_CFG )
702#define SMC_GET_RX_DROP() SMC_inl( ioaddr, RX_DROP )
703#define SMC_SET_RX_DROP(x) SMC_outl( x, ioaddr, RX_DROP )
704#define SMC_GET_MAC_CMD() SMC_inl( ioaddr, MAC_CSR_CMD )
705#define SMC_SET_MAC_CMD(x) SMC_outl( x, ioaddr, MAC_CSR_CMD )
706#define SMC_GET_MAC_DATA() SMC_inl( ioaddr, MAC_CSR_DATA )
707#define SMC_SET_MAC_DATA(x) SMC_outl( x, ioaddr, MAC_CSR_DATA )
708#define SMC_GET_AFC_CFG() SMC_inl( ioaddr, AFC_CFG )
709#define SMC_SET_AFC_CFG(x) SMC_outl( x, ioaddr, AFC_CFG )
710#define SMC_GET_E2P_CMD() SMC_inl( ioaddr, E2P_CMD )
711#define SMC_SET_E2P_CMD(x) SMC_outl( x, ioaddr, E2P_CMD )
712#define SMC_GET_E2P_DATA() SMC_inl( ioaddr, E2P_DATA )
713#define SMC_SET_E2P_DATA(x) SMC_outl( x, ioaddr, E2P_DATA )
714
715/* MAC register read/write macros */
716#define SMC_GET_MAC_CSR(a,v) \
717 do { \
718 while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_); \
719 SMC_SET_MAC_CMD(MAC_CSR_CMD_CSR_BUSY_ | \
720 MAC_CSR_CMD_R_NOT_W_ | (a) ); \
721 while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_); \
722 v = SMC_GET_MAC_DATA(); \
723 } while (0)
724#define SMC_SET_MAC_CSR(a,v) \
725 do { \
726 while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_); \
727 SMC_SET_MAC_DATA(v); \
728 SMC_SET_MAC_CMD(MAC_CSR_CMD_CSR_BUSY_ | (a) ); \
729 while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_); \
730 } while (0)
731#define SMC_GET_MAC_CR(x) SMC_GET_MAC_CSR( MAC_CR, x )
732#define SMC_SET_MAC_CR(x) SMC_SET_MAC_CSR( MAC_CR, x )
733#define SMC_GET_ADDRH(x) SMC_GET_MAC_CSR( ADDRH, x )
734#define SMC_SET_ADDRH(x) SMC_SET_MAC_CSR( ADDRH, x )
735#define SMC_GET_ADDRL(x) SMC_GET_MAC_CSR( ADDRL, x )
736#define SMC_SET_ADDRL(x) SMC_SET_MAC_CSR( ADDRL, x )
737#define SMC_GET_HASHH(x) SMC_GET_MAC_CSR( HASHH, x )
738#define SMC_SET_HASHH(x) SMC_SET_MAC_CSR( HASHH, x )
739#define SMC_GET_HASHL(x) SMC_GET_MAC_CSR( HASHL, x )
740#define SMC_SET_HASHL(x) SMC_SET_MAC_CSR( HASHL, x )
741#define SMC_GET_MII_ACC(x) SMC_GET_MAC_CSR( MII_ACC, x )
742#define SMC_SET_MII_ACC(x) SMC_SET_MAC_CSR( MII_ACC, x )
743#define SMC_GET_MII_DATA(x) SMC_GET_MAC_CSR( MII_DATA, x )
744#define SMC_SET_MII_DATA(x) SMC_SET_MAC_CSR( MII_DATA, x )
745#define SMC_GET_FLOW(x) SMC_GET_MAC_CSR( FLOW, x )
746#define SMC_SET_FLOW(x) SMC_SET_MAC_CSR( FLOW, x )
747#define SMC_GET_VLAN1(x) SMC_GET_MAC_CSR( VLAN1, x )
748#define SMC_SET_VLAN1(x) SMC_SET_MAC_CSR( VLAN1, x )
749#define SMC_GET_VLAN2(x) SMC_GET_MAC_CSR( VLAN2, x )
750#define SMC_SET_VLAN2(x) SMC_SET_MAC_CSR( VLAN2, x )
751#define SMC_SET_WUFF(x) SMC_SET_MAC_CSR( WUFF, x )
752#define SMC_GET_WUCSR(x) SMC_GET_MAC_CSR( WUCSR, x )
753#define SMC_SET_WUCSR(x) SMC_SET_MAC_CSR( WUCSR, x )
754
755/* PHY register read/write macros */
756#define SMC_GET_MII(a,phy,v) \
757 do { \
758 u32 __v; \
759 do { \
760 SMC_GET_MII_ACC(__v); \
761 } while ( __v & MII_ACC_MII_BUSY_ ); \
762 SMC_SET_MII_ACC( ((phy)<<11) | ((a)<<6) | \
763 MII_ACC_MII_BUSY_); \
764 do { \
765 SMC_GET_MII_ACC(__v); \
766 } while ( __v & MII_ACC_MII_BUSY_ ); \
767 SMC_GET_MII_DATA(v); \
768 } while (0)
769#define SMC_SET_MII(a,phy,v) \
770 do { \
771 u32 __v; \
772 do { \
773 SMC_GET_MII_ACC(__v); \
774 } while ( __v & MII_ACC_MII_BUSY_ ); \
775 SMC_SET_MII_DATA(v); \
776 SMC_SET_MII_ACC( ((phy)<<11) | ((a)<<6) | \
777 MII_ACC_MII_BUSY_ | \
778 MII_ACC_MII_WRITE_ ); \
779 do { \
780 SMC_GET_MII_ACC(__v); \
781 } while ( __v & MII_ACC_MII_BUSY_ ); \
782 } while (0)
783#define SMC_GET_PHY_BMCR(phy,x) SMC_GET_MII( MII_BMCR, phy, x )
784#define SMC_SET_PHY_BMCR(phy,x) SMC_SET_MII( MII_BMCR, phy, x )
785#define SMC_GET_PHY_BMSR(phy,x) SMC_GET_MII( MII_BMSR, phy, x )
786#define SMC_GET_PHY_ID1(phy,x) SMC_GET_MII( MII_PHYSID1, phy, x )
787#define SMC_GET_PHY_ID2(phy,x) SMC_GET_MII( MII_PHYSID2, phy, x )
788#define SMC_GET_PHY_MII_ADV(phy,x) SMC_GET_MII( MII_ADVERTISE, phy, x )
789#define SMC_SET_PHY_MII_ADV(phy,x) SMC_SET_MII( MII_ADVERTISE, phy, x )
790#define SMC_GET_PHY_MII_LPA(phy,x) SMC_GET_MII( MII_LPA, phy, x )
791#define SMC_SET_PHY_MII_LPA(phy,x) SMC_SET_MII( MII_LPA, phy, x )
792#define SMC_GET_PHY_CTRL_STS(phy,x) SMC_GET_MII( PHY_MODE_CTRL_STS, phy, x )
793#define SMC_SET_PHY_CTRL_STS(phy,x) SMC_SET_MII( PHY_MODE_CTRL_STS, phy, x )
794#define SMC_GET_PHY_INT_SRC(phy,x) SMC_GET_MII( PHY_INT_SRC, phy, x )
795#define SMC_SET_PHY_INT_SRC(phy,x) SMC_SET_MII( PHY_INT_SRC, phy, x )
796#define SMC_GET_PHY_INT_MASK(phy,x) SMC_GET_MII( PHY_INT_MASK, phy, x )
797#define SMC_SET_PHY_INT_MASK(phy,x) SMC_SET_MII( PHY_INT_MASK, phy, x )
798#define SMC_GET_PHY_SPECIAL(phy,x) SMC_GET_MII( PHY_SPECIAL, phy, x )
799
800
801
802/* Misc read/write macros */
803
804#ifndef SMC_GET_MAC_ADDR
805#define SMC_GET_MAC_ADDR(addr) \
806 do { \
807 unsigned int __v; \
808 \
809 SMC_GET_MAC_CSR(ADDRL, __v); \
810 addr[0] = __v; addr[1] = __v >> 8; \
811 addr[2] = __v >> 16; addr[3] = __v >> 24; \
812 SMC_GET_MAC_CSR(ADDRH, __v); \
813 addr[4] = __v; addr[5] = __v >> 8; \
814 } while (0)
815#endif
816
817#define SMC_SET_MAC_ADDR(addr) \
818 do { \
819 SMC_SET_MAC_CSR(ADDRL, \
820 addr[0] | \
821 (addr[1] << 8) | \
822 (addr[2] << 16) | \
823 (addr[3] << 24)); \
824 SMC_SET_MAC_CSR(ADDRH, addr[4]|(addr[5] << 8));\
825 } while (0)
826
827
828#define SMC_WRITE_EEPROM_CMD(cmd, addr) \
829 do { \
830 while (SMC_GET_E2P_CMD() & MAC_CSR_CMD_CSR_BUSY_); \
831 SMC_SET_MAC_CMD(MAC_CSR_CMD_R_NOT_W_ | a ); \
832 while (SMC_GET_MAC_CMD() & MAC_CSR_CMD_CSR_BUSY_); \
833 } while (0)
834
835#endif /* _SMC911X_H_ */
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index f86697da04d6..6cf16f322ad5 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -732,12 +732,9 @@ static int ifport;
732struct net_device * __init smc_init(int unit) 732struct net_device * __init smc_init(int unit)
733{ 733{
734 struct net_device *dev = alloc_etherdev(sizeof(struct smc_local)); 734 struct net_device *dev = alloc_etherdev(sizeof(struct smc_local));
735 static struct devlist *smcdev = smc_devlist; 735 struct devlist *smcdev = smc_devlist;
736 int err = 0; 736 int err = 0;
737 737
738#ifndef NO_AUTOPROBE
739 smcdev = smc_devlist;
740#endif
741 if (!dev) 738 if (!dev)
742 return ERR_PTR(-ENODEV); 739 return ERR_PTR(-ENODEV);
743 740
@@ -1607,7 +1604,7 @@ MODULE_PARM_DESC(io, "SMC 99194 I/O base address");
1607MODULE_PARM_DESC(irq, "SMC 99194 IRQ number"); 1604MODULE_PARM_DESC(irq, "SMC 99194 IRQ number");
1608MODULE_PARM_DESC(ifport, "SMC 99194 interface port (0-default, 1-TP, 2-AUI)"); 1605MODULE_PARM_DESC(ifport, "SMC 99194 interface port (0-default, 1-TP, 2-AUI)");
1609 1606
1610int init_module(void) 1607int __init init_module(void)
1611{ 1608{
1612 if (io == 0) 1609 if (io == 0)
1613 printk(KERN_WARNING 1610 printk(KERN_WARNING
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index e1be1af51201..f72a4f57905a 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -129,6 +129,24 @@
129#define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l)) 129#define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l))
130#define SMC_outsb(a, r, p, l) writesb((a) + (r), p, (l)) 130#define SMC_outsb(a, r, p, l) writesb((a) + (r), p, (l))
131 131
132#elif defined(CONFIG_MACH_LOGICPD_PXA270)
133
134#define SMC_CAN_USE_8BIT 0
135#define SMC_CAN_USE_16BIT 1
136#define SMC_CAN_USE_32BIT 0
137#define SMC_IO_SHIFT 0
138#define SMC_NOWAIT 1
139#define SMC_USE_PXA_DMA 1
140
141#define SMC_inb(a, r) readb((a) + (r))
142#define SMC_inw(a, r) readw((a) + (r))
143#define SMC_inl(a, r) readl((a) + (r))
144#define SMC_outb(v, a, r) writeb(v, (a) + (r))
145#define SMC_outw(v, a, r) writew(v, (a) + (r))
146#define SMC_outl(v, a, r) writel(v, (a) + (r))
147#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
148#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
149
132#elif defined(CONFIG_ARCH_INNOKOM) || \ 150#elif defined(CONFIG_ARCH_INNOKOM) || \
133 defined(CONFIG_MACH_MAINSTONE) || \ 151 defined(CONFIG_MACH_MAINSTONE) || \
134 defined(CONFIG_ARCH_PXA_IDP) || \ 152 defined(CONFIG_ARCH_PXA_IDP) || \
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index b2ddd5e79303..9282b4b0c022 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -345,9 +345,9 @@ static int bcm5421_enable_fiber(struct mii_phy* phy)
345 345
346static int bcm5461_enable_fiber(struct mii_phy* phy) 346static int bcm5461_enable_fiber(struct mii_phy* phy)
347{ 347{
348 phy_write(phy, MII_NCONFIG, 0xfc0c); 348 phy_write(phy, MII_NCONFIG, 0xfc0c);
349 phy_write(phy, MII_BMCR, 0x4140); 349 phy_write(phy, MII_BMCR, 0x4140);
350 phy_write(phy, MII_NCONFIG, 0xfc0b); 350 phy_write(phy, MII_NCONFIG, 0xfc0b);
351 phy_write(phy, MII_BMCR, 0x0140); 351 phy_write(phy, MII_BMCR, 0x0140);
352 352
353 return 0; 353 return 0;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 49ad60b72657..b2ddd4522a87 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -69,8 +69,8 @@
69 69
70#define DRV_MODULE_NAME "tg3" 70#define DRV_MODULE_NAME "tg3"
71#define PFX DRV_MODULE_NAME ": " 71#define PFX DRV_MODULE_NAME ": "
72#define DRV_MODULE_VERSION "3.58" 72#define DRV_MODULE_VERSION "3.60"
73#define DRV_MODULE_RELDATE "May 22, 2006" 73#define DRV_MODULE_RELDATE "June 17, 2006"
74 74
75#define TG3_DEF_MAC_MODE 0 75#define TG3_DEF_MAC_MODE 0
76#define TG3_DEF_RX_MODE 0 76#define TG3_DEF_RX_MODE 0
@@ -229,6 +229,8 @@ static struct pci_device_id tg3_pci_tbl[] = {
229 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 229 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
230 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M, 230 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M,
231 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 231 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
232 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5786,
233 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
232 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787, 234 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787,
233 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 235 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
234 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M, 236 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M,
@@ -2965,6 +2967,27 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset)
2965 return err; 2967 return err;
2966} 2968}
2967 2969
2970/* This is called whenever we suspect that the system chipset is re-
2971 * ordering the sequence of MMIO to the tx send mailbox. The symptom
2972 * is bogus tx completions. We try to recover by setting the
2973 * TG3_FLAG_MBOX_WRITE_REORDER flag and resetting the chip later
2974 * in the workqueue.
2975 */
2976static void tg3_tx_recover(struct tg3 *tp)
2977{
2978 BUG_ON((tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) ||
2979 tp->write32_tx_mbox == tg3_write_indirect_mbox);
2980
2981 printk(KERN_WARNING PFX "%s: The system may be re-ordering memory-"
2982 "mapped I/O cycles to the network device, attempting to "
2983 "recover. Please report the problem to the driver maintainer "
2984 "and include system chipset information.\n", tp->dev->name);
2985
2986 spin_lock(&tp->lock);
2987 tp->tg3_flags |= TG3_FLAG_TX_RECOVERY_PENDING;
2988 spin_unlock(&tp->lock);
2989}
2990
2968/* Tigon3 never reports partial packet sends. So we do not 2991/* Tigon3 never reports partial packet sends. So we do not
2969 * need special logic to handle SKBs that have not had all 2992 * need special logic to handle SKBs that have not had all
2970 * of their frags sent yet, like SunGEM does. 2993 * of their frags sent yet, like SunGEM does.
@@ -2977,9 +3000,13 @@ static void tg3_tx(struct tg3 *tp)
2977 while (sw_idx != hw_idx) { 3000 while (sw_idx != hw_idx) {
2978 struct tx_ring_info *ri = &tp->tx_buffers[sw_idx]; 3001 struct tx_ring_info *ri = &tp->tx_buffers[sw_idx];
2979 struct sk_buff *skb = ri->skb; 3002 struct sk_buff *skb = ri->skb;
2980 int i; 3003 int i, tx_bug = 0;
3004
3005 if (unlikely(skb == NULL)) {
3006 tg3_tx_recover(tp);
3007 return;
3008 }
2981 3009
2982 BUG_ON(skb == NULL);
2983 pci_unmap_single(tp->pdev, 3010 pci_unmap_single(tp->pdev,
2984 pci_unmap_addr(ri, mapping), 3011 pci_unmap_addr(ri, mapping),
2985 skb_headlen(skb), 3012 skb_headlen(skb),
@@ -2990,10 +3017,9 @@ static void tg3_tx(struct tg3 *tp)
2990 sw_idx = NEXT_TX(sw_idx); 3017 sw_idx = NEXT_TX(sw_idx);
2991 3018
2992 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 3019 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2993 BUG_ON(sw_idx == hw_idx);
2994
2995 ri = &tp->tx_buffers[sw_idx]; 3020 ri = &tp->tx_buffers[sw_idx];
2996 BUG_ON(ri->skb != NULL); 3021 if (unlikely(ri->skb != NULL || sw_idx == hw_idx))
3022 tx_bug = 1;
2997 3023
2998 pci_unmap_page(tp->pdev, 3024 pci_unmap_page(tp->pdev,
2999 pci_unmap_addr(ri, mapping), 3025 pci_unmap_addr(ri, mapping),
@@ -3004,6 +3030,11 @@ static void tg3_tx(struct tg3 *tp)
3004 } 3030 }
3005 3031
3006 dev_kfree_skb(skb); 3032 dev_kfree_skb(skb);
3033
3034 if (unlikely(tx_bug)) {
3035 tg3_tx_recover(tp);
3036 return;
3037 }
3007 } 3038 }
3008 3039
3009 tp->tx_cons = sw_idx; 3040 tp->tx_cons = sw_idx;
@@ -3331,6 +3362,11 @@ static int tg3_poll(struct net_device *netdev, int *budget)
3331 /* run TX completion thread */ 3362 /* run TX completion thread */
3332 if (sblk->idx[0].tx_consumer != tp->tx_cons) { 3363 if (sblk->idx[0].tx_consumer != tp->tx_cons) {
3333 tg3_tx(tp); 3364 tg3_tx(tp);
3365 if (unlikely(tp->tg3_flags & TG3_FLAG_TX_RECOVERY_PENDING)) {
3366 netif_rx_complete(netdev);
3367 schedule_work(&tp->reset_task);
3368 return 0;
3369 }
3334 } 3370 }
3335 3371
3336 /* run RX thread, within the bounds set by NAPI. 3372 /* run RX thread, within the bounds set by NAPI.
@@ -3391,12 +3427,10 @@ static inline void tg3_full_lock(struct tg3 *tp, int irq_sync)
3391 if (irq_sync) 3427 if (irq_sync)
3392 tg3_irq_quiesce(tp); 3428 tg3_irq_quiesce(tp);
3393 spin_lock_bh(&tp->lock); 3429 spin_lock_bh(&tp->lock);
3394 spin_lock(&tp->tx_lock);
3395} 3430}
3396 3431
3397static inline void tg3_full_unlock(struct tg3 *tp) 3432static inline void tg3_full_unlock(struct tg3 *tp)
3398{ 3433{
3399 spin_unlock(&tp->tx_lock);
3400 spin_unlock_bh(&tp->lock); 3434 spin_unlock_bh(&tp->lock);
3401} 3435}
3402 3436
@@ -3579,6 +3613,13 @@ static void tg3_reset_task(void *_data)
3579 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER; 3613 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER;
3580 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; 3614 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER;
3581 3615
3616 if (tp->tg3_flags & TG3_FLAG_TX_RECOVERY_PENDING) {
3617 tp->write32_tx_mbox = tg3_write32_tx_mbox;
3618 tp->write32_rx_mbox = tg3_write_flush_reg32;
3619 tp->tg3_flags |= TG3_FLAG_MBOX_WRITE_REORDER;
3620 tp->tg3_flags &= ~TG3_FLAG_TX_RECOVERY_PENDING;
3621 }
3622
3582 tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); 3623 tg3_halt(tp, RESET_KIND_SHUTDOWN, 0);
3583 tg3_init_hw(tp, 1); 3624 tg3_init_hw(tp, 1);
3584 3625
@@ -3718,14 +3759,11 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3718 3759
3719 len = skb_headlen(skb); 3760 len = skb_headlen(skb);
3720 3761
3721 /* No BH disabling for tx_lock here. We are running in BH disabled 3762 /* We are running in BH disabled context with netif_tx_lock
3722 * context and TX reclaim runs via tp->poll inside of a software 3763 * and TX reclaim runs via tp->poll inside of a software
3723 * interrupt. Furthermore, IRQ processing runs lockless so we have 3764 * interrupt. Furthermore, IRQ processing runs lockless so we have
3724 * no IRQ context deadlocks to worry about either. Rejoice! 3765 * no IRQ context deadlocks to worry about either. Rejoice!
3725 */ 3766 */
3726 if (!spin_trylock(&tp->tx_lock))
3727 return NETDEV_TX_LOCKED;
3728
3729 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { 3767 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) {
3730 if (!netif_queue_stopped(dev)) { 3768 if (!netif_queue_stopped(dev)) {
3731 netif_stop_queue(dev); 3769 netif_stop_queue(dev);
@@ -3734,7 +3772,6 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3734 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when " 3772 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
3735 "queue awake!\n", dev->name); 3773 "queue awake!\n", dev->name);
3736 } 3774 }
3737 spin_unlock(&tp->tx_lock);
3738 return NETDEV_TX_BUSY; 3775 return NETDEV_TX_BUSY;
3739 } 3776 }
3740 3777
@@ -3817,15 +3854,16 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3817 tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry); 3854 tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
3818 3855
3819 tp->tx_prod = entry; 3856 tp->tx_prod = entry;
3820 if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) { 3857 if (unlikely(TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1))) {
3858 spin_lock(&tp->tx_lock);
3821 netif_stop_queue(dev); 3859 netif_stop_queue(dev);
3822 if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH) 3860 if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH)
3823 netif_wake_queue(tp->dev); 3861 netif_wake_queue(tp->dev);
3862 spin_unlock(&tp->tx_lock);
3824 } 3863 }
3825 3864
3826out_unlock: 3865out_unlock:
3827 mmiowb(); 3866 mmiowb();
3828 spin_unlock(&tp->tx_lock);
3829 3867
3830 dev->trans_start = jiffies; 3868 dev->trans_start = jiffies;
3831 3869
@@ -3844,14 +3882,11 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3844 3882
3845 len = skb_headlen(skb); 3883 len = skb_headlen(skb);
3846 3884
3847 /* No BH disabling for tx_lock here. We are running in BH disabled 3885 /* We are running in BH disabled context with netif_tx_lock
3848 * context and TX reclaim runs via tp->poll inside of a software 3886 * and TX reclaim runs via tp->poll inside of a software
3849 * interrupt. Furthermore, IRQ processing runs lockless so we have 3887 * interrupt. Furthermore, IRQ processing runs lockless so we have
3850 * no IRQ context deadlocks to worry about either. Rejoice! 3888 * no IRQ context deadlocks to worry about either. Rejoice!
3851 */ 3889 */
3852 if (!spin_trylock(&tp->tx_lock))
3853 return NETDEV_TX_LOCKED;
3854
3855 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { 3890 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) {
3856 if (!netif_queue_stopped(dev)) { 3891 if (!netif_queue_stopped(dev)) {
3857 netif_stop_queue(dev); 3892 netif_stop_queue(dev);
@@ -3860,7 +3895,6 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3860 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when " 3895 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
3861 "queue awake!\n", dev->name); 3896 "queue awake!\n", dev->name);
3862 } 3897 }
3863 spin_unlock(&tp->tx_lock);
3864 return NETDEV_TX_BUSY; 3898 return NETDEV_TX_BUSY;
3865 } 3899 }
3866 3900
@@ -3998,15 +4032,16 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3998 tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry); 4032 tw32_tx_mbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
3999 4033
4000 tp->tx_prod = entry; 4034 tp->tx_prod = entry;
4001 if (TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1)) { 4035 if (unlikely(TX_BUFFS_AVAIL(tp) <= (MAX_SKB_FRAGS + 1))) {
4036 spin_lock(&tp->tx_lock);
4002 netif_stop_queue(dev); 4037 netif_stop_queue(dev);
4003 if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH) 4038 if (TX_BUFFS_AVAIL(tp) > TG3_TX_WAKEUP_THRESH)
4004 netif_wake_queue(tp->dev); 4039 netif_wake_queue(tp->dev);
4040 spin_unlock(&tp->tx_lock);
4005 } 4041 }
4006 4042
4007out_unlock: 4043out_unlock:
4008 mmiowb(); 4044 mmiowb();
4009 spin_unlock(&tp->tx_lock);
4010 4045
4011 dev->trans_start = jiffies; 4046 dev->trans_start = jiffies;
4012 4047
@@ -4485,9 +4520,8 @@ static void tg3_disable_nvram_access(struct tg3 *tp)
4485/* tp->lock is held. */ 4520/* tp->lock is held. */
4486static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) 4521static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind)
4487{ 4522{
4488 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) 4523 tg3_write_mem(tp, NIC_SRAM_FIRMWARE_MBOX,
4489 tg3_write_mem(tp, NIC_SRAM_FIRMWARE_MBOX, 4524 NIC_SRAM_FIRMWARE_MBOX_MAGIC1);
4490 NIC_SRAM_FIRMWARE_MBOX_MAGIC1);
4491 4525
4492 if (tp->tg3_flags2 & TG3_FLG2_ASF_NEW_HANDSHAKE) { 4526 if (tp->tg3_flags2 & TG3_FLG2_ASF_NEW_HANDSHAKE) {
4493 switch (kind) { 4527 switch (kind) {
@@ -4568,13 +4602,12 @@ static int tg3_chip_reset(struct tg3 *tp)
4568 void (*write_op)(struct tg3 *, u32, u32); 4602 void (*write_op)(struct tg3 *, u32, u32);
4569 int i; 4603 int i;
4570 4604
4571 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) { 4605 tg3_nvram_lock(tp);
4572 tg3_nvram_lock(tp); 4606
4573 /* No matching tg3_nvram_unlock() after this because 4607 /* No matching tg3_nvram_unlock() after this because
4574 * chip reset below will undo the nvram lock. 4608 * chip reset below will undo the nvram lock.
4575 */ 4609 */
4576 tp->nvram_lock_cnt = 0; 4610 tp->nvram_lock_cnt = 0;
4577 }
4578 4611
4579 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 || 4612 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
4580 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || 4613 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
@@ -4727,20 +4760,25 @@ static int tg3_chip_reset(struct tg3 *tp)
4727 tw32_f(MAC_MODE, 0); 4760 tw32_f(MAC_MODE, 0);
4728 udelay(40); 4761 udelay(40);
4729 4762
4730 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) { 4763 /* Wait for firmware initialization to complete. */
4731 /* Wait for firmware initialization to complete. */ 4764 for (i = 0; i < 100000; i++) {
4732 for (i = 0; i < 100000; i++) { 4765 tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val);
4733 tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val); 4766 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
4734 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1) 4767 break;
4735 break; 4768 udelay(10);
4736 udelay(10); 4769 }
4737 } 4770
4738 if (i >= 100000) { 4771 /* Chip might not be fitted with firmare. Some Sun onboard
4739 printk(KERN_ERR PFX "tg3_reset_hw timed out for %s, " 4772 * parts are configured like that. So don't signal the timeout
4740 "firmware will not restart magic=%08x\n", 4773 * of the above loop as an error, but do report the lack of
4741 tp->dev->name, val); 4774 * running firmware once.
4742 return -ENODEV; 4775 */
4743 } 4776 if (i >= 100000 &&
4777 !(tp->tg3_flags2 & TG3_FLG2_NO_FWARE_REPORTED)) {
4778 tp->tg3_flags2 |= TG3_FLG2_NO_FWARE_REPORTED;
4779
4780 printk(KERN_INFO PFX "%s: No firmware running.\n",
4781 tp->dev->name);
4744 } 4782 }
4745 4783
4746 if ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) && 4784 if ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
@@ -9075,9 +9113,6 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
9075{ 9113{
9076 int j; 9114 int j;
9077 9115
9078 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X)
9079 return;
9080
9081 tw32_f(GRC_EEPROM_ADDR, 9116 tw32_f(GRC_EEPROM_ADDR,
9082 (EEPROM_ADDR_FSM_RESET | 9117 (EEPROM_ADDR_FSM_RESET |
9083 (EEPROM_DEFAULT_CLOCK_PERIOD << 9118 (EEPROM_DEFAULT_CLOCK_PERIOD <<
@@ -9210,11 +9245,6 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
9210{ 9245{
9211 int ret; 9246 int ret;
9212 9247
9213 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
9214 printk(KERN_ERR PFX "Attempt to do nvram_read on Sun 570X\n");
9215 return -EINVAL;
9216 }
9217
9218 if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) 9248 if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
9219 return tg3_nvram_read_using_eeprom(tp, offset, val); 9249 return tg3_nvram_read_using_eeprom(tp, offset, val);
9220 9250
@@ -9447,11 +9477,6 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
9447{ 9477{
9448 int ret; 9478 int ret;
9449 9479
9450 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
9451 printk(KERN_ERR PFX "Attempt to do nvram_write on Sun 570X\n");
9452 return -EINVAL;
9453 }
9454
9455 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 9480 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
9456 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl & 9481 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
9457 ~GRC_LCLCTRL_GPIO_OUTPUT1); 9482 ~GRC_LCLCTRL_GPIO_OUTPUT1);
@@ -9578,15 +9603,19 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9578 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, 9603 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
9579 tp->misc_host_ctrl); 9604 tp->misc_host_ctrl);
9580 9605
9606 /* The memory arbiter has to be enabled in order for SRAM accesses
9607 * to succeed. Normally on powerup the tg3 chip firmware will make
9608 * sure it is enabled, but other entities such as system netboot
9609 * code might disable it.
9610 */
9611 val = tr32(MEMARB_MODE);
9612 tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE);
9613
9581 tp->phy_id = PHY_ID_INVALID; 9614 tp->phy_id = PHY_ID_INVALID;
9582 tp->led_ctrl = LED_CTRL_MODE_PHY_1; 9615 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
9583 9616
9584 /* Do not even try poking around in here on Sun parts. */ 9617 /* Assume an onboard device by default. */
9585 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) { 9618 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9586 /* All SUN chips are built-in LOMs. */
9587 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9588 return;
9589 }
9590 9619
9591 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 9620 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
9592 if (val == NIC_SRAM_DATA_SIG_MAGIC) { 9621 if (val == NIC_SRAM_DATA_SIG_MAGIC) {
@@ -9686,6 +9715,8 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9686 9715
9687 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) 9716 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP)
9688 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 9717 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9718 else
9719 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
9689 9720
9690 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 9721 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
9691 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 9722 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
@@ -9834,16 +9865,8 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
9834 int i; 9865 int i;
9835 u32 magic; 9866 u32 magic;
9836 9867
9837 if (tp->tg3_flags2 & TG3_FLG2_SUN_570X) {
9838 /* Sun decided not to put the necessary bits in the
9839 * NVRAM of their onboard tg3 parts :(
9840 */
9841 strcpy(tp->board_part_number, "Sun 570X");
9842 return;
9843 }
9844
9845 if (tg3_nvram_read_swab(tp, 0x0, &magic)) 9868 if (tg3_nvram_read_swab(tp, 0x0, &magic))
9846 return; 9869 goto out_not_found;
9847 9870
9848 if (magic == TG3_EEPROM_MAGIC) { 9871 if (magic == TG3_EEPROM_MAGIC) {
9849 for (i = 0; i < 256; i += 4) { 9872 for (i = 0; i < 256; i += 4) {
@@ -9874,6 +9897,9 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
9874 break; 9897 break;
9875 msleep(1); 9898 msleep(1);
9876 } 9899 }
9900 if (!(tmp16 & 0x8000))
9901 goto out_not_found;
9902
9877 pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA, 9903 pci_read_config_dword(tp->pdev, vpd_cap + PCI_VPD_DATA,
9878 &tmp); 9904 &tmp);
9879 tmp = cpu_to_le32(tmp); 9905 tmp = cpu_to_le32(tmp);
@@ -9965,37 +9991,6 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
9965 } 9991 }
9966} 9992}
9967 9993
9968#ifdef CONFIG_SPARC64
9969static int __devinit tg3_is_sun_570X(struct tg3 *tp)
9970{
9971 struct pci_dev *pdev = tp->pdev;
9972 struct pcidev_cookie *pcp = pdev->sysdata;
9973
9974 if (pcp != NULL) {
9975 int node = pcp->prom_node;
9976 u32 venid;
9977 int err;
9978
9979 err = prom_getproperty(node, "subsystem-vendor-id",
9980 (char *) &venid, sizeof(venid));
9981 if (err == 0 || err == -1)
9982 return 0;
9983 if (venid == PCI_VENDOR_ID_SUN)
9984 return 1;
9985
9986 /* TG3 chips onboard the SunBlade-2500 don't have the
9987 * subsystem-vendor-id set to PCI_VENDOR_ID_SUN but they
9988 * are distinguishable from non-Sun variants by being
9989 * named "network" by the firmware. Non-Sun cards will
9990 * show up as being named "ethernet".
9991 */
9992 if (!strcmp(pcp->prom_name, "network"))
9993 return 1;
9994 }
9995 return 0;
9996}
9997#endif
9998
9999static int __devinit tg3_get_invariants(struct tg3 *tp) 9994static int __devinit tg3_get_invariants(struct tg3 *tp)
10000{ 9995{
10001 static struct pci_device_id write_reorder_chipsets[] = { 9996 static struct pci_device_id write_reorder_chipsets[] = {
@@ -10012,11 +10007,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10012 u16 pci_cmd; 10007 u16 pci_cmd;
10013 int err; 10008 int err;
10014 10009
10015#ifdef CONFIG_SPARC64
10016 if (tg3_is_sun_570X(tp))
10017 tp->tg3_flags2 |= TG3_FLG2_SUN_570X;
10018#endif
10019
10020 /* Force memory write invalidate off. If we leave it on, 10010 /* Force memory write invalidate off. If we leave it on,
10021 * then on 5700_BX chips we have to enable a workaround. 10011 * then on 5700_BX chips we have to enable a workaround.
10022 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary 10012 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundary
@@ -10312,8 +10302,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10312 if (tp->write32 == tg3_write_indirect_reg32 || 10302 if (tp->write32 == tg3_write_indirect_reg32 ||
10313 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) && 10303 ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) &&
10314 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 10304 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
10315 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)) || 10305 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701)))
10316 (tp->tg3_flags2 & TG3_FLG2_SUN_570X))
10317 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG; 10306 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
10318 10307
10319 /* Get eeprom hw config before calling tg3_set_power_state(). 10308 /* Get eeprom hw config before calling tg3_set_power_state().
@@ -10594,8 +10583,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
10594#endif 10583#endif
10595 10584
10596 mac_offset = 0x7c; 10585 mac_offset = 0x7c;
10597 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 && 10586 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10598 !(tp->tg3_flags & TG3_FLG2_SUN_570X)) ||
10599 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { 10587 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) {
10600 if (tr32(TG3PCI_DUAL_MAC_CTRL) & DUAL_MAC_CTRL_ID) 10588 if (tr32(TG3PCI_DUAL_MAC_CTRL) & DUAL_MAC_CTRL_ID)
10601 mac_offset = 0xcc; 10589 mac_offset = 0xcc;
@@ -10622,8 +10610,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
10622 } 10610 }
10623 if (!addr_ok) { 10611 if (!addr_ok) {
10624 /* Next, try NVRAM. */ 10612 /* Next, try NVRAM. */
10625 if (!(tp->tg3_flags & TG3_FLG2_SUN_570X) && 10613 if (!tg3_nvram_read(tp, mac_offset + 0, &hi) &&
10626 !tg3_nvram_read(tp, mac_offset + 0, &hi) &&
10627 !tg3_nvram_read(tp, mac_offset + 4, &lo)) { 10614 !tg3_nvram_read(tp, mac_offset + 4, &lo)) {
10628 dev->dev_addr[0] = ((hi >> 16) & 0xff); 10615 dev->dev_addr[0] = ((hi >> 16) & 0xff);
10629 dev->dev_addr[1] = ((hi >> 24) & 0xff); 10616 dev->dev_addr[1] = ((hi >> 24) & 0xff);
@@ -11291,7 +11278,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11291 SET_MODULE_OWNER(dev); 11278 SET_MODULE_OWNER(dev);
11292 SET_NETDEV_DEV(dev, &pdev->dev); 11279 SET_NETDEV_DEV(dev, &pdev->dev);
11293 11280
11294 dev->features |= NETIF_F_LLTX;
11295#if TG3_VLAN_TAG_USED 11281#if TG3_VLAN_TAG_USED
11296 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 11282 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
11297 dev->vlan_rx_register = tg3_vlan_rx_register; 11283 dev->vlan_rx_register = tg3_vlan_rx_register;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 0e29b885d449..8209da5dd15f 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2074,12 +2074,22 @@ struct tg3 {
2074 2074
2075 /* SMP locking strategy: 2075 /* SMP locking strategy:
2076 * 2076 *
2077 * lock: Held during all operations except TX packet 2077 * lock: Held during reset, PHY access, timer, and when
2078 * processing. 2078 * updating tg3_flags and tg3_flags2.
2079 * 2079 *
2080 * tx_lock: Held during tg3_start_xmit and tg3_tx 2080 * tx_lock: Held during tg3_start_xmit and tg3_tx only
2081 * when calling netif_[start|stop]_queue.
2082 * tg3_start_xmit is protected by netif_tx_lock.
2081 * 2083 *
2082 * Both of these locks are to be held with BH safety. 2084 * Both of these locks are to be held with BH safety.
2085 *
2086 * Because the IRQ handler, tg3_poll, and tg3_start_xmit
2087 * are running lockless, it is necessary to completely
2088 * quiesce the chip with tg3_netif_stop and tg3_full_lock
2089 * before reconfiguring the device.
2090 *
2091 * indirect_lock: Held when accessing registers indirectly
2092 * with IRQ disabling.
2083 */ 2093 */
2084 spinlock_t lock; 2094 spinlock_t lock;
2085 spinlock_t indirect_lock; 2095 spinlock_t indirect_lock;
@@ -2155,11 +2165,7 @@ struct tg3 {
2155#define TG3_FLAG_ENABLE_ASF 0x00000020 2165#define TG3_FLAG_ENABLE_ASF 0x00000020
2156#define TG3_FLAG_5701_REG_WRITE_BUG 0x00000040 2166#define TG3_FLAG_5701_REG_WRITE_BUG 0x00000040
2157#define TG3_FLAG_POLL_SERDES 0x00000080 2167#define TG3_FLAG_POLL_SERDES 0x00000080
2158#if defined(CONFIG_X86)
2159#define TG3_FLAG_MBOX_WRITE_REORDER 0x00000100 2168#define TG3_FLAG_MBOX_WRITE_REORDER 0x00000100
2160#else
2161#define TG3_FLAG_MBOX_WRITE_REORDER 0 /* disables code too */
2162#endif
2163#define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200 2169#define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200
2164#define TG3_FLAG_WOL_SPEED_100MB 0x00000400 2170#define TG3_FLAG_WOL_SPEED_100MB 0x00000400
2165#define TG3_FLAG_WOL_ENABLE 0x00000800 2171#define TG3_FLAG_WOL_ENABLE 0x00000800
@@ -2172,6 +2178,7 @@ struct tg3 {
2172#define TG3_FLAG_PCI_HIGH_SPEED 0x00040000 2178#define TG3_FLAG_PCI_HIGH_SPEED 0x00040000
2173#define TG3_FLAG_PCI_32BIT 0x00080000 2179#define TG3_FLAG_PCI_32BIT 0x00080000
2174#define TG3_FLAG_SRAM_USE_CONFIG 0x00100000 2180#define TG3_FLAG_SRAM_USE_CONFIG 0x00100000
2181#define TG3_FLAG_TX_RECOVERY_PENDING 0x00200000
2175#define TG3_FLAG_SERDES_WOL_CAP 0x00400000 2182#define TG3_FLAG_SERDES_WOL_CAP 0x00400000
2176#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000 2183#define TG3_FLAG_JUMBO_RING_ENABLE 0x00800000
2177#define TG3_FLAG_10_100_ONLY 0x01000000 2184#define TG3_FLAG_10_100_ONLY 0x01000000
@@ -2184,7 +2191,7 @@ struct tg3 {
2184#define TG3_FLAG_INIT_COMPLETE 0x80000000 2191#define TG3_FLAG_INIT_COMPLETE 0x80000000
2185 u32 tg3_flags2; 2192 u32 tg3_flags2;
2186#define TG3_FLG2_RESTART_TIMER 0x00000001 2193#define TG3_FLG2_RESTART_TIMER 0x00000001
2187#define TG3_FLG2_SUN_570X 0x00000002 2194/* 0x00000002 available */
2188#define TG3_FLG2_NO_ETH_WIRE_SPEED 0x00000004 2195#define TG3_FLG2_NO_ETH_WIRE_SPEED 0x00000004
2189#define TG3_FLG2_IS_5788 0x00000008 2196#define TG3_FLG2_IS_5788 0x00000008
2190#define TG3_FLG2_MAX_RXPEND_64 0x00000010 2197#define TG3_FLG2_MAX_RXPEND_64 0x00000010
@@ -2216,6 +2223,7 @@ struct tg3 {
2216#define TG3_FLG2_HW_TSO (TG3_FLG2_HW_TSO_1 | TG3_FLG2_HW_TSO_2) 2223#define TG3_FLG2_HW_TSO (TG3_FLG2_HW_TSO_1 | TG3_FLG2_HW_TSO_2)
2217#define TG3_FLG2_1SHOT_MSI 0x10000000 2224#define TG3_FLG2_1SHOT_MSI 0x10000000
2218#define TG3_FLG2_PHY_JITTER_BUG 0x20000000 2225#define TG3_FLG2_PHY_JITTER_BUG 0x20000000
2226#define TG3_FLG2_NO_FWARE_REPORTED 0x40000000
2219 2227
2220 u32 split_mode_max_reqs; 2228 u32 split_mode_max_reqs;
2221#define SPLIT_MODE_5704_MAX_REQ 3 2229#define SPLIT_MODE_5704_MAX_REQ 3
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index e3dd144d326b..5f743b972949 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -227,12 +227,12 @@ enum {
227 SROMC0InfoLeaf = 27, 227 SROMC0InfoLeaf = 27,
228 MediaBlockMask = 0x3f, 228 MediaBlockMask = 0x3f,
229 MediaCustomCSRs = (1 << 6), 229 MediaCustomCSRs = (1 << 6),
230 230
231 /* PCIPM bits */ 231 /* PCIPM bits */
232 PM_Sleep = (1 << 31), 232 PM_Sleep = (1 << 31),
233 PM_Snooze = (1 << 30), 233 PM_Snooze = (1 << 30),
234 PM_Mask = PM_Sleep | PM_Snooze, 234 PM_Mask = PM_Sleep | PM_Snooze,
235 235
236 /* SIAStatus bits */ 236 /* SIAStatus bits */
237 NWayState = (1 << 14) | (1 << 13) | (1 << 12), 237 NWayState = (1 << 14) | (1 << 13) | (1 << 12),
238 NWayRestart = (1 << 12), 238 NWayRestart = (1 << 12),
@@ -858,7 +858,7 @@ static void de_stop_rxtx (struct de_private *de)
858 return; 858 return;
859 cpu_relax(); 859 cpu_relax();
860 } 860 }
861 861
862 printk(KERN_WARNING "%s: timeout expired stopping DMA\n", de->dev->name); 862 printk(KERN_WARNING "%s: timeout expired stopping DMA\n", de->dev->name);
863} 863}
864 864
@@ -931,7 +931,7 @@ static void de_set_media (struct de_private *de)
931 macmode |= FullDuplex; 931 macmode |= FullDuplex;
932 else 932 else
933 macmode &= ~FullDuplex; 933 macmode &= ~FullDuplex;
934 934
935 if (netif_msg_link(de)) { 935 if (netif_msg_link(de)) {
936 printk(KERN_INFO "%s: set link %s\n" 936 printk(KERN_INFO "%s: set link %s\n"
937 KERN_INFO "%s: mode 0x%x, sia 0x%x,0x%x,0x%x,0x%x\n" 937 KERN_INFO "%s: mode 0x%x, sia 0x%x,0x%x,0x%x,0x%x\n"
@@ -966,9 +966,9 @@ static void de21040_media_timer (unsigned long data)
966 u32 status = dr32(SIAStatus); 966 u32 status = dr32(SIAStatus);
967 unsigned int carrier; 967 unsigned int carrier;
968 unsigned long flags; 968 unsigned long flags;
969 969
970 carrier = (status & NetCxnErr) ? 0 : 1; 970 carrier = (status & NetCxnErr) ? 0 : 1;
971 971
972 if (carrier) { 972 if (carrier) {
973 if (de->media_type != DE_MEDIA_AUI && (status & LinkFailStatus)) 973 if (de->media_type != DE_MEDIA_AUI && (status & LinkFailStatus))
974 goto no_link_yet; 974 goto no_link_yet;
@@ -985,7 +985,7 @@ static void de21040_media_timer (unsigned long data)
985 return; 985 return;
986 } 986 }
987 987
988 de_link_down(de); 988 de_link_down(de);
989 989
990 if (de->media_lock) 990 if (de->media_lock)
991 return; 991 return;
@@ -1039,7 +1039,7 @@ static unsigned int de_ok_to_advertise (struct de_private *de, u32 new_media)
1039 return 0; 1039 return 0;
1040 break; 1040 break;
1041 } 1041 }
1042 1042
1043 return 1; 1043 return 1;
1044} 1044}
1045 1045
@@ -1050,9 +1050,9 @@ static void de21041_media_timer (unsigned long data)
1050 u32 status = dr32(SIAStatus); 1050 u32 status = dr32(SIAStatus);
1051 unsigned int carrier; 1051 unsigned int carrier;
1052 unsigned long flags; 1052 unsigned long flags;
1053 1053
1054 carrier = (status & NetCxnErr) ? 0 : 1; 1054 carrier = (status & NetCxnErr) ? 0 : 1;
1055 1055
1056 if (carrier) { 1056 if (carrier) {
1057 if ((de->media_type == DE_MEDIA_TP_AUTO || 1057 if ((de->media_type == DE_MEDIA_TP_AUTO ||
1058 de->media_type == DE_MEDIA_TP || 1058 de->media_type == DE_MEDIA_TP ||
@@ -1072,7 +1072,7 @@ static void de21041_media_timer (unsigned long data)
1072 return; 1072 return;
1073 } 1073 }
1074 1074
1075 de_link_down(de); 1075 de_link_down(de);
1076 1076
1077 /* if media type locked, don't switch media */ 1077 /* if media type locked, don't switch media */
1078 if (de->media_lock) 1078 if (de->media_lock)
@@ -1124,7 +1124,7 @@ static void de21041_media_timer (unsigned long data)
1124 u32 next_states[] = { DE_MEDIA_AUI, DE_MEDIA_BNC, DE_MEDIA_TP_AUTO }; 1124 u32 next_states[] = { DE_MEDIA_AUI, DE_MEDIA_BNC, DE_MEDIA_TP_AUTO };
1125 de_next_media(de, next_states, ARRAY_SIZE(next_states)); 1125 de_next_media(de, next_states, ARRAY_SIZE(next_states));
1126 } 1126 }
1127 1127
1128set_media: 1128set_media:
1129 spin_lock_irqsave(&de->lock, flags); 1129 spin_lock_irqsave(&de->lock, flags);
1130 de_stop_rxtx(de); 1130 de_stop_rxtx(de);
@@ -1148,7 +1148,7 @@ static void de_media_interrupt (struct de_private *de, u32 status)
1148 mod_timer(&de->media_timer, jiffies + DE_TIMER_LINK); 1148 mod_timer(&de->media_timer, jiffies + DE_TIMER_LINK);
1149 return; 1149 return;
1150 } 1150 }
1151 1151
1152 BUG_ON(!(status & LinkFail)); 1152 BUG_ON(!(status & LinkFail));
1153 1153
1154 if (netif_carrier_ok(de->dev)) { 1154 if (netif_carrier_ok(de->dev)) {
@@ -1227,7 +1227,7 @@ static int de_init_hw (struct de_private *de)
1227 int rc; 1227 int rc;
1228 1228
1229 de_adapter_wake(de); 1229 de_adapter_wake(de);
1230 1230
1231 macmode = dr32(MacMode) & ~MacModeClear; 1231 macmode = dr32(MacMode) & ~MacModeClear;
1232 1232
1233 rc = de_reset_mac(de); 1233 rc = de_reset_mac(de);
@@ -1413,7 +1413,7 @@ static int de_close (struct net_device *dev)
1413 netif_stop_queue(dev); 1413 netif_stop_queue(dev);
1414 netif_carrier_off(dev); 1414 netif_carrier_off(dev);
1415 spin_unlock_irqrestore(&de->lock, flags); 1415 spin_unlock_irqrestore(&de->lock, flags);
1416 1416
1417 free_irq(dev->irq, dev); 1417 free_irq(dev->irq, dev);
1418 1418
1419 de_free_rings(de); 1419 de_free_rings(de);
@@ -1441,7 +1441,7 @@ static void de_tx_timeout (struct net_device *dev)
1441 1441
1442 spin_unlock_irq(&de->lock); 1442 spin_unlock_irq(&de->lock);
1443 enable_irq(dev->irq); 1443 enable_irq(dev->irq);
1444 1444
1445 /* Update the error counts. */ 1445 /* Update the error counts. */
1446 __de_get_stats(de); 1446 __de_get_stats(de);
1447 1447
@@ -1451,7 +1451,7 @@ static void de_tx_timeout (struct net_device *dev)
1451 de_init_rings(de); 1451 de_init_rings(de);
1452 1452
1453 de_init_hw(de); 1453 de_init_hw(de);
1454 1454
1455 netif_wake_queue(dev); 1455 netif_wake_queue(dev);
1456} 1456}
1457 1457
@@ -1459,7 +1459,7 @@ static void __de_get_regs(struct de_private *de, u8 *buf)
1459{ 1459{
1460 int i; 1460 int i;
1461 u32 *rbuf = (u32 *)buf; 1461 u32 *rbuf = (u32 *)buf;
1462 1462
1463 /* read all CSRs */ 1463 /* read all CSRs */
1464 for (i = 0; i < DE_NUM_REGS; i++) 1464 for (i = 0; i < DE_NUM_REGS; i++)
1465 rbuf[i] = dr32(i * 8); 1465 rbuf[i] = dr32(i * 8);
@@ -1474,7 +1474,7 @@ static int __de_get_settings(struct de_private *de, struct ethtool_cmd *ecmd)
1474 ecmd->transceiver = XCVR_INTERNAL; 1474 ecmd->transceiver = XCVR_INTERNAL;
1475 ecmd->phy_address = 0; 1475 ecmd->phy_address = 0;
1476 ecmd->advertising = de->media_advertise; 1476 ecmd->advertising = de->media_advertise;
1477 1477
1478 switch (de->media_type) { 1478 switch (de->media_type) {
1479 case DE_MEDIA_AUI: 1479 case DE_MEDIA_AUI:
1480 ecmd->port = PORT_AUI; 1480 ecmd->port = PORT_AUI;
@@ -1489,7 +1489,7 @@ static int __de_get_settings(struct de_private *de, struct ethtool_cmd *ecmd)
1489 ecmd->speed = SPEED_10; 1489 ecmd->speed = SPEED_10;
1490 break; 1490 break;
1491 } 1491 }
1492 1492
1493 if (dr32(MacMode) & FullDuplex) 1493 if (dr32(MacMode) & FullDuplex)
1494 ecmd->duplex = DUPLEX_FULL; 1494 ecmd->duplex = DUPLEX_FULL;
1495 else 1495 else
@@ -1529,7 +1529,7 @@ static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
1529 if (ecmd->autoneg == AUTONEG_ENABLE && 1529 if (ecmd->autoneg == AUTONEG_ENABLE &&
1530 (!(ecmd->advertising & ADVERTISED_Autoneg))) 1530 (!(ecmd->advertising & ADVERTISED_Autoneg)))
1531 return -EINVAL; 1531 return -EINVAL;
1532 1532
1533 switch (ecmd->port) { 1533 switch (ecmd->port) {
1534 case PORT_AUI: 1534 case PORT_AUI:
1535 new_media = DE_MEDIA_AUI; 1535 new_media = DE_MEDIA_AUI;
@@ -1554,22 +1554,22 @@ static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
1554 return -EINVAL; 1554 return -EINVAL;
1555 break; 1555 break;
1556 } 1556 }
1557 1557
1558 media_lock = (ecmd->autoneg == AUTONEG_ENABLE) ? 0 : 1; 1558 media_lock = (ecmd->autoneg == AUTONEG_ENABLE) ? 0 : 1;
1559 1559
1560 if ((new_media == de->media_type) && 1560 if ((new_media == de->media_type) &&
1561 (media_lock == de->media_lock) && 1561 (media_lock == de->media_lock) &&
1562 (ecmd->advertising == de->media_advertise)) 1562 (ecmd->advertising == de->media_advertise))
1563 return 0; /* nothing to change */ 1563 return 0; /* nothing to change */
1564 1564
1565 de_link_down(de); 1565 de_link_down(de);
1566 de_stop_rxtx(de); 1566 de_stop_rxtx(de);
1567 1567
1568 de->media_type = new_media; 1568 de->media_type = new_media;
1569 de->media_lock = media_lock; 1569 de->media_lock = media_lock;
1570 de->media_advertise = ecmd->advertising; 1570 de->media_advertise = ecmd->advertising;
1571 de_set_media(de); 1571 de_set_media(de);
1572 1572
1573 return 0; 1573 return 0;
1574} 1574}
1575 1575
@@ -1817,7 +1817,7 @@ static void __init de21041_get_srom_info (struct de_private *de)
1817 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break; 1817 case 0x0204: de->media_type = DE_MEDIA_TP_FD; break;
1818 default: de->media_type = DE_MEDIA_TP_AUTO; break; 1818 default: de->media_type = DE_MEDIA_TP_AUTO; break;
1819 } 1819 }
1820 1820
1821 if (netif_msg_probe(de)) 1821 if (netif_msg_probe(de))
1822 printk(KERN_INFO "de%d: SROM leaf offset %u, default media %s\n", 1822 printk(KERN_INFO "de%d: SROM leaf offset %u, default media %s\n",
1823 de->board_idx, ofs, 1823 de->board_idx, ofs,
@@ -1886,7 +1886,7 @@ static void __init de21041_get_srom_info (struct de_private *de)
1886 de->media[idx].csr13, 1886 de->media[idx].csr13,
1887 de->media[idx].csr14, 1887 de->media[idx].csr14,
1888 de->media[idx].csr15); 1888 de->media[idx].csr15);
1889 1889
1890 } else if (netif_msg_probe(de)) 1890 } else if (netif_msg_probe(de))
1891 printk("\n"); 1891 printk("\n");
1892 1892
@@ -2118,7 +2118,7 @@ static int de_suspend (struct pci_dev *pdev, pm_message_t state)
2118 2118
2119 spin_unlock_irq(&de->lock); 2119 spin_unlock_irq(&de->lock);
2120 enable_irq(dev->irq); 2120 enable_irq(dev->irq);
2121 2121
2122 /* Update the error counts. */ 2122 /* Update the error counts. */
2123 __de_get_stats(de); 2123 __de_get_stats(de);
2124 2124
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index f56094102042..da8bd0d62a3f 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -41,11 +41,11 @@
41 Digital Semiconductor SROM Specification. The driver currently 41 Digital Semiconductor SROM Specification. The driver currently
42 recognises the following chips: 42 recognises the following chips:
43 43
44 DC21040 (no SROM) 44 DC21040 (no SROM)
45 DC21041[A] 45 DC21041[A]
46 DC21140[A] 46 DC21140[A]
47 DC21142 47 DC21142
48 DC21143 48 DC21143
49 49
50 So far the driver is known to work with the following cards: 50 So far the driver is known to work with the following cards:
51 51
@@ -55,7 +55,7 @@
55 SMC8432 55 SMC8432
56 SMC9332 (w/new SROM) 56 SMC9332 (w/new SROM)
57 ZNYX31[45] 57 ZNYX31[45]
58 ZNYX346 10/100 4 port (can act as a 10/100 bridge!) 58 ZNYX346 10/100 4 port (can act as a 10/100 bridge!)
59 59
60 The driver has been tested on a relatively busy network using the DE425, 60 The driver has been tested on a relatively busy network using the DE425,
61 DE434, DE435 and DE500 cards and benchmarked with 'ttcp': it transferred 61 DE434, DE435 and DE500 cards and benchmarked with 'ttcp': it transferred
@@ -106,7 +106,7 @@
106 loading by: 106 loading by:
107 107
108 insmod de4x5 io=0xghh where g = bus number 108 insmod de4x5 io=0xghh where g = bus number
109 hh = device number 109 hh = device number
110 110
111 NB: autoprobing for modules is now supported by default. You may just 111 NB: autoprobing for modules is now supported by default. You may just
112 use: 112 use:
@@ -120,11 +120,11 @@
120 4) if you are wanting to add a new card, goto 5. Otherwise, recompile a 120 4) if you are wanting to add a new card, goto 5. Otherwise, recompile a
121 kernel with the de4x5 configuration turned off and reboot. 121 kernel with the de4x5 configuration turned off and reboot.
122 5) insmod de4x5 [io=0xghh] 122 5) insmod de4x5 [io=0xghh]
123 6) run the net startup bits for your new eth?? interface(s) manually 123 6) run the net startup bits for your new eth?? interface(s) manually
124 (usually /etc/rc.inet[12] at boot time). 124 (usually /etc/rc.inet[12] at boot time).
125 7) enjoy! 125 7) enjoy!
126 126
127 To unload a module, turn off the associated interface(s) 127 To unload a module, turn off the associated interface(s)
128 'ifconfig eth?? down' then 'rmmod de4x5'. 128 'ifconfig eth?? down' then 'rmmod de4x5'.
129 129
130 Automedia detection is included so that in principal you can disconnect 130 Automedia detection is included so that in principal you can disconnect
@@ -135,7 +135,7 @@
135 By default, the driver will now autodetect any DECchip based card. 135 By default, the driver will now autodetect any DECchip based card.
136 Should you have a need to restrict the driver to DIGITAL only cards, you 136 Should you have a need to restrict the driver to DIGITAL only cards, you
137 can compile with a DEC_ONLY define, or if loading as a module, use the 137 can compile with a DEC_ONLY define, or if loading as a module, use the
138 'dec_only=1' parameter. 138 'dec_only=1' parameter.
139 139
140 I've changed the timing routines to use the kernel timer and scheduling 140 I've changed the timing routines to use the kernel timer and scheduling
141 functions so that the hangs and other assorted problems that occurred 141 functions so that the hangs and other assorted problems that occurred
@@ -204,7 +204,7 @@
204 following parameters are allowed: 204 following parameters are allowed:
205 205
206 fdx for full duplex 206 fdx for full duplex
207 autosense to set the media/speed; with the following 207 autosense to set the media/speed; with the following
208 sub-parameters: 208 sub-parameters:
209 TP, TP_NW, BNC, AUI, BNC_AUI, 100Mb, 10Mb, AUTO 209 TP, TP_NW, BNC, AUI, BNC_AUI, 100Mb, 10Mb, AUTO
210 210
@@ -235,14 +235,14 @@
235 this automatically or include #define DE4X5_FORCE_EISA on or before 235 this automatically or include #define DE4X5_FORCE_EISA on or before
236 line 1040 in the driver. 236 line 1040 in the driver.
237 237
238 TO DO: 238 TO DO:
239 ------ 239 ------
240 240
241 Revision History 241 Revision History
242 ---------------- 242 ----------------
243 243
244 Version Date Description 244 Version Date Description
245 245
246 0.1 17-Nov-94 Initial writing. ALPHA code release. 246 0.1 17-Nov-94 Initial writing. ALPHA code release.
247 0.2 13-Jan-95 Added PCI support for DE435's. 247 0.2 13-Jan-95 Added PCI support for DE435's.
248 0.21 19-Jan-95 Added auto media detection. 248 0.21 19-Jan-95 Added auto media detection.
@@ -251,7 +251,7 @@
251 Add request/release_region code. 251 Add request/release_region code.
252 Add loadable modules support for PCI. 252 Add loadable modules support for PCI.
253 Clean up loadable modules support. 253 Clean up loadable modules support.
254 0.23 28-Feb-95 Added DC21041 and DC21140 support. 254 0.23 28-Feb-95 Added DC21041 and DC21140 support.
255 Fix missed frame counter value and initialisation. 255 Fix missed frame counter value and initialisation.
256 Fixed EISA probe. 256 Fixed EISA probe.
257 0.24 11-Apr-95 Change delay routine to use <linux/udelay>. 257 0.24 11-Apr-95 Change delay routine to use <linux/udelay>.
@@ -280,7 +280,7 @@
280 Add kernel timer code (h/w is too flaky). 280 Add kernel timer code (h/w is too flaky).
281 Add MII based PHY autosense. 281 Add MII based PHY autosense.
282 Add new multicasting code. 282 Add new multicasting code.
283 Add new autosense algorithms for media/mode 283 Add new autosense algorithms for media/mode
284 selection using kernel scheduling/timing. 284 selection using kernel scheduling/timing.
285 Re-formatted. 285 Re-formatted.
286 Made changes suggested by <jeff@router.patch.net>: 286 Made changes suggested by <jeff@router.patch.net>:
@@ -307,10 +307,10 @@
307 Add Accton to the list of broken cards. 307 Add Accton to the list of broken cards.
308 Fix TX under-run bug for non DC21140 chips. 308 Fix TX under-run bug for non DC21140 chips.
309 Fix boot command probe bug in alloc_device() as 309 Fix boot command probe bug in alloc_device() as
310 reported by <koen.gadeyne@barco.com> and 310 reported by <koen.gadeyne@barco.com> and
311 <orava@nether.tky.hut.fi>. 311 <orava@nether.tky.hut.fi>.
312 Add cache locks to prevent a race condition as 312 Add cache locks to prevent a race condition as
313 reported by <csd@microplex.com> and 313 reported by <csd@microplex.com> and
314 <baba@beckman.uiuc.edu>. 314 <baba@beckman.uiuc.edu>.
315 Upgraded alloc_device() code. 315 Upgraded alloc_device() code.
316 0.431 28-Jun-96 Fix potential bug in queue_pkt() from discussion 316 0.431 28-Jun-96 Fix potential bug in queue_pkt() from discussion
@@ -322,7 +322,7 @@
322 with a loopback packet. 322 with a loopback packet.
323 0.442 9-Sep-96 Include AUI in dc21041 media printout. Bug reported 323 0.442 9-Sep-96 Include AUI in dc21041 media printout. Bug reported
324 by <bhat@mundook.cs.mu.OZ.AU> 324 by <bhat@mundook.cs.mu.OZ.AU>
325 0.45 8-Dec-96 Include endian functions for PPC use, from work 325 0.45 8-Dec-96 Include endian functions for PPC use, from work
326 by <cort@cs.nmt.edu> and <g.thomas@opengroup.org>. 326 by <cort@cs.nmt.edu> and <g.thomas@opengroup.org>.
327 0.451 28-Dec-96 Added fix to allow autoprobe for modules after 327 0.451 28-Dec-96 Added fix to allow autoprobe for modules after
328 suggestion from <mjacob@feral.com>. 328 suggestion from <mjacob@feral.com>.
@@ -346,14 +346,14 @@
346 <paubert@iram.es>. 346 <paubert@iram.es>.
347 0.52 26-Apr-97 Some changes may not credit the right people - 347 0.52 26-Apr-97 Some changes may not credit the right people -
348 a disk crash meant I lost some mail. 348 a disk crash meant I lost some mail.
349 Change RX interrupt routine to drop rather than 349 Change RX interrupt routine to drop rather than
350 defer packets to avoid hang reported by 350 defer packets to avoid hang reported by
351 <g.thomas@opengroup.org>. 351 <g.thomas@opengroup.org>.
352 Fix srom_exec() to return for COMPACT and type 1 352 Fix srom_exec() to return for COMPACT and type 1
353 infoblocks. 353 infoblocks.
354 Added DC21142 and DC21143 functions. 354 Added DC21142 and DC21143 functions.
355 Added byte counters from <phil@tazenda.demon.co.uk> 355 Added byte counters from <phil@tazenda.demon.co.uk>
356 Added SA_INTERRUPT temporary fix from 356 Added SA_INTERRUPT temporary fix from
357 <mjacob@feral.com>. 357 <mjacob@feral.com>.
358 0.53 12-Nov-97 Fix the *_probe() to include 'eth??' name during 358 0.53 12-Nov-97 Fix the *_probe() to include 'eth??' name during
359 module load: bug reported by 359 module load: bug reported by
@@ -363,10 +363,10 @@
363 Make above search independent of BIOS device scan 363 Make above search independent of BIOS device scan
364 direction. 364 direction.
365 Completed DC2114[23] autosense functions. 365 Completed DC2114[23] autosense functions.
366 0.531 21-Dec-97 Fix DE500-XA 100Mb/s bug reported by 366 0.531 21-Dec-97 Fix DE500-XA 100Mb/s bug reported by
367 <robin@intercore.com 367 <robin@intercore.com
368 Fix type1_infoblock() bug introduced in 0.53, from 368 Fix type1_infoblock() bug introduced in 0.53, from
369 problem reports by 369 problem reports by
370 <parmee@postecss.ncrfran.france.ncr.com> and 370 <parmee@postecss.ncrfran.france.ncr.com> and
371 <jo@ice.dillingen.baynet.de>. 371 <jo@ice.dillingen.baynet.de>.
372 Added argument list to set up each board from either 372 Added argument list to set up each board from either
@@ -374,7 +374,7 @@
374 Added generic MII PHY functionality to deal with 374 Added generic MII PHY functionality to deal with
375 newer PHY chips. 375 newer PHY chips.
376 Fix the mess in 2.1.67. 376 Fix the mess in 2.1.67.
377 0.532 5-Jan-98 Fix bug in mii_get_phy() reported by 377 0.532 5-Jan-98 Fix bug in mii_get_phy() reported by
378 <redhat@cococo.net>. 378 <redhat@cococo.net>.
379 Fix bug in pci_probe() for 64 bit systems reported 379 Fix bug in pci_probe() for 64 bit systems reported
380 by <belliott@accessone.com>. 380 by <belliott@accessone.com>.
@@ -398,7 +398,7 @@
398 version. I hope nothing is broken... 398 version. I hope nothing is broken...
399 Add TX done interrupt modification from suggestion 399 Add TX done interrupt modification from suggestion
400 by <Austin.Donnelly@cl.cam.ac.uk>. 400 by <Austin.Donnelly@cl.cam.ac.uk>.
401 Fix is_anc_capable() bug reported by 401 Fix is_anc_capable() bug reported by
402 <Austin.Donnelly@cl.cam.ac.uk>. 402 <Austin.Donnelly@cl.cam.ac.uk>.
403 Fix type[13]_infoblock() bug: during MII search, PHY 403 Fix type[13]_infoblock() bug: during MII search, PHY
404 lp->rst not run because lp->ibn not initialised - 404 lp->rst not run because lp->ibn not initialised -
@@ -413,7 +413,7 @@
413 Add an_exception() for old ZYNX346 and fix compile 413 Add an_exception() for old ZYNX346 and fix compile
414 warning on PPC & SPARC, from <ecd@skynet.be>. 414 warning on PPC & SPARC, from <ecd@skynet.be>.
415 Fix lastPCI to correctly work with compiled in 415 Fix lastPCI to correctly work with compiled in
416 kernels and modules from bug report by 416 kernels and modules from bug report by
417 <Zlatko.Calusic@CARNet.hr> et al. 417 <Zlatko.Calusic@CARNet.hr> et al.
418 0.542 15-Sep-98 Fix dc2114x_autoconf() to stop multiple messages 418 0.542 15-Sep-98 Fix dc2114x_autoconf() to stop multiple messages
419 when media is unconnected. 419 when media is unconnected.
@@ -425,7 +425,7 @@
425 0.544 8-May-99 Fix for buggy SROM in Motorola embedded boards using 425 0.544 8-May-99 Fix for buggy SROM in Motorola embedded boards using
426 a 21143 by <mmporter@home.com>. 426 a 21143 by <mmporter@home.com>.
427 Change PCI/EISA bus probing order. 427 Change PCI/EISA bus probing order.
428 0.545 28-Nov-99 Further Moto SROM bug fix from 428 0.545 28-Nov-99 Further Moto SROM bug fix from
429 <mporter@eng.mcd.mot.com> 429 <mporter@eng.mcd.mot.com>
430 Remove double checking for DEBUG_RX in de4x5_dbg_rx() 430 Remove double checking for DEBUG_RX in de4x5_dbg_rx()
431 from report by <geert@linux-m68k.org> 431 from report by <geert@linux-m68k.org>
@@ -434,8 +434,8 @@
434 variable 'pb', on a non de4x5 PCI device, in this 434 variable 'pb', on a non de4x5 PCI device, in this
435 case a PCI bridge (DEC chip 21152). The value of 435 case a PCI bridge (DEC chip 21152). The value of
436 'pb' is now only initialized if a de4x5 chip is 436 'pb' is now only initialized if a de4x5 chip is
437 present. 437 present.
438 <france@handhelds.org> 438 <france@handhelds.org>
439 0.547 08-Nov-01 Use library crc32 functions by <Matt_Domsch@dell.com> 439 0.547 08-Nov-01 Use library crc32 functions by <Matt_Domsch@dell.com>
440 0.548 30-Aug-03 Big 2.6 cleanup. Ported to PCI/EISA probing and 440 0.548 30-Aug-03 Big 2.6 cleanup. Ported to PCI/EISA probing and
441 generic DMA APIs. Fixed DE425 support on Alpha. 441 generic DMA APIs. Fixed DE425 support on Alpha.
@@ -584,7 +584,7 @@ static int de4x5_debug = (DEBUG_MEDIA | DEBUG_VERSION);
584 584
585/* 585/*
586** Allow per adapter set up. For modules this is simply a command line 586** Allow per adapter set up. For modules this is simply a command line
587** parameter, e.g.: 587** parameter, e.g.:
588** insmod de4x5 args='eth1:fdx autosense=BNC eth0:autosense=100Mb'. 588** insmod de4x5 args='eth1:fdx autosense=BNC eth0:autosense=100Mb'.
589** 589**
590** For a compiled in driver, place e.g. 590** For a compiled in driver, place e.g.
@@ -655,7 +655,7 @@ static c_char *de4x5_signatures[] = DE4X5_SIGNATURE;
655** Memory Alignment. Each descriptor is 4 longwords long. To force a 655** Memory Alignment. Each descriptor is 4 longwords long. To force a
656** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and 656** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and
657** DESC_ALIGN. ALIGN aligns the start address of the private memory area 657** DESC_ALIGN. ALIGN aligns the start address of the private memory area
658** and hence the RX descriptor ring's first entry. 658** and hence the RX descriptor ring's first entry.
659*/ 659*/
660#define DE4X5_ALIGN4 ((u_long)4 - 1) /* 1 longword align */ 660#define DE4X5_ALIGN4 ((u_long)4 - 1) /* 1 longword align */
661#define DE4X5_ALIGN8 ((u_long)8 - 1) /* 2 longword align */ 661#define DE4X5_ALIGN8 ((u_long)8 - 1) /* 2 longword align */
@@ -1081,8 +1081,8 @@ static int (*dc_infoblock[])(struct net_device *dev, u_char, u_char *) = {
1081 mdelay(2); /* Wait for 2ms */\ 1081 mdelay(2); /* Wait for 2ms */\
1082} 1082}
1083 1083
1084 1084
1085static int __devinit 1085static int __devinit
1086de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev) 1086de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1087{ 1087{
1088 char name[DE4X5_NAME_LENGTH + 1]; 1088 char name[DE4X5_NAME_LENGTH + 1];
@@ -1102,12 +1102,12 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1102 mdelay(10); 1102 mdelay(10);
1103 1103
1104 RESET_DE4X5; 1104 RESET_DE4X5;
1105 1105
1106 if ((inl(DE4X5_STS) & (STS_TS | STS_RS)) != 0) { 1106 if ((inl(DE4X5_STS) & (STS_TS | STS_RS)) != 0) {
1107 return -ENXIO; /* Hardware could not reset */ 1107 return -ENXIO; /* Hardware could not reset */
1108 } 1108 }
1109 1109
1110 /* 1110 /*
1111 ** Now find out what kind of DC21040/DC21041/DC21140 board we have. 1111 ** Now find out what kind of DC21040/DC21041/DC21140 board we have.
1112 */ 1112 */
1113 lp->useSROM = FALSE; 1113 lp->useSROM = FALSE;
@@ -1116,21 +1116,21 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1116 } else { 1116 } else {
1117 EISA_signature(name, gendev); 1117 EISA_signature(name, gendev);
1118 } 1118 }
1119 1119
1120 if (*name == '\0') { /* Not found a board signature */ 1120 if (*name == '\0') { /* Not found a board signature */
1121 return -ENXIO; 1121 return -ENXIO;
1122 } 1122 }
1123 1123
1124 dev->base_addr = iobase; 1124 dev->base_addr = iobase;
1125 printk ("%s: %s at 0x%04lx", gendev->bus_id, name, iobase); 1125 printk ("%s: %s at 0x%04lx", gendev->bus_id, name, iobase);
1126 1126
1127 printk(", h/w address "); 1127 printk(", h/w address ");
1128 status = get_hw_addr(dev); 1128 status = get_hw_addr(dev);
1129 for (i = 0; i < ETH_ALEN - 1; i++) { /* get the ethernet addr. */ 1129 for (i = 0; i < ETH_ALEN - 1; i++) { /* get the ethernet addr. */
1130 printk("%2.2x:", dev->dev_addr[i]); 1130 printk("%2.2x:", dev->dev_addr[i]);
1131 } 1131 }
1132 printk("%2.2x,\n", dev->dev_addr[i]); 1132 printk("%2.2x,\n", dev->dev_addr[i]);
1133 1133
1134 if (status != 0) { 1134 if (status != 0) {
1135 printk(" which has an Ethernet PROM CRC error.\n"); 1135 printk(" which has an Ethernet PROM CRC error.\n");
1136 return -ENXIO; 1136 return -ENXIO;
@@ -1171,10 +1171,10 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1171 } 1171 }
1172 1172
1173 lp->tx_ring = lp->rx_ring + NUM_RX_DESC; 1173 lp->tx_ring = lp->rx_ring + NUM_RX_DESC;
1174 1174
1175 /* 1175 /*
1176 ** Set up the RX descriptor ring (Intels) 1176 ** Set up the RX descriptor ring (Intels)
1177 ** Allocate contiguous receive buffers, long word aligned (Alphas) 1177 ** Allocate contiguous receive buffers, long word aligned (Alphas)
1178 */ 1178 */
1179#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__sparc_v9__) && !defined(DE4X5_DO_MEMCPY) 1179#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__sparc_v9__) && !defined(DE4X5_DO_MEMCPY)
1180 for (i=0; i<NUM_RX_DESC; i++) { 1180 for (i=0; i<NUM_RX_DESC; i++) {
@@ -1210,7 +1210,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1210 1210
1211 lp->rxRingSize = NUM_RX_DESC; 1211 lp->rxRingSize = NUM_RX_DESC;
1212 lp->txRingSize = NUM_TX_DESC; 1212 lp->txRingSize = NUM_TX_DESC;
1213 1213
1214 /* Write the end of list marker to the descriptor lists */ 1214 /* Write the end of list marker to the descriptor lists */
1215 lp->rx_ring[lp->rxRingSize - 1].des1 |= cpu_to_le32(RD_RER); 1215 lp->rx_ring[lp->rxRingSize - 1].des1 |= cpu_to_le32(RD_RER);
1216 lp->tx_ring[lp->txRingSize - 1].des1 |= cpu_to_le32(TD_TER); 1216 lp->tx_ring[lp->txRingSize - 1].des1 |= cpu_to_le32(TD_TER);
@@ -1219,7 +1219,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1219 outl(lp->dma_rings, DE4X5_RRBA); 1219 outl(lp->dma_rings, DE4X5_RRBA);
1220 outl(lp->dma_rings + NUM_RX_DESC * sizeof(struct de4x5_desc), 1220 outl(lp->dma_rings + NUM_RX_DESC * sizeof(struct de4x5_desc),
1221 DE4X5_TRBA); 1221 DE4X5_TRBA);
1222 1222
1223 /* Initialise the IRQ mask and Enable/Disable */ 1223 /* Initialise the IRQ mask and Enable/Disable */
1224 lp->irq_mask = IMR_RIM | IMR_TIM | IMR_TUM | IMR_UNM; 1224 lp->irq_mask = IMR_RIM | IMR_TIM | IMR_TUM | IMR_UNM;
1225 lp->irq_en = IMR_NIM | IMR_AIM; 1225 lp->irq_en = IMR_NIM | IMR_AIM;
@@ -1252,7 +1252,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1252 if ((lp->chipset != DC21040) && (lp->chipset != DC21041)) { 1252 if ((lp->chipset != DC21040) && (lp->chipset != DC21041)) {
1253 mii_get_phy(dev); 1253 mii_get_phy(dev);
1254 } 1254 }
1255 1255
1256#ifndef __sparc_v9__ 1256#ifndef __sparc_v9__
1257 printk(" and requires IRQ%d (provided by %s).\n", dev->irq, 1257 printk(" and requires IRQ%d (provided by %s).\n", dev->irq,
1258#else 1258#else
@@ -1260,11 +1260,11 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1260#endif 1260#endif
1261 ((lp->bus == PCI) ? "PCI BIOS" : "EISA CNFG")); 1261 ((lp->bus == PCI) ? "PCI BIOS" : "EISA CNFG"));
1262 } 1262 }
1263 1263
1264 if (de4x5_debug & DEBUG_VERSION) { 1264 if (de4x5_debug & DEBUG_VERSION) {
1265 printk(version); 1265 printk(version);
1266 } 1266 }
1267 1267
1268 /* The DE4X5-specific entries in the device structure. */ 1268 /* The DE4X5-specific entries in the device structure. */
1269 SET_MODULE_OWNER(dev); 1269 SET_MODULE_OWNER(dev);
1270 SET_NETDEV_DEV(dev, gendev); 1270 SET_NETDEV_DEV(dev, gendev);
@@ -1274,23 +1274,23 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1274 dev->get_stats = &de4x5_get_stats; 1274 dev->get_stats = &de4x5_get_stats;
1275 dev->set_multicast_list = &set_multicast_list; 1275 dev->set_multicast_list = &set_multicast_list;
1276 dev->do_ioctl = &de4x5_ioctl; 1276 dev->do_ioctl = &de4x5_ioctl;
1277 1277
1278 dev->mem_start = 0; 1278 dev->mem_start = 0;
1279 1279
1280 /* Fill in the generic fields of the device structure. */ 1280 /* Fill in the generic fields of the device structure. */
1281 if ((status = register_netdev (dev))) { 1281 if ((status = register_netdev (dev))) {
1282 dma_free_coherent (gendev, lp->dma_size, 1282 dma_free_coherent (gendev, lp->dma_size,
1283 lp->rx_ring, lp->dma_rings); 1283 lp->rx_ring, lp->dma_rings);
1284 return status; 1284 return status;
1285 } 1285 }
1286 1286
1287 /* Let the adapter sleep to save power */ 1287 /* Let the adapter sleep to save power */
1288 yawn(dev, SLEEP); 1288 yawn(dev, SLEEP);
1289 1289
1290 return status; 1290 return status;
1291} 1291}
1292 1292
1293 1293
1294static int 1294static int
1295de4x5_open(struct net_device *dev) 1295de4x5_open(struct net_device *dev)
1296{ 1296{
@@ -1312,15 +1312,15 @@ de4x5_open(struct net_device *dev)
1312 */ 1312 */
1313 yawn(dev, WAKEUP); 1313 yawn(dev, WAKEUP);
1314 1314
1315 /* 1315 /*
1316 ** Re-initialize the DE4X5... 1316 ** Re-initialize the DE4X5...
1317 */ 1317 */
1318 status = de4x5_init(dev); 1318 status = de4x5_init(dev);
1319 spin_lock_init(&lp->lock); 1319 spin_lock_init(&lp->lock);
1320 lp->state = OPEN; 1320 lp->state = OPEN;
1321 de4x5_dbg_open(dev); 1321 de4x5_dbg_open(dev);
1322 1322
1323 if (request_irq(dev->irq, (void *)de4x5_interrupt, SA_SHIRQ, 1323 if (request_irq(dev->irq, (void *)de4x5_interrupt, SA_SHIRQ,
1324 lp->adapter_name, dev)) { 1324 lp->adapter_name, dev)) {
1325 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq); 1325 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq);
1326 if (request_irq(dev->irq, de4x5_interrupt, SA_INTERRUPT | SA_SHIRQ, 1326 if (request_irq(dev->irq, de4x5_interrupt, SA_INTERRUPT | SA_SHIRQ,
@@ -1340,11 +1340,11 @@ de4x5_open(struct net_device *dev)
1340 1340
1341 lp->interrupt = UNMASK_INTERRUPTS; 1341 lp->interrupt = UNMASK_INTERRUPTS;
1342 dev->trans_start = jiffies; 1342 dev->trans_start = jiffies;
1343 1343
1344 START_DE4X5; 1344 START_DE4X5;
1345 1345
1346 de4x5_setup_intr(dev); 1346 de4x5_setup_intr(dev);
1347 1347
1348 if (de4x5_debug & DEBUG_OPEN) { 1348 if (de4x5_debug & DEBUG_OPEN) {
1349 printk("\tsts: 0x%08x\n", inl(DE4X5_STS)); 1349 printk("\tsts: 0x%08x\n", inl(DE4X5_STS));
1350 printk("\tbmr: 0x%08x\n", inl(DE4X5_BMR)); 1350 printk("\tbmr: 0x%08x\n", inl(DE4X5_BMR));
@@ -1355,7 +1355,7 @@ de4x5_open(struct net_device *dev)
1355 printk("\tstrr: 0x%08x\n", inl(DE4X5_STRR)); 1355 printk("\tstrr: 0x%08x\n", inl(DE4X5_STRR));
1356 printk("\tsigr: 0x%08x\n", inl(DE4X5_SIGR)); 1356 printk("\tsigr: 0x%08x\n", inl(DE4X5_SIGR));
1357 } 1357 }
1358 1358
1359 return status; 1359 return status;
1360} 1360}
1361 1361
@@ -1369,15 +1369,15 @@ de4x5_open(struct net_device *dev)
1369*/ 1369*/
1370static int 1370static int
1371de4x5_init(struct net_device *dev) 1371de4x5_init(struct net_device *dev)
1372{ 1372{
1373 /* Lock out other processes whilst setting up the hardware */ 1373 /* Lock out other processes whilst setting up the hardware */
1374 netif_stop_queue(dev); 1374 netif_stop_queue(dev);
1375 1375
1376 de4x5_sw_reset(dev); 1376 de4x5_sw_reset(dev);
1377 1377
1378 /* Autoconfigure the connected port */ 1378 /* Autoconfigure the connected port */
1379 autoconf_media(dev); 1379 autoconf_media(dev);
1380 1380
1381 return 0; 1381 return 0;
1382} 1382}
1383 1383
@@ -1388,7 +1388,7 @@ de4x5_sw_reset(struct net_device *dev)
1388 u_long iobase = dev->base_addr; 1388 u_long iobase = dev->base_addr;
1389 int i, j, status = 0; 1389 int i, j, status = 0;
1390 s32 bmr, omr; 1390 s32 bmr, omr;
1391 1391
1392 /* Select the MII or SRL port now and RESET the MAC */ 1392 /* Select the MII or SRL port now and RESET the MAC */
1393 if (!lp->useSROM) { 1393 if (!lp->useSROM) {
1394 if (lp->phy[lp->active].id != 0) { 1394 if (lp->phy[lp->active].id != 0) {
@@ -1399,7 +1399,7 @@ de4x5_sw_reset(struct net_device *dev)
1399 de4x5_switch_mac_port(dev); 1399 de4x5_switch_mac_port(dev);
1400 } 1400 }
1401 1401
1402 /* 1402 /*
1403 ** Set the programmable burst length to 8 longwords for all the DC21140 1403 ** Set the programmable burst length to 8 longwords for all the DC21140
1404 ** Fasternet chips and 4 longwords for all others: DMA errors result 1404 ** Fasternet chips and 4 longwords for all others: DMA errors result
1405 ** without these values. Cache align 16 long. 1405 ** without these values. Cache align 16 long.
@@ -1416,23 +1416,23 @@ de4x5_sw_reset(struct net_device *dev)
1416 outl(lp->dma_rings, DE4X5_RRBA); 1416 outl(lp->dma_rings, DE4X5_RRBA);
1417 outl(lp->dma_rings + NUM_RX_DESC * sizeof(struct de4x5_desc), 1417 outl(lp->dma_rings + NUM_RX_DESC * sizeof(struct de4x5_desc),
1418 DE4X5_TRBA); 1418 DE4X5_TRBA);
1419 1419
1420 lp->rx_new = lp->rx_old = 0; 1420 lp->rx_new = lp->rx_old = 0;
1421 lp->tx_new = lp->tx_old = 0; 1421 lp->tx_new = lp->tx_old = 0;
1422 1422
1423 for (i = 0; i < lp->rxRingSize; i++) { 1423 for (i = 0; i < lp->rxRingSize; i++) {
1424 lp->rx_ring[i].status = cpu_to_le32(R_OWN); 1424 lp->rx_ring[i].status = cpu_to_le32(R_OWN);
1425 } 1425 }
1426 1426
1427 for (i = 0; i < lp->txRingSize; i++) { 1427 for (i = 0; i < lp->txRingSize; i++) {
1428 lp->tx_ring[i].status = cpu_to_le32(0); 1428 lp->tx_ring[i].status = cpu_to_le32(0);
1429 } 1429 }
1430 1430
1431 barrier(); 1431 barrier();
1432 1432
1433 /* Build the setup frame depending on filtering mode */ 1433 /* Build the setup frame depending on filtering mode */
1434 SetMulticastFilter(dev); 1434 SetMulticastFilter(dev);
1435 1435
1436 load_packet(dev, lp->setup_frame, PERFECT_F|TD_SET|SETUP_FRAME_LEN, (struct sk_buff *)1); 1436 load_packet(dev, lp->setup_frame, PERFECT_F|TD_SET|SETUP_FRAME_LEN, (struct sk_buff *)1);
1437 outl(omr|OMR_ST, DE4X5_OMR); 1437 outl(omr|OMR_ST, DE4X5_OMR);
1438 1438
@@ -1445,18 +1445,18 @@ de4x5_sw_reset(struct net_device *dev)
1445 outl(omr, DE4X5_OMR); /* Stop everything! */ 1445 outl(omr, DE4X5_OMR); /* Stop everything! */
1446 1446
1447 if (j == 0) { 1447 if (j == 0) {
1448 printk("%s: Setup frame timed out, status %08x\n", dev->name, 1448 printk("%s: Setup frame timed out, status %08x\n", dev->name,
1449 inl(DE4X5_STS)); 1449 inl(DE4X5_STS));
1450 status = -EIO; 1450 status = -EIO;
1451 } 1451 }
1452 1452
1453 lp->tx_new = (++lp->tx_new) % lp->txRingSize; 1453 lp->tx_new = (++lp->tx_new) % lp->txRingSize;
1454 lp->tx_old = lp->tx_new; 1454 lp->tx_old = lp->tx_new;
1455 1455
1456 return status; 1456 return status;
1457} 1457}
1458 1458
1459/* 1459/*
1460** Writes a socket buffer address to the next available transmit descriptor. 1460** Writes a socket buffer address to the next available transmit descriptor.
1461*/ 1461*/
1462static int 1462static int
@@ -1469,9 +1469,9 @@ de4x5_queue_pkt(struct sk_buff *skb, struct net_device *dev)
1469 1469
1470 netif_stop_queue(dev); 1470 netif_stop_queue(dev);
1471 if (lp->tx_enable == NO) { /* Cannot send for now */ 1471 if (lp->tx_enable == NO) { /* Cannot send for now */
1472 return -1; 1472 return -1;
1473 } 1473 }
1474 1474
1475 /* 1475 /*
1476 ** Clean out the TX ring asynchronously to interrupts - sometimes the 1476 ** Clean out the TX ring asynchronously to interrupts - sometimes the
1477 ** interrupts are lost by delayed descriptor status updates relative to 1477 ** interrupts are lost by delayed descriptor status updates relative to
@@ -1482,7 +1482,7 @@ de4x5_queue_pkt(struct sk_buff *skb, struct net_device *dev)
1482 spin_unlock_irqrestore(&lp->lock, flags); 1482 spin_unlock_irqrestore(&lp->lock, flags);
1483 1483
1484 /* Test if cache is already locked - requeue skb if so */ 1484 /* Test if cache is already locked - requeue skb if so */
1485 if (test_and_set_bit(0, (void *)&lp->cache.lock) && !lp->interrupt) 1485 if (test_and_set_bit(0, (void *)&lp->cache.lock) && !lp->interrupt)
1486 return -1; 1486 return -1;
1487 1487
1488 /* Transmit descriptor ring full or stale skb */ 1488 /* Transmit descriptor ring full or stale skb */
@@ -1509,10 +1509,10 @@ de4x5_queue_pkt(struct sk_buff *skb, struct net_device *dev)
1509 load_packet(dev, skb->data, TD_IC | TD_LS | TD_FS | skb->len, skb); 1509 load_packet(dev, skb->data, TD_IC | TD_LS | TD_FS | skb->len, skb);
1510 lp->stats.tx_bytes += skb->len; 1510 lp->stats.tx_bytes += skb->len;
1511 outl(POLL_DEMAND, DE4X5_TPD);/* Start the TX */ 1511 outl(POLL_DEMAND, DE4X5_TPD);/* Start the TX */
1512 1512
1513 lp->tx_new = (++lp->tx_new) % lp->txRingSize; 1513 lp->tx_new = (++lp->tx_new) % lp->txRingSize;
1514 dev->trans_start = jiffies; 1514 dev->trans_start = jiffies;
1515 1515
1516 if (TX_BUFFS_AVAIL) { 1516 if (TX_BUFFS_AVAIL) {
1517 netif_start_queue(dev); /* Another pkt may be queued */ 1517 netif_start_queue(dev); /* Another pkt may be queued */
1518 } 1518 }
@@ -1521,15 +1521,15 @@ de4x5_queue_pkt(struct sk_buff *skb, struct net_device *dev)
1521 } 1521 }
1522 if (skb) de4x5_putb_cache(dev, skb); 1522 if (skb) de4x5_putb_cache(dev, skb);
1523 } 1523 }
1524 1524
1525 lp->cache.lock = 0; 1525 lp->cache.lock = 0;
1526 1526
1527 return status; 1527 return status;
1528} 1528}
1529 1529
1530/* 1530/*
1531** The DE4X5 interrupt handler. 1531** The DE4X5 interrupt handler.
1532** 1532**
1533** I/O Read/Writes through intermediate PCI bridges are never 'posted', 1533** I/O Read/Writes through intermediate PCI bridges are never 'posted',
1534** so that the asserted interrupt always has some real data to work with - 1534** so that the asserted interrupt always has some real data to work with -
1535** if these I/O accesses are ever changed to memory accesses, ensure the 1535** if these I/O accesses are ever changed to memory accesses, ensure the
@@ -1546,7 +1546,7 @@ de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1546 s32 imr, omr, sts, limit; 1546 s32 imr, omr, sts, limit;
1547 u_long iobase; 1547 u_long iobase;
1548 unsigned int handled = 0; 1548 unsigned int handled = 0;
1549 1549
1550 if (dev == NULL) { 1550 if (dev == NULL) {
1551 printk ("de4x5_interrupt(): irq %d for unknown device.\n", irq); 1551 printk ("de4x5_interrupt(): irq %d for unknown device.\n", irq);
1552 return IRQ_NONE; 1552 return IRQ_NONE;
@@ -1554,35 +1554,35 @@ de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1554 lp = netdev_priv(dev); 1554 lp = netdev_priv(dev);
1555 spin_lock(&lp->lock); 1555 spin_lock(&lp->lock);
1556 iobase = dev->base_addr; 1556 iobase = dev->base_addr;
1557 1557
1558 DISABLE_IRQs; /* Ensure non re-entrancy */ 1558 DISABLE_IRQs; /* Ensure non re-entrancy */
1559 1559
1560 if (test_and_set_bit(MASK_INTERRUPTS, (void*) &lp->interrupt)) 1560 if (test_and_set_bit(MASK_INTERRUPTS, (void*) &lp->interrupt))
1561 printk("%s: Re-entering the interrupt handler.\n", dev->name); 1561 printk("%s: Re-entering the interrupt handler.\n", dev->name);
1562 1562
1563 synchronize_irq(dev->irq); 1563 synchronize_irq(dev->irq);
1564 1564
1565 for (limit=0; limit<8; limit++) { 1565 for (limit=0; limit<8; limit++) {
1566 sts = inl(DE4X5_STS); /* Read IRQ status */ 1566 sts = inl(DE4X5_STS); /* Read IRQ status */
1567 outl(sts, DE4X5_STS); /* Reset the board interrupts */ 1567 outl(sts, DE4X5_STS); /* Reset the board interrupts */
1568 1568
1569 if (!(sts & lp->irq_mask)) break;/* All done */ 1569 if (!(sts & lp->irq_mask)) break;/* All done */
1570 handled = 1; 1570 handled = 1;
1571 1571
1572 if (sts & (STS_RI | STS_RU)) /* Rx interrupt (packet[s] arrived) */ 1572 if (sts & (STS_RI | STS_RU)) /* Rx interrupt (packet[s] arrived) */
1573 de4x5_rx(dev); 1573 de4x5_rx(dev);
1574 1574
1575 if (sts & (STS_TI | STS_TU)) /* Tx interrupt (packet sent) */ 1575 if (sts & (STS_TI | STS_TU)) /* Tx interrupt (packet sent) */
1576 de4x5_tx(dev); 1576 de4x5_tx(dev);
1577 1577
1578 if (sts & STS_LNF) { /* TP Link has failed */ 1578 if (sts & STS_LNF) { /* TP Link has failed */
1579 lp->irq_mask &= ~IMR_LFM; 1579 lp->irq_mask &= ~IMR_LFM;
1580 } 1580 }
1581 1581
1582 if (sts & STS_UNF) { /* Transmit underrun */ 1582 if (sts & STS_UNF) { /* Transmit underrun */
1583 de4x5_txur(dev); 1583 de4x5_txur(dev);
1584 } 1584 }
1585 1585
1586 if (sts & STS_SE) { /* Bus Error */ 1586 if (sts & STS_SE) { /* Bus Error */
1587 STOP_DE4X5; 1587 STOP_DE4X5;
1588 printk("%s: Fatal bus error occurred, sts=%#8x, device stopped.\n", 1588 printk("%s: Fatal bus error occurred, sts=%#8x, device stopped.\n",
@@ -1603,7 +1603,7 @@ de4x5_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1603 lp->interrupt = UNMASK_INTERRUPTS; 1603 lp->interrupt = UNMASK_INTERRUPTS;
1604 ENABLE_IRQs; 1604 ENABLE_IRQs;
1605 spin_unlock(&lp->lock); 1605 spin_unlock(&lp->lock);
1606 1606
1607 return IRQ_RETVAL(handled); 1607 return IRQ_RETVAL(handled);
1608} 1608}
1609 1609
@@ -1614,11 +1614,11 @@ de4x5_rx(struct net_device *dev)
1614 u_long iobase = dev->base_addr; 1614 u_long iobase = dev->base_addr;
1615 int entry; 1615 int entry;
1616 s32 status; 1616 s32 status;
1617 1617
1618 for (entry=lp->rx_new; (s32)le32_to_cpu(lp->rx_ring[entry].status)>=0; 1618 for (entry=lp->rx_new; (s32)le32_to_cpu(lp->rx_ring[entry].status)>=0;
1619 entry=lp->rx_new) { 1619 entry=lp->rx_new) {
1620 status = (s32)le32_to_cpu(lp->rx_ring[entry].status); 1620 status = (s32)le32_to_cpu(lp->rx_ring[entry].status);
1621 1621
1622 if (lp->rx_ovf) { 1622 if (lp->rx_ovf) {
1623 if (inl(DE4X5_MFC) & MFC_FOCM) { 1623 if (inl(DE4X5_MFC) & MFC_FOCM) {
1624 de4x5_rx_ovfc(dev); 1624 de4x5_rx_ovfc(dev);
@@ -1629,7 +1629,7 @@ de4x5_rx(struct net_device *dev)
1629 if (status & RD_FS) { /* Remember the start of frame */ 1629 if (status & RD_FS) { /* Remember the start of frame */
1630 lp->rx_old = entry; 1630 lp->rx_old = entry;
1631 } 1631 }
1632 1632
1633 if (status & RD_LS) { /* Valid frame status */ 1633 if (status & RD_LS) { /* Valid frame status */
1634 if (lp->tx_enable) lp->linkOK++; 1634 if (lp->tx_enable) lp->linkOK++;
1635 if (status & RD_ES) { /* There was an error. */ 1635 if (status & RD_ES) { /* There was an error. */
@@ -1646,9 +1646,9 @@ de4x5_rx(struct net_device *dev)
1646 struct sk_buff *skb; 1646 struct sk_buff *skb;
1647 short pkt_len = (short)(le32_to_cpu(lp->rx_ring[entry].status) 1647 short pkt_len = (short)(le32_to_cpu(lp->rx_ring[entry].status)
1648 >> 16) - 4; 1648 >> 16) - 4;
1649 1649
1650 if ((skb = de4x5_alloc_rx_buff(dev, entry, pkt_len)) == NULL) { 1650 if ((skb = de4x5_alloc_rx_buff(dev, entry, pkt_len)) == NULL) {
1651 printk("%s: Insufficient memory; nuking packet.\n", 1651 printk("%s: Insufficient memory; nuking packet.\n",
1652 dev->name); 1652 dev->name);
1653 lp->stats.rx_dropped++; 1653 lp->stats.rx_dropped++;
1654 } else { 1654 } else {
@@ -1658,14 +1658,14 @@ de4x5_rx(struct net_device *dev)
1658 skb->protocol=eth_type_trans(skb,dev); 1658 skb->protocol=eth_type_trans(skb,dev);
1659 de4x5_local_stats(dev, skb->data, pkt_len); 1659 de4x5_local_stats(dev, skb->data, pkt_len);
1660 netif_rx(skb); 1660 netif_rx(skb);
1661 1661
1662 /* Update stats */ 1662 /* Update stats */
1663 dev->last_rx = jiffies; 1663 dev->last_rx = jiffies;
1664 lp->stats.rx_packets++; 1664 lp->stats.rx_packets++;
1665 lp->stats.rx_bytes += pkt_len; 1665 lp->stats.rx_bytes += pkt_len;
1666 } 1666 }
1667 } 1667 }
1668 1668
1669 /* Change buffer ownership for this frame, back to the adapter */ 1669 /* Change buffer ownership for this frame, back to the adapter */
1670 for (;lp->rx_old!=entry;lp->rx_old=(++lp->rx_old)%lp->rxRingSize) { 1670 for (;lp->rx_old!=entry;lp->rx_old=(++lp->rx_old)%lp->rxRingSize) {
1671 lp->rx_ring[lp->rx_old].status = cpu_to_le32(R_OWN); 1671 lp->rx_ring[lp->rx_old].status = cpu_to_le32(R_OWN);
@@ -1674,13 +1674,13 @@ de4x5_rx(struct net_device *dev)
1674 lp->rx_ring[entry].status = cpu_to_le32(R_OWN); 1674 lp->rx_ring[entry].status = cpu_to_le32(R_OWN);
1675 barrier(); 1675 barrier();
1676 } 1676 }
1677 1677
1678 /* 1678 /*
1679 ** Update entry information 1679 ** Update entry information
1680 */ 1680 */
1681 lp->rx_new = (++lp->rx_new) % lp->rxRingSize; 1681 lp->rx_new = (++lp->rx_new) % lp->rxRingSize;
1682 } 1682 }
1683 1683
1684 return 0; 1684 return 0;
1685} 1685}
1686 1686
@@ -1705,20 +1705,20 @@ de4x5_tx(struct net_device *dev)
1705 u_long iobase = dev->base_addr; 1705 u_long iobase = dev->base_addr;
1706 int entry; 1706 int entry;
1707 s32 status; 1707 s32 status;
1708 1708
1709 for (entry = lp->tx_old; entry != lp->tx_new; entry = lp->tx_old) { 1709 for (entry = lp->tx_old; entry != lp->tx_new; entry = lp->tx_old) {
1710 status = (s32)le32_to_cpu(lp->tx_ring[entry].status); 1710 status = (s32)le32_to_cpu(lp->tx_ring[entry].status);
1711 if (status < 0) { /* Buffer not sent yet */ 1711 if (status < 0) { /* Buffer not sent yet */
1712 break; 1712 break;
1713 } else if (status != 0x7fffffff) { /* Not setup frame */ 1713 } else if (status != 0x7fffffff) { /* Not setup frame */
1714 if (status & TD_ES) { /* An error happened */ 1714 if (status & TD_ES) { /* An error happened */
1715 lp->stats.tx_errors++; 1715 lp->stats.tx_errors++;
1716 if (status & TD_NC) lp->stats.tx_carrier_errors++; 1716 if (status & TD_NC) lp->stats.tx_carrier_errors++;
1717 if (status & TD_LC) lp->stats.tx_window_errors++; 1717 if (status & TD_LC) lp->stats.tx_window_errors++;
1718 if (status & TD_UF) lp->stats.tx_fifo_errors++; 1718 if (status & TD_UF) lp->stats.tx_fifo_errors++;
1719 if (status & TD_EC) lp->pktStats.excessive_collisions++; 1719 if (status & TD_EC) lp->pktStats.excessive_collisions++;
1720 if (status & TD_DE) lp->stats.tx_aborted_errors++; 1720 if (status & TD_DE) lp->stats.tx_aborted_errors++;
1721 1721
1722 if (TX_PKT_PENDING) { 1722 if (TX_PKT_PENDING) {
1723 outl(POLL_DEMAND, DE4X5_TPD);/* Restart a stalled TX */ 1723 outl(POLL_DEMAND, DE4X5_TPD);/* Restart a stalled TX */
1724 } 1724 }
@@ -1727,14 +1727,14 @@ de4x5_tx(struct net_device *dev)
1727 if (lp->tx_enable) lp->linkOK++; 1727 if (lp->tx_enable) lp->linkOK++;
1728 } 1728 }
1729 /* Update the collision counter */ 1729 /* Update the collision counter */
1730 lp->stats.collisions += ((status & TD_EC) ? 16 : 1730 lp->stats.collisions += ((status & TD_EC) ? 16 :
1731 ((status & TD_CC) >> 3)); 1731 ((status & TD_CC) >> 3));
1732 1732
1733 /* Free the buffer. */ 1733 /* Free the buffer. */
1734 if (lp->tx_skb[entry] != NULL) 1734 if (lp->tx_skb[entry] != NULL)
1735 de4x5_free_tx_buff(lp, entry); 1735 de4x5_free_tx_buff(lp, entry);
1736 } 1736 }
1737 1737
1738 /* Update all the pointers */ 1738 /* Update all the pointers */
1739 lp->tx_old = (++lp->tx_old) % lp->txRingSize; 1739 lp->tx_old = (++lp->tx_old) % lp->txRingSize;
1740 } 1740 }
@@ -1746,7 +1746,7 @@ de4x5_tx(struct net_device *dev)
1746 else 1746 else
1747 netif_start_queue(dev); 1747 netif_start_queue(dev);
1748 } 1748 }
1749 1749
1750 return 0; 1750 return 0;
1751} 1751}
1752 1752
@@ -1755,9 +1755,9 @@ de4x5_ast(struct net_device *dev)
1755{ 1755{
1756 struct de4x5_private *lp = netdev_priv(dev); 1756 struct de4x5_private *lp = netdev_priv(dev);
1757 int next_tick = DE4X5_AUTOSENSE_MS; 1757 int next_tick = DE4X5_AUTOSENSE_MS;
1758 1758
1759 disable_ast(dev); 1759 disable_ast(dev);
1760 1760
1761 if (lp->useSROM) { 1761 if (lp->useSROM) {
1762 next_tick = srom_autoconf(dev); 1762 next_tick = srom_autoconf(dev);
1763 } else if (lp->chipset == DC21140) { 1763 } else if (lp->chipset == DC21140) {
@@ -1769,7 +1769,7 @@ de4x5_ast(struct net_device *dev)
1769 } 1769 }
1770 lp->linkOK = 0; 1770 lp->linkOK = 0;
1771 enable_ast(dev, next_tick); 1771 enable_ast(dev, next_tick);
1772 1772
1773 return 0; 1773 return 0;
1774} 1774}
1775 1775
@@ -1792,11 +1792,11 @@ de4x5_txur(struct net_device *dev)
1792 } 1792 }
1793 outl(omr | OMR_ST | OMR_SR, DE4X5_OMR); 1793 outl(omr | OMR_ST | OMR_SR, DE4X5_OMR);
1794 } 1794 }
1795 1795
1796 return 0; 1796 return 0;
1797} 1797}
1798 1798
1799static int 1799static int
1800de4x5_rx_ovfc(struct net_device *dev) 1800de4x5_rx_ovfc(struct net_device *dev)
1801{ 1801{
1802 struct de4x5_private *lp = netdev_priv(dev); 1802 struct de4x5_private *lp = netdev_priv(dev);
@@ -1813,7 +1813,7 @@ de4x5_rx_ovfc(struct net_device *dev)
1813 } 1813 }
1814 1814
1815 outl(omr, DE4X5_OMR); 1815 outl(omr, DE4X5_OMR);
1816 1816
1817 return 0; 1817 return 0;
1818} 1818}
1819 1819
@@ -1823,22 +1823,22 @@ de4x5_close(struct net_device *dev)
1823 struct de4x5_private *lp = netdev_priv(dev); 1823 struct de4x5_private *lp = netdev_priv(dev);
1824 u_long iobase = dev->base_addr; 1824 u_long iobase = dev->base_addr;
1825 s32 imr, omr; 1825 s32 imr, omr;
1826 1826
1827 disable_ast(dev); 1827 disable_ast(dev);
1828 1828
1829 netif_stop_queue(dev); 1829 netif_stop_queue(dev);
1830 1830
1831 if (de4x5_debug & DEBUG_CLOSE) { 1831 if (de4x5_debug & DEBUG_CLOSE) {
1832 printk("%s: Shutting down ethercard, status was %8.8x.\n", 1832 printk("%s: Shutting down ethercard, status was %8.8x.\n",
1833 dev->name, inl(DE4X5_STS)); 1833 dev->name, inl(DE4X5_STS));
1834 } 1834 }
1835 1835
1836 /* 1836 /*
1837 ** We stop the DE4X5 here... mask interrupts and stop TX & RX 1837 ** We stop the DE4X5 here... mask interrupts and stop TX & RX
1838 */ 1838 */
1839 DISABLE_IRQs; 1839 DISABLE_IRQs;
1840 STOP_DE4X5; 1840 STOP_DE4X5;
1841 1841
1842 /* Free the associated irq */ 1842 /* Free the associated irq */
1843 free_irq(dev->irq, dev); 1843 free_irq(dev->irq, dev);
1844 lp->state = CLOSED; 1844 lp->state = CLOSED;
@@ -1846,10 +1846,10 @@ de4x5_close(struct net_device *dev)
1846 /* Free any socket buffers */ 1846 /* Free any socket buffers */
1847 de4x5_free_rx_buffs(dev); 1847 de4x5_free_rx_buffs(dev);
1848 de4x5_free_tx_buffs(dev); 1848 de4x5_free_tx_buffs(dev);
1849 1849
1850 /* Put the adapter to sleep to save power */ 1850 /* Put the adapter to sleep to save power */
1851 yawn(dev, SLEEP); 1851 yawn(dev, SLEEP);
1852 1852
1853 return 0; 1853 return 0;
1854} 1854}
1855 1855
@@ -1858,9 +1858,9 @@ de4x5_get_stats(struct net_device *dev)
1858{ 1858{
1859 struct de4x5_private *lp = netdev_priv(dev); 1859 struct de4x5_private *lp = netdev_priv(dev);
1860 u_long iobase = dev->base_addr; 1860 u_long iobase = dev->base_addr;
1861 1861
1862 lp->stats.rx_missed_errors = (int)(inl(DE4X5_MFC) & (MFC_OVFL | MFC_CNTR)); 1862 lp->stats.rx_missed_errors = (int)(inl(DE4X5_MFC) & (MFC_OVFL | MFC_CNTR));
1863 1863
1864 return &lp->stats; 1864 return &lp->stats;
1865} 1865}
1866 1866
@@ -1886,7 +1886,7 @@ de4x5_local_stats(struct net_device *dev, char *buf, int pkt_len)
1886 (*(s16 *)&buf[4] == *(s16 *)&dev->dev_addr[4])) { 1886 (*(s16 *)&buf[4] == *(s16 *)&dev->dev_addr[4])) {
1887 lp->pktStats.unicast++; 1887 lp->pktStats.unicast++;
1888 } 1888 }
1889 1889
1890 lp->pktStats.bins[0]++; /* Duplicates stats.rx_packets */ 1890 lp->pktStats.bins[0]++; /* Duplicates stats.rx_packets */
1891 if (lp->pktStats.bins[0] == 0) { /* Reset counters */ 1891 if (lp->pktStats.bins[0] == 0) { /* Reset counters */
1892 memset((char *)&lp->pktStats, 0, sizeof(lp->pktStats)); 1892 memset((char *)&lp->pktStats, 0, sizeof(lp->pktStats));
@@ -1937,11 +1937,11 @@ set_multicast_list(struct net_device *dev)
1937 omr = inl(DE4X5_OMR); 1937 omr = inl(DE4X5_OMR);
1938 omr |= OMR_PR; 1938 omr |= OMR_PR;
1939 outl(omr, DE4X5_OMR); 1939 outl(omr, DE4X5_OMR);
1940 } else { 1940 } else {
1941 SetMulticastFilter(dev); 1941 SetMulticastFilter(dev);
1942 load_packet(dev, lp->setup_frame, TD_IC | PERFECT_F | TD_SET | 1942 load_packet(dev, lp->setup_frame, TD_IC | PERFECT_F | TD_SET |
1943 SETUP_FRAME_LEN, (struct sk_buff *)1); 1943 SETUP_FRAME_LEN, (struct sk_buff *)1);
1944 1944
1945 lp->tx_new = (++lp->tx_new) % lp->txRingSize; 1945 lp->tx_new = (++lp->tx_new) % lp->txRingSize;
1946 outl(POLL_DEMAND, DE4X5_TPD); /* Start the TX */ 1946 outl(POLL_DEMAND, DE4X5_TPD); /* Start the TX */
1947 dev->trans_start = jiffies; 1947 dev->trans_start = jiffies;
@@ -1969,20 +1969,20 @@ SetMulticastFilter(struct net_device *dev)
1969 omr = inl(DE4X5_OMR); 1969 omr = inl(DE4X5_OMR);
1970 omr &= ~(OMR_PR | OMR_PM); 1970 omr &= ~(OMR_PR | OMR_PM);
1971 pa = build_setup_frame(dev, ALL); /* Build the basic frame */ 1971 pa = build_setup_frame(dev, ALL); /* Build the basic frame */
1972 1972
1973 if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 14)) { 1973 if ((dev->flags & IFF_ALLMULTI) || (dev->mc_count > 14)) {
1974 omr |= OMR_PM; /* Pass all multicasts */ 1974 omr |= OMR_PM; /* Pass all multicasts */
1975 } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */ 1975 } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */
1976 for (i=0;i<dev->mc_count;i++) { /* for each address in the list */ 1976 for (i=0;i<dev->mc_count;i++) { /* for each address in the list */
1977 addrs=dmi->dmi_addr; 1977 addrs=dmi->dmi_addr;
1978 dmi=dmi->next; 1978 dmi=dmi->next;
1979 if ((*addrs & 0x01) == 1) { /* multicast address? */ 1979 if ((*addrs & 0x01) == 1) { /* multicast address? */
1980 crc = ether_crc_le(ETH_ALEN, addrs); 1980 crc = ether_crc_le(ETH_ALEN, addrs);
1981 hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */ 1981 hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */
1982 1982
1983 byte = hashcode >> 3; /* bit[3-8] -> byte in filter */ 1983 byte = hashcode >> 3; /* bit[3-8] -> byte in filter */
1984 bit = 1 << (hashcode & 0x07);/* bit[0-2] -> bit in byte */ 1984 bit = 1 << (hashcode & 0x07);/* bit[0-2] -> bit in byte */
1985 1985
1986 byte <<= 1; /* calc offset into setup frame */ 1986 byte <<= 1; /* calc offset into setup frame */
1987 if (byte & 0x02) { 1987 if (byte & 0x02) {
1988 byte -= 1; 1988 byte -= 1;
@@ -1994,14 +1994,14 @@ SetMulticastFilter(struct net_device *dev)
1994 for (j=0; j<dev->mc_count; j++) { 1994 for (j=0; j<dev->mc_count; j++) {
1995 addrs=dmi->dmi_addr; 1995 addrs=dmi->dmi_addr;
1996 dmi=dmi->next; 1996 dmi=dmi->next;
1997 for (i=0; i<ETH_ALEN; i++) { 1997 for (i=0; i<ETH_ALEN; i++) {
1998 *(pa + (i&1)) = *addrs++; 1998 *(pa + (i&1)) = *addrs++;
1999 if (i & 0x01) pa += 4; 1999 if (i & 0x01) pa += 4;
2000 } 2000 }
2001 } 2001 }
2002 } 2002 }
2003 outl(omr, DE4X5_OMR); 2003 outl(omr, DE4X5_OMR);
2004 2004
2005 return; 2005 return;
2006} 2006}
2007 2007
@@ -2031,18 +2031,18 @@ static int __init de4x5_eisa_probe (struct device *gendev)
2031 status = -EBUSY; 2031 status = -EBUSY;
2032 goto release_reg_1; 2032 goto release_reg_1;
2033 } 2033 }
2034 2034
2035 if (!(dev = alloc_etherdev (sizeof (struct de4x5_private)))) { 2035 if (!(dev = alloc_etherdev (sizeof (struct de4x5_private)))) {
2036 status = -ENOMEM; 2036 status = -ENOMEM;
2037 goto release_reg_2; 2037 goto release_reg_2;
2038 } 2038 }
2039 lp = netdev_priv(dev); 2039 lp = netdev_priv(dev);
2040 2040
2041 cfid = (u32) inl(PCI_CFID); 2041 cfid = (u32) inl(PCI_CFID);
2042 lp->cfrv = (u_short) inl(PCI_CFRV); 2042 lp->cfrv = (u_short) inl(PCI_CFRV);
2043 device = (cfid >> 8) & 0x00ffff00; 2043 device = (cfid >> 8) & 0x00ffff00;
2044 vendor = (u_short) cfid; 2044 vendor = (u_short) cfid;
2045 2045
2046 /* Read the EISA Configuration Registers */ 2046 /* Read the EISA Configuration Registers */
2047 regval = inb(EISA_REG0) & (ER0_INTL | ER0_INTT); 2047 regval = inb(EISA_REG0) & (ER0_INTL | ER0_INTT);
2048#ifdef CONFIG_ALPHA 2048#ifdef CONFIG_ALPHA
@@ -2050,7 +2050,7 @@ static int __init de4x5_eisa_probe (struct device *gendev)
2050 * care about the EISA configuration, and thus doesn't 2050 * care about the EISA configuration, and thus doesn't
2051 * configure the PLX bridge properly. Oh well... Simply mimic 2051 * configure the PLX bridge properly. Oh well... Simply mimic
2052 * the EISA config file to sort it out. */ 2052 * the EISA config file to sort it out. */
2053 2053
2054 /* EISA REG1: Assert DecChip 21040 HW Reset */ 2054 /* EISA REG1: Assert DecChip 21040 HW Reset */
2055 outb (ER1_IAM | 1, EISA_REG1); 2055 outb (ER1_IAM | 1, EISA_REG1);
2056 mdelay (1); 2056 mdelay (1);
@@ -2061,12 +2061,12 @@ static int __init de4x5_eisa_probe (struct device *gendev)
2061 2061
2062 /* EISA REG3: R/W Burst Transfer Enable */ 2062 /* EISA REG3: R/W Burst Transfer Enable */
2063 outb (ER3_BWE | ER3_BRE, EISA_REG3); 2063 outb (ER3_BWE | ER3_BRE, EISA_REG3);
2064 2064
2065 /* 32_bit slave/master, Preempt Time=23 bclks, Unlatched Interrupt */ 2065 /* 32_bit slave/master, Preempt Time=23 bclks, Unlatched Interrupt */
2066 outb (ER0_BSW | ER0_BMW | ER0_EPT | regval, EISA_REG0); 2066 outb (ER0_BSW | ER0_BMW | ER0_EPT | regval, EISA_REG0);
2067#endif 2067#endif
2068 irq = de4x5_irq[(regval >> 1) & 0x03]; 2068 irq = de4x5_irq[(regval >> 1) & 0x03];
2069 2069
2070 if (is_DC2114x) { 2070 if (is_DC2114x) {
2071 device = ((lp->cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); 2071 device = ((lp->cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
2072 } 2072 }
@@ -2077,7 +2077,7 @@ static int __init de4x5_eisa_probe (struct device *gendev)
2077 outl(PCI_COMMAND_IO | PCI_COMMAND_MASTER, PCI_CFCS); 2077 outl(PCI_COMMAND_IO | PCI_COMMAND_MASTER, PCI_CFCS);
2078 outl(0x00006000, PCI_CFLT); 2078 outl(0x00006000, PCI_CFLT);
2079 outl(iobase, PCI_CBIO); 2079 outl(iobase, PCI_CBIO);
2080 2080
2081 DevicePresent(dev, EISA_APROM); 2081 DevicePresent(dev, EISA_APROM);
2082 2082
2083 dev->irq = irq; 2083 dev->irq = irq;
@@ -2102,7 +2102,7 @@ static int __devexit de4x5_eisa_remove (struct device *device)
2102 2102
2103 dev = device->driver_data; 2103 dev = device->driver_data;
2104 iobase = dev->base_addr; 2104 iobase = dev->base_addr;
2105 2105
2106 unregister_netdev (dev); 2106 unregister_netdev (dev);
2107 free_netdev (dev); 2107 free_netdev (dev);
2108 release_region (iobase + DE4X5_EISA_IO_PORTS, DE4X5_EISA_TOTAL_SIZE); 2108 release_region (iobase + DE4X5_EISA_IO_PORTS, DE4X5_EISA_TOTAL_SIZE);
@@ -2131,11 +2131,11 @@ MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids);
2131 2131
2132/* 2132/*
2133** This function searches the current bus (which is >0) for a DECchip with an 2133** This function searches the current bus (which is >0) for a DECchip with an
2134** SROM, so that in multiport cards that have one SROM shared between multiple 2134** SROM, so that in multiport cards that have one SROM shared between multiple
2135** DECchips, we can find the base SROM irrespective of the BIOS scan direction. 2135** DECchips, we can find the base SROM irrespective of the BIOS scan direction.
2136** For single port cards this is a time waster... 2136** For single port cards this is a time waster...
2137*/ 2137*/
2138static void __devinit 2138static void __devinit
2139srom_search(struct net_device *dev, struct pci_dev *pdev) 2139srom_search(struct net_device *dev, struct pci_dev *pdev)
2140{ 2140{
2141 u_char pb; 2141 u_char pb;
@@ -2163,7 +2163,7 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
2163 /* Set the device number information */ 2163 /* Set the device number information */
2164 lp->device = PCI_SLOT(this_dev->devfn); 2164 lp->device = PCI_SLOT(this_dev->devfn);
2165 lp->bus_num = pb; 2165 lp->bus_num = pb;
2166 2166
2167 /* Set the chipset information */ 2167 /* Set the chipset information */
2168 if (is_DC2114x) { 2168 if (is_DC2114x) {
2169 device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); 2169 device = ((cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
@@ -2176,7 +2176,7 @@ srom_search(struct net_device *dev, struct pci_dev *pdev)
2176 /* Fetch the IRQ to be used */ 2176 /* Fetch the IRQ to be used */
2177 irq = this_dev->irq; 2177 irq = this_dev->irq;
2178 if ((irq == 0) || (irq == 0xff) || ((int)irq == -1)) continue; 2178 if ((irq == 0) || (irq == 0xff) || ((int)irq == -1)) continue;
2179 2179
2180 /* Check if I/O accesses are enabled */ 2180 /* Check if I/O accesses are enabled */
2181 pci_read_config_word(this_dev, PCI_COMMAND, &status); 2181 pci_read_config_word(this_dev, PCI_COMMAND, &status);
2182 if (!(status & PCI_COMMAND_IO)) continue; 2182 if (!(status & PCI_COMMAND_IO)) continue;
@@ -2254,7 +2254,7 @@ static int __devinit de4x5_pci_probe (struct pci_dev *pdev,
2254 lp = netdev_priv(dev); 2254 lp = netdev_priv(dev);
2255 lp->bus = PCI; 2255 lp->bus = PCI;
2256 lp->bus_num = 0; 2256 lp->bus_num = 0;
2257 2257
2258 /* Search for an SROM on this bus */ 2258 /* Search for an SROM on this bus */
2259 if (lp->bus_num != pb) { 2259 if (lp->bus_num != pb) {
2260 lp->bus_num = pb; 2260 lp->bus_num = pb;
@@ -2267,7 +2267,7 @@ static int __devinit de4x5_pci_probe (struct pci_dev *pdev,
2267 /* Set the device number information */ 2267 /* Set the device number information */
2268 lp->device = dev_num; 2268 lp->device = dev_num;
2269 lp->bus_num = pb; 2269 lp->bus_num = pb;
2270 2270
2271 /* Set the chipset information */ 2271 /* Set the chipset information */
2272 if (is_DC2114x) { 2272 if (is_DC2114x) {
2273 device = ((lp->cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143); 2273 device = ((lp->cfrv & CFRV_RN) < DC2114x_BRK ? DC21142 : DC21143);
@@ -2283,7 +2283,7 @@ static int __devinit de4x5_pci_probe (struct pci_dev *pdev,
2283 error = -ENODEV; 2283 error = -ENODEV;
2284 goto free_dev; 2284 goto free_dev;
2285 } 2285 }
2286 2286
2287 /* Check if I/O accesses and Bus Mastering are enabled */ 2287 /* Check if I/O accesses and Bus Mastering are enabled */
2288 pci_read_config_word(pdev, PCI_COMMAND, &status); 2288 pci_read_config_word(pdev, PCI_COMMAND, &status);
2289#ifdef __powerpc__ 2289#ifdef __powerpc__
@@ -2322,7 +2322,7 @@ static int __devinit de4x5_pci_probe (struct pci_dev *pdev,
2322 } 2322 }
2323 2323
2324 dev->irq = irq; 2324 dev->irq = irq;
2325 2325
2326 if ((error = de4x5_hw_init(dev, iobase, &pdev->dev))) { 2326 if ((error = de4x5_hw_init(dev, iobase, &pdev->dev))) {
2327 goto release; 2327 goto release;
2328 } 2328 }
@@ -2377,7 +2377,7 @@ static struct pci_driver de4x5_pci_driver = {
2377** Auto configure the media here rather than setting the port at compile 2377** Auto configure the media here rather than setting the port at compile
2378** time. This routine is called by de4x5_init() and when a loss of media is 2378** time. This routine is called by de4x5_init() and when a loss of media is
2379** detected (excessive collisions, loss of carrier, no carrier or link fail 2379** detected (excessive collisions, loss of carrier, no carrier or link fail
2380** [TP] or no recent receive activity) to check whether the user has been 2380** [TP] or no recent receive activity) to check whether the user has been
2381** sneaky and changed the port on us. 2381** sneaky and changed the port on us.
2382*/ 2382*/
2383static int 2383static int
@@ -2405,7 +2405,7 @@ autoconf_media(struct net_device *dev)
2405 } 2405 }
2406 2406
2407 enable_ast(dev, next_tick); 2407 enable_ast(dev, next_tick);
2408 2408
2409 return (lp->media); 2409 return (lp->media);
2410} 2410}
2411 2411
@@ -2428,7 +2428,7 @@ dc21040_autoconf(struct net_device *dev)
2428 u_long iobase = dev->base_addr; 2428 u_long iobase = dev->base_addr;
2429 int next_tick = DE4X5_AUTOSENSE_MS; 2429 int next_tick = DE4X5_AUTOSENSE_MS;
2430 s32 imr; 2430 s32 imr;
2431 2431
2432 switch (lp->media) { 2432 switch (lp->media) {
2433 case INIT: 2433 case INIT:
2434 DISABLE_IRQs; 2434 DISABLE_IRQs;
@@ -2447,36 +2447,36 @@ dc21040_autoconf(struct net_device *dev)
2447 lp->local_state = 0; 2447 lp->local_state = 0;
2448 next_tick = dc21040_autoconf(dev); 2448 next_tick = dc21040_autoconf(dev);
2449 break; 2449 break;
2450 2450
2451 case TP: 2451 case TP:
2452 next_tick = dc21040_state(dev, 0x8f01, 0xffff, 0x0000, 3000, BNC_AUI, 2452 next_tick = dc21040_state(dev, 0x8f01, 0xffff, 0x0000, 3000, BNC_AUI,
2453 TP_SUSPECT, test_tp); 2453 TP_SUSPECT, test_tp);
2454 break; 2454 break;
2455 2455
2456 case TP_SUSPECT: 2456 case TP_SUSPECT:
2457 next_tick = de4x5_suspect_state(dev, 1000, TP, test_tp, dc21040_autoconf); 2457 next_tick = de4x5_suspect_state(dev, 1000, TP, test_tp, dc21040_autoconf);
2458 break; 2458 break;
2459 2459
2460 case BNC: 2460 case BNC:
2461 case AUI: 2461 case AUI:
2462 case BNC_AUI: 2462 case BNC_AUI:
2463 next_tick = dc21040_state(dev, 0x8f09, 0x0705, 0x0006, 3000, EXT_SIA, 2463 next_tick = dc21040_state(dev, 0x8f09, 0x0705, 0x0006, 3000, EXT_SIA,
2464 BNC_AUI_SUSPECT, ping_media); 2464 BNC_AUI_SUSPECT, ping_media);
2465 break; 2465 break;
2466 2466
2467 case BNC_AUI_SUSPECT: 2467 case BNC_AUI_SUSPECT:
2468 next_tick = de4x5_suspect_state(dev, 1000, BNC_AUI, ping_media, dc21040_autoconf); 2468 next_tick = de4x5_suspect_state(dev, 1000, BNC_AUI, ping_media, dc21040_autoconf);
2469 break; 2469 break;
2470 2470
2471 case EXT_SIA: 2471 case EXT_SIA:
2472 next_tick = dc21040_state(dev, 0x3041, 0x0000, 0x0006, 3000, 2472 next_tick = dc21040_state(dev, 0x3041, 0x0000, 0x0006, 3000,
2473 NC, EXT_SIA_SUSPECT, ping_media); 2473 NC, EXT_SIA_SUSPECT, ping_media);
2474 break; 2474 break;
2475 2475
2476 case EXT_SIA_SUSPECT: 2476 case EXT_SIA_SUSPECT:
2477 next_tick = de4x5_suspect_state(dev, 1000, EXT_SIA, ping_media, dc21040_autoconf); 2477 next_tick = de4x5_suspect_state(dev, 1000, EXT_SIA, ping_media, dc21040_autoconf);
2478 break; 2478 break;
2479 2479
2480 case NC: 2480 case NC:
2481 /* default to TP for all */ 2481 /* default to TP for all */
2482 reset_init_sia(dev, 0x8f01, 0xffff, 0x0000); 2482 reset_init_sia(dev, 0x8f01, 0xffff, 0x0000);
@@ -2488,13 +2488,13 @@ dc21040_autoconf(struct net_device *dev)
2488 lp->tx_enable = NO; 2488 lp->tx_enable = NO;
2489 break; 2489 break;
2490 } 2490 }
2491 2491
2492 return next_tick; 2492 return next_tick;
2493} 2493}
2494 2494
2495static int 2495static int
2496dc21040_state(struct net_device *dev, int csr13, int csr14, int csr15, int timeout, 2496dc21040_state(struct net_device *dev, int csr13, int csr14, int csr15, int timeout,
2497 int next_state, int suspect_state, 2497 int next_state, int suspect_state,
2498 int (*fn)(struct net_device *, int)) 2498 int (*fn)(struct net_device *, int))
2499{ 2499{
2500 struct de4x5_private *lp = netdev_priv(dev); 2500 struct de4x5_private *lp = netdev_priv(dev);
@@ -2507,7 +2507,7 @@ dc21040_state(struct net_device *dev, int csr13, int csr14, int csr15, int timeo
2507 lp->local_state++; 2507 lp->local_state++;
2508 next_tick = 500; 2508 next_tick = 500;
2509 break; 2509 break;
2510 2510
2511 case 1: 2511 case 1:
2512 if (!lp->tx_enable) { 2512 if (!lp->tx_enable) {
2513 linkBad = fn(dev, timeout); 2513 linkBad = fn(dev, timeout);
@@ -2527,7 +2527,7 @@ dc21040_state(struct net_device *dev, int csr13, int csr14, int csr15, int timeo
2527 } 2527 }
2528 break; 2528 break;
2529 } 2529 }
2530 2530
2531 return next_tick; 2531 return next_tick;
2532} 2532}
2533 2533
@@ -2582,7 +2582,7 @@ dc21041_autoconf(struct net_device *dev)
2582 u_long iobase = dev->base_addr; 2582 u_long iobase = dev->base_addr;
2583 s32 sts, irqs, irq_mask, imr, omr; 2583 s32 sts, irqs, irq_mask, imr, omr;
2584 int next_tick = DE4X5_AUTOSENSE_MS; 2584 int next_tick = DE4X5_AUTOSENSE_MS;
2585 2585
2586 switch (lp->media) { 2586 switch (lp->media) {
2587 case INIT: 2587 case INIT:
2588 DISABLE_IRQs; 2588 DISABLE_IRQs;
@@ -2603,7 +2603,7 @@ dc21041_autoconf(struct net_device *dev)
2603 lp->local_state = 0; 2603 lp->local_state = 0;
2604 next_tick = dc21041_autoconf(dev); 2604 next_tick = dc21041_autoconf(dev);
2605 break; 2605 break;
2606 2606
2607 case TP_NW: 2607 case TP_NW:
2608 if (lp->timeout < 0) { 2608 if (lp->timeout < 0) {
2609 omr = inl(DE4X5_OMR);/* Set up full duplex for the autonegotiate */ 2609 omr = inl(DE4X5_OMR);/* Set up full duplex for the autonegotiate */
@@ -2623,7 +2623,7 @@ dc21041_autoconf(struct net_device *dev)
2623 next_tick = dc21041_autoconf(dev); 2623 next_tick = dc21041_autoconf(dev);
2624 } 2624 }
2625 break; 2625 break;
2626 2626
2627 case ANS: 2627 case ANS:
2628 if (!lp->tx_enable) { 2628 if (!lp->tx_enable) {
2629 irqs = STS_LNP; 2629 irqs = STS_LNP;
@@ -2645,11 +2645,11 @@ dc21041_autoconf(struct net_device *dev)
2645 next_tick = 3000; 2645 next_tick = 3000;
2646 } 2646 }
2647 break; 2647 break;
2648 2648
2649 case ANS_SUSPECT: 2649 case ANS_SUSPECT:
2650 next_tick = de4x5_suspect_state(dev, 1000, ANS, test_tp, dc21041_autoconf); 2650 next_tick = de4x5_suspect_state(dev, 1000, ANS, test_tp, dc21041_autoconf);
2651 break; 2651 break;
2652 2652
2653 case TP: 2653 case TP:
2654 if (!lp->tx_enable) { 2654 if (!lp->tx_enable) {
2655 if (lp->timeout < 0) { 2655 if (lp->timeout < 0) {
@@ -2679,11 +2679,11 @@ dc21041_autoconf(struct net_device *dev)
2679 next_tick = 3000; 2679 next_tick = 3000;
2680 } 2680 }
2681 break; 2681 break;
2682 2682
2683 case TP_SUSPECT: 2683 case TP_SUSPECT:
2684 next_tick = de4x5_suspect_state(dev, 1000, TP, test_tp, dc21041_autoconf); 2684 next_tick = de4x5_suspect_state(dev, 1000, TP, test_tp, dc21041_autoconf);
2685 break; 2685 break;
2686 2686
2687 case AUI: 2687 case AUI:
2688 if (!lp->tx_enable) { 2688 if (!lp->tx_enable) {
2689 if (lp->timeout < 0) { 2689 if (lp->timeout < 0) {
@@ -2709,11 +2709,11 @@ dc21041_autoconf(struct net_device *dev)
2709 next_tick = 3000; 2709 next_tick = 3000;
2710 } 2710 }
2711 break; 2711 break;
2712 2712
2713 case AUI_SUSPECT: 2713 case AUI_SUSPECT:
2714 next_tick = de4x5_suspect_state(dev, 1000, AUI, ping_media, dc21041_autoconf); 2714 next_tick = de4x5_suspect_state(dev, 1000, AUI, ping_media, dc21041_autoconf);
2715 break; 2715 break;
2716 2716
2717 case BNC: 2717 case BNC:
2718 switch (lp->local_state) { 2718 switch (lp->local_state) {
2719 case 0: 2719 case 0:
@@ -2731,7 +2731,7 @@ dc21041_autoconf(struct net_device *dev)
2731 next_tick = dc21041_autoconf(dev); 2731 next_tick = dc21041_autoconf(dev);
2732 } 2732 }
2733 break; 2733 break;
2734 2734
2735 case 1: 2735 case 1:
2736 if (!lp->tx_enable) { 2736 if (!lp->tx_enable) {
2737 if ((sts = ping_media(dev, 3000)) < 0) { 2737 if ((sts = ping_media(dev, 3000)) < 0) {
@@ -2751,11 +2751,11 @@ dc21041_autoconf(struct net_device *dev)
2751 break; 2751 break;
2752 } 2752 }
2753 break; 2753 break;
2754 2754
2755 case BNC_SUSPECT: 2755 case BNC_SUSPECT:
2756 next_tick = de4x5_suspect_state(dev, 1000, BNC, ping_media, dc21041_autoconf); 2756 next_tick = de4x5_suspect_state(dev, 1000, BNC, ping_media, dc21041_autoconf);
2757 break; 2757 break;
2758 2758
2759 case NC: 2759 case NC:
2760 omr = inl(DE4X5_OMR); /* Set up full duplex for the autonegotiate */ 2760 omr = inl(DE4X5_OMR); /* Set up full duplex for the autonegotiate */
2761 outl(omr | OMR_FDX, DE4X5_OMR); 2761 outl(omr | OMR_FDX, DE4X5_OMR);
@@ -2768,7 +2768,7 @@ dc21041_autoconf(struct net_device *dev)
2768 lp->tx_enable = NO; 2768 lp->tx_enable = NO;
2769 break; 2769 break;
2770 } 2770 }
2771 2771
2772 return next_tick; 2772 return next_tick;
2773} 2773}
2774 2774
@@ -2784,9 +2784,9 @@ dc21140m_autoconf(struct net_device *dev)
2784 int ana, anlpa, cap, cr, slnk, sr; 2784 int ana, anlpa, cap, cr, slnk, sr;
2785 int next_tick = DE4X5_AUTOSENSE_MS; 2785 int next_tick = DE4X5_AUTOSENSE_MS;
2786 u_long imr, omr, iobase = dev->base_addr; 2786 u_long imr, omr, iobase = dev->base_addr;
2787 2787
2788 switch(lp->media) { 2788 switch(lp->media) {
2789 case INIT: 2789 case INIT:
2790 if (lp->timeout < 0) { 2790 if (lp->timeout < 0) {
2791 DISABLE_IRQs; 2791 DISABLE_IRQs;
2792 lp->tx_enable = FALSE; 2792 lp->tx_enable = FALSE;
@@ -2813,7 +2813,7 @@ dc21140m_autoconf(struct net_device *dev)
2813 lp->media = _100Mb; 2813 lp->media = _100Mb;
2814 } else if (lp->autosense == _10Mb) { 2814 } else if (lp->autosense == _10Mb) {
2815 lp->media = _10Mb; 2815 lp->media = _10Mb;
2816 } else if ((lp->autosense == AUTO) && 2816 } else if ((lp->autosense == AUTO) &&
2817 ((sr=is_anc_capable(dev)) & MII_SR_ANC)) { 2817 ((sr=is_anc_capable(dev)) & MII_SR_ANC)) {
2818 ana = (((sr >> 6) & MII_ANA_TAF) | MII_ANA_CSMA); 2818 ana = (((sr >> 6) & MII_ANA_TAF) | MII_ANA_CSMA);
2819 ana &= (lp->fdx ? ~0 : ~MII_ANA_FDAM); 2819 ana &= (lp->fdx ? ~0 : ~MII_ANA_FDAM);
@@ -2831,7 +2831,7 @@ dc21140m_autoconf(struct net_device *dev)
2831 next_tick = dc21140m_autoconf(dev); 2831 next_tick = dc21140m_autoconf(dev);
2832 } 2832 }
2833 break; 2833 break;
2834 2834
2835 case ANS: 2835 case ANS:
2836 switch (lp->local_state) { 2836 switch (lp->local_state) {
2837 case 0: 2837 case 0:
@@ -2851,7 +2851,7 @@ dc21140m_autoconf(struct net_device *dev)
2851 next_tick = dc21140m_autoconf(dev); 2851 next_tick = dc21140m_autoconf(dev);
2852 } 2852 }
2853 break; 2853 break;
2854 2854
2855 case 1: 2855 case 1:
2856 if ((sr=test_mii_reg(dev, MII_SR, MII_SR_ASSC, TRUE, 2000)) < 0) { 2856 if ((sr=test_mii_reg(dev, MII_SR, MII_SR_ASSC, TRUE, 2000)) < 0) {
2857 next_tick = sr & ~TIMER_CB; 2857 next_tick = sr & ~TIMER_CB;
@@ -2862,7 +2862,7 @@ dc21140m_autoconf(struct net_device *dev)
2862 lp->tmp = MII_SR_ASSC; 2862 lp->tmp = MII_SR_ASSC;
2863 anlpa = mii_rd(MII_ANLPA, lp->phy[lp->active].addr, DE4X5_MII); 2863 anlpa = mii_rd(MII_ANLPA, lp->phy[lp->active].addr, DE4X5_MII);
2864 ana = mii_rd(MII_ANA, lp->phy[lp->active].addr, DE4X5_MII); 2864 ana = mii_rd(MII_ANA, lp->phy[lp->active].addr, DE4X5_MII);
2865 if (!(anlpa & MII_ANLPA_RF) && 2865 if (!(anlpa & MII_ANLPA_RF) &&
2866 (cap = anlpa & MII_ANLPA_TAF & ana)) { 2866 (cap = anlpa & MII_ANLPA_TAF & ana)) {
2867 if (cap & MII_ANA_100M) { 2867 if (cap & MII_ANA_100M) {
2868 lp->fdx = ((ana & anlpa & MII_ANA_FDAM & MII_ANA_100M) ? TRUE : FALSE); 2868 lp->fdx = ((ana & anlpa & MII_ANA_FDAM & MII_ANA_100M) ? TRUE : FALSE);
@@ -2879,10 +2879,10 @@ dc21140m_autoconf(struct net_device *dev)
2879 break; 2879 break;
2880 } 2880 }
2881 break; 2881 break;
2882 2882
2883 case SPD_DET: /* Choose 10Mb/s or 100Mb/s */ 2883 case SPD_DET: /* Choose 10Mb/s or 100Mb/s */
2884 if (lp->timeout < 0) { 2884 if (lp->timeout < 0) {
2885 lp->tmp = (lp->phy[lp->active].id ? MII_SR_LKS : 2885 lp->tmp = (lp->phy[lp->active].id ? MII_SR_LKS :
2886 (~gep_rd(dev) & GEP_LNP)); 2886 (~gep_rd(dev) & GEP_LNP));
2887 SET_100Mb_PDET; 2887 SET_100Mb_PDET;
2888 } 2888 }
@@ -2899,7 +2899,7 @@ dc21140m_autoconf(struct net_device *dev)
2899 next_tick = dc21140m_autoconf(dev); 2899 next_tick = dc21140m_autoconf(dev);
2900 } 2900 }
2901 break; 2901 break;
2902 2902
2903 case _100Mb: /* Set 100Mb/s */ 2903 case _100Mb: /* Set 100Mb/s */
2904 next_tick = 3000; 2904 next_tick = 3000;
2905 if (!lp->tx_enable) { 2905 if (!lp->tx_enable) {
@@ -2933,7 +2933,7 @@ dc21140m_autoconf(struct net_device *dev)
2933 } 2933 }
2934 } 2934 }
2935 break; 2935 break;
2936 2936
2937 case NC: 2937 case NC:
2938 if (lp->media != lp->c_media) { 2938 if (lp->media != lp->c_media) {
2939 de4x5_dbg_media(dev); 2939 de4x5_dbg_media(dev);
@@ -2943,7 +2943,7 @@ dc21140m_autoconf(struct net_device *dev)
2943 lp->tx_enable = FALSE; 2943 lp->tx_enable = FALSE;
2944 break; 2944 break;
2945 } 2945 }
2946 2946
2947 return next_tick; 2947 return next_tick;
2948} 2948}
2949 2949
@@ -3002,7 +3002,7 @@ dc2114x_autoconf(struct net_device *dev)
3002 lp->media = AUI; 3002 lp->media = AUI;
3003 } else { 3003 } else {
3004 lp->media = SPD_DET; 3004 lp->media = SPD_DET;
3005 if ((lp->infoblock_media == ANS) && 3005 if ((lp->infoblock_media == ANS) &&
3006 ((sr=is_anc_capable(dev)) & MII_SR_ANC)) { 3006 ((sr=is_anc_capable(dev)) & MII_SR_ANC)) {
3007 ana = (((sr >> 6) & MII_ANA_TAF) | MII_ANA_CSMA); 3007 ana = (((sr >> 6) & MII_ANA_TAF) | MII_ANA_CSMA);
3008 ana &= (lp->fdx ? ~0 : ~MII_ANA_FDAM); 3008 ana &= (lp->fdx ? ~0 : ~MII_ANA_FDAM);
@@ -3014,7 +3014,7 @@ dc2114x_autoconf(struct net_device *dev)
3014 next_tick = dc2114x_autoconf(dev); 3014 next_tick = dc2114x_autoconf(dev);
3015 } 3015 }
3016 break; 3016 break;
3017 3017
3018 case ANS: 3018 case ANS:
3019 switch (lp->local_state) { 3019 switch (lp->local_state) {
3020 case 0: 3020 case 0:
@@ -3034,7 +3034,7 @@ dc2114x_autoconf(struct net_device *dev)
3034 next_tick = dc2114x_autoconf(dev); 3034 next_tick = dc2114x_autoconf(dev);
3035 } 3035 }
3036 break; 3036 break;
3037 3037
3038 case 1: 3038 case 1:
3039 if ((sr=test_mii_reg(dev, MII_SR, MII_SR_ASSC, TRUE, 2000)) < 0) { 3039 if ((sr=test_mii_reg(dev, MII_SR, MII_SR_ASSC, TRUE, 2000)) < 0) {
3040 next_tick = sr & ~TIMER_CB; 3040 next_tick = sr & ~TIMER_CB;
@@ -3045,7 +3045,7 @@ dc2114x_autoconf(struct net_device *dev)
3045 lp->tmp = MII_SR_ASSC; 3045 lp->tmp = MII_SR_ASSC;
3046 anlpa = mii_rd(MII_ANLPA, lp->phy[lp->active].addr, DE4X5_MII); 3046 anlpa = mii_rd(MII_ANLPA, lp->phy[lp->active].addr, DE4X5_MII);
3047 ana = mii_rd(MII_ANA, lp->phy[lp->active].addr, DE4X5_MII); 3047 ana = mii_rd(MII_ANA, lp->phy[lp->active].addr, DE4X5_MII);
3048 if (!(anlpa & MII_ANLPA_RF) && 3048 if (!(anlpa & MII_ANLPA_RF) &&
3049 (cap = anlpa & MII_ANLPA_TAF & ana)) { 3049 (cap = anlpa & MII_ANLPA_TAF & ana)) {
3050 if (cap & MII_ANA_100M) { 3050 if (cap & MII_ANA_100M) {
3051 lp->fdx = ((ana & anlpa & MII_ANA_FDAM & MII_ANA_100M) ? TRUE : FALSE); 3051 lp->fdx = ((ana & anlpa & MII_ANA_FDAM & MII_ANA_100M) ? TRUE : FALSE);
@@ -3087,11 +3087,11 @@ dc2114x_autoconf(struct net_device *dev)
3087 next_tick = 3000; 3087 next_tick = 3000;
3088 } 3088 }
3089 break; 3089 break;
3090 3090
3091 case AUI_SUSPECT: 3091 case AUI_SUSPECT:
3092 next_tick = de4x5_suspect_state(dev, 1000, AUI, ping_media, dc2114x_autoconf); 3092 next_tick = de4x5_suspect_state(dev, 1000, AUI, ping_media, dc2114x_autoconf);
3093 break; 3093 break;
3094 3094
3095 case BNC: 3095 case BNC:
3096 switch (lp->local_state) { 3096 switch (lp->local_state) {
3097 case 0: 3097 case 0:
@@ -3109,7 +3109,7 @@ dc2114x_autoconf(struct net_device *dev)
3109 next_tick = dc2114x_autoconf(dev); 3109 next_tick = dc2114x_autoconf(dev);
3110 } 3110 }
3111 break; 3111 break;
3112 3112
3113 case 1: 3113 case 1:
3114 if (!lp->tx_enable) { 3114 if (!lp->tx_enable) {
3115 if ((sts = ping_media(dev, 3000)) < 0) { 3115 if ((sts = ping_media(dev, 3000)) < 0) {
@@ -3130,11 +3130,11 @@ dc2114x_autoconf(struct net_device *dev)
3130 break; 3130 break;
3131 } 3131 }
3132 break; 3132 break;
3133 3133
3134 case BNC_SUSPECT: 3134 case BNC_SUSPECT:
3135 next_tick = de4x5_suspect_state(dev, 1000, BNC, ping_media, dc2114x_autoconf); 3135 next_tick = de4x5_suspect_state(dev, 1000, BNC, ping_media, dc2114x_autoconf);
3136 break; 3136 break;
3137 3137
3138 case SPD_DET: /* Choose 10Mb/s or 100Mb/s */ 3138 case SPD_DET: /* Choose 10Mb/s or 100Mb/s */
3139 if (srom_map_media(dev) < 0) { 3139 if (srom_map_media(dev) < 0) {
3140 lp->tcount++; 3140 lp->tcount++;
@@ -3161,7 +3161,7 @@ dc2114x_autoconf(struct net_device *dev)
3161 next_tick = dc2114x_autoconf(dev); 3161 next_tick = dc2114x_autoconf(dev);
3162 } else if (((lp->media == _100Mb) && is_100_up(dev)) || 3162 } else if (((lp->media == _100Mb) && is_100_up(dev)) ||
3163 (((lp->media == _10Mb) || (lp->media == TP) || 3163 (((lp->media == _10Mb) || (lp->media == TP) ||
3164 (lp->media == BNC) || (lp->media == AUI)) && 3164 (lp->media == BNC) || (lp->media == AUI)) &&
3165 is_10_up(dev))) { 3165 is_10_up(dev))) {
3166 next_tick = dc2114x_autoconf(dev); 3166 next_tick = dc2114x_autoconf(dev);
3167 } else { 3167 } else {
@@ -3169,7 +3169,7 @@ dc2114x_autoconf(struct net_device *dev)
3169 lp->media = INIT; 3169 lp->media = INIT;
3170 } 3170 }
3171 break; 3171 break;
3172 3172
3173 case _10Mb: 3173 case _10Mb:
3174 next_tick = 3000; 3174 next_tick = 3000;
3175 if (!lp->tx_enable) { 3175 if (!lp->tx_enable) {
@@ -3208,7 +3208,7 @@ printk("Huh?: media:%02x\n", lp->media);
3208 lp->media = INIT; 3208 lp->media = INIT;
3209 break; 3209 break;
3210 } 3210 }
3211 3211
3212 return next_tick; 3212 return next_tick;
3213} 3213}
3214 3214
@@ -3231,7 +3231,7 @@ srom_map_media(struct net_device *dev)
3231 struct de4x5_private *lp = netdev_priv(dev); 3231 struct de4x5_private *lp = netdev_priv(dev);
3232 3232
3233 lp->fdx = 0; 3233 lp->fdx = 0;
3234 if (lp->infoblock_media == lp->media) 3234 if (lp->infoblock_media == lp->media)
3235 return 0; 3235 return 0;
3236 3236
3237 switch(lp->infoblock_media) { 3237 switch(lp->infoblock_media) {
@@ -3270,7 +3270,7 @@ srom_map_media(struct net_device *dev)
3270 case SROM_100BASEFF: 3270 case SROM_100BASEFF:
3271 if (!lp->params.fdx) return -1; 3271 if (!lp->params.fdx) return -1;
3272 lp->fdx = TRUE; 3272 lp->fdx = TRUE;
3273 case SROM_100BASEF: 3273 case SROM_100BASEF:
3274 if (lp->params.fdx && !lp->fdx) return -1; 3274 if (lp->params.fdx && !lp->fdx) return -1;
3275 lp->media = _100Mb; 3275 lp->media = _100Mb;
3276 break; 3276 break;
@@ -3280,8 +3280,8 @@ srom_map_media(struct net_device *dev)
3280 lp->fdx = lp->params.fdx; 3280 lp->fdx = lp->params.fdx;
3281 break; 3281 break;
3282 3282
3283 default: 3283 default:
3284 printk("%s: Bad media code [%d] detected in SROM!\n", dev->name, 3284 printk("%s: Bad media code [%d] detected in SROM!\n", dev->name,
3285 lp->infoblock_media); 3285 lp->infoblock_media);
3286 return -1; 3286 return -1;
3287 break; 3287 break;
@@ -3359,7 +3359,7 @@ test_media(struct net_device *dev, s32 irqs, s32 irq_mask, s32 csr13, s32 csr14,
3359 struct de4x5_private *lp = netdev_priv(dev); 3359 struct de4x5_private *lp = netdev_priv(dev);
3360 u_long iobase = dev->base_addr; 3360 u_long iobase = dev->base_addr;
3361 s32 sts, csr12; 3361 s32 sts, csr12;
3362 3362
3363 if (lp->timeout < 0) { 3363 if (lp->timeout < 0) {
3364 lp->timeout = msec/100; 3364 lp->timeout = msec/100;
3365 if (!lp->useSROM) { /* Already done if by SROM, else dc2104[01] */ 3365 if (!lp->useSROM) { /* Already done if by SROM, else dc2104[01] */
@@ -3372,22 +3372,22 @@ test_media(struct net_device *dev, s32 irqs, s32 irq_mask, s32 csr13, s32 csr14,
3372 /* clear all pending interrupts */ 3372 /* clear all pending interrupts */
3373 sts = inl(DE4X5_STS); 3373 sts = inl(DE4X5_STS);
3374 outl(sts, DE4X5_STS); 3374 outl(sts, DE4X5_STS);
3375 3375
3376 /* clear csr12 NRA and SRA bits */ 3376 /* clear csr12 NRA and SRA bits */
3377 if ((lp->chipset == DC21041) || lp->useSROM) { 3377 if ((lp->chipset == DC21041) || lp->useSROM) {
3378 csr12 = inl(DE4X5_SISR); 3378 csr12 = inl(DE4X5_SISR);
3379 outl(csr12, DE4X5_SISR); 3379 outl(csr12, DE4X5_SISR);
3380 } 3380 }
3381 } 3381 }
3382 3382
3383 sts = inl(DE4X5_STS) & ~TIMER_CB; 3383 sts = inl(DE4X5_STS) & ~TIMER_CB;
3384 3384
3385 if (!(sts & irqs) && --lp->timeout) { 3385 if (!(sts & irqs) && --lp->timeout) {
3386 sts = 100 | TIMER_CB; 3386 sts = 100 | TIMER_CB;
3387 } else { 3387 } else {
3388 lp->timeout = -1; 3388 lp->timeout = -1;
3389 } 3389 }
3390 3390
3391 return sts; 3391 return sts;
3392} 3392}
3393 3393
@@ -3397,11 +3397,11 @@ test_tp(struct net_device *dev, s32 msec)
3397 struct de4x5_private *lp = netdev_priv(dev); 3397 struct de4x5_private *lp = netdev_priv(dev);
3398 u_long iobase = dev->base_addr; 3398 u_long iobase = dev->base_addr;
3399 int sisr; 3399 int sisr;
3400 3400
3401 if (lp->timeout < 0) { 3401 if (lp->timeout < 0) {
3402 lp->timeout = msec/100; 3402 lp->timeout = msec/100;
3403 } 3403 }
3404 3404
3405 sisr = (inl(DE4X5_SISR) & ~TIMER_CB) & (SISR_LKF | SISR_NCR); 3405 sisr = (inl(DE4X5_SISR) & ~TIMER_CB) & (SISR_LKF | SISR_NCR);
3406 3406
3407 if (sisr && --lp->timeout) { 3407 if (sisr && --lp->timeout) {
@@ -3409,7 +3409,7 @@ test_tp(struct net_device *dev, s32 msec)
3409 } else { 3409 } else {
3410 lp->timeout = -1; 3410 lp->timeout = -1;
3411 } 3411 }
3412 3412
3413 return sisr; 3413 return sisr;
3414} 3414}
3415 3415
@@ -3436,7 +3436,7 @@ test_for_100Mb(struct net_device *dev, int msec)
3436 lp->timeout = msec/SAMPLE_INTERVAL; 3436 lp->timeout = msec/SAMPLE_INTERVAL;
3437 } 3437 }
3438 } 3438 }
3439 3439
3440 if (lp->phy[lp->active].id || lp->useSROM) { 3440 if (lp->phy[lp->active].id || lp->useSROM) {
3441 gep = is_100_up(dev) | is_spd_100(dev); 3441 gep = is_100_up(dev) | is_spd_100(dev);
3442 } else { 3442 } else {
@@ -3447,7 +3447,7 @@ test_for_100Mb(struct net_device *dev, int msec)
3447 } else { 3447 } else {
3448 lp->timeout = -1; 3448 lp->timeout = -1;
3449 } 3449 }
3450 3450
3451 return gep; 3451 return gep;
3452} 3452}
3453 3453
@@ -3459,13 +3459,13 @@ wait_for_link(struct net_device *dev)
3459 if (lp->timeout < 0) { 3459 if (lp->timeout < 0) {
3460 lp->timeout = 1; 3460 lp->timeout = 1;
3461 } 3461 }
3462 3462
3463 if (lp->timeout--) { 3463 if (lp->timeout--) {
3464 return TIMER_CB; 3464 return TIMER_CB;
3465 } else { 3465 } else {
3466 lp->timeout = -1; 3466 lp->timeout = -1;
3467 } 3467 }
3468 3468
3469 return 0; 3469 return 0;
3470} 3470}
3471 3471
@@ -3479,21 +3479,21 @@ test_mii_reg(struct net_device *dev, int reg, int mask, int pol, long msec)
3479 struct de4x5_private *lp = netdev_priv(dev); 3479 struct de4x5_private *lp = netdev_priv(dev);
3480 int test; 3480 int test;
3481 u_long iobase = dev->base_addr; 3481 u_long iobase = dev->base_addr;
3482 3482
3483 if (lp->timeout < 0) { 3483 if (lp->timeout < 0) {
3484 lp->timeout = msec/100; 3484 lp->timeout = msec/100;
3485 } 3485 }
3486 3486
3487 if (pol) pol = ~0; 3487 if (pol) pol = ~0;
3488 reg = mii_rd((u_char)reg, lp->phy[lp->active].addr, DE4X5_MII) & mask; 3488 reg = mii_rd((u_char)reg, lp->phy[lp->active].addr, DE4X5_MII) & mask;
3489 test = (reg ^ pol) & mask; 3489 test = (reg ^ pol) & mask;
3490 3490
3491 if (test && --lp->timeout) { 3491 if (test && --lp->timeout) {
3492 reg = 100 | TIMER_CB; 3492 reg = 100 | TIMER_CB;
3493 } else { 3493 } else {
3494 lp->timeout = -1; 3494 lp->timeout = -1;
3495 } 3495 }
3496 3496
3497 return reg; 3497 return reg;
3498} 3498}
3499 3499
@@ -3503,7 +3503,7 @@ is_spd_100(struct net_device *dev)
3503 struct de4x5_private *lp = netdev_priv(dev); 3503 struct de4x5_private *lp = netdev_priv(dev);
3504 u_long iobase = dev->base_addr; 3504 u_long iobase = dev->base_addr;
3505 int spd; 3505 int spd;
3506 3506
3507 if (lp->useMII) { 3507 if (lp->useMII) {
3508 spd = mii_rd(lp->phy[lp->active].spd.reg, lp->phy[lp->active].addr, DE4X5_MII); 3508 spd = mii_rd(lp->phy[lp->active].spd.reg, lp->phy[lp->active].addr, DE4X5_MII);
3509 spd = ~(spd ^ lp->phy[lp->active].spd.value); 3509 spd = ~(spd ^ lp->phy[lp->active].spd.value);
@@ -3517,7 +3517,7 @@ is_spd_100(struct net_device *dev)
3517 spd = (lp->asBitValid & (lp->asPolarity ^ (gep_rd(dev) & lp->asBit))) | 3517 spd = (lp->asBitValid & (lp->asPolarity ^ (gep_rd(dev) & lp->asBit))) |
3518 (lp->linkOK & ~lp->asBitValid); 3518 (lp->linkOK & ~lp->asBitValid);
3519 } 3519 }
3520 3520
3521 return spd; 3521 return spd;
3522} 3522}
3523 3523
@@ -3526,7 +3526,7 @@ is_100_up(struct net_device *dev)
3526{ 3526{
3527 struct de4x5_private *lp = netdev_priv(dev); 3527 struct de4x5_private *lp = netdev_priv(dev);
3528 u_long iobase = dev->base_addr; 3528 u_long iobase = dev->base_addr;
3529 3529
3530 if (lp->useMII) { 3530 if (lp->useMII) {
3531 /* Double read for sticky bits & temporary drops */ 3531 /* Double read for sticky bits & temporary drops */
3532 mii_rd(MII_SR, lp->phy[lp->active].addr, DE4X5_MII); 3532 mii_rd(MII_SR, lp->phy[lp->active].addr, DE4X5_MII);
@@ -3547,7 +3547,7 @@ is_10_up(struct net_device *dev)
3547{ 3547{
3548 struct de4x5_private *lp = netdev_priv(dev); 3548 struct de4x5_private *lp = netdev_priv(dev);
3549 u_long iobase = dev->base_addr; 3549 u_long iobase = dev->base_addr;
3550 3550
3551 if (lp->useMII) { 3551 if (lp->useMII) {
3552 /* Double read for sticky bits & temporary drops */ 3552 /* Double read for sticky bits & temporary drops */
3553 mii_rd(MII_SR, lp->phy[lp->active].addr, DE4X5_MII); 3553 mii_rd(MII_SR, lp->phy[lp->active].addr, DE4X5_MII);
@@ -3570,7 +3570,7 @@ is_anc_capable(struct net_device *dev)
3570{ 3570{
3571 struct de4x5_private *lp = netdev_priv(dev); 3571 struct de4x5_private *lp = netdev_priv(dev);
3572 u_long iobase = dev->base_addr; 3572 u_long iobase = dev->base_addr;
3573 3573
3574 if (lp->phy[lp->active].id && (!lp->useSROM || lp->useMII)) { 3574 if (lp->phy[lp->active].id && (!lp->useSROM || lp->useMII)) {
3575 return (mii_rd(MII_SR, lp->phy[lp->active].addr, DE4X5_MII)); 3575 return (mii_rd(MII_SR, lp->phy[lp->active].addr, DE4X5_MII));
3576 } else if ((lp->chipset & ~0x00ff) == DC2114x) { 3576 } else if ((lp->chipset & ~0x00ff) == DC2114x) {
@@ -3590,24 +3590,24 @@ ping_media(struct net_device *dev, int msec)
3590 struct de4x5_private *lp = netdev_priv(dev); 3590 struct de4x5_private *lp = netdev_priv(dev);
3591 u_long iobase = dev->base_addr; 3591 u_long iobase = dev->base_addr;
3592 int sisr; 3592 int sisr;
3593 3593
3594 if (lp->timeout < 0) { 3594 if (lp->timeout < 0) {
3595 lp->timeout = msec/100; 3595 lp->timeout = msec/100;
3596 3596
3597 lp->tmp = lp->tx_new; /* Remember the ring position */ 3597 lp->tmp = lp->tx_new; /* Remember the ring position */
3598 load_packet(dev, lp->frame, TD_LS | TD_FS | sizeof(lp->frame), (struct sk_buff *)1); 3598 load_packet(dev, lp->frame, TD_LS | TD_FS | sizeof(lp->frame), (struct sk_buff *)1);
3599 lp->tx_new = (++lp->tx_new) % lp->txRingSize; 3599 lp->tx_new = (++lp->tx_new) % lp->txRingSize;
3600 outl(POLL_DEMAND, DE4X5_TPD); 3600 outl(POLL_DEMAND, DE4X5_TPD);
3601 } 3601 }
3602 3602
3603 sisr = inl(DE4X5_SISR); 3603 sisr = inl(DE4X5_SISR);
3604 3604
3605 if ((!(sisr & SISR_NCR)) && 3605 if ((!(sisr & SISR_NCR)) &&
3606 ((s32)le32_to_cpu(lp->tx_ring[lp->tmp].status) < 0) && 3606 ((s32)le32_to_cpu(lp->tx_ring[lp->tmp].status) < 0) &&
3607 (--lp->timeout)) { 3607 (--lp->timeout)) {
3608 sisr = 100 | TIMER_CB; 3608 sisr = 100 | TIMER_CB;
3609 } else { 3609 } else {
3610 if ((!(sisr & SISR_NCR)) && 3610 if ((!(sisr & SISR_NCR)) &&
3611 !(le32_to_cpu(lp->tx_ring[lp->tmp].status) & (T_OWN | TD_ES)) && 3611 !(le32_to_cpu(lp->tx_ring[lp->tmp].status) & (T_OWN | TD_ES)) &&
3612 lp->timeout) { 3612 lp->timeout) {
3613 sisr = 0; 3613 sisr = 0;
@@ -3616,7 +3616,7 @@ ping_media(struct net_device *dev, int msec)
3616 } 3616 }
3617 lp->timeout = -1; 3617 lp->timeout = -1;
3618 } 3618 }
3619 3619
3620 return sisr; 3620 return sisr;
3621} 3621}
3622 3622
@@ -3668,7 +3668,7 @@ de4x5_alloc_rx_buff(struct net_device *dev, int index, int len)
3668 } else { /* Linear buffer */ 3668 } else { /* Linear buffer */
3669 memcpy(skb_put(p,len),lp->rx_bufs + lp->rx_old * RX_BUFF_SZ,len); 3669 memcpy(skb_put(p,len),lp->rx_bufs + lp->rx_old * RX_BUFF_SZ,len);
3670 } 3670 }
3671 3671
3672 return p; 3672 return p;
3673#endif 3673#endif
3674} 3674}
@@ -3751,23 +3751,23 @@ de4x5_rst_desc_ring(struct net_device *dev)
3751 outl(lp->dma_rings, DE4X5_RRBA); 3751 outl(lp->dma_rings, DE4X5_RRBA);
3752 outl(lp->dma_rings + NUM_RX_DESC * sizeof(struct de4x5_desc), 3752 outl(lp->dma_rings + NUM_RX_DESC * sizeof(struct de4x5_desc),
3753 DE4X5_TRBA); 3753 DE4X5_TRBA);
3754 3754
3755 lp->rx_new = lp->rx_old = 0; 3755 lp->rx_new = lp->rx_old = 0;
3756 lp->tx_new = lp->tx_old = 0; 3756 lp->tx_new = lp->tx_old = 0;
3757 3757
3758 for (i = 0; i < lp->rxRingSize; i++) { 3758 for (i = 0; i < lp->rxRingSize; i++) {
3759 lp->rx_ring[i].status = cpu_to_le32(R_OWN); 3759 lp->rx_ring[i].status = cpu_to_le32(R_OWN);
3760 } 3760 }
3761 3761
3762 for (i = 0; i < lp->txRingSize; i++) { 3762 for (i = 0; i < lp->txRingSize; i++) {
3763 lp->tx_ring[i].status = cpu_to_le32(0); 3763 lp->tx_ring[i].status = cpu_to_le32(0);
3764 } 3764 }
3765 3765
3766 barrier(); 3766 barrier();
3767 lp->cache.save_cnt--; 3767 lp->cache.save_cnt--;
3768 START_DE4X5; 3768 START_DE4X5;
3769 } 3769 }
3770 3770
3771 return; 3771 return;
3772} 3772}
3773 3773
@@ -3792,7 +3792,7 @@ de4x5_cache_state(struct net_device *dev, int flag)
3792 gep_wr(lp->cache.gepc, dev); 3792 gep_wr(lp->cache.gepc, dev);
3793 gep_wr(lp->cache.gep, dev); 3793 gep_wr(lp->cache.gep, dev);
3794 } else { 3794 } else {
3795 reset_init_sia(dev, lp->cache.csr13, lp->cache.csr14, 3795 reset_init_sia(dev, lp->cache.csr13, lp->cache.csr14,
3796 lp->cache.csr15); 3796 lp->cache.csr15);
3797 } 3797 }
3798 break; 3798 break;
@@ -3854,25 +3854,25 @@ test_ans(struct net_device *dev, s32 irqs, s32 irq_mask, s32 msec)
3854 struct de4x5_private *lp = netdev_priv(dev); 3854 struct de4x5_private *lp = netdev_priv(dev);
3855 u_long iobase = dev->base_addr; 3855 u_long iobase = dev->base_addr;
3856 s32 sts, ans; 3856 s32 sts, ans;
3857 3857
3858 if (lp->timeout < 0) { 3858 if (lp->timeout < 0) {
3859 lp->timeout = msec/100; 3859 lp->timeout = msec/100;
3860 outl(irq_mask, DE4X5_IMR); 3860 outl(irq_mask, DE4X5_IMR);
3861 3861
3862 /* clear all pending interrupts */ 3862 /* clear all pending interrupts */
3863 sts = inl(DE4X5_STS); 3863 sts = inl(DE4X5_STS);
3864 outl(sts, DE4X5_STS); 3864 outl(sts, DE4X5_STS);
3865 } 3865 }
3866 3866
3867 ans = inl(DE4X5_SISR) & SISR_ANS; 3867 ans = inl(DE4X5_SISR) & SISR_ANS;
3868 sts = inl(DE4X5_STS) & ~TIMER_CB; 3868 sts = inl(DE4X5_STS) & ~TIMER_CB;
3869 3869
3870 if (!(sts & irqs) && (ans ^ ANS_NWOK) && --lp->timeout) { 3870 if (!(sts & irqs) && (ans ^ ANS_NWOK) && --lp->timeout) {
3871 sts = 100 | TIMER_CB; 3871 sts = 100 | TIMER_CB;
3872 } else { 3872 } else {
3873 lp->timeout = -1; 3873 lp->timeout = -1;
3874 } 3874 }
3875 3875
3876 return sts; 3876 return sts;
3877} 3877}
3878 3878
@@ -3882,7 +3882,7 @@ de4x5_setup_intr(struct net_device *dev)
3882 struct de4x5_private *lp = netdev_priv(dev); 3882 struct de4x5_private *lp = netdev_priv(dev);
3883 u_long iobase = dev->base_addr; 3883 u_long iobase = dev->base_addr;
3884 s32 imr, sts; 3884 s32 imr, sts;
3885 3885
3886 if (inl(DE4X5_OMR) & OMR_SR) { /* Only unmask if TX/RX is enabled */ 3886 if (inl(DE4X5_OMR) & OMR_SR) { /* Only unmask if TX/RX is enabled */
3887 imr = 0; 3887 imr = 0;
3888 UNMASK_IRQs; 3888 UNMASK_IRQs;
@@ -3890,7 +3890,7 @@ de4x5_setup_intr(struct net_device *dev)
3890 outl(sts, DE4X5_STS); 3890 outl(sts, DE4X5_STS);
3891 ENABLE_IRQs; 3891 ENABLE_IRQs;
3892 } 3892 }
3893 3893
3894 return; 3894 return;
3895} 3895}
3896 3896
@@ -3936,17 +3936,17 @@ create_packet(struct net_device *dev, char *frame, int len)
3936{ 3936{
3937 int i; 3937 int i;
3938 char *buf = frame; 3938 char *buf = frame;
3939 3939
3940 for (i=0; i<ETH_ALEN; i++) { /* Use this source address */ 3940 for (i=0; i<ETH_ALEN; i++) { /* Use this source address */
3941 *buf++ = dev->dev_addr[i]; 3941 *buf++ = dev->dev_addr[i];
3942 } 3942 }
3943 for (i=0; i<ETH_ALEN; i++) { /* Use this destination address */ 3943 for (i=0; i<ETH_ALEN; i++) { /* Use this destination address */
3944 *buf++ = dev->dev_addr[i]; 3944 *buf++ = dev->dev_addr[i];
3945 } 3945 }
3946 3946
3947 *buf++ = 0; /* Packet length (2 bytes) */ 3947 *buf++ = 0; /* Packet length (2 bytes) */
3948 *buf++ = 1; 3948 *buf++ = 1;
3949 3949
3950 return; 3950 return;
3951} 3951}
3952 3952
@@ -3978,7 +3978,7 @@ static int
3978PCI_signature(char *name, struct de4x5_private *lp) 3978PCI_signature(char *name, struct de4x5_private *lp)
3979{ 3979{
3980 int i, status = 0, siglen = sizeof(de4x5_signatures)/sizeof(c_char *); 3980 int i, status = 0, siglen = sizeof(de4x5_signatures)/sizeof(c_char *);
3981 3981
3982 if (lp->chipset == DC21040) { 3982 if (lp->chipset == DC21040) {
3983 strcpy(name, "DE434/5"); 3983 strcpy(name, "DE434/5");
3984 return status; 3984 return status;
@@ -4007,7 +4007,7 @@ PCI_signature(char *name, struct de4x5_private *lp)
4007 } else if ((lp->chipset & ~0x00ff) == DC2114x) { 4007 } else if ((lp->chipset & ~0x00ff) == DC2114x) {
4008 lp->useSROM = TRUE; 4008 lp->useSROM = TRUE;
4009 } 4009 }
4010 4010
4011 return status; 4011 return status;
4012} 4012}
4013 4013
@@ -4024,7 +4024,7 @@ DevicePresent(struct net_device *dev, u_long aprom_addr)
4024{ 4024{
4025 int i, j=0; 4025 int i, j=0;
4026 struct de4x5_private *lp = netdev_priv(dev); 4026 struct de4x5_private *lp = netdev_priv(dev);
4027 4027
4028 if (lp->chipset == DC21040) { 4028 if (lp->chipset == DC21040) {
4029 if (lp->bus == EISA) { 4029 if (lp->bus == EISA) {
4030 enet_addr_rst(aprom_addr); /* Reset Ethernet Address ROM Pointer */ 4030 enet_addr_rst(aprom_addr); /* Reset Ethernet Address ROM Pointer */
@@ -4049,7 +4049,7 @@ DevicePresent(struct net_device *dev, u_long aprom_addr)
4049 } 4049 }
4050 de4x5_dbg_srom((struct de4x5_srom *)&lp->srom); 4050 de4x5_dbg_srom((struct de4x5_srom *)&lp->srom);
4051 } 4051 }
4052 4052
4053 return; 4053 return;
4054} 4054}
4055 4055
@@ -4071,11 +4071,11 @@ enet_addr_rst(u_long aprom_addr)
4071 short sigLength=0; 4071 short sigLength=0;
4072 s8 data; 4072 s8 data;
4073 int i, j; 4073 int i, j;
4074 4074
4075 dev.llsig.a = ETH_PROM_SIG; 4075 dev.llsig.a = ETH_PROM_SIG;
4076 dev.llsig.b = ETH_PROM_SIG; 4076 dev.llsig.b = ETH_PROM_SIG;
4077 sigLength = sizeof(u32) << 1; 4077 sigLength = sizeof(u32) << 1;
4078 4078
4079 for (i=0,j=0;j<sigLength && i<PROBE_LENGTH+sigLength-1;i++) { 4079 for (i=0,j=0;j<sigLength && i<PROBE_LENGTH+sigLength-1;i++) {
4080 data = inb(aprom_addr); 4080 data = inb(aprom_addr);
4081 if (dev.Sig[j] == data) { /* track signature */ 4081 if (dev.Sig[j] == data) { /* track signature */
@@ -4088,7 +4088,7 @@ enet_addr_rst(u_long aprom_addr)
4088 } 4088 }
4089 } 4089 }
4090 } 4090 }
4091 4091
4092 return; 4092 return;
4093} 4093}
4094 4094
@@ -4111,7 +4111,7 @@ get_hw_addr(struct net_device *dev)
4111 for (i=0,k=0,j=0;j<3;j++) { 4111 for (i=0,k=0,j=0;j<3;j++) {
4112 k <<= 1; 4112 k <<= 1;
4113 if (k > 0xffff) k-=0xffff; 4113 if (k > 0xffff) k-=0xffff;
4114 4114
4115 if (lp->bus == PCI) { 4115 if (lp->bus == PCI) {
4116 if (lp->chipset == DC21040) { 4116 if (lp->chipset == DC21040) {
4117 while ((tmp = inl(DE4X5_APROM)) < 0); 4117 while ((tmp = inl(DE4X5_APROM)) < 0);
@@ -4133,11 +4133,11 @@ get_hw_addr(struct net_device *dev)
4133 k += (u_short) ((tmp = inb(EISA_APROM)) << 8); 4133 k += (u_short) ((tmp = inb(EISA_APROM)) << 8);
4134 dev->dev_addr[i++] = (u_char) tmp; 4134 dev->dev_addr[i++] = (u_char) tmp;
4135 } 4135 }
4136 4136
4137 if (k > 0xffff) k-=0xffff; 4137 if (k > 0xffff) k-=0xffff;
4138 } 4138 }
4139 if (k == 0xffff) k=0; 4139 if (k == 0xffff) k=0;
4140 4140
4141 if (lp->bus == PCI) { 4141 if (lp->bus == PCI) {
4142 if (lp->chipset == DC21040) { 4142 if (lp->chipset == DC21040) {
4143 while ((tmp = inl(DE4X5_APROM)) < 0); 4143 while ((tmp = inl(DE4X5_APROM)) < 0);
@@ -4156,7 +4156,7 @@ get_hw_addr(struct net_device *dev)
4156 srom_repair(dev, broken); 4156 srom_repair(dev, broken);
4157 4157
4158#ifdef CONFIG_PPC_MULTIPLATFORM 4158#ifdef CONFIG_PPC_MULTIPLATFORM
4159 /* 4159 /*
4160 ** If the address starts with 00 a0, we have to bit-reverse 4160 ** If the address starts with 00 a0, we have to bit-reverse
4161 ** each byte of the address. 4161 ** each byte of the address.
4162 */ 4162 */
@@ -4245,7 +4245,7 @@ test_bad_enet(struct net_device *dev, int status)
4245 4245
4246 for (tmp=0,i=0; i<ETH_ALEN; i++) tmp += (u_char)dev->dev_addr[i]; 4246 for (tmp=0,i=0; i<ETH_ALEN; i++) tmp += (u_char)dev->dev_addr[i];
4247 if ((tmp == 0) || (tmp == 0x5fa)) { 4247 if ((tmp == 0) || (tmp == 0x5fa)) {
4248 if ((lp->chipset == last.chipset) && 4248 if ((lp->chipset == last.chipset) &&
4249 (lp->bus_num == last.bus) && (lp->bus_num > 0)) { 4249 (lp->bus_num == last.bus) && (lp->bus_num > 0)) {
4250 for (i=0; i<ETH_ALEN; i++) dev->dev_addr[i] = last.addr[i]; 4250 for (i=0; i<ETH_ALEN; i++) dev->dev_addr[i] = last.addr[i];
4251 for (i=ETH_ALEN-1; i>2; --i) { 4251 for (i=ETH_ALEN-1; i>2; --i) {
@@ -4275,7 +4275,7 @@ test_bad_enet(struct net_device *dev, int status)
4275static int 4275static int
4276an_exception(struct de4x5_private *lp) 4276an_exception(struct de4x5_private *lp)
4277{ 4277{
4278 if ((*(u_short *)lp->srom.sub_vendor_id == 0x00c0) && 4278 if ((*(u_short *)lp->srom.sub_vendor_id == 0x00c0) &&
4279 (*(u_short *)lp->srom.sub_system_id == 0x95e0)) { 4279 (*(u_short *)lp->srom.sub_system_id == 0x95e0)) {
4280 return -1; 4280 return -1;
4281 } 4281 }
@@ -4290,11 +4290,11 @@ static short
4290srom_rd(u_long addr, u_char offset) 4290srom_rd(u_long addr, u_char offset)
4291{ 4291{
4292 sendto_srom(SROM_RD | SROM_SR, addr); 4292 sendto_srom(SROM_RD | SROM_SR, addr);
4293 4293
4294 srom_latch(SROM_RD | SROM_SR | DT_CS, addr); 4294 srom_latch(SROM_RD | SROM_SR | DT_CS, addr);
4295 srom_command(SROM_RD | SROM_SR | DT_IN | DT_CS, addr); 4295 srom_command(SROM_RD | SROM_SR | DT_IN | DT_CS, addr);
4296 srom_address(SROM_RD | SROM_SR | DT_CS, addr, offset); 4296 srom_address(SROM_RD | SROM_SR | DT_CS, addr, offset);
4297 4297
4298 return srom_data(SROM_RD | SROM_SR | DT_CS, addr); 4298 return srom_data(SROM_RD | SROM_SR | DT_CS, addr);
4299} 4299}
4300 4300
@@ -4304,7 +4304,7 @@ srom_latch(u_int command, u_long addr)
4304 sendto_srom(command, addr); 4304 sendto_srom(command, addr);
4305 sendto_srom(command | DT_CLK, addr); 4305 sendto_srom(command | DT_CLK, addr);
4306 sendto_srom(command, addr); 4306 sendto_srom(command, addr);
4307 4307
4308 return; 4308 return;
4309} 4309}
4310 4310
@@ -4314,7 +4314,7 @@ srom_command(u_int command, u_long addr)
4314 srom_latch(command, addr); 4314 srom_latch(command, addr);
4315 srom_latch(command, addr); 4315 srom_latch(command, addr);
4316 srom_latch((command & 0x0000ff00) | DT_CS, addr); 4316 srom_latch((command & 0x0000ff00) | DT_CS, addr);
4317 4317
4318 return; 4318 return;
4319} 4319}
4320 4320
@@ -4322,15 +4322,15 @@ static void
4322srom_address(u_int command, u_long addr, u_char offset) 4322srom_address(u_int command, u_long addr, u_char offset)
4323{ 4323{
4324 int i, a; 4324 int i, a;
4325 4325
4326 a = offset << 2; 4326 a = offset << 2;
4327 for (i=0; i<6; i++, a <<= 1) { 4327 for (i=0; i<6; i++, a <<= 1) {
4328 srom_latch(command | ((a & 0x80) ? DT_IN : 0), addr); 4328 srom_latch(command | ((a & 0x80) ? DT_IN : 0), addr);
4329 } 4329 }
4330 udelay(1); 4330 udelay(1);
4331 4331
4332 i = (getfrom_srom(addr) >> 3) & 0x01; 4332 i = (getfrom_srom(addr) >> 3) & 0x01;
4333 4333
4334 return; 4334 return;
4335} 4335}
4336 4336
@@ -4340,17 +4340,17 @@ srom_data(u_int command, u_long addr)
4340 int i; 4340 int i;
4341 short word = 0; 4341 short word = 0;
4342 s32 tmp; 4342 s32 tmp;
4343 4343
4344 for (i=0; i<16; i++) { 4344 for (i=0; i<16; i++) {
4345 sendto_srom(command | DT_CLK, addr); 4345 sendto_srom(command | DT_CLK, addr);
4346 tmp = getfrom_srom(addr); 4346 tmp = getfrom_srom(addr);
4347 sendto_srom(command, addr); 4347 sendto_srom(command, addr);
4348 4348
4349 word = (word << 1) | ((tmp >> 3) & 0x01); 4349 word = (word << 1) | ((tmp >> 3) & 0x01);
4350 } 4350 }
4351 4351
4352 sendto_srom(command & 0x0000ff00, addr); 4352 sendto_srom(command & 0x0000ff00, addr);
4353 4353
4354 return word; 4354 return word;
4355} 4355}
4356 4356
@@ -4359,13 +4359,13 @@ static void
4359srom_busy(u_int command, u_long addr) 4359srom_busy(u_int command, u_long addr)
4360{ 4360{
4361 sendto_srom((command & 0x0000ff00) | DT_CS, addr); 4361 sendto_srom((command & 0x0000ff00) | DT_CS, addr);
4362 4362
4363 while (!((getfrom_srom(addr) >> 3) & 0x01)) { 4363 while (!((getfrom_srom(addr) >> 3) & 0x01)) {
4364 mdelay(1); 4364 mdelay(1);
4365 } 4365 }
4366 4366
4367 sendto_srom(command & 0x0000ff00, addr); 4367 sendto_srom(command & 0x0000ff00, addr);
4368 4368
4369 return; 4369 return;
4370} 4370}
4371*/ 4371*/
@@ -4375,7 +4375,7 @@ sendto_srom(u_int command, u_long addr)
4375{ 4375{
4376 outl(command, addr); 4376 outl(command, addr);
4377 udelay(1); 4377 udelay(1);
4378 4378
4379 return; 4379 return;
4380} 4380}
4381 4381
@@ -4383,10 +4383,10 @@ static int
4383getfrom_srom(u_long addr) 4383getfrom_srom(u_long addr)
4384{ 4384{
4385 s32 tmp; 4385 s32 tmp;
4386 4386
4387 tmp = inl(addr); 4387 tmp = inl(addr);
4388 udelay(1); 4388 udelay(1);
4389 4389
4390 return tmp; 4390 return tmp;
4391} 4391}
4392 4392
@@ -4403,7 +4403,7 @@ srom_infoleaf_info(struct net_device *dev)
4403 } 4403 }
4404 if (i == INFOLEAF_SIZE) { 4404 if (i == INFOLEAF_SIZE) {
4405 lp->useSROM = FALSE; 4405 lp->useSROM = FALSE;
4406 printk("%s: Cannot find correct chipset for SROM decoding!\n", 4406 printk("%s: Cannot find correct chipset for SROM decoding!\n",
4407 dev->name); 4407 dev->name);
4408 return -ENXIO; 4408 return -ENXIO;
4409 } 4409 }
@@ -4420,7 +4420,7 @@ srom_infoleaf_info(struct net_device *dev)
4420 } 4420 }
4421 if (i == 0) { 4421 if (i == 0) {
4422 lp->useSROM = FALSE; 4422 lp->useSROM = FALSE;
4423 printk("%s: Cannot find correct PCI device [%d] for SROM decoding!\n", 4423 printk("%s: Cannot find correct PCI device [%d] for SROM decoding!\n",
4424 dev->name, lp->device); 4424 dev->name, lp->device);
4425 return -ENXIO; 4425 return -ENXIO;
4426 } 4426 }
@@ -4494,9 +4494,9 @@ srom_exec(struct net_device *dev, u_char *p)
4494 if (((lp->ibn != 1) && (lp->ibn != 3) && (lp->ibn != 5)) || !count) return; 4494 if (((lp->ibn != 1) && (lp->ibn != 3) && (lp->ibn != 5)) || !count) return;
4495 4495
4496 if (lp->chipset != DC21140) RESET_SIA; 4496 if (lp->chipset != DC21140) RESET_SIA;
4497 4497
4498 while (count--) { 4498 while (count--) {
4499 gep_wr(((lp->chipset==DC21140) && (lp->ibn!=5) ? 4499 gep_wr(((lp->chipset==DC21140) && (lp->ibn!=5) ?
4500 *p++ : TWIDDLE(w++)), dev); 4500 *p++ : TWIDDLE(w++)), dev);
4501 mdelay(2); /* 2ms per action */ 4501 mdelay(2); /* 2ms per action */
4502 } 4502 }
@@ -4514,13 +4514,13 @@ srom_exec(struct net_device *dev, u_char *p)
4514** unless I implement the DC21041 SROM functions. There's no need 4514** unless I implement the DC21041 SROM functions. There's no need
4515** since the existing code will be satisfactory for all boards. 4515** since the existing code will be satisfactory for all boards.
4516*/ 4516*/
4517static int 4517static int
4518dc21041_infoleaf(struct net_device *dev) 4518dc21041_infoleaf(struct net_device *dev)
4519{ 4519{
4520 return DE4X5_AUTOSENSE_MS; 4520 return DE4X5_AUTOSENSE_MS;
4521} 4521}
4522 4522
4523static int 4523static int
4524dc21140_infoleaf(struct net_device *dev) 4524dc21140_infoleaf(struct net_device *dev)
4525{ 4525{
4526 struct de4x5_private *lp = netdev_priv(dev); 4526 struct de4x5_private *lp = netdev_priv(dev);
@@ -4558,7 +4558,7 @@ dc21140_infoleaf(struct net_device *dev)
4558 return next_tick & ~TIMER_CB; 4558 return next_tick & ~TIMER_CB;
4559} 4559}
4560 4560
4561static int 4561static int
4562dc21142_infoleaf(struct net_device *dev) 4562dc21142_infoleaf(struct net_device *dev)
4563{ 4563{
4564 struct de4x5_private *lp = netdev_priv(dev); 4564 struct de4x5_private *lp = netdev_priv(dev);
@@ -4593,7 +4593,7 @@ dc21142_infoleaf(struct net_device *dev)
4593 return next_tick & ~TIMER_CB; 4593 return next_tick & ~TIMER_CB;
4594} 4594}
4595 4595
4596static int 4596static int
4597dc21143_infoleaf(struct net_device *dev) 4597dc21143_infoleaf(struct net_device *dev)
4598{ 4598{
4599 struct de4x5_private *lp = netdev_priv(dev); 4599 struct de4x5_private *lp = netdev_priv(dev);
@@ -4631,7 +4631,7 @@ dc21143_infoleaf(struct net_device *dev)
4631** The compact infoblock is only designed for DC21140[A] chips, so 4631** The compact infoblock is only designed for DC21140[A] chips, so
4632** we'll reuse the dc21140m_autoconf function. Non MII media only. 4632** we'll reuse the dc21140m_autoconf function. Non MII media only.
4633*/ 4633*/
4634static int 4634static int
4635compact_infoblock(struct net_device *dev, u_char count, u_char *p) 4635compact_infoblock(struct net_device *dev, u_char count, u_char *p)
4636{ 4636{
4637 struct de4x5_private *lp = netdev_priv(dev); 4637 struct de4x5_private *lp = netdev_priv(dev);
@@ -4671,7 +4671,7 @@ compact_infoblock(struct net_device *dev, u_char count, u_char *p)
4671/* 4671/*
4672** This block describes non MII media for the DC21140[A] only. 4672** This block describes non MII media for the DC21140[A] only.
4673*/ 4673*/
4674static int 4674static int
4675type0_infoblock(struct net_device *dev, u_char count, u_char *p) 4675type0_infoblock(struct net_device *dev, u_char count, u_char *p)
4676{ 4676{
4677 struct de4x5_private *lp = netdev_priv(dev); 4677 struct de4x5_private *lp = netdev_priv(dev);
@@ -4711,7 +4711,7 @@ type0_infoblock(struct net_device *dev, u_char count, u_char *p)
4711 4711
4712/* These functions are under construction! */ 4712/* These functions are under construction! */
4713 4713
4714static int 4714static int
4715type1_infoblock(struct net_device *dev, u_char count, u_char *p) 4715type1_infoblock(struct net_device *dev, u_char count, u_char *p)
4716{ 4716{
4717 struct de4x5_private *lp = netdev_priv(dev); 4717 struct de4x5_private *lp = netdev_priv(dev);
@@ -4750,7 +4750,7 @@ type1_infoblock(struct net_device *dev, u_char count, u_char *p)
4750 return dc21140m_autoconf(dev); 4750 return dc21140m_autoconf(dev);
4751} 4751}
4752 4752
4753static int 4753static int
4754type2_infoblock(struct net_device *dev, u_char count, u_char *p) 4754type2_infoblock(struct net_device *dev, u_char count, u_char *p)
4755{ 4755{
4756 struct de4x5_private *lp = netdev_priv(dev); 4756 struct de4x5_private *lp = netdev_priv(dev);
@@ -4791,7 +4791,7 @@ type2_infoblock(struct net_device *dev, u_char count, u_char *p)
4791 return dc2114x_autoconf(dev); 4791 return dc2114x_autoconf(dev);
4792} 4792}
4793 4793
4794static int 4794static int
4795type3_infoblock(struct net_device *dev, u_char count, u_char *p) 4795type3_infoblock(struct net_device *dev, u_char count, u_char *p)
4796{ 4796{
4797 struct de4x5_private *lp = netdev_priv(dev); 4797 struct de4x5_private *lp = netdev_priv(dev);
@@ -4833,7 +4833,7 @@ type3_infoblock(struct net_device *dev, u_char count, u_char *p)
4833 return dc2114x_autoconf(dev); 4833 return dc2114x_autoconf(dev);
4834} 4834}
4835 4835
4836static int 4836static int
4837type4_infoblock(struct net_device *dev, u_char count, u_char *p) 4837type4_infoblock(struct net_device *dev, u_char count, u_char *p)
4838{ 4838{
4839 struct de4x5_private *lp = netdev_priv(dev); 4839 struct de4x5_private *lp = netdev_priv(dev);
@@ -4878,7 +4878,7 @@ type4_infoblock(struct net_device *dev, u_char count, u_char *p)
4878** This block type provides information for resetting external devices 4878** This block type provides information for resetting external devices
4879** (chips) through the General Purpose Register. 4879** (chips) through the General Purpose Register.
4880*/ 4880*/
4881static int 4881static int
4882type5_infoblock(struct net_device *dev, u_char count, u_char *p) 4882type5_infoblock(struct net_device *dev, u_char count, u_char *p)
4883{ 4883{
4884 struct de4x5_private *lp = netdev_priv(dev); 4884 struct de4x5_private *lp = netdev_priv(dev);
@@ -4916,7 +4916,7 @@ mii_rd(u_char phyreg, u_char phyaddr, u_long ioaddr)
4916 mii_address(phyaddr, ioaddr); /* PHY address to be accessed */ 4916 mii_address(phyaddr, ioaddr); /* PHY address to be accessed */
4917 mii_address(phyreg, ioaddr); /* PHY Register to read */ 4917 mii_address(phyreg, ioaddr); /* PHY Register to read */
4918 mii_ta(MII_STRD, ioaddr); /* Turn around time - 2 MDC */ 4918 mii_ta(MII_STRD, ioaddr); /* Turn around time - 2 MDC */
4919 4919
4920 return mii_rdata(ioaddr); /* Read data */ 4920 return mii_rdata(ioaddr); /* Read data */
4921} 4921}
4922 4922
@@ -4931,7 +4931,7 @@ mii_wr(int data, u_char phyreg, u_char phyaddr, u_long ioaddr)
4931 mii_ta(MII_STWR, ioaddr); /* Turn around time - 2 MDC */ 4931 mii_ta(MII_STWR, ioaddr); /* Turn around time - 2 MDC */
4932 data = mii_swap(data, 16); /* Swap data bit ordering */ 4932 data = mii_swap(data, 16); /* Swap data bit ordering */
4933 mii_wdata(data, 16, ioaddr); /* Write data */ 4933 mii_wdata(data, 16, ioaddr); /* Write data */
4934 4934
4935 return; 4935 return;
4936} 4936}
4937 4937
@@ -4940,12 +4940,12 @@ mii_rdata(u_long ioaddr)
4940{ 4940{
4941 int i; 4941 int i;
4942 s32 tmp = 0; 4942 s32 tmp = 0;
4943 4943
4944 for (i=0; i<16; i++) { 4944 for (i=0; i<16; i++) {
4945 tmp <<= 1; 4945 tmp <<= 1;
4946 tmp |= getfrom_mii(MII_MRD | MII_RD, ioaddr); 4946 tmp |= getfrom_mii(MII_MRD | MII_RD, ioaddr);
4947 } 4947 }
4948 4948
4949 return tmp; 4949 return tmp;
4950} 4950}
4951 4951
@@ -4953,12 +4953,12 @@ static void
4953mii_wdata(int data, int len, u_long ioaddr) 4953mii_wdata(int data, int len, u_long ioaddr)
4954{ 4954{
4955 int i; 4955 int i;
4956 4956
4957 for (i=0; i<len; i++) { 4957 for (i=0; i<len; i++) {
4958 sendto_mii(MII_MWR | MII_WR, data, ioaddr); 4958 sendto_mii(MII_MWR | MII_WR, data, ioaddr);
4959 data >>= 1; 4959 data >>= 1;
4960 } 4960 }
4961 4961
4962 return; 4962 return;
4963} 4963}
4964 4964
@@ -4966,13 +4966,13 @@ static void
4966mii_address(u_char addr, u_long ioaddr) 4966mii_address(u_char addr, u_long ioaddr)
4967{ 4967{
4968 int i; 4968 int i;
4969 4969
4970 addr = mii_swap(addr, 5); 4970 addr = mii_swap(addr, 5);
4971 for (i=0; i<5; i++) { 4971 for (i=0; i<5; i++) {
4972 sendto_mii(MII_MWR | MII_WR, addr, ioaddr); 4972 sendto_mii(MII_MWR | MII_WR, addr, ioaddr);
4973 addr >>= 1; 4973 addr >>= 1;
4974 } 4974 }
4975 4975
4976 return; 4976 return;
4977} 4977}
4978 4978
@@ -4980,12 +4980,12 @@ static void
4980mii_ta(u_long rw, u_long ioaddr) 4980mii_ta(u_long rw, u_long ioaddr)
4981{ 4981{
4982 if (rw == MII_STWR) { 4982 if (rw == MII_STWR) {
4983 sendto_mii(MII_MWR | MII_WR, 1, ioaddr); 4983 sendto_mii(MII_MWR | MII_WR, 1, ioaddr);
4984 sendto_mii(MII_MWR | MII_WR, 0, ioaddr); 4984 sendto_mii(MII_MWR | MII_WR, 0, ioaddr);
4985 } else { 4985 } else {
4986 getfrom_mii(MII_MRD | MII_RD, ioaddr); /* Tri-state MDIO */ 4986 getfrom_mii(MII_MRD | MII_RD, ioaddr); /* Tri-state MDIO */
4987 } 4987 }
4988 4988
4989 return; 4989 return;
4990} 4990}
4991 4991
@@ -4993,13 +4993,13 @@ static int
4993mii_swap(int data, int len) 4993mii_swap(int data, int len)
4994{ 4994{
4995 int i, tmp = 0; 4995 int i, tmp = 0;
4996 4996
4997 for (i=0; i<len; i++) { 4997 for (i=0; i<len; i++) {
4998 tmp <<= 1; 4998 tmp <<= 1;
4999 tmp |= (data & 1); 4999 tmp |= (data & 1);
5000 data >>= 1; 5000 data >>= 1;
5001 } 5001 }
5002 5002
5003 return tmp; 5003 return tmp;
5004} 5004}
5005 5005
@@ -5007,13 +5007,13 @@ static void
5007sendto_mii(u32 command, int data, u_long ioaddr) 5007sendto_mii(u32 command, int data, u_long ioaddr)
5008{ 5008{
5009 u32 j; 5009 u32 j;
5010 5010
5011 j = (data & 1) << 17; 5011 j = (data & 1) << 17;
5012 outl(command | j, ioaddr); 5012 outl(command | j, ioaddr);
5013 udelay(1); 5013 udelay(1);
5014 outl(command | MII_MDC | j, ioaddr); 5014 outl(command | MII_MDC | j, ioaddr);
5015 udelay(1); 5015 udelay(1);
5016 5016
5017 return; 5017 return;
5018} 5018}
5019 5019
@@ -5024,7 +5024,7 @@ getfrom_mii(u32 command, u_long ioaddr)
5024 udelay(1); 5024 udelay(1);
5025 outl(command | MII_MDC, ioaddr); 5025 outl(command | MII_MDC, ioaddr);
5026 udelay(1); 5026 udelay(1);
5027 5027
5028 return ((inl(ioaddr) >> 19) & 1); 5028 return ((inl(ioaddr) >> 19) & 1);
5029} 5029}
5030 5030
@@ -5085,7 +5085,7 @@ mii_get_phy(struct net_device *dev)
5085 u_long iobase = dev->base_addr; 5085 u_long iobase = dev->base_addr;
5086 int i, j, k, n, limit=sizeof(phy_info)/sizeof(struct phy_table); 5086 int i, j, k, n, limit=sizeof(phy_info)/sizeof(struct phy_table);
5087 int id; 5087 int id;
5088 5088
5089 lp->active = 0; 5089 lp->active = 0;
5090 lp->useMII = TRUE; 5090 lp->useMII = TRUE;
5091 5091
@@ -5094,7 +5094,7 @@ mii_get_phy(struct net_device *dev)
5094 lp->phy[lp->active].addr = i; 5094 lp->phy[lp->active].addr = i;
5095 if (i==0) n++; /* Count cycles */ 5095 if (i==0) n++; /* Count cycles */
5096 while (de4x5_reset_phy(dev)<0) udelay(100);/* Wait for reset */ 5096 while (de4x5_reset_phy(dev)<0) udelay(100);/* Wait for reset */
5097 id = mii_get_oui(i, DE4X5_MII); 5097 id = mii_get_oui(i, DE4X5_MII);
5098 if ((id == 0) || (id == 65535)) continue; /* Valid ID? */ 5098 if ((id == 0) || (id == 65535)) continue; /* Valid ID? */
5099 for (j=0; j<limit; j++) { /* Search PHY table */ 5099 for (j=0; j<limit; j++) { /* Search PHY table */
5100 if (id != phy_info[j].id) continue; /* ID match? */ 5100 if (id != phy_info[j].id) continue; /* ID match? */
@@ -5133,7 +5133,7 @@ mii_get_phy(struct net_device *dev)
5133 for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY); k++) { /*For each PHY*/ 5133 for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY); k++) { /*For each PHY*/
5134 mii_wr(MII_CR_RST, MII_CR, lp->phy[k].addr, DE4X5_MII); 5134 mii_wr(MII_CR_RST, MII_CR, lp->phy[k].addr, DE4X5_MII);
5135 while (mii_rd(MII_CR, lp->phy[k].addr, DE4X5_MII) & MII_CR_RST); 5135 while (mii_rd(MII_CR, lp->phy[k].addr, DE4X5_MII) & MII_CR_RST);
5136 5136
5137 de4x5_dbg_mii(dev, k); 5137 de4x5_dbg_mii(dev, k);
5138 } 5138 }
5139 } 5139 }
@@ -5148,12 +5148,12 @@ build_setup_frame(struct net_device *dev, int mode)
5148 struct de4x5_private *lp = netdev_priv(dev); 5148 struct de4x5_private *lp = netdev_priv(dev);
5149 int i; 5149 int i;
5150 char *pa = lp->setup_frame; 5150 char *pa = lp->setup_frame;
5151 5151
5152 /* Initialise the setup frame */ 5152 /* Initialise the setup frame */
5153 if (mode == ALL) { 5153 if (mode == ALL) {
5154 memset(lp->setup_frame, 0, SETUP_FRAME_LEN); 5154 memset(lp->setup_frame, 0, SETUP_FRAME_LEN);
5155 } 5155 }
5156 5156
5157 if (lp->setup_f == HASH_PERF) { 5157 if (lp->setup_f == HASH_PERF) {
5158 for (pa=lp->setup_frame+IMPERF_PA_OFFSET, i=0; i<ETH_ALEN; i++) { 5158 for (pa=lp->setup_frame+IMPERF_PA_OFFSET, i=0; i<ETH_ALEN; i++) {
5159 *(pa + i) = dev->dev_addr[i]; /* Host address */ 5159 *(pa + i) = dev->dev_addr[i]; /* Host address */
@@ -5170,7 +5170,7 @@ build_setup_frame(struct net_device *dev, int mode)
5170 if (i & 0x01) pa += 4; 5170 if (i & 0x01) pa += 4;
5171 } 5171 }
5172 } 5172 }
5173 5173
5174 return pa; /* Points to the next entry */ 5174 return pa; /* Points to the next entry */
5175} 5175}
5176 5176
@@ -5178,7 +5178,7 @@ static void
5178enable_ast(struct net_device *dev, u32 time_out) 5178enable_ast(struct net_device *dev, u32 time_out)
5179{ 5179{
5180 timeout(dev, (void *)&de4x5_ast, (u_long)dev, time_out); 5180 timeout(dev, (void *)&de4x5_ast, (u_long)dev, time_out);
5181 5181
5182 return; 5182 return;
5183} 5183}
5184 5184
@@ -5186,9 +5186,9 @@ static void
5186disable_ast(struct net_device *dev) 5186disable_ast(struct net_device *dev)
5187{ 5187{
5188 struct de4x5_private *lp = netdev_priv(dev); 5188 struct de4x5_private *lp = netdev_priv(dev);
5189 5189
5190 del_timer(&lp->timer); 5190 del_timer(&lp->timer);
5191 5191
5192 return; 5192 return;
5193} 5193}
5194 5194
@@ -5207,10 +5207,10 @@ de4x5_switch_mac_port(struct net_device *dev)
5207 omr |= lp->infoblock_csr6; 5207 omr |= lp->infoblock_csr6;
5208 if (omr & OMR_PS) omr |= OMR_HBD; 5208 if (omr & OMR_PS) omr |= OMR_HBD;
5209 outl(omr, DE4X5_OMR); 5209 outl(omr, DE4X5_OMR);
5210 5210
5211 /* Soft Reset */ 5211 /* Soft Reset */
5212 RESET_DE4X5; 5212 RESET_DE4X5;
5213 5213
5214 /* Restore the GEP - especially for COMPACT and Type 0 Infoblocks */ 5214 /* Restore the GEP - especially for COMPACT and Type 0 Infoblocks */
5215 if (lp->chipset == DC21140) { 5215 if (lp->chipset == DC21140) {
5216 gep_wr(lp->cache.gepc, dev); 5216 gep_wr(lp->cache.gepc, dev);
@@ -5263,21 +5263,21 @@ timeout(struct net_device *dev, void (*fn)(u_long data), u_long data, u_long mse
5263{ 5263{
5264 struct de4x5_private *lp = netdev_priv(dev); 5264 struct de4x5_private *lp = netdev_priv(dev);
5265 int dt; 5265 int dt;
5266 5266
5267 /* First, cancel any pending timer events */ 5267 /* First, cancel any pending timer events */
5268 del_timer(&lp->timer); 5268 del_timer(&lp->timer);
5269 5269
5270 /* Convert msec to ticks */ 5270 /* Convert msec to ticks */
5271 dt = (msec * HZ) / 1000; 5271 dt = (msec * HZ) / 1000;
5272 if (dt==0) dt=1; 5272 if (dt==0) dt=1;
5273 5273
5274 /* Set up timer */ 5274 /* Set up timer */
5275 init_timer(&lp->timer); 5275 init_timer(&lp->timer);
5276 lp->timer.expires = jiffies + dt; 5276 lp->timer.expires = jiffies + dt;
5277 lp->timer.function = fn; 5277 lp->timer.function = fn;
5278 lp->timer.data = data; 5278 lp->timer.data = data;
5279 add_timer(&lp->timer); 5279 add_timer(&lp->timer);
5280 5280
5281 return; 5281 return;
5282} 5282}
5283 5283
@@ -5375,7 +5375,7 @@ de4x5_dbg_open(struct net_device *dev)
5375{ 5375{
5376 struct de4x5_private *lp = netdev_priv(dev); 5376 struct de4x5_private *lp = netdev_priv(dev);
5377 int i; 5377 int i;
5378 5378
5379 if (de4x5_debug & DEBUG_OPEN) { 5379 if (de4x5_debug & DEBUG_OPEN) {
5380 printk("%s: de4x5 opening with irq %d\n",dev->name,dev->irq); 5380 printk("%s: de4x5 opening with irq %d\n",dev->name,dev->irq);
5381 printk("\tphysical address: "); 5381 printk("\tphysical address: ");
@@ -5413,11 +5413,11 @@ de4x5_dbg_open(struct net_device *dev)
5413 } 5413 }
5414 } 5414 }
5415 printk("...0x%8.8x\n", le32_to_cpu(lp->tx_ring[i].buf)); 5415 printk("...0x%8.8x\n", le32_to_cpu(lp->tx_ring[i].buf));
5416 printk("Ring size: \nRX: %d\nTX: %d\n", 5416 printk("Ring size: \nRX: %d\nTX: %d\n",
5417 (short)lp->rxRingSize, 5417 (short)lp->rxRingSize,
5418 (short)lp->txRingSize); 5418 (short)lp->txRingSize);
5419 } 5419 }
5420 5420
5421 return; 5421 return;
5422} 5422}
5423 5423
@@ -5426,7 +5426,7 @@ de4x5_dbg_mii(struct net_device *dev, int k)
5426{ 5426{
5427 struct de4x5_private *lp = netdev_priv(dev); 5427 struct de4x5_private *lp = netdev_priv(dev);
5428 u_long iobase = dev->base_addr; 5428 u_long iobase = dev->base_addr;
5429 5429
5430 if (de4x5_debug & DEBUG_MII) { 5430 if (de4x5_debug & DEBUG_MII) {
5431 printk("\nMII device address: %d\n", lp->phy[k].addr); 5431 printk("\nMII device address: %d\n", lp->phy[k].addr);
5432 printk("MII CR: %x\n",mii_rd(MII_CR,lp->phy[k].addr,DE4X5_MII)); 5432 printk("MII CR: %x\n",mii_rd(MII_CR,lp->phy[k].addr,DE4X5_MII));
@@ -5445,7 +5445,7 @@ de4x5_dbg_mii(struct net_device *dev, int k)
5445 printk("MII 20: %x\n",mii_rd(0x14,lp->phy[k].addr,DE4X5_MII)); 5445 printk("MII 20: %x\n",mii_rd(0x14,lp->phy[k].addr,DE4X5_MII));
5446 } 5446 }
5447 } 5447 }
5448 5448
5449 return; 5449 return;
5450} 5450}
5451 5451
@@ -5453,17 +5453,17 @@ static void
5453de4x5_dbg_media(struct net_device *dev) 5453de4x5_dbg_media(struct net_device *dev)
5454{ 5454{
5455 struct de4x5_private *lp = netdev_priv(dev); 5455 struct de4x5_private *lp = netdev_priv(dev);
5456 5456
5457 if (lp->media != lp->c_media) { 5457 if (lp->media != lp->c_media) {
5458 if (de4x5_debug & DEBUG_MEDIA) { 5458 if (de4x5_debug & DEBUG_MEDIA) {
5459 printk("%s: media is %s%s\n", dev->name, 5459 printk("%s: media is %s%s\n", dev->name,
5460 (lp->media == NC ? "unconnected, link down or incompatible connection" : 5460 (lp->media == NC ? "unconnected, link down or incompatible connection" :
5461 (lp->media == TP ? "TP" : 5461 (lp->media == TP ? "TP" :
5462 (lp->media == ANS ? "TP/Nway" : 5462 (lp->media == ANS ? "TP/Nway" :
5463 (lp->media == BNC ? "BNC" : 5463 (lp->media == BNC ? "BNC" :
5464 (lp->media == AUI ? "AUI" : 5464 (lp->media == AUI ? "AUI" :
5465 (lp->media == BNC_AUI ? "BNC/AUI" : 5465 (lp->media == BNC_AUI ? "BNC/AUI" :
5466 (lp->media == EXT_SIA ? "EXT SIA" : 5466 (lp->media == EXT_SIA ? "EXT SIA" :
5467 (lp->media == _100Mb ? "100Mb/s" : 5467 (lp->media == _100Mb ? "100Mb/s" :
5468 (lp->media == _10Mb ? "10Mb/s" : 5468 (lp->media == _10Mb ? "10Mb/s" :
5469 "???" 5469 "???"
@@ -5471,7 +5471,7 @@ de4x5_dbg_media(struct net_device *dev)
5471 } 5471 }
5472 lp->c_media = lp->media; 5472 lp->c_media = lp->media;
5473 } 5473 }
5474 5474
5475 return; 5475 return;
5476} 5476}
5477 5477
@@ -5554,7 +5554,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5554 u32 lval[36]; 5554 u32 lval[36];
5555 } tmp; 5555 } tmp;
5556 u_long flags = 0; 5556 u_long flags = 0;
5557 5557
5558 switch(ioc->cmd) { 5558 switch(ioc->cmd) {
5559 case DE4X5_GET_HWADDR: /* Get the hardware address */ 5559 case DE4X5_GET_HWADDR: /* Get the hardware address */
5560 ioc->len = ETH_ALEN; 5560 ioc->len = ETH_ALEN;
@@ -5575,7 +5575,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5575 } 5575 }
5576 build_setup_frame(dev, PHYS_ADDR_ONLY); 5576 build_setup_frame(dev, PHYS_ADDR_ONLY);
5577 /* Set up the descriptor and give ownership to the card */ 5577 /* Set up the descriptor and give ownership to the card */
5578 load_packet(dev, lp->setup_frame, TD_IC | PERFECT_F | TD_SET | 5578 load_packet(dev, lp->setup_frame, TD_IC | PERFECT_F | TD_SET |
5579 SETUP_FRAME_LEN, (struct sk_buff *)1); 5579 SETUP_FRAME_LEN, (struct sk_buff *)1);
5580 lp->tx_new = (++lp->tx_new) % lp->txRingSize; 5580 lp->tx_new = (++lp->tx_new) % lp->txRingSize;
5581 outl(POLL_DEMAND, DE4X5_TPD); /* Start the TX */ 5581 outl(POLL_DEMAND, DE4X5_TPD); /* Start the TX */
@@ -5617,8 +5617,8 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5617 spin_lock_irqsave(&lp->lock, flags); 5617 spin_lock_irqsave(&lp->lock, flags);
5618 memcpy(&statbuf, &lp->pktStats, ioc->len); 5618 memcpy(&statbuf, &lp->pktStats, ioc->len);
5619 spin_unlock_irqrestore(&lp->lock, flags); 5619 spin_unlock_irqrestore(&lp->lock, flags);
5620 if (copy_to_user(ioc->data, &statbuf, ioc->len)) 5620 if (copy_to_user(ioc->data, &statbuf, ioc->len))
5621 return -EFAULT; 5621 return -EFAULT;
5622 break; 5622 break;
5623 } 5623 }
5624 case DE4X5_CLR_STATS: /* Zero out the driver statistics */ 5624 case DE4X5_CLR_STATS: /* Zero out the driver statistics */
@@ -5652,9 +5652,9 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5652 ioc->len = j; 5652 ioc->len = j;
5653 if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT; 5653 if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
5654 break; 5654 break;
5655 5655
5656#define DE4X5_DUMP 0x0f /* Dump the DE4X5 Status */ 5656#define DE4X5_DUMP 0x0f /* Dump the DE4X5 Status */
5657/* 5657/*
5658 case DE4X5_DUMP: 5658 case DE4X5_DUMP:
5659 j = 0; 5659 j = 0;
5660 tmp.addr[j++] = dev->irq; 5660 tmp.addr[j++] = dev->irq;
@@ -5664,7 +5664,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5664 tmp.addr[j++] = lp->rxRingSize; 5664 tmp.addr[j++] = lp->rxRingSize;
5665 tmp.lval[j>>2] = (long)lp->rx_ring; j+=4; 5665 tmp.lval[j>>2] = (long)lp->rx_ring; j+=4;
5666 tmp.lval[j>>2] = (long)lp->tx_ring; j+=4; 5666 tmp.lval[j>>2] = (long)lp->tx_ring; j+=4;
5667 5667
5668 for (i=0;i<lp->rxRingSize-1;i++){ 5668 for (i=0;i<lp->rxRingSize-1;i++){
5669 if (i < 3) { 5669 if (i < 3) {
5670 tmp.lval[j>>2] = (long)&lp->rx_ring[i].status; j+=4; 5670 tmp.lval[j>>2] = (long)&lp->rx_ring[i].status; j+=4;
@@ -5677,7 +5677,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5677 } 5677 }
5678 } 5678 }
5679 tmp.lval[j>>2] = (long)&lp->tx_ring[i].status; j+=4; 5679 tmp.lval[j>>2] = (long)&lp->tx_ring[i].status; j+=4;
5680 5680
5681 for (i=0;i<lp->rxRingSize-1;i++){ 5681 for (i=0;i<lp->rxRingSize-1;i++){
5682 if (i < 3) { 5682 if (i < 3) {
5683 tmp.lval[j>>2] = (s32)le32_to_cpu(lp->rx_ring[i].buf); j+=4; 5683 tmp.lval[j>>2] = (s32)le32_to_cpu(lp->rx_ring[i].buf); j+=4;
@@ -5690,14 +5690,14 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5690 } 5690 }
5691 } 5691 }
5692 tmp.lval[j>>2] = (s32)le32_to_cpu(lp->tx_ring[i].buf); j+=4; 5692 tmp.lval[j>>2] = (s32)le32_to_cpu(lp->tx_ring[i].buf); j+=4;
5693 5693
5694 for (i=0;i<lp->rxRingSize;i++){ 5694 for (i=0;i<lp->rxRingSize;i++){
5695 tmp.lval[j>>2] = le32_to_cpu(lp->rx_ring[i].status); j+=4; 5695 tmp.lval[j>>2] = le32_to_cpu(lp->rx_ring[i].status); j+=4;
5696 } 5696 }
5697 for (i=0;i<lp->txRingSize;i++){ 5697 for (i=0;i<lp->txRingSize;i++){
5698 tmp.lval[j>>2] = le32_to_cpu(lp->tx_ring[i].status); j+=4; 5698 tmp.lval[j>>2] = le32_to_cpu(lp->tx_ring[i].status); j+=4;
5699 } 5699 }
5700 5700
5701 tmp.lval[j>>2] = inl(DE4X5_BMR); j+=4; 5701 tmp.lval[j>>2] = inl(DE4X5_BMR); j+=4;
5702 tmp.lval[j>>2] = inl(DE4X5_TPD); j+=4; 5702 tmp.lval[j>>2] = inl(DE4X5_TPD); j+=4;
5703 tmp.lval[j>>2] = inl(DE4X5_RPD); j+=4; 5703 tmp.lval[j>>2] = inl(DE4X5_RPD); j+=4;
@@ -5706,18 +5706,18 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5706 tmp.lval[j>>2] = inl(DE4X5_STS); j+=4; 5706 tmp.lval[j>>2] = inl(DE4X5_STS); j+=4;
5707 tmp.lval[j>>2] = inl(DE4X5_OMR); j+=4; 5707 tmp.lval[j>>2] = inl(DE4X5_OMR); j+=4;
5708 tmp.lval[j>>2] = inl(DE4X5_IMR); j+=4; 5708 tmp.lval[j>>2] = inl(DE4X5_IMR); j+=4;
5709 tmp.lval[j>>2] = lp->chipset; j+=4; 5709 tmp.lval[j>>2] = lp->chipset; j+=4;
5710 if (lp->chipset == DC21140) { 5710 if (lp->chipset == DC21140) {
5711 tmp.lval[j>>2] = gep_rd(dev); j+=4; 5711 tmp.lval[j>>2] = gep_rd(dev); j+=4;
5712 } else { 5712 } else {
5713 tmp.lval[j>>2] = inl(DE4X5_SISR); j+=4; 5713 tmp.lval[j>>2] = inl(DE4X5_SISR); j+=4;
5714 tmp.lval[j>>2] = inl(DE4X5_SICR); j+=4; 5714 tmp.lval[j>>2] = inl(DE4X5_SICR); j+=4;
5715 tmp.lval[j>>2] = inl(DE4X5_STRR); j+=4; 5715 tmp.lval[j>>2] = inl(DE4X5_STRR); j+=4;
5716 tmp.lval[j>>2] = inl(DE4X5_SIGR); j+=4; 5716 tmp.lval[j>>2] = inl(DE4X5_SIGR); j+=4;
5717 } 5717 }
5718 tmp.lval[j>>2] = lp->phy[lp->active].id; j+=4; 5718 tmp.lval[j>>2] = lp->phy[lp->active].id; j+=4;
5719 if (lp->phy[lp->active].id && (!lp->useSROM || lp->useMII)) { 5719 if (lp->phy[lp->active].id && (!lp->useSROM || lp->useMII)) {
5720 tmp.lval[j>>2] = lp->active; j+=4; 5720 tmp.lval[j>>2] = lp->active; j+=4;
5721 tmp.lval[j>>2]=mii_rd(MII_CR,lp->phy[lp->active].addr,DE4X5_MII); j+=4; 5721 tmp.lval[j>>2]=mii_rd(MII_CR,lp->phy[lp->active].addr,DE4X5_MII); j+=4;
5722 tmp.lval[j>>2]=mii_rd(MII_SR,lp->phy[lp->active].addr,DE4X5_MII); j+=4; 5722 tmp.lval[j>>2]=mii_rd(MII_SR,lp->phy[lp->active].addr,DE4X5_MII); j+=4;
5723 tmp.lval[j>>2]=mii_rd(MII_ID0,lp->phy[lp->active].addr,DE4X5_MII); j+=4; 5723 tmp.lval[j>>2]=mii_rd(MII_ID0,lp->phy[lp->active].addr,DE4X5_MII); j+=4;
@@ -5734,10 +5734,10 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5734 tmp.lval[j>>2]=mii_rd(0x14,lp->phy[lp->active].addr,DE4X5_MII); j+=4; 5734 tmp.lval[j>>2]=mii_rd(0x14,lp->phy[lp->active].addr,DE4X5_MII); j+=4;
5735 } 5735 }
5736 } 5736 }
5737 5737
5738 tmp.addr[j++] = lp->txRingSize; 5738 tmp.addr[j++] = lp->txRingSize;
5739 tmp.addr[j++] = netif_queue_stopped(dev); 5739 tmp.addr[j++] = netif_queue_stopped(dev);
5740 5740
5741 ioc->len = j; 5741 ioc->len = j;
5742 if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT; 5742 if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
5743 break; 5743 break;
@@ -5746,7 +5746,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5746 default: 5746 default:
5747 return -EOPNOTSUPP; 5747 return -EOPNOTSUPP;
5748 } 5748 }
5749 5749
5750 return status; 5750 return status;
5751} 5751}
5752 5752
diff --git a/drivers/net/tulip/de4x5.h b/drivers/net/tulip/de4x5.h
index ad37a4074302..57226e5eb8a6 100644
--- a/drivers/net/tulip/de4x5.h
+++ b/drivers/net/tulip/de4x5.h
@@ -38,11 +38,11 @@
38/* 38/*
39** EISA Register Address Map 39** EISA Register Address Map
40*/ 40*/
41#define EISA_ID iobase+0x0c80 /* EISA ID Registers */ 41#define EISA_ID iobase+0x0c80 /* EISA ID Registers */
42#define EISA_ID0 iobase+0x0c80 /* EISA ID Register 0 */ 42#define EISA_ID0 iobase+0x0c80 /* EISA ID Register 0 */
43#define EISA_ID1 iobase+0x0c81 /* EISA ID Register 1 */ 43#define EISA_ID1 iobase+0x0c81 /* EISA ID Register 1 */
44#define EISA_ID2 iobase+0x0c82 /* EISA ID Register 2 */ 44#define EISA_ID2 iobase+0x0c82 /* EISA ID Register 2 */
45#define EISA_ID3 iobase+0x0c83 /* EISA ID Register 3 */ 45#define EISA_ID3 iobase+0x0c83 /* EISA ID Register 3 */
46#define EISA_CR iobase+0x0c84 /* EISA Control Register */ 46#define EISA_CR iobase+0x0c84 /* EISA Control Register */
47#define EISA_REG0 iobase+0x0c88 /* EISA Configuration Register 0 */ 47#define EISA_REG0 iobase+0x0c88 /* EISA Configuration Register 0 */
48#define EISA_REG1 iobase+0x0c89 /* EISA Configuration Register 1 */ 48#define EISA_REG1 iobase+0x0c89 /* EISA Configuration Register 1 */
@@ -1008,8 +1008,8 @@ struct de4x5_ioctl {
1008 unsigned char __user *data; /* Pointer to the data buffer */ 1008 unsigned char __user *data; /* Pointer to the data buffer */
1009}; 1009};
1010 1010
1011/* 1011/*
1012** Recognised commands for the driver 1012** Recognised commands for the driver
1013*/ 1013*/
1014#define DE4X5_GET_HWADDR 0x01 /* Get the hardware address */ 1014#define DE4X5_GET_HWADDR 0x01 /* Get the hardware address */
1015#define DE4X5_SET_HWADDR 0x02 /* Set the hardware address */ 1015#define DE4X5_SET_HWADDR 0x02 /* Set the hardware address */
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 74e9075d9c48..ba5b112093f4 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -50,7 +50,7 @@
50 forget to unmap PCI mapped skbs. 50 forget to unmap PCI mapped skbs.
51 51
52 Alan Cox <alan@redhat.com> 52 Alan Cox <alan@redhat.com>
53 Added new PCI identifiers provided by Clear Zhang at ALi 53 Added new PCI identifiers provided by Clear Zhang at ALi
54 for their 1563 ethernet device. 54 for their 1563 ethernet device.
55 55
56 TODO 56 TODO
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index fbd9ab60b052..5ffbd5b300c0 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -96,11 +96,11 @@ static const char *block_name[] __devinitdata = {
96 * tulip_build_fake_mediatable - Build a fake mediatable entry. 96 * tulip_build_fake_mediatable - Build a fake mediatable entry.
97 * @tp: Ptr to the tulip private data. 97 * @tp: Ptr to the tulip private data.
98 * 98 *
99 * Some cards like the 3x5 HSC cards (J3514A) do not have a standard 99 * Some cards like the 3x5 HSC cards (J3514A) do not have a standard
100 * srom and can not be handled under the fixup routine. These cards 100 * srom and can not be handled under the fixup routine. These cards
101 * still need a valid mediatable entry for correct csr12 setup and 101 * still need a valid mediatable entry for correct csr12 setup and
102 * mii handling. 102 * mii handling.
103 * 103 *
104 * Since this is currently a parisc-linux specific function, the 104 * Since this is currently a parisc-linux specific function, the
105 * #ifdef __hppa__ should completely optimize this function away for 105 * #ifdef __hppa__ should completely optimize this function away for
106 * non-parisc hardware. 106 * non-parisc hardware.
@@ -140,7 +140,7 @@ static void __devinit tulip_build_fake_mediatable(struct tulip_private *tp)
140 tp->flags |= HAS_PHY_IRQ; 140 tp->flags |= HAS_PHY_IRQ;
141 tp->csr12_shadow = -1; 141 tp->csr12_shadow = -1;
142 } 142 }
143#endif 143#endif
144} 144}
145 145
146void __devinit tulip_parse_eeprom(struct net_device *dev) 146void __devinit tulip_parse_eeprom(struct net_device *dev)
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
index bb3558164a5b..da4f7593c50f 100644
--- a/drivers/net/tulip/interrupt.c
+++ b/drivers/net/tulip/interrupt.c
@@ -139,22 +139,22 @@ int tulip_poll(struct net_device *dev, int *budget)
139 } 139 }
140 /* Acknowledge current RX interrupt sources. */ 140 /* Acknowledge current RX interrupt sources. */
141 iowrite32((RxIntr | RxNoBuf), tp->base_addr + CSR5); 141 iowrite32((RxIntr | RxNoBuf), tp->base_addr + CSR5);
142 142
143 143
144 /* If we own the next entry, it is a new packet. Send it up. */ 144 /* If we own the next entry, it is a new packet. Send it up. */
145 while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) { 145 while ( ! (tp->rx_ring[entry].status & cpu_to_le32(DescOwned))) {
146 s32 status = le32_to_cpu(tp->rx_ring[entry].status); 146 s32 status = le32_to_cpu(tp->rx_ring[entry].status);
147 147
148 148
149 if (tp->dirty_rx + RX_RING_SIZE == tp->cur_rx) 149 if (tp->dirty_rx + RX_RING_SIZE == tp->cur_rx)
150 break; 150 break;
151 151
152 if (tulip_debug > 5) 152 if (tulip_debug > 5)
153 printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n", 153 printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n",
154 dev->name, entry, status); 154 dev->name, entry, status);
155 if (--rx_work_limit < 0) 155 if (--rx_work_limit < 0)
156 goto not_done; 156 goto not_done;
157 157
158 if ((status & 0x38008300) != 0x0300) { 158 if ((status & 0x38008300) != 0x0300) {
159 if ((status & 0x38000300) != 0x0300) { 159 if ((status & 0x38000300) != 0x0300) {
160 /* Ingore earlier buffers. */ 160 /* Ingore earlier buffers. */
@@ -180,7 +180,7 @@ int tulip_poll(struct net_device *dev, int *budget)
180 /* Omit the four octet CRC from the length. */ 180 /* Omit the four octet CRC from the length. */
181 short pkt_len = ((status >> 16) & 0x7ff) - 4; 181 short pkt_len = ((status >> 16) & 0x7ff) - 4;
182 struct sk_buff *skb; 182 struct sk_buff *skb;
183 183
184#ifndef final_version 184#ifndef final_version
185 if (pkt_len > 1518) { 185 if (pkt_len > 1518) {
186 printk(KERN_WARNING "%s: Bogus packet size of %d (%#x).\n", 186 printk(KERN_WARNING "%s: Bogus packet size of %d (%#x).\n",
@@ -213,7 +213,7 @@ int tulip_poll(struct net_device *dev, int *budget)
213 } else { /* Pass up the skb already on the Rx ring. */ 213 } else { /* Pass up the skb already on the Rx ring. */
214 char *temp = skb_put(skb = tp->rx_buffers[entry].skb, 214 char *temp = skb_put(skb = tp->rx_buffers[entry].skb,
215 pkt_len); 215 pkt_len);
216 216
217#ifndef final_version 217#ifndef final_version
218 if (tp->rx_buffers[entry].mapping != 218 if (tp->rx_buffers[entry].mapping !=
219 le32_to_cpu(tp->rx_ring[entry].buffer1)) { 219 le32_to_cpu(tp->rx_ring[entry].buffer1)) {
@@ -225,17 +225,17 @@ int tulip_poll(struct net_device *dev, int *budget)
225 skb->head, temp); 225 skb->head, temp);
226 } 226 }
227#endif 227#endif
228 228
229 pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping, 229 pci_unmap_single(tp->pdev, tp->rx_buffers[entry].mapping,
230 PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 230 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
231 231
232 tp->rx_buffers[entry].skb = NULL; 232 tp->rx_buffers[entry].skb = NULL;
233 tp->rx_buffers[entry].mapping = 0; 233 tp->rx_buffers[entry].mapping = 0;
234 } 234 }
235 skb->protocol = eth_type_trans(skb, dev); 235 skb->protocol = eth_type_trans(skb, dev);
236 236
237 netif_receive_skb(skb); 237 netif_receive_skb(skb);
238 238
239 dev->last_rx = jiffies; 239 dev->last_rx = jiffies;
240 tp->stats.rx_packets++; 240 tp->stats.rx_packets++;
241 tp->stats.rx_bytes += pkt_len; 241 tp->stats.rx_bytes += pkt_len;
@@ -245,12 +245,12 @@ int tulip_poll(struct net_device *dev, int *budget)
245 entry = (++tp->cur_rx) % RX_RING_SIZE; 245 entry = (++tp->cur_rx) % RX_RING_SIZE;
246 if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/4) 246 if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/4)
247 tulip_refill_rx(dev); 247 tulip_refill_rx(dev);
248 248
249 } 249 }
250 250
251 /* New ack strategy... irq does not ack Rx any longer 251 /* New ack strategy... irq does not ack Rx any longer
252 hopefully this helps */ 252 hopefully this helps */
253 253
254 /* Really bad things can happen here... If new packet arrives 254 /* Really bad things can happen here... If new packet arrives
255 * and an irq arrives (tx or just due to occasionally unset 255 * and an irq arrives (tx or just due to occasionally unset
256 * mask), it will be acked by irq handler, but new thread 256 * mask), it will be acked by irq handler, but new thread
@@ -259,28 +259,28 @@ int tulip_poll(struct net_device *dev, int *budget)
259 * tomorrow (night 011029). If it will not fail, we won 259 * tomorrow (night 011029). If it will not fail, we won
260 * finally: amount of IO did not increase at all. */ 260 * finally: amount of IO did not increase at all. */
261 } while ((ioread32(tp->base_addr + CSR5) & RxIntr)); 261 } while ((ioread32(tp->base_addr + CSR5) & RxIntr));
262 262
263done: 263done:
264 264
265 #ifdef CONFIG_TULIP_NAPI_HW_MITIGATION 265 #ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
266 266
267 /* We use this simplistic scheme for IM. It's proven by 267 /* We use this simplistic scheme for IM. It's proven by
268 real life installations. We can have IM enabled 268 real life installations. We can have IM enabled
269 continuesly but this would cause unnecessary latency. 269 continuesly but this would cause unnecessary latency.
270 Unfortunely we can't use all the NET_RX_* feedback here. 270 Unfortunely we can't use all the NET_RX_* feedback here.
271 This would turn on IM for devices that is not contributing 271 This would turn on IM for devices that is not contributing
272 to backlog congestion with unnecessary latency. 272 to backlog congestion with unnecessary latency.
273 273
274 We monitor the the device RX-ring and have: 274 We monitor the the device RX-ring and have:
275 275
276 HW Interrupt Mitigation either ON or OFF. 276 HW Interrupt Mitigation either ON or OFF.
277 277
278 ON: More then 1 pkt received (per intr.) OR we are dropping 278 ON: More then 1 pkt received (per intr.) OR we are dropping
279 OFF: Only 1 pkt received 279 OFF: Only 1 pkt received
280 280
281 Note. We only use min and max (0, 15) settings from mit_table */ 281 Note. We only use min and max (0, 15) settings from mit_table */
282 282
283 283
284 if( tp->flags & HAS_INTR_MITIGATION) { 284 if( tp->flags & HAS_INTR_MITIGATION) {
285 if( received > 1 ) { 285 if( received > 1 ) {
286 if( ! tp->mit_on ) { 286 if( ! tp->mit_on ) {
@@ -297,20 +297,20 @@ done:
297 } 297 }
298 298
299#endif /* CONFIG_TULIP_NAPI_HW_MITIGATION */ 299#endif /* CONFIG_TULIP_NAPI_HW_MITIGATION */
300 300
301 dev->quota -= received; 301 dev->quota -= received;
302 *budget -= received; 302 *budget -= received;
303 303
304 tulip_refill_rx(dev); 304 tulip_refill_rx(dev);
305 305
306 /* If RX ring is not full we are out of memory. */ 306 /* If RX ring is not full we are out of memory. */
307 if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) goto oom; 307 if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) goto oom;
308 308
309 /* Remove us from polling list and enable RX intr. */ 309 /* Remove us from polling list and enable RX intr. */
310 310
311 netif_rx_complete(dev); 311 netif_rx_complete(dev);
312 iowrite32(tulip_tbl[tp->chip_id].valid_intrs, tp->base_addr+CSR7); 312 iowrite32(tulip_tbl[tp->chip_id].valid_intrs, tp->base_addr+CSR7);
313 313
314 /* The last op happens after poll completion. Which means the following: 314 /* The last op happens after poll completion. Which means the following:
315 * 1. it can race with disabling irqs in irq handler 315 * 1. it can race with disabling irqs in irq handler
316 * 2. it can race with dise/enabling irqs in other poll threads 316 * 2. it can race with dise/enabling irqs in other poll threads
@@ -321,9 +321,9 @@ done:
321 * due to races in masking and due to too late acking of already 321 * due to races in masking and due to too late acking of already
322 * processed irqs. But it must not result in losing events. 322 * processed irqs. But it must not result in losing events.
323 */ 323 */
324 324
325 return 0; 325 return 0;
326 326
327 not_done: 327 not_done:
328 if (!received) { 328 if (!received) {
329 329
@@ -331,29 +331,29 @@ done:
331 } 331 }
332 dev->quota -= received; 332 dev->quota -= received;
333 *budget -= received; 333 *budget -= received;
334 334
335 if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 || 335 if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/2 ||
336 tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) 336 tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL)
337 tulip_refill_rx(dev); 337 tulip_refill_rx(dev);
338 338
339 if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) goto oom; 339 if (tp->rx_buffers[tp->dirty_rx % RX_RING_SIZE].skb == NULL) goto oom;
340 340
341 return 1; 341 return 1;
342 342
343 343
344 oom: /* Executed with RX ints disabled */ 344 oom: /* Executed with RX ints disabled */
345 345
346 346
347 /* Start timer, stop polling, but do not enable rx interrupts. */ 347 /* Start timer, stop polling, but do not enable rx interrupts. */
348 mod_timer(&tp->oom_timer, jiffies+1); 348 mod_timer(&tp->oom_timer, jiffies+1);
349 349
350 /* Think: timer_pending() was an explicit signature of bug. 350 /* Think: timer_pending() was an explicit signature of bug.
351 * Timer can be pending now but fired and completed 351 * Timer can be pending now but fired and completed
352 * before we did netif_rx_complete(). See? We would lose it. */ 352 * before we did netif_rx_complete(). See? We would lose it. */
353 353
354 /* remove ourselves from the polling list */ 354 /* remove ourselves from the polling list */
355 netif_rx_complete(dev); 355 netif_rx_complete(dev);
356 356
357 return 0; 357 return 0;
358} 358}
359 359
@@ -521,9 +521,9 @@ irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
521 /* Let's see whether the interrupt really is for us */ 521 /* Let's see whether the interrupt really is for us */
522 csr5 = ioread32(ioaddr + CSR5); 522 csr5 = ioread32(ioaddr + CSR5);
523 523
524 if (tp->flags & HAS_PHY_IRQ) 524 if (tp->flags & HAS_PHY_IRQ)
525 handled = phy_interrupt (dev); 525 handled = phy_interrupt (dev);
526 526
527 if ((csr5 & (NormalIntr|AbnormalIntr)) == 0) 527 if ((csr5 & (NormalIntr|AbnormalIntr)) == 0)
528 return IRQ_RETVAL(handled); 528 return IRQ_RETVAL(handled);
529 529
@@ -538,17 +538,17 @@ irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
538 /* Mask RX intrs and add the device to poll list. */ 538 /* Mask RX intrs and add the device to poll list. */
539 iowrite32(tulip_tbl[tp->chip_id].valid_intrs&~RxPollInt, ioaddr + CSR7); 539 iowrite32(tulip_tbl[tp->chip_id].valid_intrs&~RxPollInt, ioaddr + CSR7);
540 netif_rx_schedule(dev); 540 netif_rx_schedule(dev);
541 541
542 if (!(csr5&~(AbnormalIntr|NormalIntr|RxPollInt|TPLnkPass))) 542 if (!(csr5&~(AbnormalIntr|NormalIntr|RxPollInt|TPLnkPass)))
543 break; 543 break;
544 } 544 }
545 545
546 /* Acknowledge the interrupt sources we handle here ASAP 546 /* Acknowledge the interrupt sources we handle here ASAP
547 the poll function does Rx and RxNoBuf acking */ 547 the poll function does Rx and RxNoBuf acking */
548 548
549 iowrite32(csr5 & 0x0001ff3f, ioaddr + CSR5); 549 iowrite32(csr5 & 0x0001ff3f, ioaddr + CSR5);
550 550
551#else 551#else
552 /* Acknowledge all of the current interrupt sources ASAP. */ 552 /* Acknowledge all of the current interrupt sources ASAP. */
553 iowrite32(csr5 & 0x0001ffff, ioaddr + CSR5); 553 iowrite32(csr5 & 0x0001ffff, ioaddr + CSR5);
554 554
@@ -559,11 +559,11 @@ irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
559 } 559 }
560 560
561#endif /* CONFIG_TULIP_NAPI */ 561#endif /* CONFIG_TULIP_NAPI */
562 562
563 if (tulip_debug > 4) 563 if (tulip_debug > 4)
564 printk(KERN_DEBUG "%s: interrupt csr5=%#8.8x new csr5=%#8.8x.\n", 564 printk(KERN_DEBUG "%s: interrupt csr5=%#8.8x new csr5=%#8.8x.\n",
565 dev->name, csr5, ioread32(ioaddr + CSR5)); 565 dev->name, csr5, ioread32(ioaddr + CSR5));
566 566
567 567
568 if (csr5 & (TxNoBuf | TxDied | TxIntr | TimerInt)) { 568 if (csr5 & (TxNoBuf | TxDied | TxIntr | TimerInt)) {
569 unsigned int dirty_tx; 569 unsigned int dirty_tx;
@@ -737,17 +737,17 @@ irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
737#ifdef CONFIG_TULIP_NAPI 737#ifdef CONFIG_TULIP_NAPI
738 if (rxd) 738 if (rxd)
739 csr5 &= ~RxPollInt; 739 csr5 &= ~RxPollInt;
740 } while ((csr5 & (TxNoBuf | 740 } while ((csr5 & (TxNoBuf |
741 TxDied | 741 TxDied |
742 TxIntr | 742 TxIntr |
743 TimerInt | 743 TimerInt |
744 /* Abnormal intr. */ 744 /* Abnormal intr. */
745 RxDied | 745 RxDied |
746 TxFIFOUnderflow | 746 TxFIFOUnderflow |
747 TxJabber | 747 TxJabber |
748 TPLnkFail | 748 TPLnkFail |
749 SytemError )) != 0); 749 SytemError )) != 0);
750#else 750#else
751 } while ((csr5 & (NormalIntr|AbnormalIntr)) != 0); 751 } while ((csr5 & (NormalIntr|AbnormalIntr)) != 0);
752 752
753 tulip_refill_rx(dev); 753 tulip_refill_rx(dev);
diff --git a/drivers/net/tulip/media.c b/drivers/net/tulip/media.c
index f53396fe79c9..e9bc2a958c14 100644
--- a/drivers/net/tulip/media.c
+++ b/drivers/net/tulip/media.c
@@ -140,7 +140,7 @@ void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int val)
140 spin_unlock_irqrestore(&tp->mii_lock, flags); 140 spin_unlock_irqrestore(&tp->mii_lock, flags);
141 return; 141 return;
142 } 142 }
143 143
144 /* Establish sync by sending 32 logic ones. */ 144 /* Establish sync by sending 32 logic ones. */
145 for (i = 32; i >= 0; i--) { 145 for (i = 32; i >= 0; i--) {
146 iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr); 146 iowrite32(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index 05d2d96f7be2..d25020da6798 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -259,7 +259,7 @@ enum t21143_csr6_bits {
259 There are no ill effects from too-large receive rings. */ 259 There are no ill effects from too-large receive rings. */
260 260
261#define TX_RING_SIZE 32 261#define TX_RING_SIZE 32
262#define RX_RING_SIZE 128 262#define RX_RING_SIZE 128
263#define MEDIA_MASK 31 263#define MEDIA_MASK 31
264 264
265#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */ 265#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index c67c91251d04..cabdf894e21e 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1224,7 +1224,7 @@ out:
1224 * Chips that have the MRM/reserved bit quirk and the burst quirk. That 1224 * Chips that have the MRM/reserved bit quirk and the burst quirk. That
1225 * is the DM910X and the on chip ULi devices 1225 * is the DM910X and the on chip ULi devices
1226 */ 1226 */
1227 1227
1228static int tulip_uli_dm_quirk(struct pci_dev *pdev) 1228static int tulip_uli_dm_quirk(struct pci_dev *pdev)
1229{ 1229{
1230 if (pdev->vendor == 0x1282 && pdev->device == 0x9102) 1230 if (pdev->vendor == 0x1282 && pdev->device == 0x9102)
@@ -1297,7 +1297,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1297 */ 1297 */
1298 1298
1299 /* 1. Intel Saturn. Switch to 8 long words burst, 8 long word cache 1299 /* 1. Intel Saturn. Switch to 8 long words burst, 8 long word cache
1300 aligned. Aries might need this too. The Saturn errata are not 1300 aligned. Aries might need this too. The Saturn errata are not
1301 pretty reading but thankfully it's an old 486 chipset. 1301 pretty reading but thankfully it's an old 486 chipset.
1302 1302
1303 2. The dreaded SiS496 486 chipset. Same workaround as Intel 1303 2. The dreaded SiS496 486 chipset. Same workaround as Intel
@@ -1483,14 +1483,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1483 sa_offset = 2; /* Grrr, damn Matrox boards. */ 1483 sa_offset = 2; /* Grrr, damn Matrox boards. */
1484 multiport_cnt = 4; 1484 multiport_cnt = 4;
1485 } 1485 }
1486#ifdef CONFIG_DDB5476
1487 if ((pdev->bus->number == 0) && (PCI_SLOT(pdev->devfn) == 6)) {
1488 /* DDB5476 MAC address in first EEPROM locations. */
1489 sa_offset = 0;
1490 /* No media table either */
1491 tp->flags &= ~HAS_MEDIA_TABLE;
1492 }
1493#endif
1494#ifdef CONFIG_DDB5477 1486#ifdef CONFIG_DDB5477
1495 if ((pdev->bus->number == 0) && (PCI_SLOT(pdev->devfn) == 4)) { 1487 if ((pdev->bus->number == 0) && (PCI_SLOT(pdev->devfn) == 4)) {
1496 /* DDB5477 MAC address in first EEPROM locations. */ 1488 /* DDB5477 MAC address in first EEPROM locations. */
@@ -1500,7 +1492,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1500 } 1492 }
1501#endif 1493#endif
1502#ifdef CONFIG_MIPS_COBALT 1494#ifdef CONFIG_MIPS_COBALT
1503 if ((pdev->bus->number == 0) && 1495 if ((pdev->bus->number == 0) &&
1504 ((PCI_SLOT(pdev->devfn) == 7) || 1496 ((PCI_SLOT(pdev->devfn) == 7) ||
1505 (PCI_SLOT(pdev->devfn) == 12))) { 1497 (PCI_SLOT(pdev->devfn) == 12))) {
1506 /* Cobalt MAC address in first EEPROM locations. */ 1498 /* Cobalt MAC address in first EEPROM locations. */
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index 238e9c72cb3a..8b3a28f53c3d 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -9,7 +9,7 @@
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details. 10 GNU General Public License for more details.
11 11
12 12
13*/ 13*/
14 14
15#define DRV_NAME "uli526x" 15#define DRV_NAME "uli526x"
@@ -185,7 +185,7 @@ struct uli526x_board_info {
185 185
186 /* NIC SROM data */ 186 /* NIC SROM data */
187 unsigned char srom[128]; 187 unsigned char srom[128];
188 u8 init; 188 u8 init;
189}; 189};
190 190
191enum uli526x_offsets { 191enum uli526x_offsets {
@@ -258,7 +258,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
258 struct uli526x_board_info *db; /* board information structure */ 258 struct uli526x_board_info *db; /* board information structure */
259 struct net_device *dev; 259 struct net_device *dev;
260 int i, err; 260 int i, err;
261 261
262 ULI526X_DBUG(0, "uli526x_init_one()", 0); 262 ULI526X_DBUG(0, "uli526x_init_one()", 0);
263 263
264 if (!printed_version++) 264 if (!printed_version++)
@@ -316,7 +316,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
316 err = -ENOMEM; 316 err = -ENOMEM;
317 goto err_out_nomem; 317 goto err_out_nomem;
318 } 318 }
319 319
320 db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; 320 db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr;
321 db->first_tx_desc_dma = db->desc_pool_dma_ptr; 321 db->first_tx_desc_dma = db->desc_pool_dma_ptr;
322 db->buf_pool_start = db->buf_pool_ptr; 322 db->buf_pool_start = db->buf_pool_ptr;
@@ -324,14 +324,14 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
324 324
325 db->chip_id = ent->driver_data; 325 db->chip_id = ent->driver_data;
326 db->ioaddr = pci_resource_start(pdev, 0); 326 db->ioaddr = pci_resource_start(pdev, 0);
327 327
328 db->pdev = pdev; 328 db->pdev = pdev;
329 db->init = 1; 329 db->init = 1;
330 330
331 dev->base_addr = db->ioaddr; 331 dev->base_addr = db->ioaddr;
332 dev->irq = pdev->irq; 332 dev->irq = pdev->irq;
333 pci_set_drvdata(pdev, dev); 333 pci_set_drvdata(pdev, dev);
334 334
335 /* Register some necessary functions */ 335 /* Register some necessary functions */
336 dev->open = &uli526x_open; 336 dev->open = &uli526x_open;
337 dev->hard_start_xmit = &uli526x_start_xmit; 337 dev->hard_start_xmit = &uli526x_start_xmit;
@@ -341,7 +341,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
341 dev->ethtool_ops = &netdev_ethtool_ops; 341 dev->ethtool_ops = &netdev_ethtool_ops;
342 spin_lock_init(&db->lock); 342 spin_lock_init(&db->lock);
343 343
344 344
345 /* read 64 word srom data */ 345 /* read 64 word srom data */
346 for (i = 0; i < 64; i++) 346 for (i = 0; i < 64; i++)
347 ((u16 *) db->srom)[i] = cpu_to_le16(read_srom_word(db->ioaddr, i)); 347 ((u16 *) db->srom)[i] = cpu_to_le16(read_srom_word(db->ioaddr, i));
@@ -374,7 +374,7 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
374 goto err_out_res; 374 goto err_out_res;
375 375
376 printk(KERN_INFO "%s: ULi M%04lx at pci%s,",dev->name,ent->driver_data >> 16,pci_name(pdev)); 376 printk(KERN_INFO "%s: ULi M%04lx at pci%s,",dev->name,ent->driver_data >> 16,pci_name(pdev));
377 377
378 for (i = 0; i < 6; i++) 378 for (i = 0; i < 6; i++)
379 printk("%c%02x", i ? ':' : ' ', dev->dev_addr[i]); 379 printk("%c%02x", i ? ':' : ' ', dev->dev_addr[i]);
380 printk(", irq %d.\n", dev->irq); 380 printk(", irq %d.\n", dev->irq);
@@ -389,7 +389,7 @@ err_out_nomem:
389 if(db->desc_pool_ptr) 389 if(db->desc_pool_ptr)
390 pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, 390 pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
391 db->desc_pool_ptr, db->desc_pool_dma_ptr); 391 db->desc_pool_ptr, db->desc_pool_dma_ptr);
392 392
393 if(db->buf_pool_ptr != NULL) 393 if(db->buf_pool_ptr != NULL)
394 pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, 394 pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
395 db->buf_pool_ptr, db->buf_pool_dma_ptr); 395 db->buf_pool_ptr, db->buf_pool_dma_ptr);
@@ -433,7 +433,7 @@ static int uli526x_open(struct net_device *dev)
433{ 433{
434 int ret; 434 int ret;
435 struct uli526x_board_info *db = netdev_priv(dev); 435 struct uli526x_board_info *db = netdev_priv(dev);
436 436
437 ULI526X_DBUG(0, "uli526x_open", 0); 437 ULI526X_DBUG(0, "uli526x_open", 0);
438 438
439 ret = request_irq(dev->irq, &uli526x_interrupt, SA_SHIRQ, dev->name, dev); 439 ret = request_irq(dev->irq, &uli526x_interrupt, SA_SHIRQ, dev->name, dev);
@@ -454,7 +454,7 @@ static int uli526x_open(struct net_device *dev)
454 /* CR6 operation mode decision */ 454 /* CR6 operation mode decision */
455 db->cr6_data |= ULI526X_TXTH_256; 455 db->cr6_data |= ULI526X_TXTH_256;
456 db->cr0_data = CR0_DEFAULT; 456 db->cr0_data = CR0_DEFAULT;
457 457
458 /* Initialize ULI526X board */ 458 /* Initialize ULI526X board */
459 uli526x_init(dev); 459 uli526x_init(dev);
460 460
@@ -604,7 +604,7 @@ static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev)
604 /* Restore CR7 to enable interrupt */ 604 /* Restore CR7 to enable interrupt */
605 spin_unlock_irqrestore(&db->lock, flags); 605 spin_unlock_irqrestore(&db->lock, flags);
606 outl(db->cr7_data, dev->base_addr + DCR7); 606 outl(db->cr7_data, dev->base_addr + DCR7);
607 607
608 /* free this SKB */ 608 /* free this SKB */
609 dev_kfree_skb(skb); 609 dev_kfree_skb(skb);
610 610
@@ -782,7 +782,7 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
782 struct sk_buff *skb; 782 struct sk_buff *skb;
783 int rxlen; 783 int rxlen;
784 u32 rdes0; 784 u32 rdes0;
785 785
786 rxptr = db->rx_ready_ptr; 786 rxptr = db->rx_ready_ptr;
787 787
788 while(db->rx_avail_cnt) { 788 while(db->rx_avail_cnt) {
@@ -821,7 +821,7 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
821 if ( !(rdes0 & 0x8000) || 821 if ( !(rdes0 & 0x8000) ||
822 ((db->cr6_data & CR6_PM) && (rxlen>6)) ) { 822 ((db->cr6_data & CR6_PM) && (rxlen>6)) ) {
823 skb = rxptr->rx_skb_ptr; 823 skb = rxptr->rx_skb_ptr;
824 824
825 /* Good packet, send to upper layer */ 825 /* Good packet, send to upper layer */
826 /* Shorst packet used new SKB */ 826 /* Shorst packet used new SKB */
827 if ( (rxlen < RX_COPY_SIZE) && 827 if ( (rxlen < RX_COPY_SIZE) &&
@@ -841,7 +841,7 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
841 dev->last_rx = jiffies; 841 dev->last_rx = jiffies;
842 db->stats.rx_packets++; 842 db->stats.rx_packets++;
843 db->stats.rx_bytes += rxlen; 843 db->stats.rx_bytes += rxlen;
844 844
845 } else { 845 } else {
846 /* Reuse SKB buffer when the packet is error */ 846 /* Reuse SKB buffer when the packet is error */
847 ULI526X_DBUG(0, "Reuse SK buffer, rdes0", rdes0); 847 ULI526X_DBUG(0, "Reuse SK buffer, rdes0", rdes0);
@@ -911,7 +911,7 @@ ULi_ethtool_gset(struct uli526x_board_info *db, struct ethtool_cmd *ecmd)
911 SUPPORTED_100baseT_Full | 911 SUPPORTED_100baseT_Full |
912 SUPPORTED_Autoneg | 912 SUPPORTED_Autoneg |
913 SUPPORTED_MII); 913 SUPPORTED_MII);
914 914
915 ecmd->advertising = (ADVERTISED_10baseT_Half | 915 ecmd->advertising = (ADVERTISED_10baseT_Half |
916 ADVERTISED_10baseT_Full | 916 ADVERTISED_10baseT_Full |
917 ADVERTISED_100baseT_Half | 917 ADVERTISED_100baseT_Half |
@@ -924,13 +924,13 @@ ULi_ethtool_gset(struct uli526x_board_info *db, struct ethtool_cmd *ecmd)
924 ecmd->phy_address = db->phy_addr; 924 ecmd->phy_address = db->phy_addr;
925 925
926 ecmd->transceiver = XCVR_EXTERNAL; 926 ecmd->transceiver = XCVR_EXTERNAL;
927 927
928 ecmd->speed = 10; 928 ecmd->speed = 10;
929 ecmd->duplex = DUPLEX_HALF; 929 ecmd->duplex = DUPLEX_HALF;
930 930
931 if(db->op_mode==ULI526X_100MHF || db->op_mode==ULI526X_100MFD) 931 if(db->op_mode==ULI526X_100MHF || db->op_mode==ULI526X_100MFD)
932 { 932 {
933 ecmd->speed = 100; 933 ecmd->speed = 100;
934 } 934 }
935 if(db->op_mode==ULI526X_10MFD || db->op_mode==ULI526X_100MFD) 935 if(db->op_mode==ULI526X_10MFD || db->op_mode==ULI526X_100MFD)
936 { 936 {
@@ -939,11 +939,11 @@ ULi_ethtool_gset(struct uli526x_board_info *db, struct ethtool_cmd *ecmd)
939 if(db->link_failed) 939 if(db->link_failed)
940 { 940 {
941 ecmd->speed = -1; 941 ecmd->speed = -1;
942 ecmd->duplex = -1; 942 ecmd->duplex = -1;
943 } 943 }
944 944
945 if (db->media_mode & ULI526X_AUTO) 945 if (db->media_mode & ULI526X_AUTO)
946 { 946 {
947 ecmd->autoneg = AUTONEG_ENABLE; 947 ecmd->autoneg = AUTONEG_ENABLE;
948 } 948 }
949} 949}
@@ -964,15 +964,15 @@ static void netdev_get_drvinfo(struct net_device *dev,
964 964
965static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { 965static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) {
966 struct uli526x_board_info *np = netdev_priv(dev); 966 struct uli526x_board_info *np = netdev_priv(dev);
967 967
968 ULi_ethtool_gset(np, cmd); 968 ULi_ethtool_gset(np, cmd);
969 969
970 return 0; 970 return 0;
971} 971}
972 972
973static u32 netdev_get_link(struct net_device *dev) { 973static u32 netdev_get_link(struct net_device *dev) {
974 struct uli526x_board_info *np = netdev_priv(dev); 974 struct uli526x_board_info *np = netdev_priv(dev);
975 975
976 if(np->link_failed) 976 if(np->link_failed)
977 return 0; 977 return 0;
978 else 978 else
@@ -1005,11 +1005,11 @@ static void uli526x_timer(unsigned long data)
1005 struct uli526x_board_info *db = netdev_priv(dev); 1005 struct uli526x_board_info *db = netdev_priv(dev);
1006 unsigned long flags; 1006 unsigned long flags;
1007 u8 TmpSpeed=10; 1007 u8 TmpSpeed=10;
1008 1008
1009 //ULI526X_DBUG(0, "uli526x_timer()", 0); 1009 //ULI526X_DBUG(0, "uli526x_timer()", 0);
1010 spin_lock_irqsave(&db->lock, flags); 1010 spin_lock_irqsave(&db->lock, flags);
1011 1011
1012 1012
1013 /* Dynamic reset ULI526X : system error or transmit time-out */ 1013 /* Dynamic reset ULI526X : system error or transmit time-out */
1014 tmp_cr8 = inl(db->ioaddr + DCR8); 1014 tmp_cr8 = inl(db->ioaddr + DCR8);
1015 if ( (db->interval_rx_cnt==0) && (tmp_cr8) ) { 1015 if ( (db->interval_rx_cnt==0) && (tmp_cr8) ) {
@@ -1021,9 +1021,9 @@ static void uli526x_timer(unsigned long data)
1021 /* TX polling kick monitor */ 1021 /* TX polling kick monitor */
1022 if ( db->tx_packet_cnt && 1022 if ( db->tx_packet_cnt &&
1023 time_after(jiffies, dev->trans_start + ULI526X_TX_KICK) ) { 1023 time_after(jiffies, dev->trans_start + ULI526X_TX_KICK) ) {
1024 outl(0x1, dev->base_addr + DCR1); // Tx polling again 1024 outl(0x1, dev->base_addr + DCR1); // Tx polling again
1025 1025
1026 // TX Timeout 1026 // TX Timeout
1027 if ( time_after(jiffies, dev->trans_start + ULI526X_TX_TIMEOUT) ) { 1027 if ( time_after(jiffies, dev->trans_start + ULI526X_TX_TIMEOUT) ) {
1028 db->reset_TXtimeout++; 1028 db->reset_TXtimeout++;
1029 db->wait_reset = 1; 1029 db->wait_reset = 1;
@@ -1073,7 +1073,7 @@ static void uli526x_timer(unsigned long data)
1073 uli526x_sense_speed(db) ) 1073 uli526x_sense_speed(db) )
1074 db->link_failed = 1; 1074 db->link_failed = 1;
1075 uli526x_process_mode(db); 1075 uli526x_process_mode(db);
1076 1076
1077 if(db->link_failed==0) 1077 if(db->link_failed==0)
1078 { 1078 {
1079 if(db->op_mode==ULI526X_100MHF || db->op_mode==ULI526X_100MFD) 1079 if(db->op_mode==ULI526X_100MHF || db->op_mode==ULI526X_100MFD)
@@ -1404,7 +1404,7 @@ static u8 uli526x_sense_speed(struct uli526x_board_info * db)
1404 phy_mode = phy_read(db->ioaddr, db->phy_addr, 1, db->chip_id); 1404 phy_mode = phy_read(db->ioaddr, db->phy_addr, 1, db->chip_id);
1405 1405
1406 if ( (phy_mode & 0x24) == 0x24 ) { 1406 if ( (phy_mode & 0x24) == 0x24 ) {
1407 1407
1408 phy_mode = ((phy_read(db->ioaddr, db->phy_addr, 5, db->chip_id) & 0x01e0)<<7); 1408 phy_mode = ((phy_read(db->ioaddr, db->phy_addr, 5, db->chip_id) & 0x01e0)<<7);
1409 if(phy_mode&0x8000) 1409 if(phy_mode&0x8000)
1410 phy_mode = 0x8000; 1410 phy_mode = 0x8000;
@@ -1414,7 +1414,7 @@ static u8 uli526x_sense_speed(struct uli526x_board_info * db)
1414 phy_mode = 0x2000; 1414 phy_mode = 0x2000;
1415 else 1415 else
1416 phy_mode = 0x1000; 1416 phy_mode = 0x1000;
1417 1417
1418 /* printk(DRV_NAME ": Phy_mode %x ",phy_mode); */ 1418 /* printk(DRV_NAME ": Phy_mode %x ",phy_mode); */
1419 switch (phy_mode) { 1419 switch (phy_mode) {
1420 case 0x1000: db->op_mode = ULI526X_10MHF; break; 1420 case 0x1000: db->op_mode = ULI526X_10MHF; break;
@@ -1442,7 +1442,7 @@ static u8 uli526x_sense_speed(struct uli526x_board_info * db)
1442static void uli526x_set_phyxcer(struct uli526x_board_info *db) 1442static void uli526x_set_phyxcer(struct uli526x_board_info *db)
1443{ 1443{
1444 u16 phy_reg; 1444 u16 phy_reg;
1445 1445
1446 /* Phyxcer capability setting */ 1446 /* Phyxcer capability setting */
1447 phy_reg = phy_read(db->ioaddr, db->phy_addr, 4, db->chip_id) & ~0x01e0; 1447 phy_reg = phy_read(db->ioaddr, db->phy_addr, 4, db->chip_id) & ~0x01e0;
1448 1448
@@ -1457,7 +1457,7 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *db)
1457 case ULI526X_100MHF: phy_reg |= 0x80; break; 1457 case ULI526X_100MHF: phy_reg |= 0x80; break;
1458 case ULI526X_100MFD: phy_reg |= 0x100; break; 1458 case ULI526X_100MFD: phy_reg |= 0x100; break;
1459 } 1459 }
1460 1460
1461 } 1461 }
1462 1462
1463 /* Write new capability to Phyxcer Reg4 */ 1463 /* Write new capability to Phyxcer Reg4 */
@@ -1556,7 +1556,7 @@ static void phy_write(unsigned long iobase, u8 phy_addr, u8 offset, u16 phy_data
1556 /* Write a word data to PHY controller */ 1556 /* Write a word data to PHY controller */
1557 for ( i = 0x8000; i > 0; i >>= 1) 1557 for ( i = 0x8000; i > 0; i >>= 1)
1558 phy_write_1bit(ioaddr, phy_data & i ? PHY_DATA_1 : PHY_DATA_0, chip_id); 1558 phy_write_1bit(ioaddr, phy_data & i ? PHY_DATA_1 : PHY_DATA_0, chip_id);
1559 1559
1560} 1560}
1561 1561
1562 1562
@@ -1574,7 +1574,7 @@ static u16 phy_read(unsigned long iobase, u8 phy_addr, u8 offset, u32 chip_id)
1574 return phy_readby_cr10(iobase, phy_addr, offset); 1574 return phy_readby_cr10(iobase, phy_addr, offset);
1575 /* M5261/M5263 Chip */ 1575 /* M5261/M5263 Chip */
1576 ioaddr = iobase + DCR9; 1576 ioaddr = iobase + DCR9;
1577 1577
1578 /* Send 33 synchronization clock to Phy controller */ 1578 /* Send 33 synchronization clock to Phy controller */
1579 for (i = 0; i < 35; i++) 1579 for (i = 0; i < 35; i++)
1580 phy_write_1bit(ioaddr, PHY_DATA_1, chip_id); 1580 phy_write_1bit(ioaddr, PHY_DATA_1, chip_id);
@@ -1610,7 +1610,7 @@ static u16 phy_read(unsigned long iobase, u8 phy_addr, u8 offset, u32 chip_id)
1610static u16 phy_readby_cr10(unsigned long iobase, u8 phy_addr, u8 offset) 1610static u16 phy_readby_cr10(unsigned long iobase, u8 phy_addr, u8 offset)
1611{ 1611{
1612 unsigned long ioaddr,cr10_value; 1612 unsigned long ioaddr,cr10_value;
1613 1613
1614 ioaddr = iobase + DCR10; 1614 ioaddr = iobase + DCR10;
1615 cr10_value = phy_addr; 1615 cr10_value = phy_addr;
1616 cr10_value = (cr10_value<<5) + offset; 1616 cr10_value = (cr10_value<<5) + offset;
@@ -1629,7 +1629,7 @@ static u16 phy_readby_cr10(unsigned long iobase, u8 phy_addr, u8 offset)
1629static void phy_writeby_cr10(unsigned long iobase, u8 phy_addr, u8 offset, u16 phy_data) 1629static void phy_writeby_cr10(unsigned long iobase, u8 phy_addr, u8 offset, u16 phy_data)
1630{ 1630{
1631 unsigned long ioaddr,cr10_value; 1631 unsigned long ioaddr,cr10_value;
1632 1632
1633 ioaddr = iobase + DCR10; 1633 ioaddr = iobase + DCR10;
1634 cr10_value = phy_addr; 1634 cr10_value = phy_addr;
1635 cr10_value = (cr10_value<<5) + offset; 1635 cr10_value = (cr10_value<<5) + offset;
@@ -1659,7 +1659,7 @@ static void phy_write_1bit(unsigned long ioaddr, u32 phy_data, u32 chip_id)
1659static u16 phy_read_1bit(unsigned long ioaddr, u32 chip_id) 1659static u16 phy_read_1bit(unsigned long ioaddr, u32 chip_id)
1660{ 1660{
1661 u16 phy_data; 1661 u16 phy_data;
1662 1662
1663 outl(0x50000 , ioaddr); 1663 outl(0x50000 , ioaddr);
1664 udelay(1); 1664 udelay(1);
1665 phy_data = ( inl(ioaddr) >> 19 ) & 0x1; 1665 phy_data = ( inl(ioaddr) >> 19 ) & 0x1;
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 136a70c4d5e4..8fea2aa455d4 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -38,12 +38,12 @@
38 Copyright (C) 2001 Manfred Spraul 38 Copyright (C) 2001 Manfred Spraul
39 * ethtool support (jgarzik) 39 * ethtool support (jgarzik)
40 * Replace some MII-related magic numbers with constants (jgarzik) 40 * Replace some MII-related magic numbers with constants (jgarzik)
41 41
42 TODO: 42 TODO:
43 * enable pci_power_off 43 * enable pci_power_off
44 * Wake-On-LAN 44 * Wake-On-LAN
45*/ 45*/
46 46
47#define DRV_NAME "winbond-840" 47#define DRV_NAME "winbond-840"
48#define DRV_VERSION "1.01-d" 48#define DRV_VERSION "1.01-d"
49#define DRV_RELDATE "Nov-17-2001" 49#define DRV_RELDATE "Nov-17-2001"
@@ -57,7 +57,7 @@ c-help-name: Winbond W89c840 PCI Ethernet support
57c-help-symbol: CONFIG_WINBOND_840 57c-help-symbol: CONFIG_WINBOND_840
58c-help: This driver is for the Winbond W89c840 chip. It also works with 58c-help: This driver is for the Winbond W89c840 chip. It also works with
59c-help: the TX9882 chip on the Compex RL100-ATX board. 59c-help: the TX9882 chip on the Compex RL100-ATX board.
60c-help: More specific information and updates are available from 60c-help: More specific information and updates are available from
61c-help: http://www.scyld.com/network/drivers.html 61c-help: http://www.scyld.com/network/drivers.html
62*/ 62*/
63 63
@@ -207,7 +207,7 @@ Test with 'ping -s 10000' on a fast computer.
207 207
208*/ 208*/
209 209
210 210
211 211
212/* 212/*
213 PCI probe table. 213 PCI probe table.
@@ -374,7 +374,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
374static struct ethtool_ops netdev_ethtool_ops; 374static struct ethtool_ops netdev_ethtool_ops;
375static int netdev_close(struct net_device *dev); 375static int netdev_close(struct net_device *dev);
376 376
377 377
378 378
379static int __devinit w840_probe1 (struct pci_dev *pdev, 379static int __devinit w840_probe1 (struct pci_dev *pdev,
380 const struct pci_device_id *ent) 380 const struct pci_device_id *ent)
@@ -434,7 +434,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
434 np->mii_if.mdio_read = mdio_read; 434 np->mii_if.mdio_read = mdio_read;
435 np->mii_if.mdio_write = mdio_write; 435 np->mii_if.mdio_write = mdio_write;
436 np->base_addr = ioaddr; 436 np->base_addr = ioaddr;
437 437
438 pci_set_drvdata(pdev, dev); 438 pci_set_drvdata(pdev, dev);
439 439
440 if (dev->mem_start) 440 if (dev->mem_start)
@@ -510,7 +510,7 @@ err_out_netdev:
510 return -ENODEV; 510 return -ENODEV;
511} 511}
512 512
513 513
514/* Read the EEPROM and MII Management Data I/O (MDIO) interfaces. These are 514/* Read the EEPROM and MII Management Data I/O (MDIO) interfaces. These are
515 often serial bit streams generated by the host processor. 515 often serial bit streams generated by the host processor.
516 The example below is for the common 93c46 EEPROM, 64 16 bit words. */ 516 The example below is for the common 93c46 EEPROM, 64 16 bit words. */
@@ -660,7 +660,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
660 return; 660 return;
661} 661}
662 662
663 663
664static int netdev_open(struct net_device *dev) 664static int netdev_open(struct net_device *dev)
665{ 665{
666 struct netdev_private *np = netdev_priv(dev); 666 struct netdev_private *np = netdev_priv(dev);
@@ -731,7 +731,7 @@ static int update_link(struct net_device *dev)
731 dev->name, np->phys[0]); 731 dev->name, np->phys[0]);
732 netif_carrier_on(dev); 732 netif_carrier_on(dev);
733 } 733 }
734 734
735 if ((np->mii & ~0xf) == MII_DAVICOM_DM9101) { 735 if ((np->mii & ~0xf) == MII_DAVICOM_DM9101) {
736 /* If the link partner doesn't support autonegotiation 736 /* If the link partner doesn't support autonegotiation
737 * the MII detects it's abilities with the "parallel detection". 737 * the MII detects it's abilities with the "parallel detection".
@@ -761,7 +761,7 @@ static int update_link(struct net_device *dev)
761 result |= 0x20000000; 761 result |= 0x20000000;
762 if (result != np->csr6 && debug) 762 if (result != np->csr6 && debug)
763 printk(KERN_INFO "%s: Setting %dMBit-%s-duplex based on MII#%d\n", 763 printk(KERN_INFO "%s: Setting %dMBit-%s-duplex based on MII#%d\n",
764 dev->name, fasteth ? 100 : 10, 764 dev->name, fasteth ? 100 : 10,
765 duplex ? "full" : "half", np->phys[0]); 765 duplex ? "full" : "half", np->phys[0]);
766 return result; 766 return result;
767} 767}
@@ -947,7 +947,7 @@ static void init_registers(struct net_device *dev)
947 iowrite32(i, ioaddr + PCIBusCfg); 947 iowrite32(i, ioaddr + PCIBusCfg);
948 948
949 np->csr6 = 0; 949 np->csr6 = 0;
950 /* 128 byte Tx threshold; 950 /* 128 byte Tx threshold;
951 Transmit on; Receive on; */ 951 Transmit on; Receive on; */
952 update_csr6(dev, 0x00022002 | update_link(dev) | __set_rx_mode(dev)); 952 update_csr6(dev, 0x00022002 | update_link(dev) | __set_rx_mode(dev));
953 953
@@ -1584,7 +1584,7 @@ static int netdev_close(struct net_device *dev)
1584static void __devexit w840_remove1 (struct pci_dev *pdev) 1584static void __devexit w840_remove1 (struct pci_dev *pdev)
1585{ 1585{
1586 struct net_device *dev = pci_get_drvdata(pdev); 1586 struct net_device *dev = pci_get_drvdata(pdev);
1587 1587
1588 if (dev) { 1588 if (dev) {
1589 struct netdev_private *np = netdev_priv(dev); 1589 struct netdev_private *np = netdev_priv(dev);
1590 unregister_netdev(dev); 1590 unregister_netdev(dev);
@@ -1605,11 +1605,11 @@ static void __devexit w840_remove1 (struct pci_dev *pdev)
1605 * - get_stats: 1605 * - get_stats:
1606 * spin_lock_irq(np->lock), doesn't touch hw if not present 1606 * spin_lock_irq(np->lock), doesn't touch hw if not present
1607 * - hard_start_xmit: 1607 * - hard_start_xmit:
1608 * netif_stop_queue + spin_unlock_wait(&dev->xmit_lock); 1608 * synchronize_irq + netif_tx_disable;
1609 * - tx_timeout: 1609 * - tx_timeout:
1610 * netif_device_detach + spin_unlock_wait(&dev->xmit_lock); 1610 * netif_device_detach + netif_tx_disable;
1611 * - set_multicast_list 1611 * - set_multicast_list
1612 * netif_device_detach + spin_unlock_wait(&dev->xmit_lock); 1612 * netif_device_detach + netif_tx_disable;
1613 * - interrupt handler 1613 * - interrupt handler
1614 * doesn't touch hw if not present, synchronize_irq waits for 1614 * doesn't touch hw if not present, synchronize_irq waits for
1615 * running instances of the interrupt handler. 1615 * running instances of the interrupt handler.
@@ -1635,11 +1635,10 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
1635 netif_device_detach(dev); 1635 netif_device_detach(dev);
1636 update_csr6(dev, 0); 1636 update_csr6(dev, 0);
1637 iowrite32(0, ioaddr + IntrEnable); 1637 iowrite32(0, ioaddr + IntrEnable);
1638 netif_stop_queue(dev);
1639 spin_unlock_irq(&np->lock); 1638 spin_unlock_irq(&np->lock);
1640 1639
1641 spin_unlock_wait(&dev->xmit_lock);
1642 synchronize_irq(dev->irq); 1640 synchronize_irq(dev->irq);
1641 netif_tx_disable(dev);
1643 1642
1644 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff; 1643 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
1645 1644
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 56344103ac23..63c2175ed138 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * xircom_cb: A driver for the (tulip-like) Xircom Cardbus ethernet cards 2 * xircom_cb: A driver for the (tulip-like) Xircom Cardbus ethernet cards
3 * 3 *
4 * This software is (C) by the respective authors, and licensed under the GPL 4 * This software is (C) by the respective authors, and licensed under the GPL
5 * License. 5 * License.
6 * 6 *
7 * Written by Arjan van de Ven for Red Hat, Inc. 7 * Written by Arjan van de Ven for Red Hat, Inc.
8 * Based on work by Jeff Garzik, Doug Ledford and Donald Becker 8 * Based on work by Jeff Garzik, Doug Ledford and Donald Becker
9 * 9 *
10 * This software may be used and distributed according to the terms 10 * This software may be used and distributed according to the terms
11 * of the GNU General Public License, incorporated herein by reference. 11 * of the GNU General Public License, incorporated herein by reference.
@@ -93,7 +93,7 @@ struct xircom_private {
93 93
94 unsigned long io_port; 94 unsigned long io_port;
95 int open; 95 int open;
96 96
97 /* transmit_used is the rotating counter that indicates which transmit 97 /* transmit_used is the rotating counter that indicates which transmit
98 descriptor has to be used next */ 98 descriptor has to be used next */
99 int transmit_used; 99 int transmit_used;
@@ -153,10 +153,10 @@ static struct pci_device_id xircom_pci_table[] = {
153MODULE_DEVICE_TABLE(pci, xircom_pci_table); 153MODULE_DEVICE_TABLE(pci, xircom_pci_table);
154 154
155static struct pci_driver xircom_ops = { 155static struct pci_driver xircom_ops = {
156 .name = "xircom_cb", 156 .name = "xircom_cb",
157 .id_table = xircom_pci_table, 157 .id_table = xircom_pci_table,
158 .probe = xircom_probe, 158 .probe = xircom_probe,
159 .remove = xircom_remove, 159 .remove = xircom_remove,
160 .suspend =NULL, 160 .suspend =NULL,
161 .resume =NULL 161 .resume =NULL
162}; 162};
@@ -174,7 +174,7 @@ static void print_binary(unsigned int number)
174 buffer[i2++]='1'; 174 buffer[i2++]='1';
175 else 175 else
176 buffer[i2++]='0'; 176 buffer[i2++]='0';
177 if ((i&3)==0) 177 if ((i&3)==0)
178 buffer[i2++]=' '; 178 buffer[i2++]=' ';
179 } 179 }
180 printk("%s\n",buffer); 180 printk("%s\n",buffer);
@@ -196,10 +196,10 @@ static struct ethtool_ops netdev_ethtool_ops = {
196 196
197/* xircom_probe is the code that gets called on device insertion. 197/* xircom_probe is the code that gets called on device insertion.
198 it sets up the hardware and registers the device to the networklayer. 198 it sets up the hardware and registers the device to the networklayer.
199 199
200 TODO: Send 1 or 2 "dummy" packets here as the card seems to discard the 200 TODO: Send 1 or 2 "dummy" packets here as the card seems to discard the
201 first two packets that get send, and pump hates that. 201 first two packets that get send, and pump hates that.
202 202
203 */ 203 */
204static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_id *id) 204static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_id *id)
205{ 205{
@@ -209,7 +209,7 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
209 unsigned long flags; 209 unsigned long flags;
210 unsigned short tmp16; 210 unsigned short tmp16;
211 enter("xircom_probe"); 211 enter("xircom_probe");
212 212
213 /* First do the PCI initialisation */ 213 /* First do the PCI initialisation */
214 214
215 if (pci_enable_device(pdev)) 215 if (pci_enable_device(pdev))
@@ -217,24 +217,24 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
217 217
218 /* disable all powermanagement */ 218 /* disable all powermanagement */
219 pci_write_config_dword(pdev, PCI_POWERMGMT, 0x0000); 219 pci_write_config_dword(pdev, PCI_POWERMGMT, 0x0000);
220 220
221 pci_set_master(pdev); /* Why isn't this done by pci_enable_device ?*/ 221 pci_set_master(pdev); /* Why isn't this done by pci_enable_device ?*/
222 222
223 /* clear PCI status, if any */ 223 /* clear PCI status, if any */
224 pci_read_config_word (pdev,PCI_STATUS, &tmp16); 224 pci_read_config_word (pdev,PCI_STATUS, &tmp16);
225 pci_write_config_word (pdev, PCI_STATUS,tmp16); 225 pci_write_config_word (pdev, PCI_STATUS,tmp16);
226 226
227 pci_read_config_byte(pdev, PCI_REVISION_ID, &chip_rev); 227 pci_read_config_byte(pdev, PCI_REVISION_ID, &chip_rev);
228 228
229 if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) { 229 if (!request_region(pci_resource_start(pdev, 0), 128, "xircom_cb")) {
230 printk(KERN_ERR "xircom_probe: failed to allocate io-region\n"); 230 printk(KERN_ERR "xircom_probe: failed to allocate io-region\n");
231 return -ENODEV; 231 return -ENODEV;
232 } 232 }
233 233
234 /* 234 /*
235 Before changing the hardware, allocate the memory. 235 Before changing the hardware, allocate the memory.
236 This way, we can fail gracefully if not enough memory 236 This way, we can fail gracefully if not enough memory
237 is available. 237 is available.
238 */ 238 */
239 dev = alloc_etherdev(sizeof(struct xircom_private)); 239 dev = alloc_etherdev(sizeof(struct xircom_private));
240 if (!dev) { 240 if (!dev) {
@@ -242,13 +242,13 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
242 goto device_fail; 242 goto device_fail;
243 } 243 }
244 private = netdev_priv(dev); 244 private = netdev_priv(dev);
245 245
246 /* Allocate the send/receive buffers */ 246 /* Allocate the send/receive buffers */
247 private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle); 247 private->rx_buffer = pci_alloc_consistent(pdev,8192,&private->rx_dma_handle);
248 if (private->rx_buffer == NULL) { 248 if (private->rx_buffer == NULL) {
249 printk(KERN_ERR "xircom_probe: no memory for rx buffer \n"); 249 printk(KERN_ERR "xircom_probe: no memory for rx buffer \n");
250 goto rx_buf_fail; 250 goto rx_buf_fail;
251 } 251 }
252 private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle); 252 private->tx_buffer = pci_alloc_consistent(pdev,8192,&private->tx_dma_handle);
253 if (private->tx_buffer == NULL) { 253 if (private->tx_buffer == NULL) {
254 printk(KERN_ERR "xircom_probe: no memory for tx buffer \n"); 254 printk(KERN_ERR "xircom_probe: no memory for tx buffer \n");
@@ -265,11 +265,11 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
265 spin_lock_init(&private->lock); 265 spin_lock_init(&private->lock);
266 dev->irq = pdev->irq; 266 dev->irq = pdev->irq;
267 dev->base_addr = private->io_port; 267 dev->base_addr = private->io_port;
268 268
269 initialize_card(private); 269 initialize_card(private);
270 read_mac_address(private); 270 read_mac_address(private);
271 setup_descriptors(private); 271 setup_descriptors(private);
272 272
273 dev->open = &xircom_open; 273 dev->open = &xircom_open;
274 dev->hard_start_xmit = &xircom_start_xmit; 274 dev->hard_start_xmit = &xircom_start_xmit;
275 dev->stop = &xircom_close; 275 dev->stop = &xircom_close;
@@ -285,19 +285,19 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
285 printk(KERN_ERR "xircom_probe: netdevice registration failed.\n"); 285 printk(KERN_ERR "xircom_probe: netdevice registration failed.\n");
286 goto reg_fail; 286 goto reg_fail;
287 } 287 }
288 288
289 printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq); 289 printk(KERN_INFO "%s: Xircom cardbus revision %i at irq %i \n", dev->name, chip_rev, pdev->irq);
290 /* start the transmitter to get a heartbeat */ 290 /* start the transmitter to get a heartbeat */
291 /* TODO: send 2 dummy packets here */ 291 /* TODO: send 2 dummy packets here */
292 transceiver_voodoo(private); 292 transceiver_voodoo(private);
293 293
294 spin_lock_irqsave(&private->lock,flags); 294 spin_lock_irqsave(&private->lock,flags);
295 activate_transmitter(private); 295 activate_transmitter(private);
296 activate_receiver(private); 296 activate_receiver(private);
297 spin_unlock_irqrestore(&private->lock,flags); 297 spin_unlock_irqrestore(&private->lock,flags);
298 298
299 trigger_receive(private); 299 trigger_receive(private);
300 300
301 leave("xircom_probe"); 301 leave("xircom_probe");
302 return 0; 302 return 0;
303 303
@@ -332,7 +332,7 @@ static void __devexit xircom_remove(struct pci_dev *pdev)
332 free_netdev(dev); 332 free_netdev(dev);
333 pci_set_drvdata(pdev, NULL); 333 pci_set_drvdata(pdev, NULL);
334 leave("xircom_remove"); 334 leave("xircom_remove");
335} 335}
336 336
337static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs) 337static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
338{ 338{
@@ -346,11 +346,11 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs
346 spin_lock(&card->lock); 346 spin_lock(&card->lock);
347 status = inl(card->io_port+CSR5); 347 status = inl(card->io_port+CSR5);
348 348
349#ifdef DEBUG 349#ifdef DEBUG
350 print_binary(status); 350 print_binary(status);
351 printk("tx status 0x%08x 0x%08x \n",card->tx_buffer[0],card->tx_buffer[4]); 351 printk("tx status 0x%08x 0x%08x \n",card->tx_buffer[0],card->tx_buffer[4]);
352 printk("rx status 0x%08x 0x%08x \n",card->rx_buffer[0],card->rx_buffer[4]); 352 printk("rx status 0x%08x 0x%08x \n",card->rx_buffer[0],card->rx_buffer[4]);
353#endif 353#endif
354 /* Handle shared irq and hotplug */ 354 /* Handle shared irq and hotplug */
355 if (status == 0 || status == 0xffffffff) { 355 if (status == 0 || status == 0xffffffff) {
356 spin_unlock(&card->lock); 356 spin_unlock(&card->lock);
@@ -366,21 +366,21 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance, struct pt_regs
366 netif_carrier_on(dev); 366 netif_carrier_on(dev);
367 else 367 else
368 netif_carrier_off(dev); 368 netif_carrier_off(dev);
369 369
370 } 370 }
371 371
372 /* Clear all remaining interrupts */ 372 /* Clear all remaining interrupts */
373 status |= 0xffffffff; /* FIXME: make this clear only the 373 status |= 0xffffffff; /* FIXME: make this clear only the
374 real existing bits */ 374 real existing bits */
375 outl(status,card->io_port+CSR5); 375 outl(status,card->io_port+CSR5);
376
377 376
378 for (i=0;i<NUMDESCRIPTORS;i++) 377
378 for (i=0;i<NUMDESCRIPTORS;i++)
379 investigate_write_descriptor(dev,card,i,bufferoffsets[i]); 379 investigate_write_descriptor(dev,card,i,bufferoffsets[i]);
380 for (i=0;i<NUMDESCRIPTORS;i++) 380 for (i=0;i<NUMDESCRIPTORS;i++)
381 investigate_read_descriptor(dev,card,i,bufferoffsets[i]); 381 investigate_read_descriptor(dev,card,i,bufferoffsets[i]);
382 382
383 383
384 spin_unlock(&card->lock); 384 spin_unlock(&card->lock);
385 leave("xircom_interrupt"); 385 leave("xircom_interrupt");
386 return IRQ_HANDLED; 386 return IRQ_HANDLED;
@@ -393,38 +393,38 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
393 int nextdescriptor; 393 int nextdescriptor;
394 int desc; 394 int desc;
395 enter("xircom_start_xmit"); 395 enter("xircom_start_xmit");
396 396
397 card = netdev_priv(dev); 397 card = netdev_priv(dev);
398 spin_lock_irqsave(&card->lock,flags); 398 spin_lock_irqsave(&card->lock,flags);
399 399
400 /* First see if we can free some descriptors */ 400 /* First see if we can free some descriptors */
401 for (desc=0;desc<NUMDESCRIPTORS;desc++) 401 for (desc=0;desc<NUMDESCRIPTORS;desc++)
402 investigate_write_descriptor(dev,card,desc,bufferoffsets[desc]); 402 investigate_write_descriptor(dev,card,desc,bufferoffsets[desc]);
403 403
404 404
405 nextdescriptor = (card->transmit_used +1) % (NUMDESCRIPTORS); 405 nextdescriptor = (card->transmit_used +1) % (NUMDESCRIPTORS);
406 desc = card->transmit_used; 406 desc = card->transmit_used;
407 407
408 /* only send the packet if the descriptor is free */ 408 /* only send the packet if the descriptor is free */
409 if (card->tx_buffer[4*desc]==0) { 409 if (card->tx_buffer[4*desc]==0) {
410 /* Copy the packet data; zero the memory first as the card 410 /* Copy the packet data; zero the memory first as the card
411 sometimes sends more than you ask it to. */ 411 sometimes sends more than you ask it to. */
412 412
413 memset(&card->tx_buffer[bufferoffsets[desc]/4],0,1536); 413 memset(&card->tx_buffer[bufferoffsets[desc]/4],0,1536);
414 memcpy(&(card->tx_buffer[bufferoffsets[desc]/4]),skb->data,skb->len); 414 memcpy(&(card->tx_buffer[bufferoffsets[desc]/4]),skb->data,skb->len);
415 415
416 416
417 /* FIXME: The specification tells us that the length we send HAS to be a multiple of 417 /* FIXME: The specification tells us that the length we send HAS to be a multiple of
418 4 bytes. */ 418 4 bytes. */
419 419
420 card->tx_buffer[4*desc+1] = skb->len; 420 card->tx_buffer[4*desc+1] = skb->len;
421 if (desc == NUMDESCRIPTORS-1) 421 if (desc == NUMDESCRIPTORS-1)
422 card->tx_buffer[4*desc+1] |= (1<<25); /* bit 25: last descriptor of the ring */ 422 card->tx_buffer[4*desc+1] |= (1<<25); /* bit 25: last descriptor of the ring */
423 423
424 card->tx_buffer[4*desc+1] |= 0xF0000000; 424 card->tx_buffer[4*desc+1] |= 0xF0000000;
425 /* 0xF0... means want interrupts*/ 425 /* 0xF0... means want interrupts*/
426 card->tx_skb[desc] = skb; 426 card->tx_skb[desc] = skb;
427 427
428 wmb(); 428 wmb();
429 /* This gives the descriptor to the card */ 429 /* This gives the descriptor to the card */
430 card->tx_buffer[4*desc] = 0x80000000; 430 card->tx_buffer[4*desc] = 0x80000000;
@@ -433,18 +433,18 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
433 netif_stop_queue(dev); 433 netif_stop_queue(dev);
434 } 434 }
435 card->transmit_used = nextdescriptor; 435 card->transmit_used = nextdescriptor;
436 leave("xircom-start_xmit - sent"); 436 leave("xircom-start_xmit - sent");
437 spin_unlock_irqrestore(&card->lock,flags); 437 spin_unlock_irqrestore(&card->lock,flags);
438 return 0; 438 return 0;
439 } 439 }
440 440
441 441
442 442
443 /* Uh oh... no free descriptor... drop the packet */ 443 /* Uh oh... no free descriptor... drop the packet */
444 netif_stop_queue(dev); 444 netif_stop_queue(dev);
445 spin_unlock_irqrestore(&card->lock,flags); 445 spin_unlock_irqrestore(&card->lock,flags);
446 trigger_transmit(card); 446 trigger_transmit(card);
447 447
448 return -EIO; 448 return -EIO;
449} 449}
450 450
@@ -462,7 +462,7 @@ static int xircom_open(struct net_device *dev)
462 leave("xircom_open - No IRQ"); 462 leave("xircom_open - No IRQ");
463 return retval; 463 return retval;
464 } 464 }
465 465
466 xircom_up(xp); 466 xircom_up(xp);
467 xp->open = 1; 467 xp->open = 1;
468 leave("xircom_open"); 468 leave("xircom_open");
@@ -473,31 +473,31 @@ static int xircom_close(struct net_device *dev)
473{ 473{
474 struct xircom_private *card; 474 struct xircom_private *card;
475 unsigned long flags; 475 unsigned long flags;
476 476
477 enter("xircom_close"); 477 enter("xircom_close");
478 card = netdev_priv(dev); 478 card = netdev_priv(dev);
479 netif_stop_queue(dev); /* we don't want new packets */ 479 netif_stop_queue(dev); /* we don't want new packets */
480 480
481 481
482 spin_lock_irqsave(&card->lock,flags); 482 spin_lock_irqsave(&card->lock,flags);
483 483
484 disable_all_interrupts(card); 484 disable_all_interrupts(card);
485#if 0 485#if 0
486 /* We can enable this again once we send dummy packets on ifconfig ethX up */ 486 /* We can enable this again once we send dummy packets on ifconfig ethX up */
487 deactivate_receiver(card); 487 deactivate_receiver(card);
488 deactivate_transmitter(card); 488 deactivate_transmitter(card);
489#endif 489#endif
490 remove_descriptors(card); 490 remove_descriptors(card);
491 491
492 spin_unlock_irqrestore(&card->lock,flags); 492 spin_unlock_irqrestore(&card->lock,flags);
493 493
494 card->open = 0; 494 card->open = 0;
495 free_irq(dev->irq,dev); 495 free_irq(dev->irq,dev);
496 496
497 leave("xircom_close"); 497 leave("xircom_close");
498 498
499 return 0; 499 return 0;
500 500
501} 501}
502 502
503 503
@@ -506,8 +506,8 @@ static struct net_device_stats *xircom_get_stats(struct net_device *dev)
506{ 506{
507 struct xircom_private *card = netdev_priv(dev); 507 struct xircom_private *card = netdev_priv(dev);
508 return &card->stats; 508 return &card->stats;
509} 509}
510 510
511 511
512#ifdef CONFIG_NET_POLL_CONTROLLER 512#ifdef CONFIG_NET_POLL_CONTROLLER
513static void xircom_poll_controller(struct net_device *dev) 513static void xircom_poll_controller(struct net_device *dev)
@@ -540,7 +540,7 @@ static void initialize_card(struct xircom_private *card)
540 outl(val, card->io_port + CSR0); 540 outl(val, card->io_port + CSR0);
541 541
542 542
543 val = 0; /* Value 0x00 is a safe and conservative value 543 val = 0; /* Value 0x00 is a safe and conservative value
544 for the PCI configuration settings */ 544 for the PCI configuration settings */
545 outl(val, card->io_port + CSR0); 545 outl(val, card->io_port + CSR0);
546 546
@@ -617,23 +617,23 @@ static void setup_descriptors(struct xircom_private *card)
617 617
618 /* Rx Descr2: address of the buffer 618 /* Rx Descr2: address of the buffer
619 we store the buffer at the 2nd half of the page */ 619 we store the buffer at the 2nd half of the page */
620 620
621 address = (unsigned long) card->rx_dma_handle; 621 address = (unsigned long) card->rx_dma_handle;
622 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]); 622 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]);
623 /* Rx Desc3: address of 2nd buffer -> 0 */ 623 /* Rx Desc3: address of 2nd buffer -> 0 */
624 card->rx_buffer[i*4 + 3] = 0; 624 card->rx_buffer[i*4 + 3] = 0;
625 } 625 }
626 626
627 wmb(); 627 wmb();
628 /* Write the receive descriptor ring address to the card */ 628 /* Write the receive descriptor ring address to the card */
629 address = (unsigned long) card->rx_dma_handle; 629 address = (unsigned long) card->rx_dma_handle;
630 val = cpu_to_le32(address); 630 val = cpu_to_le32(address);
631 outl(val, card->io_port + CSR3); /* Receive descr list address */ 631 outl(val, card->io_port + CSR3); /* Receive descr list address */
632 632
633 633
634 /* transmit descriptors */ 634 /* transmit descriptors */
635 memset(card->tx_buffer, 0, 128); /* clear the descriptors */ 635 memset(card->tx_buffer, 0, 128); /* clear the descriptors */
636 636
637 for (i=0;i<NUMDESCRIPTORS;i++ ) { 637 for (i=0;i<NUMDESCRIPTORS;i++ ) {
638 /* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */ 638 /* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */
639 card->tx_buffer[i*4 + 0] = 0x00000000; 639 card->tx_buffer[i*4 + 0] = 0x00000000;
@@ -641,7 +641,7 @@ static void setup_descriptors(struct xircom_private *card)
641 card->tx_buffer[i*4 + 1] = 1536; 641 card->tx_buffer[i*4 + 1] = 1536;
642 if (i==NUMDESCRIPTORS-1) 642 if (i==NUMDESCRIPTORS-1)
643 card->tx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */ 643 card->tx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */
644 644
645 /* Tx Descr2: address of the buffer 645 /* Tx Descr2: address of the buffer
646 we store the buffer at the 2nd half of the page */ 646 we store the buffer at the 2nd half of the page */
647 address = (unsigned long) card->tx_dma_handle; 647 address = (unsigned long) card->tx_dma_handle;
@@ -748,7 +748,7 @@ static int receive_active(struct xircom_private *card)
748activate_receiver enables the receiver on the card. 748activate_receiver enables the receiver on the card.
749Before being allowed to active the receiver, the receiver 749Before being allowed to active the receiver, the receiver
750must be completely de-activated. To achieve this, 750must be completely de-activated. To achieve this,
751this code actually disables the receiver first; then it waits for the 751this code actually disables the receiver first; then it waits for the
752receiver to become inactive, then it activates the receiver and then 752receiver to become inactive, then it activates the receiver and then
753it waits for the receiver to be active. 753it waits for the receiver to be active.
754 754
@@ -762,13 +762,13 @@ static void activate_receiver(struct xircom_private *card)
762 762
763 763
764 val = inl(card->io_port + CSR6); /* Operation mode */ 764 val = inl(card->io_port + CSR6); /* Operation mode */
765 765
766 /* If the "active" bit is set and the receiver is already 766 /* If the "active" bit is set and the receiver is already
767 active, no need to do the expensive thing */ 767 active, no need to do the expensive thing */
768 if ((val&2) && (receive_active(card))) 768 if ((val&2) && (receive_active(card)))
769 return; 769 return;
770 770
771 771
772 val = val & ~2; /* disable the receiver */ 772 val = val & ~2; /* disable the receiver */
773 outl(val, card->io_port + CSR6); 773 outl(val, card->io_port + CSR6);
774 774
@@ -805,7 +805,7 @@ static void activate_receiver(struct xircom_private *card)
805 805
806/* 806/*
807deactivate_receiver disables the receiver on the card. 807deactivate_receiver disables the receiver on the card.
808To achieve this this code disables the receiver first; 808To achieve this this code disables the receiver first;
809then it waits for the receiver to become inactive. 809then it waits for the receiver to become inactive.
810 810
811must be called with the lock held and interrupts disabled. 811must be called with the lock held and interrupts disabled.
@@ -840,7 +840,7 @@ static void deactivate_receiver(struct xircom_private *card)
840activate_transmitter enables the transmitter on the card. 840activate_transmitter enables the transmitter on the card.
841Before being allowed to active the transmitter, the transmitter 841Before being allowed to active the transmitter, the transmitter
842must be completely de-activated. To achieve this, 842must be completely de-activated. To achieve this,
843this code actually disables the transmitter first; then it waits for the 843this code actually disables the transmitter first; then it waits for the
844transmitter to become inactive, then it activates the transmitter and then 844transmitter to become inactive, then it activates the transmitter and then
845it waits for the transmitter to be active again. 845it waits for the transmitter to be active again.
846 846
@@ -856,7 +856,7 @@ static void activate_transmitter(struct xircom_private *card)
856 val = inl(card->io_port + CSR6); /* Operation mode */ 856 val = inl(card->io_port + CSR6); /* Operation mode */
857 857
858 /* If the "active" bit is set and the receiver is already 858 /* If the "active" bit is set and the receiver is already
859 active, no need to do the expensive thing */ 859 active, no need to do the expensive thing */
860 if ((val&(1<<13)) && (transmit_active(card))) 860 if ((val&(1<<13)) && (transmit_active(card)))
861 return; 861 return;
862 862
@@ -896,7 +896,7 @@ static void activate_transmitter(struct xircom_private *card)
896 896
897/* 897/*
898deactivate_transmitter disables the transmitter on the card. 898deactivate_transmitter disables the transmitter on the card.
899To achieve this this code disables the transmitter first; 899To achieve this this code disables the transmitter first;
900then it waits for the transmitter to become inactive. 900then it waits for the transmitter to become inactive.
901 901
902must be called with the lock held and interrupts disabled. 902must be called with the lock held and interrupts disabled.
@@ -990,7 +990,7 @@ static void disable_all_interrupts(struct xircom_private *card)
990{ 990{
991 unsigned int val; 991 unsigned int val;
992 enter("enable_all_interrupts"); 992 enter("enable_all_interrupts");
993 993
994 val = 0; /* disable all interrupts */ 994 val = 0; /* disable all interrupts */
995 outl(val, card->io_port + CSR7); 995 outl(val, card->io_port + CSR7);
996 996
@@ -1031,8 +1031,8 @@ static int enable_promisc(struct xircom_private *card)
1031 unsigned int val; 1031 unsigned int val;
1032 enter("enable_promisc"); 1032 enter("enable_promisc");
1033 1033
1034 val = inl(card->io_port + CSR6); 1034 val = inl(card->io_port + CSR6);
1035 val = val | (1 << 6); 1035 val = val | (1 << 6);
1036 outl(val, card->io_port + CSR6); 1036 outl(val, card->io_port + CSR6);
1037 1037
1038 leave("enable_promisc"); 1038 leave("enable_promisc");
@@ -1042,7 +1042,7 @@ static int enable_promisc(struct xircom_private *card)
1042 1042
1043 1043
1044 1044
1045/* 1045/*
1046link_status() checks the the links status and will return 0 for no link, 10 for 10mbit link and 100 for.. guess what. 1046link_status() checks the the links status and will return 0 for no link, 10 for 10mbit link and 100 for.. guess what.
1047 1047
1048Must be called in locked state with interrupts disabled 1048Must be called in locked state with interrupts disabled
@@ -1051,15 +1051,15 @@ static int link_status(struct xircom_private *card)
1051{ 1051{
1052 unsigned int val; 1052 unsigned int val;
1053 enter("link_status"); 1053 enter("link_status");
1054 1054
1055 val = inb(card->io_port + CSR12); 1055 val = inb(card->io_port + CSR12);
1056 1056
1057 if (!(val&(1<<2))) /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */ 1057 if (!(val&(1<<2))) /* bit 2 is 0 for 10mbit link, 1 for not an 10mbit link */
1058 return 10; 1058 return 10;
1059 if (!(val&(1<<1))) /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */ 1059 if (!(val&(1<<1))) /* bit 1 is 0 for 100mbit link, 1 for not an 100mbit link */
1060 return 100; 1060 return 100;
1061 1061
1062 /* If we get here -> no link at all */ 1062 /* If we get here -> no link at all */
1063 1063
1064 leave("link_status"); 1064 leave("link_status");
1065 return 0; 1065 return 0;
@@ -1071,7 +1071,7 @@ static int link_status(struct xircom_private *card)
1071 1071
1072/* 1072/*
1073 read_mac_address() reads the MAC address from the NIC and stores it in the "dev" structure. 1073 read_mac_address() reads the MAC address from the NIC and stores it in the "dev" structure.
1074 1074
1075 This function will take the spinlock itself and can, as a result, not be called with the lock helt. 1075 This function will take the spinlock itself and can, as a result, not be called with the lock helt.
1076 */ 1076 */
1077static void read_mac_address(struct xircom_private *card) 1077static void read_mac_address(struct xircom_private *card)
@@ -1081,7 +1081,7 @@ static void read_mac_address(struct xircom_private *card)
1081 int i; 1081 int i;
1082 1082
1083 enter("read_mac_address"); 1083 enter("read_mac_address");
1084 1084
1085 spin_lock_irqsave(&card->lock, flags); 1085 spin_lock_irqsave(&card->lock, flags);
1086 1086
1087 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */ 1087 outl(1 << 12, card->io_port + CSR9); /* enable boot rom access */
@@ -1095,7 +1095,7 @@ static void read_mac_address(struct xircom_private *card)
1095 outl(i + 3, card->io_port + CSR10); 1095 outl(i + 3, card->io_port + CSR10);
1096 data_count = inl(card->io_port + CSR9) & 0xff; 1096 data_count = inl(card->io_port + CSR9) & 0xff;
1097 if ((tuple == 0x22) && (data_id == 0x04) && (data_count == 0x06)) { 1097 if ((tuple == 0x22) && (data_id == 0x04) && (data_count == 0x06)) {
1098 /* 1098 /*
1099 * This is it. We have the data we want. 1099 * This is it. We have the data we want.
1100 */ 1100 */
1101 for (j = 0; j < 6; j++) { 1101 for (j = 0; j < 6; j++) {
@@ -1136,12 +1136,12 @@ static void transceiver_voodoo(struct xircom_private *card)
1136 spin_lock_irqsave(&card->lock, flags); 1136 spin_lock_irqsave(&card->lock, flags);
1137 1137
1138 outl(0x0008, card->io_port + CSR15); 1138 outl(0x0008, card->io_port + CSR15);
1139 udelay(25); 1139 udelay(25);
1140 outl(0xa8050000, card->io_port + CSR15); 1140 outl(0xa8050000, card->io_port + CSR15);
1141 udelay(25); 1141 udelay(25);
1142 outl(0xa00f0000, card->io_port + CSR15); 1142 outl(0xa00f0000, card->io_port + CSR15);
1143 udelay(25); 1143 udelay(25);
1144 1144
1145 spin_unlock_irqrestore(&card->lock, flags); 1145 spin_unlock_irqrestore(&card->lock, flags);
1146 1146
1147 netif_start_queue(card->dev); 1147 netif_start_queue(card->dev);
@@ -1163,15 +1163,15 @@ static void xircom_up(struct xircom_private *card)
1163 1163
1164 spin_lock_irqsave(&card->lock, flags); 1164 spin_lock_irqsave(&card->lock, flags);
1165 1165
1166 1166
1167 enable_link_interrupt(card); 1167 enable_link_interrupt(card);
1168 enable_transmit_interrupt(card); 1168 enable_transmit_interrupt(card);
1169 enable_receive_interrupt(card); 1169 enable_receive_interrupt(card);
1170 enable_common_interrupts(card); 1170 enable_common_interrupts(card);
1171 enable_promisc(card); 1171 enable_promisc(card);
1172 1172
1173 /* The card can have received packets already, read them away now */ 1173 /* The card can have received packets already, read them away now */
1174 for (i=0;i<NUMDESCRIPTORS;i++) 1174 for (i=0;i<NUMDESCRIPTORS;i++)
1175 investigate_read_descriptor(card->dev,card,i,bufferoffsets[i]); 1175 investigate_read_descriptor(card->dev,card,i,bufferoffsets[i]);
1176 1176
1177 1177
@@ -1185,15 +1185,15 @@ static void xircom_up(struct xircom_private *card)
1185/* Bufferoffset is in BYTES */ 1185/* Bufferoffset is in BYTES */
1186static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset) 1186static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset)
1187{ 1187{
1188 int status; 1188 int status;
1189 1189
1190 enter("investigate_read_descriptor"); 1190 enter("investigate_read_descriptor");
1191 status = card->rx_buffer[4*descnr]; 1191 status = card->rx_buffer[4*descnr];
1192 1192
1193 if ((status > 0)) { /* packet received */ 1193 if ((status > 0)) { /* packet received */
1194 1194
1195 /* TODO: discard error packets */ 1195 /* TODO: discard error packets */
1196 1196
1197 short pkt_len = ((status >> 16) & 0x7ff) - 4; /* minus 4, we don't want the CRC */ 1197 short pkt_len = ((status >> 16) & 0x7ff) - 4; /* minus 4, we don't want the CRC */
1198 struct sk_buff *skb; 1198 struct sk_buff *skb;
1199 1199
@@ -1216,7 +1216,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1216 dev->last_rx = jiffies; 1216 dev->last_rx = jiffies;
1217 card->stats.rx_packets++; 1217 card->stats.rx_packets++;
1218 card->stats.rx_bytes += pkt_len; 1218 card->stats.rx_bytes += pkt_len;
1219 1219
1220 out: 1220 out:
1221 /* give the buffer back to the card */ 1221 /* give the buffer back to the card */
1222 card->rx_buffer[4*descnr] = 0x80000000; 1222 card->rx_buffer[4*descnr] = 0x80000000;
@@ -1234,9 +1234,9 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p
1234 int status; 1234 int status;
1235 1235
1236 enter("investigate_write_descriptor"); 1236 enter("investigate_write_descriptor");
1237 1237
1238 status = card->tx_buffer[4*descnr]; 1238 status = card->tx_buffer[4*descnr];
1239#if 0 1239#if 0
1240 if (status & 0x8000) { /* Major error */ 1240 if (status & 0x8000) { /* Major error */
1241 printk(KERN_ERR "Major transmit error status %x \n", status); 1241 printk(KERN_ERR "Major transmit error status %x \n", status);
1242 card->tx_buffer[4*descnr] = 0; 1242 card->tx_buffer[4*descnr] = 0;
@@ -1258,7 +1258,7 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p
1258 } 1258 }
1259 1259
1260 leave("investigate_write_descriptor"); 1260 leave("investigate_write_descriptor");
1261 1261
1262} 1262}
1263 1263
1264 1264
@@ -1271,8 +1271,8 @@ static int __init xircom_init(void)
1271static void __exit xircom_exit(void) 1271static void __exit xircom_exit(void)
1272{ 1272{
1273 pci_unregister_driver(&xircom_ops); 1273 pci_unregister_driver(&xircom_ops);
1274} 1274}
1275 1275
1276module_init(xircom_init) 1276module_init(xircom_init)
1277module_exit(xircom_exit) 1277module_exit(xircom_exit)
1278 1278
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index ed1f837c8fda..2eb6b5f9ba0d 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1899,6 +1899,13 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
1899 1899
1900 int pktlen = skb->len; 1900 int pktlen = skb->len;
1901 1901
1902#ifdef VELOCITY_ZERO_COPY_SUPPORT
1903 if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) {
1904 kfree_skb(skb);
1905 return 0;
1906 }
1907#endif
1908
1902 spin_lock_irqsave(&vptr->lock, flags); 1909 spin_lock_irqsave(&vptr->lock, flags);
1903 1910
1904 index = vptr->td_curr[qnum]; 1911 index = vptr->td_curr[qnum];
@@ -1914,8 +1921,6 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
1914 */ 1921 */
1915 if (pktlen < ETH_ZLEN) { 1922 if (pktlen < ETH_ZLEN) {
1916 /* Cannot occur until ZC support */ 1923 /* Cannot occur until ZC support */
1917 if(skb_linearize(skb, GFP_ATOMIC))
1918 return 0;
1919 pktlen = ETH_ZLEN; 1924 pktlen = ETH_ZLEN;
1920 memcpy(tdinfo->buf, skb->data, skb->len); 1925 memcpy(tdinfo->buf, skb->data, skb->len);
1921 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len); 1926 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
@@ -1933,7 +1938,6 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
1933 int nfrags = skb_shinfo(skb)->nr_frags; 1938 int nfrags = skb_shinfo(skb)->nr_frags;
1934 tdinfo->skb = skb; 1939 tdinfo->skb = skb;
1935 if (nfrags > 6) { 1940 if (nfrags > 6) {
1936 skb_linearize(skb, GFP_ATOMIC);
1937 memcpy(tdinfo->buf, skb->data, skb->len); 1941 memcpy(tdinfo->buf, skb->data, skb->len);
1938 tdinfo->skb_dma[0] = tdinfo->buf_dma; 1942 tdinfo->skb_dma[0] = tdinfo->buf_dma;
1939 td_ptr->tdesc0.pktsize = 1943 td_ptr->tdesc0.pktsize =
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
index d9a774b91ddc..f1b2640ebdc6 100644
--- a/drivers/net/via-velocity.h
+++ b/drivers/net/via-velocity.h
@@ -307,7 +307,7 @@ enum velocity_owner {
307#define TX_QUEUE_NO 4 307#define TX_QUEUE_NO 4
308 308
309#define MAX_HW_MIB_COUNTER 32 309#define MAX_HW_MIB_COUNTER 32
310#define VELOCITY_MIN_MTU (1514-14) 310#define VELOCITY_MIN_MTU (64)
311#define VELOCITY_MAX_MTU (9000) 311#define VELOCITY_MAX_MTU (9000)
312 312
313/* 313/*
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index eba8e5cfacc2..f485a97844cc 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -50,10 +50,6 @@ static const char* devname = "PCI200SYN";
50static int pci_clock_freq = 33000000; 50static int pci_clock_freq = 33000000;
51#define CLOCK_BASE pci_clock_freq 51#define CLOCK_BASE pci_clock_freq
52 52
53#define PCI_VENDOR_ID_GORAMO 0x10B5 /* uses PLX:9050 ID - this card */
54#define PCI_DEVICE_ID_PCI200SYN 0x9050 /* doesn't have its own ID */
55
56
57/* 53/*
58 * PLX PCI9052 local configuration and shared runtime registers. 54 * PLX PCI9052 local configuration and shared runtime registers.
59 * This structure can be used to access 9052 registers (memory mapped). 55 * This structure can be used to access 9052 registers (memory mapped).
@@ -262,7 +258,7 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)
262 int i; 258 int i;
263 card_t *card = pci_get_drvdata(pdev); 259 card_t *card = pci_get_drvdata(pdev);
264 260
265 for(i = 0; i < 2; i++) 261 for (i = 0; i < 2; i++)
266 if (card->ports[i].card) { 262 if (card->ports[i].card) {
267 struct net_device *dev = port_to_dev(&card->ports[i]); 263 struct net_device *dev = port_to_dev(&card->ports[i]);
268 unregister_hdlc_device(dev); 264 unregister_hdlc_device(dev);
@@ -385,6 +381,15 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
385 " %u RX packets rings\n", ramsize / 1024, ramphys, 381 " %u RX packets rings\n", ramsize / 1024, ramphys,
386 pdev->irq, card->tx_ring_buffers, card->rx_ring_buffers); 382 pdev->irq, card->tx_ring_buffers, card->rx_ring_buffers);
387 383
384 if (pdev->subsystem_device == PCI_DEVICE_ID_PLX_9050) {
385 printk(KERN_ERR "Detected PCI200SYN card with old "
386 "configuration data.\n");
387 printk(KERN_ERR "See <http://www.kernel.org/pub/"
388 "linux/utils/net/hdlc/pci200syn/> for update.\n");
389 printk(KERN_ERR "The card will stop working with"
390 " future versions of Linux if not updated.\n");
391 }
392
388 if (card->tx_ring_buffers < 1) { 393 if (card->tx_ring_buffers < 1) {
389 printk(KERN_ERR "pci200syn: RAM test failed\n"); 394 printk(KERN_ERR "pci200syn: RAM test failed\n");
390 pci200_pci_remove_one(pdev); 395 pci200_pci_remove_one(pdev);
@@ -396,7 +401,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
396 writew(readw(p) | 0x0040, p); 401 writew(readw(p) | 0x0040, p);
397 402
398 /* Allocate IRQ */ 403 /* Allocate IRQ */
399 if(request_irq(pdev->irq, sca_intr, SA_SHIRQ, devname, card)) { 404 if (request_irq(pdev->irq, sca_intr, SA_SHIRQ, devname, card)) {
400 printk(KERN_WARNING "pci200syn: could not allocate IRQ%d.\n", 405 printk(KERN_WARNING "pci200syn: could not allocate IRQ%d.\n",
401 pdev->irq); 406 pdev->irq);
402 pci200_pci_remove_one(pdev); 407 pci200_pci_remove_one(pdev);
@@ -406,7 +411,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
406 411
407 sca_init(card, 0); 412 sca_init(card, 0);
408 413
409 for(i = 0; i < 2; i++) { 414 for (i = 0; i < 2; i++) {
410 port_t *port = &card->ports[i]; 415 port_t *port = &card->ports[i];
411 struct net_device *dev = port_to_dev(port); 416 struct net_device *dev = port_to_dev(port);
412 hdlc_device *hdlc = dev_to_hdlc(dev); 417 hdlc_device *hdlc = dev_to_hdlc(dev);
@@ -425,7 +430,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
425 hdlc->xmit = sca_xmit; 430 hdlc->xmit = sca_xmit;
426 port->settings.clock_type = CLOCK_EXT; 431 port->settings.clock_type = CLOCK_EXT;
427 port->card = card; 432 port->card = card;
428 if(register_hdlc_device(dev)) { 433 if (register_hdlc_device(dev)) {
429 printk(KERN_ERR "pci200syn: unable to register hdlc " 434 printk(KERN_ERR "pci200syn: unable to register hdlc "
430 "device\n"); 435 "device\n");
431 port->card = NULL; 436 port->card = NULL;
@@ -445,8 +450,10 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
445 450
446 451
447static struct pci_device_id pci200_pci_tbl[] __devinitdata = { 452static struct pci_device_id pci200_pci_tbl[] __devinitdata = {
448 { PCI_VENDOR_ID_GORAMO, PCI_DEVICE_ID_PCI200SYN, PCI_ANY_ID, 453 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_PLX,
449 PCI_ANY_ID, 0, 0, 0 }, 454 PCI_DEVICE_ID_PLX_9050, 0, 0, 0 },
455 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_PLX,
456 PCI_DEVICE_ID_PLX_PCI200SYN, 0, 0, 0 },
450 { 0, } 457 { 0, }
451}; 458};
452 459
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index e0874cbfefea..30ec235e6935 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -235,7 +235,35 @@ config IPW2200_MONITOR
235 promiscuous mode via the Wireless Tool's Monitor mode. While in this 235 promiscuous mode via the Wireless Tool's Monitor mode. While in this
236 mode, no packets can be sent. 236 mode, no packets can be sent.
237 237
238config IPW_QOS 238config IPW2200_RADIOTAP
239 bool "Enable radiotap format 802.11 raw packet support"
240 depends on IPW2200_MONITOR
241
242config IPW2200_PROMISCUOUS
243 bool "Enable creation of a RF radiotap promiscuous interface"
244 depends on IPW2200_MONITOR
245 select IPW2200_RADIOTAP
246 ---help---
247 Enables the creation of a second interface prefixed 'rtap'.
248 This second interface will provide every received in radiotap
249 format.
250
251 This is useful for performing wireless network analysis while
252 maintaining an active association.
253
254 Example usage:
255
256 % modprobe ipw2200 rtap_iface=1
257 % ifconfig rtap0 up
258 % tethereal -i rtap0
259
260 If you do not specify 'rtap_iface=1' as a module parameter then
261 the rtap interface will not be created and you will need to turn
262 it on via sysfs:
263
264 % echo 1 > /sys/bus/pci/drivers/ipw2200/*/rtap_iface
265
266config IPW2200_QOS
239 bool "Enable QoS support" 267 bool "Enable QoS support"
240 depends on IPW2200 && EXPERIMENTAL 268 depends on IPW2200 && EXPERIMENTAL
241 269
@@ -503,6 +531,23 @@ config PRISM54
503 say M here and read <file:Documentation/modules.txt>. The module 531 say M here and read <file:Documentation/modules.txt>. The module
504 will be called prism54.ko. 532 will be called prism54.ko.
505 533
534config USB_ZD1201
535 tristate "USB ZD1201 based Wireless device support"
536 depends on USB && NET_RADIO
537 select FW_LOADER
538 ---help---
539 Say Y if you want to use wireless LAN adapters based on the ZyDAS
540 ZD1201 chip.
541
542 This driver makes the adapter appear as a normal Ethernet interface,
543 typically on wlan0.
544
545 The zd1201 device requires external firmware to be loaded.
546 This can be found at http://linux-lc100020.sourceforge.net/
547
548 To compile this driver as a module, choose M here: the
549 module will be called zd1201.
550
506source "drivers/net/wireless/hostap/Kconfig" 551source "drivers/net/wireless/hostap/Kconfig"
507source "drivers/net/wireless/bcm43xx/Kconfig" 552source "drivers/net/wireless/bcm43xx/Kconfig"
508 553
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index c86779879361..512603de309a 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -40,3 +40,5 @@ obj-$(CONFIG_BCM43XX) += bcm43xx/
40# 16-bit wireless PCMCIA client drivers 40# 16-bit wireless PCMCIA client drivers
41obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o 41obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
42obj-$(CONFIG_PCMCIA_WL3501) += wl3501_cs.o 42obj-$(CONFIG_PCMCIA_WL3501) += wl3501_cs.o
43
44obj-$(CONFIG_USB_ZD1201) += zd1201.o
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 00764ddd74d8..4069b79d8259 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -47,6 +47,7 @@
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/pci.h> 48#include <linux/pci.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <net/ieee80211.h>
50 51
51#include "airo.h" 52#include "airo.h"
52 53
@@ -467,6 +468,8 @@ static int do8bitIO = 0;
467#define RID_ECHOTEST_RESULTS 0xFF71 468#define RID_ECHOTEST_RESULTS 0xFF71
468#define RID_BSSLISTFIRST 0xFF72 469#define RID_BSSLISTFIRST 0xFF72
469#define RID_BSSLISTNEXT 0xFF73 470#define RID_BSSLISTNEXT 0xFF73
471#define RID_WPA_BSSLISTFIRST 0xFF74
472#define RID_WPA_BSSLISTNEXT 0xFF75
470 473
471typedef struct { 474typedef struct {
472 u16 cmd; 475 u16 cmd;
@@ -739,6 +742,14 @@ typedef struct {
739 u16 extSoftCap; 742 u16 extSoftCap;
740} CapabilityRid; 743} CapabilityRid;
741 744
745
746/* Only present on firmware >= 5.30.17 */
747typedef struct {
748 u16 unknown[4];
749 u8 fixed[12]; /* WLAN management frame */
750 u8 iep[624];
751} BSSListRidExtra;
752
742typedef struct { 753typedef struct {
743 u16 len; 754 u16 len;
744 u16 index; /* First is 0 and 0xffff means end of list */ 755 u16 index; /* First is 0 and 0xffff means end of list */
@@ -767,6 +778,9 @@ typedef struct {
767 } fh; 778 } fh;
768 u16 dsChannel; 779 u16 dsChannel;
769 u16 atimWindow; 780 u16 atimWindow;
781
782 /* Only present on firmware >= 5.30.17 */
783 BSSListRidExtra extra;
770} BSSListRid; 784} BSSListRid;
771 785
772typedef struct { 786typedef struct {
@@ -1140,8 +1154,6 @@ struct airo_info {
1140 char defindex; // Used with auto wep 1154 char defindex; // Used with auto wep
1141 struct proc_dir_entry *proc_entry; 1155 struct proc_dir_entry *proc_entry;
1142 spinlock_t aux_lock; 1156 spinlock_t aux_lock;
1143 unsigned long flags;
1144#define FLAG_PROMISC 8 /* IFF_PROMISC 0x100 - include/linux/if.h */
1145#define FLAG_RADIO_OFF 0 /* User disabling of MAC */ 1157#define FLAG_RADIO_OFF 0 /* User disabling of MAC */
1146#define FLAG_RADIO_DOWN 1 /* ifup/ifdown disabling of MAC */ 1158#define FLAG_RADIO_DOWN 1 /* ifup/ifdown disabling of MAC */
1147#define FLAG_RADIO_MASK 0x03 1159#define FLAG_RADIO_MASK 0x03
@@ -1151,6 +1163,7 @@ struct airo_info {
1151#define FLAG_UPDATE_MULTI 5 1163#define FLAG_UPDATE_MULTI 5
1152#define FLAG_UPDATE_UNI 6 1164#define FLAG_UPDATE_UNI 6
1153#define FLAG_802_11 7 1165#define FLAG_802_11 7
1166#define FLAG_PROMISC 8 /* IFF_PROMISC 0x100 - include/linux/if.h */
1154#define FLAG_PENDING_XMIT 9 1167#define FLAG_PENDING_XMIT 9
1155#define FLAG_PENDING_XMIT11 10 1168#define FLAG_PENDING_XMIT11 10
1156#define FLAG_MPI 11 1169#define FLAG_MPI 11
@@ -1158,17 +1171,19 @@ struct airo_info {
1158#define FLAG_COMMIT 13 1171#define FLAG_COMMIT 13
1159#define FLAG_RESET 14 1172#define FLAG_RESET 14
1160#define FLAG_FLASHING 15 1173#define FLAG_FLASHING 15
1161#define JOB_MASK 0x2ff0000 1174#define FLAG_WPA_CAPABLE 16
1162#define JOB_DIE 16 1175 unsigned long flags;
1163#define JOB_XMIT 17 1176#define JOB_DIE 0
1164#define JOB_XMIT11 18 1177#define JOB_XMIT 1
1165#define JOB_STATS 19 1178#define JOB_XMIT11 2
1166#define JOB_PROMISC 20 1179#define JOB_STATS 3
1167#define JOB_MIC 21 1180#define JOB_PROMISC 4
1168#define JOB_EVENT 22 1181#define JOB_MIC 5
1169#define JOB_AUTOWEP 23 1182#define JOB_EVENT 6
1170#define JOB_WSTATS 24 1183#define JOB_AUTOWEP 7
1171#define JOB_SCAN_RESULTS 25 1184#define JOB_WSTATS 8
1185#define JOB_SCAN_RESULTS 9
1186 unsigned long jobs;
1172 int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen, 1187 int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen,
1173 int whichbap); 1188 int whichbap);
1174 unsigned short *flash; 1189 unsigned short *flash;
@@ -1208,6 +1223,11 @@ struct airo_info {
1208#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE 1223#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
1209 char proc_name[IFNAMSIZ]; 1224 char proc_name[IFNAMSIZ];
1210 1225
1226 /* WPA-related stuff */
1227 unsigned int bssListFirst;
1228 unsigned int bssListNext;
1229 unsigned int bssListRidLen;
1230
1211 struct list_head network_list; 1231 struct list_head network_list;
1212 struct list_head network_free_list; 1232 struct list_head network_free_list;
1213 BSSListElement *networks; 1233 BSSListElement *networks;
@@ -1264,7 +1284,7 @@ static void micinit(struct airo_info *ai)
1264{ 1284{
1265 MICRid mic_rid; 1285 MICRid mic_rid;
1266 1286
1267 clear_bit(JOB_MIC, &ai->flags); 1287 clear_bit(JOB_MIC, &ai->jobs);
1268 PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0); 1288 PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0);
1269 up(&ai->sem); 1289 up(&ai->sem);
1270 1290
@@ -1705,24 +1725,24 @@ static void emmh32_final(emmh32_context *context, u8 digest[4])
1705static int readBSSListRid(struct airo_info *ai, int first, 1725static int readBSSListRid(struct airo_info *ai, int first,
1706 BSSListRid *list) { 1726 BSSListRid *list) {
1707 int rc; 1727 int rc;
1708 Cmd cmd; 1728 Cmd cmd;
1709 Resp rsp; 1729 Resp rsp;
1710 1730
1711 if (first == 1) { 1731 if (first == 1) {
1712 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; 1732 if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN;
1713 memset(&cmd, 0, sizeof(cmd)); 1733 memset(&cmd, 0, sizeof(cmd));
1714 cmd.cmd=CMD_LISTBSS; 1734 cmd.cmd=CMD_LISTBSS;
1715 if (down_interruptible(&ai->sem)) 1735 if (down_interruptible(&ai->sem))
1716 return -ERESTARTSYS; 1736 return -ERESTARTSYS;
1717 issuecommand(ai, &cmd, &rsp); 1737 issuecommand(ai, &cmd, &rsp);
1718 up(&ai->sem); 1738 up(&ai->sem);
1719 /* Let the command take effect */ 1739 /* Let the command take effect */
1720 ai->task = current; 1740 ai->task = current;
1721 ssleep(3); 1741 ssleep(3);
1722 ai->task = NULL; 1742 ai->task = NULL;
1723 } 1743 }
1724 rc = PC4500_readrid(ai, first ? RID_BSSLISTFIRST : RID_BSSLISTNEXT, 1744 rc = PC4500_readrid(ai, first ? ai->bssListFirst : ai->bssListNext,
1725 list, sizeof(*list), 1); 1745 list, ai->bssListRidLen, 1);
1726 1746
1727 list->len = le16_to_cpu(list->len); 1747 list->len = le16_to_cpu(list->len);
1728 list->index = le16_to_cpu(list->index); 1748 list->index = le16_to_cpu(list->index);
@@ -2112,7 +2132,7 @@ static void airo_end_xmit(struct net_device *dev) {
2112 int fid = priv->xmit.fid; 2132 int fid = priv->xmit.fid;
2113 u32 *fids = priv->fids; 2133 u32 *fids = priv->fids;
2114 2134
2115 clear_bit(JOB_XMIT, &priv->flags); 2135 clear_bit(JOB_XMIT, &priv->jobs);
2116 clear_bit(FLAG_PENDING_XMIT, &priv->flags); 2136 clear_bit(FLAG_PENDING_XMIT, &priv->flags);
2117 status = transmit_802_3_packet (priv, fids[fid], skb->data); 2137 status = transmit_802_3_packet (priv, fids[fid], skb->data);
2118 up(&priv->sem); 2138 up(&priv->sem);
@@ -2162,7 +2182,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
2162 if (down_trylock(&priv->sem) != 0) { 2182 if (down_trylock(&priv->sem) != 0) {
2163 set_bit(FLAG_PENDING_XMIT, &priv->flags); 2183 set_bit(FLAG_PENDING_XMIT, &priv->flags);
2164 netif_stop_queue(dev); 2184 netif_stop_queue(dev);
2165 set_bit(JOB_XMIT, &priv->flags); 2185 set_bit(JOB_XMIT, &priv->jobs);
2166 wake_up_interruptible(&priv->thr_wait); 2186 wake_up_interruptible(&priv->thr_wait);
2167 } else 2187 } else
2168 airo_end_xmit(dev); 2188 airo_end_xmit(dev);
@@ -2177,7 +2197,7 @@ static void airo_end_xmit11(struct net_device *dev) {
2177 int fid = priv->xmit11.fid; 2197 int fid = priv->xmit11.fid;
2178 u32 *fids = priv->fids; 2198 u32 *fids = priv->fids;
2179 2199
2180 clear_bit(JOB_XMIT11, &priv->flags); 2200 clear_bit(JOB_XMIT11, &priv->jobs);
2181 clear_bit(FLAG_PENDING_XMIT11, &priv->flags); 2201 clear_bit(FLAG_PENDING_XMIT11, &priv->flags);
2182 status = transmit_802_11_packet (priv, fids[fid], skb->data); 2202 status = transmit_802_11_packet (priv, fids[fid], skb->data);
2183 up(&priv->sem); 2203 up(&priv->sem);
@@ -2233,7 +2253,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
2233 if (down_trylock(&priv->sem) != 0) { 2253 if (down_trylock(&priv->sem) != 0) {
2234 set_bit(FLAG_PENDING_XMIT11, &priv->flags); 2254 set_bit(FLAG_PENDING_XMIT11, &priv->flags);
2235 netif_stop_queue(dev); 2255 netif_stop_queue(dev);
2236 set_bit(JOB_XMIT11, &priv->flags); 2256 set_bit(JOB_XMIT11, &priv->jobs);
2237 wake_up_interruptible(&priv->thr_wait); 2257 wake_up_interruptible(&priv->thr_wait);
2238 } else 2258 } else
2239 airo_end_xmit11(dev); 2259 airo_end_xmit11(dev);
@@ -2244,7 +2264,7 @@ static void airo_read_stats(struct airo_info *ai) {
2244 StatsRid stats_rid; 2264 StatsRid stats_rid;
2245 u32 *vals = stats_rid.vals; 2265 u32 *vals = stats_rid.vals;
2246 2266
2247 clear_bit(JOB_STATS, &ai->flags); 2267 clear_bit(JOB_STATS, &ai->jobs);
2248 if (ai->power.event) { 2268 if (ai->power.event) {
2249 up(&ai->sem); 2269 up(&ai->sem);
2250 return; 2270 return;
@@ -2272,10 +2292,10 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev)
2272{ 2292{
2273 struct airo_info *local = dev->priv; 2293 struct airo_info *local = dev->priv;
2274 2294
2275 if (!test_bit(JOB_STATS, &local->flags)) { 2295 if (!test_bit(JOB_STATS, &local->jobs)) {
2276 /* Get stats out of the card if available */ 2296 /* Get stats out of the card if available */
2277 if (down_trylock(&local->sem) != 0) { 2297 if (down_trylock(&local->sem) != 0) {
2278 set_bit(JOB_STATS, &local->flags); 2298 set_bit(JOB_STATS, &local->jobs);
2279 wake_up_interruptible(&local->thr_wait); 2299 wake_up_interruptible(&local->thr_wait);
2280 } else 2300 } else
2281 airo_read_stats(local); 2301 airo_read_stats(local);
@@ -2290,7 +2310,7 @@ static void airo_set_promisc(struct airo_info *ai) {
2290 2310
2291 memset(&cmd, 0, sizeof(cmd)); 2311 memset(&cmd, 0, sizeof(cmd));
2292 cmd.cmd=CMD_SETMODE; 2312 cmd.cmd=CMD_SETMODE;
2293 clear_bit(JOB_PROMISC, &ai->flags); 2313 clear_bit(JOB_PROMISC, &ai->jobs);
2294 cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; 2314 cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC;
2295 issuecommand(ai, &cmd, &rsp); 2315 issuecommand(ai, &cmd, &rsp);
2296 up(&ai->sem); 2316 up(&ai->sem);
@@ -2302,7 +2322,7 @@ static void airo_set_multicast_list(struct net_device *dev) {
2302 if ((dev->flags ^ ai->flags) & IFF_PROMISC) { 2322 if ((dev->flags ^ ai->flags) & IFF_PROMISC) {
2303 change_bit(FLAG_PROMISC, &ai->flags); 2323 change_bit(FLAG_PROMISC, &ai->flags);
2304 if (down_trylock(&ai->sem) != 0) { 2324 if (down_trylock(&ai->sem) != 0) {
2305 set_bit(JOB_PROMISC, &ai->flags); 2325 set_bit(JOB_PROMISC, &ai->jobs);
2306 wake_up_interruptible(&ai->thr_wait); 2326 wake_up_interruptible(&ai->thr_wait);
2307 } else 2327 } else
2308 airo_set_promisc(ai); 2328 airo_set_promisc(ai);
@@ -2380,7 +2400,7 @@ void stop_airo_card( struct net_device *dev, int freeres )
2380 } 2400 }
2381 clear_bit(FLAG_REGISTERED, &ai->flags); 2401 clear_bit(FLAG_REGISTERED, &ai->flags);
2382 } 2402 }
2383 set_bit(JOB_DIE, &ai->flags); 2403 set_bit(JOB_DIE, &ai->jobs);
2384 kill_proc(ai->thr_pid, SIGTERM, 1); 2404 kill_proc(ai->thr_pid, SIGTERM, 1);
2385 wait_for_completion(&ai->thr_exited); 2405 wait_for_completion(&ai->thr_exited);
2386 2406
@@ -2701,14 +2721,14 @@ static int reset_card( struct net_device *dev , int lock) {
2701 return 0; 2721 return 0;
2702} 2722}
2703 2723
2704#define MAX_NETWORK_COUNT 64 2724#define AIRO_MAX_NETWORK_COUNT 64
2705static int airo_networks_allocate(struct airo_info *ai) 2725static int airo_networks_allocate(struct airo_info *ai)
2706{ 2726{
2707 if (ai->networks) 2727 if (ai->networks)
2708 return 0; 2728 return 0;
2709 2729
2710 ai->networks = 2730 ai->networks =
2711 kzalloc(MAX_NETWORK_COUNT * sizeof(BSSListElement), 2731 kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement),
2712 GFP_KERNEL); 2732 GFP_KERNEL);
2713 if (!ai->networks) { 2733 if (!ai->networks) {
2714 airo_print_warn(ai->dev->name, "Out of memory allocating beacons"); 2734 airo_print_warn(ai->dev->name, "Out of memory allocating beacons");
@@ -2732,11 +2752,33 @@ static void airo_networks_initialize(struct airo_info *ai)
2732 2752
2733 INIT_LIST_HEAD(&ai->network_free_list); 2753 INIT_LIST_HEAD(&ai->network_free_list);
2734 INIT_LIST_HEAD(&ai->network_list); 2754 INIT_LIST_HEAD(&ai->network_list);
2735 for (i = 0; i < MAX_NETWORK_COUNT; i++) 2755 for (i = 0; i < AIRO_MAX_NETWORK_COUNT; i++)
2736 list_add_tail(&ai->networks[i].list, 2756 list_add_tail(&ai->networks[i].list,
2737 &ai->network_free_list); 2757 &ai->network_free_list);
2738} 2758}
2739 2759
2760static int airo_test_wpa_capable(struct airo_info *ai)
2761{
2762 int status;
2763 CapabilityRid cap_rid;
2764 const char *name = ai->dev->name;
2765
2766 status = readCapabilityRid(ai, &cap_rid, 1);
2767 if (status != SUCCESS) return 0;
2768
2769 /* Only firmware versions 5.30.17 or better can do WPA */
2770 if ((cap_rid.softVer > 0x530)
2771 || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) {
2772 airo_print_info(name, "WPA is supported.");
2773 return 1;
2774 }
2775
2776 /* No WPA support */
2777 airo_print_info(name, "WPA unsupported (only firmware versions 5.30.17"
2778 " and greater support WPA. Detected %s)", cap_rid.prodVer);
2779 return 0;
2780}
2781
2740static struct net_device *_init_airo_card( unsigned short irq, int port, 2782static struct net_device *_init_airo_card( unsigned short irq, int port,
2741 int is_pcmcia, struct pci_dev *pci, 2783 int is_pcmcia, struct pci_dev *pci,
2742 struct device *dmdev ) 2784 struct device *dmdev )
@@ -2759,6 +2801,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2759 ai = dev->priv; 2801 ai = dev->priv;
2760 ai->wifidev = NULL; 2802 ai->wifidev = NULL;
2761 ai->flags = 0; 2803 ai->flags = 0;
2804 ai->jobs = 0;
2762 ai->dev = dev; 2805 ai->dev = dev;
2763 if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { 2806 if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) {
2764 airo_print_dbg(dev->name, "Found an MPI350 card"); 2807 airo_print_dbg(dev->name, "Found an MPI350 card");
@@ -2838,6 +2881,18 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2838 set_bit(FLAG_FLASHING, &ai->flags); 2881 set_bit(FLAG_FLASHING, &ai->flags);
2839 } 2882 }
2840 2883
2884 /* Test for WPA support */
2885 if (airo_test_wpa_capable(ai)) {
2886 set_bit(FLAG_WPA_CAPABLE, &ai->flags);
2887 ai->bssListFirst = RID_WPA_BSSLISTFIRST;
2888 ai->bssListNext = RID_WPA_BSSLISTNEXT;
2889 ai->bssListRidLen = sizeof(BSSListRid);
2890 } else {
2891 ai->bssListFirst = RID_BSSLISTFIRST;
2892 ai->bssListNext = RID_BSSLISTNEXT;
2893 ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra);
2894 }
2895
2841 rc = register_netdev(dev); 2896 rc = register_netdev(dev);
2842 if (rc) { 2897 if (rc) {
2843 airo_print_err(dev->name, "Couldn't register_netdev"); 2898 airo_print_err(dev->name, "Couldn't register_netdev");
@@ -2875,7 +2930,7 @@ err_out_irq:
2875err_out_unlink: 2930err_out_unlink:
2876 del_airo_dev(dev); 2931 del_airo_dev(dev);
2877err_out_thr: 2932err_out_thr:
2878 set_bit(JOB_DIE, &ai->flags); 2933 set_bit(JOB_DIE, &ai->jobs);
2879 kill_proc(ai->thr_pid, SIGTERM, 1); 2934 kill_proc(ai->thr_pid, SIGTERM, 1);
2880 wait_for_completion(&ai->thr_exited); 2935 wait_for_completion(&ai->thr_exited);
2881err_out_free: 2936err_out_free:
@@ -2933,7 +2988,7 @@ static void airo_send_event(struct net_device *dev) {
2933 union iwreq_data wrqu; 2988 union iwreq_data wrqu;
2934 StatusRid status_rid; 2989 StatusRid status_rid;
2935 2990
2936 clear_bit(JOB_EVENT, &ai->flags); 2991 clear_bit(JOB_EVENT, &ai->jobs);
2937 PC4500_readrid(ai, RID_STATUS, &status_rid, sizeof(status_rid), 0); 2992 PC4500_readrid(ai, RID_STATUS, &status_rid, sizeof(status_rid), 0);
2938 up(&ai->sem); 2993 up(&ai->sem);
2939 wrqu.data.length = 0; 2994 wrqu.data.length = 0;
@@ -2947,7 +3002,7 @@ static void airo_send_event(struct net_device *dev) {
2947 3002
2948static void airo_process_scan_results (struct airo_info *ai) { 3003static void airo_process_scan_results (struct airo_info *ai) {
2949 union iwreq_data wrqu; 3004 union iwreq_data wrqu;
2950 BSSListRid BSSList; 3005 BSSListRid bss;
2951 int rc; 3006 int rc;
2952 BSSListElement * loop_net; 3007 BSSListElement * loop_net;
2953 BSSListElement * tmp_net; 3008 BSSListElement * tmp_net;
@@ -2960,15 +3015,15 @@ static void airo_process_scan_results (struct airo_info *ai) {
2960 } 3015 }
2961 3016
2962 /* Try to read the first entry of the scan result */ 3017 /* Try to read the first entry of the scan result */
2963 rc = PC4500_readrid(ai, RID_BSSLISTFIRST, &BSSList, sizeof(BSSList), 0); 3018 rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0);
2964 if((rc) || (BSSList.index == 0xffff)) { 3019 if((rc) || (bss.index == 0xffff)) {
2965 /* No scan results */ 3020 /* No scan results */
2966 goto out; 3021 goto out;
2967 } 3022 }
2968 3023
2969 /* Read and parse all entries */ 3024 /* Read and parse all entries */
2970 tmp_net = NULL; 3025 tmp_net = NULL;
2971 while((!rc) && (BSSList.index != 0xffff)) { 3026 while((!rc) && (bss.index != 0xffff)) {
2972 /* Grab a network off the free list */ 3027 /* Grab a network off the free list */
2973 if (!list_empty(&ai->network_free_list)) { 3028 if (!list_empty(&ai->network_free_list)) {
2974 tmp_net = list_entry(ai->network_free_list.next, 3029 tmp_net = list_entry(ai->network_free_list.next,
@@ -2977,19 +3032,19 @@ static void airo_process_scan_results (struct airo_info *ai) {
2977 } 3032 }
2978 3033
2979 if (tmp_net != NULL) { 3034 if (tmp_net != NULL) {
2980 memcpy(tmp_net, &BSSList, sizeof(tmp_net->bss)); 3035 memcpy(tmp_net, &bss, sizeof(tmp_net->bss));
2981 list_add_tail(&tmp_net->list, &ai->network_list); 3036 list_add_tail(&tmp_net->list, &ai->network_list);
2982 tmp_net = NULL; 3037 tmp_net = NULL;
2983 } 3038 }
2984 3039
2985 /* Read next entry */ 3040 /* Read next entry */
2986 rc = PC4500_readrid(ai, RID_BSSLISTNEXT, 3041 rc = PC4500_readrid(ai, ai->bssListNext,
2987 &BSSList, sizeof(BSSList), 0); 3042 &bss, ai->bssListRidLen, 0);
2988 } 3043 }
2989 3044
2990out: 3045out:
2991 ai->scan_timeout = 0; 3046 ai->scan_timeout = 0;
2992 clear_bit(JOB_SCAN_RESULTS, &ai->flags); 3047 clear_bit(JOB_SCAN_RESULTS, &ai->jobs);
2993 up(&ai->sem); 3048 up(&ai->sem);
2994 3049
2995 /* Send an empty event to user space. 3050 /* Send an empty event to user space.
@@ -3019,10 +3074,10 @@ static int airo_thread(void *data) {
3019 /* make swsusp happy with our thread */ 3074 /* make swsusp happy with our thread */
3020 try_to_freeze(); 3075 try_to_freeze();
3021 3076
3022 if (test_bit(JOB_DIE, &ai->flags)) 3077 if (test_bit(JOB_DIE, &ai->jobs))
3023 break; 3078 break;
3024 3079
3025 if (ai->flags & JOB_MASK) { 3080 if (ai->jobs) {
3026 locked = down_interruptible(&ai->sem); 3081 locked = down_interruptible(&ai->sem);
3027 } else { 3082 } else {
3028 wait_queue_t wait; 3083 wait_queue_t wait;
@@ -3031,16 +3086,16 @@ static int airo_thread(void *data) {
3031 add_wait_queue(&ai->thr_wait, &wait); 3086 add_wait_queue(&ai->thr_wait, &wait);
3032 for (;;) { 3087 for (;;) {
3033 set_current_state(TASK_INTERRUPTIBLE); 3088 set_current_state(TASK_INTERRUPTIBLE);
3034 if (ai->flags & JOB_MASK) 3089 if (ai->jobs)
3035 break; 3090 break;
3036 if (ai->expires || ai->scan_timeout) { 3091 if (ai->expires || ai->scan_timeout) {
3037 if (ai->scan_timeout && 3092 if (ai->scan_timeout &&
3038 time_after_eq(jiffies,ai->scan_timeout)){ 3093 time_after_eq(jiffies,ai->scan_timeout)){
3039 set_bit(JOB_SCAN_RESULTS,&ai->flags); 3094 set_bit(JOB_SCAN_RESULTS, &ai->jobs);
3040 break; 3095 break;
3041 } else if (ai->expires && 3096 } else if (ai->expires &&
3042 time_after_eq(jiffies,ai->expires)){ 3097 time_after_eq(jiffies,ai->expires)){
3043 set_bit(JOB_AUTOWEP,&ai->flags); 3098 set_bit(JOB_AUTOWEP, &ai->jobs);
3044 break; 3099 break;
3045 } 3100 }
3046 if (!signal_pending(current)) { 3101 if (!signal_pending(current)) {
@@ -3069,7 +3124,7 @@ static int airo_thread(void *data) {
3069 if (locked) 3124 if (locked)
3070 continue; 3125 continue;
3071 3126
3072 if (test_bit(JOB_DIE, &ai->flags)) { 3127 if (test_bit(JOB_DIE, &ai->jobs)) {
3073 up(&ai->sem); 3128 up(&ai->sem);
3074 break; 3129 break;
3075 } 3130 }
@@ -3079,23 +3134,23 @@ static int airo_thread(void *data) {
3079 continue; 3134 continue;
3080 } 3135 }
3081 3136
3082 if (test_bit(JOB_XMIT, &ai->flags)) 3137 if (test_bit(JOB_XMIT, &ai->jobs))
3083 airo_end_xmit(dev); 3138 airo_end_xmit(dev);
3084 else if (test_bit(JOB_XMIT11, &ai->flags)) 3139 else if (test_bit(JOB_XMIT11, &ai->jobs))
3085 airo_end_xmit11(dev); 3140 airo_end_xmit11(dev);
3086 else if (test_bit(JOB_STATS, &ai->flags)) 3141 else if (test_bit(JOB_STATS, &ai->jobs))
3087 airo_read_stats(ai); 3142 airo_read_stats(ai);
3088 else if (test_bit(JOB_WSTATS, &ai->flags)) 3143 else if (test_bit(JOB_WSTATS, &ai->jobs))
3089 airo_read_wireless_stats(ai); 3144 airo_read_wireless_stats(ai);
3090 else if (test_bit(JOB_PROMISC, &ai->flags)) 3145 else if (test_bit(JOB_PROMISC, &ai->jobs))
3091 airo_set_promisc(ai); 3146 airo_set_promisc(ai);
3092 else if (test_bit(JOB_MIC, &ai->flags)) 3147 else if (test_bit(JOB_MIC, &ai->jobs))
3093 micinit(ai); 3148 micinit(ai);
3094 else if (test_bit(JOB_EVENT, &ai->flags)) 3149 else if (test_bit(JOB_EVENT, &ai->jobs))
3095 airo_send_event(dev); 3150 airo_send_event(dev);
3096 else if (test_bit(JOB_AUTOWEP, &ai->flags)) 3151 else if (test_bit(JOB_AUTOWEP, &ai->jobs))
3097 timer_func(dev); 3152 timer_func(dev);
3098 else if (test_bit(JOB_SCAN_RESULTS, &ai->flags)) 3153 else if (test_bit(JOB_SCAN_RESULTS, &ai->jobs))
3099 airo_process_scan_results(ai); 3154 airo_process_scan_results(ai);
3100 else /* Shouldn't get here, but we make sure to unlock */ 3155 else /* Shouldn't get here, but we make sure to unlock */
3101 up(&ai->sem); 3156 up(&ai->sem);
@@ -3133,7 +3188,7 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
3133 if ( status & EV_MIC ) { 3188 if ( status & EV_MIC ) {
3134 OUT4500( apriv, EVACK, EV_MIC ); 3189 OUT4500( apriv, EVACK, EV_MIC );
3135 if (test_bit(FLAG_MIC_CAPABLE, &apriv->flags)) { 3190 if (test_bit(FLAG_MIC_CAPABLE, &apriv->flags)) {
3136 set_bit(JOB_MIC, &apriv->flags); 3191 set_bit(JOB_MIC, &apriv->jobs);
3137 wake_up_interruptible(&apriv->thr_wait); 3192 wake_up_interruptible(&apriv->thr_wait);
3138 } 3193 }
3139 } 3194 }
@@ -3187,7 +3242,7 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
3187 set_bit(FLAG_UPDATE_MULTI, &apriv->flags); 3242 set_bit(FLAG_UPDATE_MULTI, &apriv->flags);
3188 3243
3189 if (down_trylock(&apriv->sem) != 0) { 3244 if (down_trylock(&apriv->sem) != 0) {
3190 set_bit(JOB_EVENT, &apriv->flags); 3245 set_bit(JOB_EVENT, &apriv->jobs);
3191 wake_up_interruptible(&apriv->thr_wait); 3246 wake_up_interruptible(&apriv->thr_wait);
3192 } else 3247 } else
3193 airo_send_event(dev); 3248 airo_send_event(dev);
@@ -5485,7 +5540,7 @@ static void timer_func( struct net_device *dev ) {
5485 up(&apriv->sem); 5540 up(&apriv->sem);
5486 5541
5487/* Schedule check to see if the change worked */ 5542/* Schedule check to see if the change worked */
5488 clear_bit(JOB_AUTOWEP, &apriv->flags); 5543 clear_bit(JOB_AUTOWEP, &apriv->jobs);
5489 apriv->expires = RUN_AT(HZ*3); 5544 apriv->expires = RUN_AT(HZ*3);
5490} 5545}
5491 5546
@@ -6876,7 +6931,7 @@ static int airo_get_range(struct net_device *dev,
6876 } 6931 }
6877 range->num_txpower = i; 6932 range->num_txpower = i;
6878 range->txpower_capa = IW_TXPOW_MWATT; 6933 range->txpower_capa = IW_TXPOW_MWATT;
6879 range->we_version_source = 12; 6934 range->we_version_source = 19;
6880 range->we_version_compiled = WIRELESS_EXT; 6935 range->we_version_compiled = WIRELESS_EXT;
6881 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; 6936 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
6882 range->retry_flags = IW_RETRY_LIMIT; 6937 range->retry_flags = IW_RETRY_LIMIT;
@@ -7152,6 +7207,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
7152 u16 capabilities; 7207 u16 capabilities;
7153 char * current_val; /* For rates */ 7208 char * current_val; /* For rates */
7154 int i; 7209 int i;
7210 char * buf;
7155 7211
7156 /* First entry *MUST* be the AP MAC address */ 7212 /* First entry *MUST* be the AP MAC address */
7157 iwe.cmd = SIOCGIWAP; 7213 iwe.cmd = SIOCGIWAP;
@@ -7238,8 +7294,69 @@ static inline char *airo_translate_scan(struct net_device *dev,
7238 if((current_val - current_ev) > IW_EV_LCP_LEN) 7294 if((current_val - current_ev) > IW_EV_LCP_LEN)
7239 current_ev = current_val; 7295 current_ev = current_val;
7240 7296
7241 /* The other data in the scan result are not really 7297 /* Beacon interval */
7242 * interesting, so for now drop it - Jean II */ 7298 buf = kmalloc(30, GFP_KERNEL);
7299 if (buf) {
7300 iwe.cmd = IWEVCUSTOM;
7301 sprintf(buf, "bcn_int=%d", bss->beaconInterval);
7302 iwe.u.data.length = strlen(buf);
7303 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf);
7304 kfree(buf);
7305 }
7306
7307 /* Put WPA/RSN Information Elements into the event stream */
7308 if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) {
7309 unsigned int num_null_ies = 0;
7310 u16 length = sizeof (bss->extra.iep);
7311 struct ieee80211_info_element *info_element =
7312 (struct ieee80211_info_element *) &bss->extra.iep;
7313
7314 while ((length >= sizeof(*info_element)) && (num_null_ies < 2)) {
7315 if (sizeof(*info_element) + info_element->len > length) {
7316 /* Invalid element, don't continue parsing IE */
7317 break;
7318 }
7319
7320 switch (info_element->id) {
7321 case MFIE_TYPE_SSID:
7322 /* Two zero-length SSID elements
7323 * mean we're done parsing elements */
7324 if (!info_element->len)
7325 num_null_ies++;
7326 break;
7327
7328 case MFIE_TYPE_GENERIC:
7329 if (info_element->len >= 4 &&
7330 info_element->data[0] == 0x00 &&
7331 info_element->data[1] == 0x50 &&
7332 info_element->data[2] == 0xf2 &&
7333 info_element->data[3] == 0x01) {
7334 iwe.cmd = IWEVGENIE;
7335 iwe.u.data.length = min(info_element->len + 2,
7336 MAX_WPA_IE_LEN);
7337 current_ev = iwe_stream_add_point(current_ev, end_buf,
7338 &iwe, (char *) info_element);
7339 }
7340 break;
7341
7342 case MFIE_TYPE_RSN:
7343 iwe.cmd = IWEVGENIE;
7344 iwe.u.data.length = min(info_element->len + 2,
7345 MAX_WPA_IE_LEN);
7346 current_ev = iwe_stream_add_point(current_ev, end_buf,
7347 &iwe, (char *) info_element);
7348 break;
7349
7350 default:
7351 break;
7352 }
7353
7354 length -= sizeof(*info_element) + info_element->len;
7355 info_element =
7356 (struct ieee80211_info_element *)&info_element->
7357 data[info_element->len];
7358 }
7359 }
7243 return current_ev; 7360 return current_ev;
7244} 7361}
7245 7362
@@ -7521,7 +7638,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
7521 u32 *vals = stats_rid.vals; 7638 u32 *vals = stats_rid.vals;
7522 7639
7523 /* Get stats out of the card */ 7640 /* Get stats out of the card */
7524 clear_bit(JOB_WSTATS, &local->flags); 7641 clear_bit(JOB_WSTATS, &local->jobs);
7525 if (local->power.event) { 7642 if (local->power.event) {
7526 up(&local->sem); 7643 up(&local->sem);
7527 return; 7644 return;
@@ -7565,10 +7682,10 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
7565{ 7682{
7566 struct airo_info *local = dev->priv; 7683 struct airo_info *local = dev->priv;
7567 7684
7568 if (!test_bit(JOB_WSTATS, &local->flags)) { 7685 if (!test_bit(JOB_WSTATS, &local->jobs)) {
7569 /* Get stats out of the card if available */ 7686 /* Get stats out of the card if available */
7570 if (down_trylock(&local->sem) != 0) { 7687 if (down_trylock(&local->sem) != 0) {
7571 set_bit(JOB_WSTATS, &local->flags); 7688 set_bit(JOB_WSTATS, &local->jobs);
7572 wake_up_interruptible(&local->thr_wait); 7689 wake_up_interruptible(&local->thr_wait);
7573 } else 7690 } else
7574 airo_read_wireless_stats(local); 7691 airo_read_wireless_stats(local);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 2e83083935e1..e66fdb1f3cfd 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -645,7 +645,6 @@ struct bcm43xx_private {
645 unsigned int irq; 645 unsigned int irq;
646 646
647 void __iomem *mmio_addr; 647 void __iomem *mmio_addr;
648 unsigned int mmio_len;
649 648
650 /* Do not use the lock directly. Use the bcm43xx_lock* helper 649 /* Do not use the lock directly. Use the bcm43xx_lock* helper
651 * functions, to be MMIO-safe. */ 650 * functions, to be MMIO-safe. */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
index 35a4fcb6d923..7497fb16076e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
@@ -92,7 +92,7 @@ static ssize_t devinfo_read_file(struct file *file, char __user *userbuf,
92 fappend("subsystem_vendor: 0x%04x subsystem_device: 0x%04x\n", 92 fappend("subsystem_vendor: 0x%04x subsystem_device: 0x%04x\n",
93 pci_dev->subsystem_vendor, pci_dev->subsystem_device); 93 pci_dev->subsystem_vendor, pci_dev->subsystem_device);
94 fappend("IRQ: %d\n", bcm->irq); 94 fappend("IRQ: %d\n", bcm->irq);
95 fappend("mmio_addr: 0x%p mmio_len: %u\n", bcm->mmio_addr, bcm->mmio_len); 95 fappend("mmio_addr: 0x%p\n", bcm->mmio_addr);
96 fappend("chip_id: 0x%04x chip_rev: 0x%02x\n", bcm->chip_id, bcm->chip_rev); 96 fappend("chip_id: 0x%04x chip_rev: 0x%02x\n", bcm->chip_id, bcm->chip_rev);
97 if ((bcm->core_80211[0].rev >= 3) && (bcm43xx_read32(bcm, 0x0158) & (1 << 16))) 97 if ((bcm->core_80211[0].rev >= 3) && (bcm43xx_read32(bcm, 0x0158) & (1 << 16)))
98 fappend("Radio disabled by hardware!\n"); 98 fappend("Radio disabled by hardware!\n");
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 7ed18cad29f7..736dde96c4a3 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -128,13 +128,15 @@ MODULE_PARM_DESC(fwpostfix, "Postfix for .fw files. Useful for debugging.");
128 static struct pci_device_id bcm43xx_pci_tbl[] = { 128 static struct pci_device_id bcm43xx_pci_tbl[] = {
129 /* Broadcom 4303 802.11b */ 129 /* Broadcom 4303 802.11b */
130 { PCI_VENDOR_ID_BROADCOM, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 130 { PCI_VENDOR_ID_BROADCOM, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
131 /* Broadcom 4307 802.11b */ 131 /* Broadcom 4307 802.11b */
132 { PCI_VENDOR_ID_BROADCOM, 0x4307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 132 { PCI_VENDOR_ID_BROADCOM, 0x4307, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
133 /* Broadcom 4318 802.11b/g */ 133 /* Broadcom 4318 802.11b/g */
134 { PCI_VENDOR_ID_BROADCOM, 0x4318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 134 { PCI_VENDOR_ID_BROADCOM, 0x4318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
135 /* Broadcom 4319 802.11a/b/g */
136 { PCI_VENDOR_ID_BROADCOM, 0x4319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
135 /* Broadcom 4306 802.11b/g */ 137 /* Broadcom 4306 802.11b/g */
136 { PCI_VENDOR_ID_BROADCOM, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 138 { PCI_VENDOR_ID_BROADCOM, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
137 /* Broadcom 4306 802.11a */ 139 /* Broadcom 4306 802.11a */
138// { PCI_VENDOR_ID_BROADCOM, 0x4321, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 140// { PCI_VENDOR_ID_BROADCOM, 0x4321, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
139 /* Broadcom 4309 802.11a/b/g */ 141 /* Broadcom 4309 802.11a/b/g */
140 { PCI_VENDOR_ID_BROADCOM, 0x4324, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 142 { PCI_VENDOR_ID_BROADCOM, 0x4324, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
@@ -3299,8 +3301,7 @@ static void bcm43xx_detach_board(struct bcm43xx_private *bcm)
3299 3301
3300 bcm43xx_chipset_detach(bcm); 3302 bcm43xx_chipset_detach(bcm);
3301 /* Do _not_ access the chip, after it is detached. */ 3303 /* Do _not_ access the chip, after it is detached. */
3302 iounmap(bcm->mmio_addr); 3304 pci_iounmap(pci_dev, bcm->mmio_addr);
3303
3304 pci_release_regions(pci_dev); 3305 pci_release_regions(pci_dev);
3305 pci_disable_device(pci_dev); 3306 pci_disable_device(pci_dev);
3306 3307
@@ -3390,40 +3391,26 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm)
3390 struct net_device *net_dev = bcm->net_dev; 3391 struct net_device *net_dev = bcm->net_dev;
3391 int err; 3392 int err;
3392 int i; 3393 int i;
3393 unsigned long mmio_start, mmio_flags, mmio_len;
3394 u32 coremask; 3394 u32 coremask;
3395 3395
3396 err = pci_enable_device(pci_dev); 3396 err = pci_enable_device(pci_dev);
3397 if (err) { 3397 if (err) {
3398 printk(KERN_ERR PFX "unable to wake up pci device (%i)\n", err); 3398 printk(KERN_ERR PFX "pci_enable_device() failed\n");
3399 goto out; 3399 goto out;
3400 } 3400 }
3401 mmio_start = pci_resource_start(pci_dev, 0);
3402 mmio_flags = pci_resource_flags(pci_dev, 0);
3403 mmio_len = pci_resource_len(pci_dev, 0);
3404 if (!(mmio_flags & IORESOURCE_MEM)) {
3405 printk(KERN_ERR PFX
3406 "%s, region #0 not an MMIO resource, aborting\n",
3407 pci_name(pci_dev));
3408 err = -ENODEV;
3409 goto err_pci_disable;
3410 }
3411 err = pci_request_regions(pci_dev, KBUILD_MODNAME); 3401 err = pci_request_regions(pci_dev, KBUILD_MODNAME);
3412 if (err) { 3402 if (err) {
3413 printk(KERN_ERR PFX 3403 printk(KERN_ERR PFX "pci_request_regions() failed\n");
3414 "could not access PCI resources (%i)\n", err);
3415 goto err_pci_disable; 3404 goto err_pci_disable;
3416 } 3405 }
3417 /* enable PCI bus-mastering */ 3406 /* enable PCI bus-mastering */
3418 pci_set_master(pci_dev); 3407 pci_set_master(pci_dev);
3419 bcm->mmio_addr = ioremap(mmio_start, mmio_len); 3408 bcm->mmio_addr = pci_iomap(pci_dev, 0, ~0UL);
3420 if (!bcm->mmio_addr) { 3409 if (!bcm->mmio_addr) {
3421 printk(KERN_ERR PFX "%s: cannot remap MMIO, aborting\n", 3410 printk(KERN_ERR PFX "pci_iomap() failed\n");
3422 pci_name(pci_dev));
3423 err = -EIO; 3411 err = -EIO;
3424 goto err_pci_release; 3412 goto err_pci_release;
3425 } 3413 }
3426 bcm->mmio_len = mmio_len;
3427 net_dev->base_addr = (unsigned long)bcm->mmio_addr; 3414 net_dev->base_addr = (unsigned long)bcm->mmio_addr;
3428 3415
3429 bcm43xx_pci_read_config16(bcm, PCI_SUBSYSTEM_VENDOR_ID, 3416 bcm43xx_pci_read_config16(bcm, PCI_SUBSYSTEM_VENDOR_ID,
@@ -3517,7 +3504,7 @@ err_80211_unwind:
3517err_chipset_detach: 3504err_chipset_detach:
3518 bcm43xx_chipset_detach(bcm); 3505 bcm43xx_chipset_detach(bcm);
3519err_iounmap: 3506err_iounmap:
3520 iounmap(bcm->mmio_addr); 3507 pci_iounmap(pci_dev, bcm->mmio_addr);
3521err_pci_release: 3508err_pci_release:
3522 pci_release_regions(pci_dev); 3509 pci_release_regions(pci_dev);
3523err_pci_disable: 3510err_pci_disable:
@@ -3568,7 +3555,7 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
3568 unsigned long flags; 3555 unsigned long flags;
3569 int keyidx; 3556 int keyidx;
3570 3557
3571 dprintk(KERN_INFO PFX "set security called\n"); 3558 dprintk(KERN_INFO PFX "set security called");
3572 3559
3573 bcm43xx_lock_mmio(bcm, flags); 3560 bcm43xx_lock_mmio(bcm, flags);
3574 3561
@@ -3581,24 +3568,25 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
3581 3568
3582 if (sec->flags & SEC_ACTIVE_KEY) { 3569 if (sec->flags & SEC_ACTIVE_KEY) {
3583 secinfo->active_key = sec->active_key; 3570 secinfo->active_key = sec->active_key;
3584 dprintk(KERN_INFO PFX " .active_key = %d\n", sec->active_key); 3571 dprintk(", .active_key = %d", sec->active_key);
3585 } 3572 }
3586 if (sec->flags & SEC_UNICAST_GROUP) { 3573 if (sec->flags & SEC_UNICAST_GROUP) {
3587 secinfo->unicast_uses_group = sec->unicast_uses_group; 3574 secinfo->unicast_uses_group = sec->unicast_uses_group;
3588 dprintk(KERN_INFO PFX " .unicast_uses_group = %d\n", sec->unicast_uses_group); 3575 dprintk(", .unicast_uses_group = %d", sec->unicast_uses_group);
3589 } 3576 }
3590 if (sec->flags & SEC_LEVEL) { 3577 if (sec->flags & SEC_LEVEL) {
3591 secinfo->level = sec->level; 3578 secinfo->level = sec->level;
3592 dprintk(KERN_INFO PFX " .level = %d\n", sec->level); 3579 dprintk(", .level = %d", sec->level);
3593 } 3580 }
3594 if (sec->flags & SEC_ENABLED) { 3581 if (sec->flags & SEC_ENABLED) {
3595 secinfo->enabled = sec->enabled; 3582 secinfo->enabled = sec->enabled;
3596 dprintk(KERN_INFO PFX " .enabled = %d\n", sec->enabled); 3583 dprintk(", .enabled = %d", sec->enabled);
3597 } 3584 }
3598 if (sec->flags & SEC_ENCRYPT) { 3585 if (sec->flags & SEC_ENCRYPT) {
3599 secinfo->encrypt = sec->encrypt; 3586 secinfo->encrypt = sec->encrypt;
3600 dprintk(KERN_INFO PFX " .encrypt = %d\n", sec->encrypt); 3587 dprintk(", .encrypt = %d", sec->encrypt);
3601 } 3588 }
3589 dprintk("\n");
3602 if (bcm->initialized && !bcm->ieee->host_encrypt) { 3590 if (bcm->initialized && !bcm->ieee->host_encrypt) {
3603 if (secinfo->enabled) { 3591 if (secinfo->enabled) {
3604 /* upload WEP keys to hardware */ 3592 /* upload WEP keys to hardware */
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 346c6febb033..2aa2f389c0d5 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -121,12 +121,6 @@ void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
121 hw->iobase = address; 121 hw->iobase = address;
122 hw->reg_spacing = reg_spacing; 122 hw->reg_spacing = reg_spacing;
123 hw->inten = 0x0; 123 hw->inten = 0x0;
124
125#ifdef HERMES_DEBUG_BUFFER
126 hw->dbufp = 0;
127 memset(&hw->dbuf, 0xff, sizeof(hw->dbuf));
128 memset(&hw->profile, 0, sizeof(hw->profile));
129#endif
130} 124}
131 125
132int hermes_init(hermes_t *hw) 126int hermes_init(hermes_t *hw)
@@ -347,19 +341,6 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
347 reg = hermes_read_reg(hw, oreg); 341 reg = hermes_read_reg(hw, oreg);
348 } 342 }
349 343
350#ifdef HERMES_DEBUG_BUFFER
351 hw->profile[HERMES_BAP_BUSY_TIMEOUT - k]++;
352
353 if (k < HERMES_BAP_BUSY_TIMEOUT) {
354 struct hermes_debug_entry *e =
355 &hw->dbuf[(hw->dbufp++) % HERMES_DEBUG_BUFSIZE];
356 e->bap = bap;
357 e->id = id;
358 e->offset = offset;
359 e->cycles = HERMES_BAP_BUSY_TIMEOUT - k;
360 }
361#endif
362
363 if (reg & HERMES_OFFSET_BUSY) 344 if (reg & HERMES_OFFSET_BUSY)
364 return -ETIMEDOUT; 345 return -ETIMEDOUT;
365 346
@@ -419,8 +400,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
419} 400}
420 401
421/* Write a block of data to the chip's buffer, via the 402/* Write a block of data to the chip's buffer, via the
422 * BAP. Synchronization/serialization is the caller's problem. len 403 * BAP. Synchronization/serialization is the caller's problem.
423 * must be even.
424 * 404 *
425 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 405 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
426 */ 406 */
@@ -430,7 +410,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
430 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 410 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
431 int err = 0; 411 int err = 0;
432 412
433 if ( (len < 0) || (len % 2) ) 413 if (len < 0)
434 return -EINVAL; 414 return -EINVAL;
435 415
436 err = hermes_bap_seek(hw, bap, id, offset); 416 err = hermes_bap_seek(hw, bap, id, offset);
@@ -438,49 +418,12 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
438 goto out; 418 goto out;
439 419
440 /* Actually do the transfer */ 420 /* Actually do the transfer */
441 hermes_write_words(hw, dreg, buf, len/2); 421 hermes_write_bytes(hw, dreg, buf, len);
442 422
443 out: 423 out:
444 return err; 424 return err;
445} 425}
446 426
447/* Write a block of data to the chip's buffer with padding if
448 * neccessary, via the BAP. Synchronization/serialization is the
449 * caller's problem. len must be even.
450 *
451 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
452 */
453int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, int len,
454 u16 id, u16 offset)
455{
456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
457 int err = 0;
458
459 if (len < 0 || len % 2 || data_len > len)
460 return -EINVAL;
461
462 err = hermes_bap_seek(hw, bap, id, offset);
463 if (err)
464 goto out;
465
466 /* Transfer all the complete words of data */
467 hermes_write_words(hw, dreg, buf, data_len/2);
468 /* If there is an odd byte left over pad and transfer it */
469 if (data_len & 1) {
470 u8 end[2];
471 end[1] = 0;
472 end[0] = ((unsigned char *)buf)[data_len - 1];
473 hermes_write_words(hw, dreg, end, 1);
474 data_len ++;
475 }
476 /* Now send zeros for the padding */
477 if (data_len < len)
478 hermes_clear_words(hw, dreg, (len - data_len) / 2);
479 /* Complete */
480 out:
481 return err;
482}
483
484/* Read a Length-Type-Value record from the card. 427/* Read a Length-Type-Value record from the card.
485 * 428 *
486 * If length is NULL, we ignore the length read from the card, and 429 * If length is NULL, we ignore the length read from the card, and
@@ -553,7 +496,7 @@ int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
553 496
554 count = length - 1; 497 count = length - 1;
555 498
556 hermes_write_words(hw, dreg, value, count); 499 hermes_write_bytes(hw, dreg, value, count << 1);
557 500
558 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, 501 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE,
559 rid, NULL); 502 rid, NULL);
@@ -568,7 +511,6 @@ EXPORT_SYMBOL(hermes_allocate);
568 511
569EXPORT_SYMBOL(hermes_bap_pread); 512EXPORT_SYMBOL(hermes_bap_pread);
570EXPORT_SYMBOL(hermes_bap_pwrite); 513EXPORT_SYMBOL(hermes_bap_pwrite);
571EXPORT_SYMBOL(hermes_bap_pwrite_pad);
572EXPORT_SYMBOL(hermes_read_ltv); 514EXPORT_SYMBOL(hermes_read_ltv);
573EXPORT_SYMBOL(hermes_write_ltv); 515EXPORT_SYMBOL(hermes_write_ltv);
574 516
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
index 7644f72a9f4e..8e3f0e3edb58 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/hermes.h
@@ -328,16 +328,6 @@ struct hermes_multicast {
328 u8 addr[HERMES_MAX_MULTICAST][ETH_ALEN]; 328 u8 addr[HERMES_MAX_MULTICAST][ETH_ALEN];
329} __attribute__ ((packed)); 329} __attribute__ ((packed));
330 330
331// #define HERMES_DEBUG_BUFFER 1
332#define HERMES_DEBUG_BUFSIZE 4096
333struct hermes_debug_entry {
334 int bap;
335 u16 id, offset;
336 int cycles;
337};
338
339#ifdef __KERNEL__
340
341/* Timeouts */ 331/* Timeouts */
342#define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */ 332#define HERMES_BAP_BUSY_TIMEOUT (10000) /* In iterations of ~1us */
343 333
@@ -347,14 +337,7 @@ typedef struct hermes {
347 int reg_spacing; 337 int reg_spacing;
348#define HERMES_16BIT_REGSPACING 0 338#define HERMES_16BIT_REGSPACING 0
349#define HERMES_32BIT_REGSPACING 1 339#define HERMES_32BIT_REGSPACING 1
350
351 u16 inten; /* Which interrupts should be enabled? */ 340 u16 inten; /* Which interrupts should be enabled? */
352
353#ifdef HERMES_DEBUG_BUFFER
354 struct hermes_debug_entry dbuf[HERMES_DEBUG_BUFSIZE];
355 unsigned long dbufp;
356 unsigned long profile[HERMES_BAP_BUSY_TIMEOUT+1];
357#endif
358} hermes_t; 341} hermes_t;
359 342
360/* Register access convenience macros */ 343/* Register access convenience macros */
@@ -376,8 +359,6 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
376 u16 id, u16 offset); 359 u16 id, u16 offset);
377int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, 360int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
378 u16 id, u16 offset); 361 u16 id, u16 offset);
379int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf,
380 unsigned data_len, int len, u16 id, u16 offset);
381int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen, 362int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen,
382 u16 *length, void *buf); 363 u16 *length, void *buf);
383int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 364int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
@@ -425,10 +406,13 @@ static inline void hermes_read_words(struct hermes *hw, int off, void *buf, unsi
425 ioread16_rep(hw->iobase + off, buf, count); 406 ioread16_rep(hw->iobase + off, buf, count);
426} 407}
427 408
428static inline void hermes_write_words(struct hermes *hw, int off, const void *buf, unsigned count) 409static inline void hermes_write_bytes(struct hermes *hw, int off,
410 const char *buf, unsigned count)
429{ 411{
430 off = off << hw->reg_spacing; 412 off = off << hw->reg_spacing;
431 iowrite16_rep(hw->iobase + off, buf, count); 413 iowrite16_rep(hw->iobase + off, buf, count >> 1);
414 if (unlikely(count & 1))
415 iowrite8(buf[count - 1], hw->iobase + off);
432} 416}
433 417
434static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count) 418static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count)
@@ -462,21 +446,4 @@ static inline int hermes_write_wordrec(hermes_t *hw, int bap, u16 rid, u16 word)
462 return HERMES_WRITE_RECORD(hw, bap, rid, &rec); 446 return HERMES_WRITE_RECORD(hw, bap, rid, &rec);
463} 447}
464 448
465#else /* ! __KERNEL__ */
466
467/* These are provided for the benefit of userspace drivers and testing programs
468 which use ioperm() or iopl() */
469
470#define hermes_read_reg(base, off) (inw((base) + (off)))
471#define hermes_write_reg(base, off, val) (outw((val), (base) + (off)))
472
473#define hermes_read_regn(base, name) (hermes_read_reg((base), HERMES_##name))
474#define hermes_write_regn(base, name, val) (hermes_write_reg((base), HERMES_##name, (val)))
475
476/* Note that for the next two, the count is in 16-bit words, not bytes */
477#define hermes_read_data(base, off, buf, count) (insw((base) + (off), (buf), (count)))
478#define hermes_write_data(base, off, buf, count) (outsw((base) + (off), (buf), (count)))
479
480#endif /* ! __KERNEL__ */
481
482#endif /* _HERMES_H */ 449#endif /* _HERMES_H */
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 06a5214145e3..4a5be70c0419 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -534,5 +534,4 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
534} 534}
535 535
536 536
537EXPORT_SYMBOL(hostap_dump_tx_80211);
538EXPORT_SYMBOL(hostap_master_start_xmit); 537EXPORT_SYMBOL(hostap_master_start_xmit);
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 06c3fa32b310..ba13125024cb 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -3276,17 +3276,6 @@ EXPORT_SYMBOL(hostap_init_data);
3276EXPORT_SYMBOL(hostap_init_ap_proc); 3276EXPORT_SYMBOL(hostap_init_ap_proc);
3277EXPORT_SYMBOL(hostap_free_data); 3277EXPORT_SYMBOL(hostap_free_data);
3278EXPORT_SYMBOL(hostap_check_sta_fw_version); 3278EXPORT_SYMBOL(hostap_check_sta_fw_version);
3279EXPORT_SYMBOL(hostap_handle_sta_tx);
3280EXPORT_SYMBOL(hostap_handle_sta_release);
3281EXPORT_SYMBOL(hostap_handle_sta_tx_exc); 3279EXPORT_SYMBOL(hostap_handle_sta_tx_exc);
3282EXPORT_SYMBOL(hostap_update_sta_ps);
3283EXPORT_SYMBOL(hostap_handle_sta_rx);
3284EXPORT_SYMBOL(hostap_is_sta_assoc);
3285EXPORT_SYMBOL(hostap_is_sta_authorized);
3286EXPORT_SYMBOL(hostap_add_sta);
3287EXPORT_SYMBOL(hostap_update_rates);
3288EXPORT_SYMBOL(hostap_add_wds_links);
3289EXPORT_SYMBOL(hostap_wds_link_oper);
3290#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 3280#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3291EXPORT_SYMBOL(hostap_deauth_all_stas);
3292#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 3281#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 55bed923fbe9..db03dc2646df 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -881,6 +881,12 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
881 PCMCIA_DEVICE_PROD_ID12( 881 PCMCIA_DEVICE_PROD_ID12(
882 "ZoomAir 11Mbps High", "Rate wireless Networking", 882 "ZoomAir 11Mbps High", "Rate wireless Networking",
883 0x273fe3db, 0x32a1eaee), 883 0x273fe3db, 0x32a1eaee),
884 PCMCIA_DEVICE_PROD_ID123(
885 "Pretec", "CompactWLAN Card 802.11b", "2.5",
886 0x1cadd3e5, 0xe697636c, 0x7a5bfcf1),
887 PCMCIA_DEVICE_PROD_ID123(
888 "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",
889 0xc7b8df9d, 0x1700d087, 0x4b74baa0),
884 PCMCIA_DEVICE_NULL 890 PCMCIA_DEVICE_NULL
885}; 891};
886MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids); 892MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 8dd4c4446a64..93786f4218f0 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -1125,11 +1125,9 @@ EXPORT_SYMBOL(hostap_set_auth_algs);
1125EXPORT_SYMBOL(hostap_dump_rx_header); 1125EXPORT_SYMBOL(hostap_dump_rx_header);
1126EXPORT_SYMBOL(hostap_dump_tx_header); 1126EXPORT_SYMBOL(hostap_dump_tx_header);
1127EXPORT_SYMBOL(hostap_80211_header_parse); 1127EXPORT_SYMBOL(hostap_80211_header_parse);
1128EXPORT_SYMBOL(hostap_80211_prism_header_parse);
1129EXPORT_SYMBOL(hostap_80211_get_hdrlen); 1128EXPORT_SYMBOL(hostap_80211_get_hdrlen);
1130EXPORT_SYMBOL(hostap_get_stats); 1129EXPORT_SYMBOL(hostap_get_stats);
1131EXPORT_SYMBOL(hostap_setup_dev); 1130EXPORT_SYMBOL(hostap_setup_dev);
1132EXPORT_SYMBOL(hostap_proc);
1133EXPORT_SYMBOL(hostap_set_multicast_list_queue); 1131EXPORT_SYMBOL(hostap_set_multicast_list_queue);
1134EXPORT_SYMBOL(hostap_set_hostapd); 1132EXPORT_SYMBOL(hostap_set_hostapd);
1135EXPORT_SYMBOL(hostap_set_hostapd_sta); 1133EXPORT_SYMBOL(hostap_set_hostapd_sta);
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index bca89cff85a6..39f82f219749 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -33,7 +33,44 @@
33#include "ipw2200.h" 33#include "ipw2200.h"
34#include <linux/version.h> 34#include <linux/version.h>
35 35
36#define IPW2200_VERSION "git-1.1.1" 36
37#ifndef KBUILD_EXTMOD
38#define VK "k"
39#else
40#define VK
41#endif
42
43#ifdef CONFIG_IPW2200_DEBUG
44#define VD "d"
45#else
46#define VD
47#endif
48
49#ifdef CONFIG_IPW2200_MONITOR
50#define VM "m"
51#else
52#define VM
53#endif
54
55#ifdef CONFIG_IPW2200_PROMISCUOUS
56#define VP "p"
57#else
58#define VP
59#endif
60
61#ifdef CONFIG_IPW2200_RADIOTAP
62#define VR "r"
63#else
64#define VR
65#endif
66
67#ifdef CONFIG_IPW2200_QOS
68#define VQ "q"
69#else
70#define VQ
71#endif
72
73#define IPW2200_VERSION "1.1.2" VK VD VM VP VR VQ
37#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" 74#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver"
38#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" 75#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
39#define DRV_VERSION IPW2200_VERSION 76#define DRV_VERSION IPW2200_VERSION
@@ -46,7 +83,9 @@ MODULE_AUTHOR(DRV_COPYRIGHT);
46MODULE_LICENSE("GPL"); 83MODULE_LICENSE("GPL");
47 84
48static int cmdlog = 0; 85static int cmdlog = 0;
86#ifdef CONFIG_IPW2200_DEBUG
49static int debug = 0; 87static int debug = 0;
88#endif
50static int channel = 0; 89static int channel = 0;
51static int mode = 0; 90static int mode = 0;
52 91
@@ -61,8 +100,14 @@ static int roaming = 1;
61static const char ipw_modes[] = { 100static const char ipw_modes[] = {
62 'a', 'b', 'g', '?' 101 'a', 'b', 'g', '?'
63}; 102};
103static int antenna = CFG_SYS_ANTENNA_BOTH;
64 104
65#ifdef CONFIG_IPW_QOS 105#ifdef CONFIG_IPW2200_PROMISCUOUS
106static int rtap_iface = 0; /* def: 0 -- do not create rtap interface */
107#endif
108
109
110#ifdef CONFIG_IPW2200_QOS
66static int qos_enable = 0; 111static int qos_enable = 0;
67static int qos_burst_enable = 0; 112static int qos_burst_enable = 0;
68static int qos_no_ack_mask = 0; 113static int qos_no_ack_mask = 0;
@@ -126,7 +171,7 @@ static int ipw_send_qos_params_command(struct ipw_priv *priv, struct ieee80211_q
126 *qos_param); 171 *qos_param);
127static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element 172static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos_information_element
128 *qos_param); 173 *qos_param);
129#endif /* CONFIG_IPW_QOS */ 174#endif /* CONFIG_IPW2200_QOS */
130 175
131static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev); 176static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev);
132static void ipw_remove_current_network(struct ipw_priv *priv); 177static void ipw_remove_current_network(struct ipw_priv *priv);
@@ -1269,6 +1314,105 @@ static ssize_t show_cmd_log(struct device *d,
1269 1314
1270static DEVICE_ATTR(cmd_log, S_IRUGO, show_cmd_log, NULL); 1315static DEVICE_ATTR(cmd_log, S_IRUGO, show_cmd_log, NULL);
1271 1316
1317#ifdef CONFIG_IPW2200_PROMISCUOUS
1318static void ipw_prom_free(struct ipw_priv *priv);
1319static int ipw_prom_alloc(struct ipw_priv *priv);
1320static ssize_t store_rtap_iface(struct device *d,
1321 struct device_attribute *attr,
1322 const char *buf, size_t count)
1323{
1324 struct ipw_priv *priv = dev_get_drvdata(d);
1325 int rc = 0;
1326
1327 if (count < 1)
1328 return -EINVAL;
1329
1330 switch (buf[0]) {
1331 case '0':
1332 if (!rtap_iface)
1333 return count;
1334
1335 if (netif_running(priv->prom_net_dev)) {
1336 IPW_WARNING("Interface is up. Cannot unregister.\n");
1337 return count;
1338 }
1339
1340 ipw_prom_free(priv);
1341 rtap_iface = 0;
1342 break;
1343
1344 case '1':
1345 if (rtap_iface)
1346 return count;
1347
1348 rc = ipw_prom_alloc(priv);
1349 if (!rc)
1350 rtap_iface = 1;
1351 break;
1352
1353 default:
1354 return -EINVAL;
1355 }
1356
1357 if (rc) {
1358 IPW_ERROR("Failed to register promiscuous network "
1359 "device (error %d).\n", rc);
1360 }
1361
1362 return count;
1363}
1364
1365static ssize_t show_rtap_iface(struct device *d,
1366 struct device_attribute *attr,
1367 char *buf)
1368{
1369 struct ipw_priv *priv = dev_get_drvdata(d);
1370 if (rtap_iface)
1371 return sprintf(buf, "%s", priv->prom_net_dev->name);
1372 else {
1373 buf[0] = '-';
1374 buf[1] = '1';
1375 buf[2] = '\0';
1376 return 3;
1377 }
1378}
1379
1380static DEVICE_ATTR(rtap_iface, S_IWUSR | S_IRUSR, show_rtap_iface,
1381 store_rtap_iface);
1382
1383static ssize_t store_rtap_filter(struct device *d,
1384 struct device_attribute *attr,
1385 const char *buf, size_t count)
1386{
1387 struct ipw_priv *priv = dev_get_drvdata(d);
1388
1389 if (!priv->prom_priv) {
1390 IPW_ERROR("Attempting to set filter without "
1391 "rtap_iface enabled.\n");
1392 return -EPERM;
1393 }
1394
1395 priv->prom_priv->filter = simple_strtol(buf, NULL, 0);
1396
1397 IPW_DEBUG_INFO("Setting rtap filter to " BIT_FMT16 "\n",
1398 BIT_ARG16(priv->prom_priv->filter));
1399
1400 return count;
1401}
1402
1403static ssize_t show_rtap_filter(struct device *d,
1404 struct device_attribute *attr,
1405 char *buf)
1406{
1407 struct ipw_priv *priv = dev_get_drvdata(d);
1408 return sprintf(buf, "0x%04X",
1409 priv->prom_priv ? priv->prom_priv->filter : 0);
1410}
1411
1412static DEVICE_ATTR(rtap_filter, S_IWUSR | S_IRUSR, show_rtap_filter,
1413 store_rtap_filter);
1414#endif
1415
1272static ssize_t show_scan_age(struct device *d, struct device_attribute *attr, 1416static ssize_t show_scan_age(struct device *d, struct device_attribute *attr,
1273 char *buf) 1417 char *buf)
1274{ 1418{
@@ -2025,16 +2169,11 @@ static int ipw_send_host_complete(struct ipw_priv *priv)
2025 return ipw_send_cmd_simple(priv, IPW_CMD_HOST_COMPLETE); 2169 return ipw_send_cmd_simple(priv, IPW_CMD_HOST_COMPLETE);
2026} 2170}
2027 2171
2028static int ipw_send_system_config(struct ipw_priv *priv, 2172static int ipw_send_system_config(struct ipw_priv *priv)
2029 struct ipw_sys_config *config)
2030{ 2173{
2031 if (!priv || !config) { 2174 return ipw_send_cmd_pdu(priv, IPW_CMD_SYSTEM_CONFIG,
2032 IPW_ERROR("Invalid args\n"); 2175 sizeof(priv->sys_config),
2033 return -1; 2176 &priv->sys_config);
2034 }
2035
2036 return ipw_send_cmd_pdu(priv, IPW_CMD_SYSTEM_CONFIG, sizeof(*config),
2037 config);
2038} 2177}
2039 2178
2040static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len) 2179static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len)
@@ -3104,10 +3243,10 @@ static int ipw_reset_nic(struct ipw_priv *priv)
3104 3243
3105 3244
3106struct ipw_fw { 3245struct ipw_fw {
3107 u32 ver; 3246 __le32 ver;
3108 u32 boot_size; 3247 __le32 boot_size;
3109 u32 ucode_size; 3248 __le32 ucode_size;
3110 u32 fw_size; 3249 __le32 fw_size;
3111 u8 data[0]; 3250 u8 data[0];
3112}; 3251};
3113 3252
@@ -3131,8 +3270,8 @@ static int ipw_get_fw(struct ipw_priv *priv,
3131 3270
3132 fw = (void *)(*raw)->data; 3271 fw = (void *)(*raw)->data;
3133 3272
3134 if ((*raw)->size < sizeof(*fw) + 3273 if ((*raw)->size < sizeof(*fw) + le32_to_cpu(fw->boot_size) +
3135 fw->boot_size + fw->ucode_size + fw->fw_size) { 3274 le32_to_cpu(fw->ucode_size) + le32_to_cpu(fw->fw_size)) {
3136 IPW_ERROR("%s is too small or corrupt (%zd)\n", 3275 IPW_ERROR("%s is too small or corrupt (%zd)\n",
3137 name, (*raw)->size); 3276 name, (*raw)->size);
3138 return -EINVAL; 3277 return -EINVAL;
@@ -3237,8 +3376,9 @@ static int ipw_load(struct ipw_priv *priv)
3237 3376
3238 fw = (void *)raw->data; 3377 fw = (void *)raw->data;
3239 boot_img = &fw->data[0]; 3378 boot_img = &fw->data[0];
3240 ucode_img = &fw->data[fw->boot_size]; 3379 ucode_img = &fw->data[le32_to_cpu(fw->boot_size)];
3241 fw_img = &fw->data[fw->boot_size + fw->ucode_size]; 3380 fw_img = &fw->data[le32_to_cpu(fw->boot_size) +
3381 le32_to_cpu(fw->ucode_size)];
3242 3382
3243 if (rc < 0) 3383 if (rc < 0)
3244 goto error; 3384 goto error;
@@ -3272,7 +3412,7 @@ static int ipw_load(struct ipw_priv *priv)
3272 IPW_NIC_SRAM_UPPER_BOUND - IPW_NIC_SRAM_LOWER_BOUND); 3412 IPW_NIC_SRAM_UPPER_BOUND - IPW_NIC_SRAM_LOWER_BOUND);
3273 3413
3274 /* DMA the initial boot firmware into the device */ 3414 /* DMA the initial boot firmware into the device */
3275 rc = ipw_load_firmware(priv, boot_img, fw->boot_size); 3415 rc = ipw_load_firmware(priv, boot_img, le32_to_cpu(fw->boot_size));
3276 if (rc < 0) { 3416 if (rc < 0) {
3277 IPW_ERROR("Unable to load boot firmware: %d\n", rc); 3417 IPW_ERROR("Unable to load boot firmware: %d\n", rc);
3278 goto error; 3418 goto error;
@@ -3294,7 +3434,7 @@ static int ipw_load(struct ipw_priv *priv)
3294 ipw_write32(priv, IPW_INTA_RW, IPW_INTA_BIT_FW_INITIALIZATION_DONE); 3434 ipw_write32(priv, IPW_INTA_RW, IPW_INTA_BIT_FW_INITIALIZATION_DONE);
3295 3435
3296 /* DMA the ucode into the device */ 3436 /* DMA the ucode into the device */
3297 rc = ipw_load_ucode(priv, ucode_img, fw->ucode_size); 3437 rc = ipw_load_ucode(priv, ucode_img, le32_to_cpu(fw->ucode_size));
3298 if (rc < 0) { 3438 if (rc < 0) {
3299 IPW_ERROR("Unable to load ucode: %d\n", rc); 3439 IPW_ERROR("Unable to load ucode: %d\n", rc);
3300 goto error; 3440 goto error;
@@ -3304,7 +3444,7 @@ static int ipw_load(struct ipw_priv *priv)
3304 ipw_stop_nic(priv); 3444 ipw_stop_nic(priv);
3305 3445
3306 /* DMA bss firmware into the device */ 3446 /* DMA bss firmware into the device */
3307 rc = ipw_load_firmware(priv, fw_img, fw->fw_size); 3447 rc = ipw_load_firmware(priv, fw_img, le32_to_cpu(fw->fw_size));
3308 if (rc < 0) { 3448 if (rc < 0) {
3309 IPW_ERROR("Unable to load firmware: %d\n", rc); 3449 IPW_ERROR("Unable to load firmware: %d\n", rc);
3310 goto error; 3450 goto error;
@@ -3700,7 +3840,17 @@ static void ipw_bg_disassociate(void *data)
3700static void ipw_system_config(void *data) 3840static void ipw_system_config(void *data)
3701{ 3841{
3702 struct ipw_priv *priv = data; 3842 struct ipw_priv *priv = data;
3703 ipw_send_system_config(priv, &priv->sys_config); 3843
3844#ifdef CONFIG_IPW2200_PROMISCUOUS
3845 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
3846 priv->sys_config.accept_all_data_frames = 1;
3847 priv->sys_config.accept_non_directed_frames = 1;
3848 priv->sys_config.accept_all_mgmt_bcpr = 1;
3849 priv->sys_config.accept_all_mgmt_frames = 1;
3850 }
3851#endif
3852
3853 ipw_send_system_config(priv);
3704} 3854}
3705 3855
3706struct ipw_status_code { 3856struct ipw_status_code {
@@ -3771,6 +3921,13 @@ static void inline average_init(struct average *avg)
3771 memset(avg, 0, sizeof(*avg)); 3921 memset(avg, 0, sizeof(*avg));
3772} 3922}
3773 3923
3924#define DEPTH_RSSI 8
3925#define DEPTH_NOISE 16
3926static s16 exponential_average(s16 prev_avg, s16 val, u8 depth)
3927{
3928 return ((depth-1)*prev_avg + val)/depth;
3929}
3930
3774static void average_add(struct average *avg, s16 val) 3931static void average_add(struct average *avg, s16 val)
3775{ 3932{
3776 avg->sum -= avg->entries[avg->pos]; 3933 avg->sum -= avg->entries[avg->pos];
@@ -3800,8 +3957,8 @@ static void ipw_reset_stats(struct ipw_priv *priv)
3800 priv->quality = 0; 3957 priv->quality = 0;
3801 3958
3802 average_init(&priv->average_missed_beacons); 3959 average_init(&priv->average_missed_beacons);
3803 average_init(&priv->average_rssi); 3960 priv->exp_avg_rssi = -60;
3804 average_init(&priv->average_noise); 3961 priv->exp_avg_noise = -85 + 0x100;
3805 3962
3806 priv->last_rate = 0; 3963 priv->last_rate = 0;
3807 priv->last_missed_beacons = 0; 3964 priv->last_missed_beacons = 0;
@@ -4008,7 +4165,7 @@ static void ipw_gather_stats(struct ipw_priv *priv)
4008 IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n", 4165 IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n",
4009 tx_quality, tx_failures_delta, tx_packets_delta); 4166 tx_quality, tx_failures_delta, tx_packets_delta);
4010 4167
4011 rssi = average_value(&priv->average_rssi); 4168 rssi = priv->exp_avg_rssi;
4012 signal_quality = 4169 signal_quality =
4013 (100 * 4170 (100 *
4014 (priv->ieee->perfect_rssi - priv->ieee->worst_rssi) * 4171 (priv->ieee->perfect_rssi - priv->ieee->worst_rssi) *
@@ -4185,7 +4342,7 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4185 queue_work(priv->workqueue, 4342 queue_work(priv->workqueue,
4186 &priv->system_config); 4343 &priv->system_config);
4187 4344
4188#ifdef CONFIG_IPW_QOS 4345#ifdef CONFIG_IPW2200_QOS
4189#define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \ 4346#define IPW_GET_PACKET_STYPE(x) WLAN_FC_GET_STYPE( \
4190 le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_ctl)) 4347 le16_to_cpu(((struct ieee80211_hdr *)(x))->frame_ctl))
4191 if ((priv->status & STATUS_AUTH) && 4348 if ((priv->status & STATUS_AUTH) &&
@@ -4482,6 +4639,24 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4482 && priv->status & STATUS_ASSOCIATED) 4639 && priv->status & STATUS_ASSOCIATED)
4483 queue_delayed_work(priv->workqueue, 4640 queue_delayed_work(priv->workqueue,
4484 &priv->request_scan, HZ); 4641 &priv->request_scan, HZ);
4642
4643 /* Send an empty event to user space.
4644 * We don't send the received data on the event because
4645 * it would require us to do complex transcoding, and
4646 * we want to minimise the work done in the irq handler
4647 * Use a request to extract the data.
4648 * Also, we generate this even for any scan, regardless
4649 * on how the scan was initiated. User space can just
4650 * sync on periodic scan to get fresh data...
4651 * Jean II */
4652 if (x->status == SCAN_COMPLETED_STATUS_COMPLETE) {
4653 union iwreq_data wrqu;
4654
4655 wrqu.data.length = 0;
4656 wrqu.data.flags = 0;
4657 wireless_send_event(priv->net_dev, SIOCGIWSCAN,
4658 &wrqu, NULL);
4659 }
4485 break; 4660 break;
4486 } 4661 }
4487 4662
@@ -4577,11 +4752,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4577 4752
4578 case HOST_NOTIFICATION_NOISE_STATS:{ 4753 case HOST_NOTIFICATION_NOISE_STATS:{
4579 if (notif->size == sizeof(u32)) { 4754 if (notif->size == sizeof(u32)) {
4580 priv->last_noise = 4755 priv->exp_avg_noise =
4581 (u8) (le32_to_cpu(notif->u.noise.value) & 4756 exponential_average(priv->exp_avg_noise,
4582 0xff); 4757 (u8) (le32_to_cpu(notif->u.noise.value) & 0xff),
4583 average_add(&priv->average_noise, 4758 DEPTH_NOISE);
4584 priv->last_noise);
4585 break; 4759 break;
4586 } 4760 }
4587 4761
@@ -6170,8 +6344,6 @@ static void ipw_wpa_assoc_frame(struct ipw_priv *priv, char *wpa_ie,
6170{ 6344{
6171 /* make sure WPA is enabled */ 6345 /* make sure WPA is enabled */
6172 ipw_wpa_enable(priv, 1); 6346 ipw_wpa_enable(priv, 1);
6173
6174 ipw_disassociate(priv);
6175} 6347}
6176 6348
6177static int ipw_set_rsn_capa(struct ipw_priv *priv, 6349static int ipw_set_rsn_capa(struct ipw_priv *priv,
@@ -6365,6 +6537,7 @@ static int ipw_wx_set_auth(struct net_device *dev,
6365 6537
6366 case IW_AUTH_WPA_ENABLED: 6538 case IW_AUTH_WPA_ENABLED:
6367 ret = ipw_wpa_enable(priv, param->value); 6539 ret = ipw_wpa_enable(priv, param->value);
6540 ipw_disassociate(priv);
6368 break; 6541 break;
6369 6542
6370 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 6543 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
@@ -6506,7 +6679,7 @@ static int ipw_wx_set_mlme(struct net_device *dev,
6506 return 0; 6679 return 0;
6507} 6680}
6508 6681
6509#ifdef CONFIG_IPW_QOS 6682#ifdef CONFIG_IPW2200_QOS
6510 6683
6511/* QoS */ 6684/* QoS */
6512/* 6685/*
@@ -6853,61 +7026,55 @@ static int ipw_get_tx_queue_number(struct ipw_priv *priv, u16 priority)
6853 return from_priority_to_tx_queue[priority] - 1; 7026 return from_priority_to_tx_queue[priority] - 1;
6854} 7027}
6855 7028
6856/* 7029static int ipw_is_qos_active(struct net_device *dev,
6857* add QoS parameter to the TX command 7030 struct sk_buff *skb)
6858*/
6859static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
6860 u16 priority,
6861 struct tfd_data *tfd, u8 unicast)
6862{ 7031{
6863 int ret = 0; 7032 struct ipw_priv *priv = ieee80211_priv(dev);
6864 int tx_queue_id = 0;
6865 struct ieee80211_qos_data *qos_data = NULL; 7033 struct ieee80211_qos_data *qos_data = NULL;
6866 int active, supported; 7034 int active, supported;
6867 unsigned long flags; 7035 u8 *daddr = skb->data + ETH_ALEN;
7036 int unicast = !is_multicast_ether_addr(daddr);
6868 7037
6869 if (!(priv->status & STATUS_ASSOCIATED)) 7038 if (!(priv->status & STATUS_ASSOCIATED))
6870 return 0; 7039 return 0;
6871 7040
6872 qos_data = &priv->assoc_network->qos_data; 7041 qos_data = &priv->assoc_network->qos_data;
6873 7042
6874 spin_lock_irqsave(&priv->ieee->lock, flags);
6875
6876 if (priv->ieee->iw_mode == IW_MODE_ADHOC) { 7043 if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
6877 if (unicast == 0) 7044 if (unicast == 0)
6878 qos_data->active = 0; 7045 qos_data->active = 0;
6879 else 7046 else
6880 qos_data->active = qos_data->supported; 7047 qos_data->active = qos_data->supported;
6881 } 7048 }
6882
6883 active = qos_data->active; 7049 active = qos_data->active;
6884 supported = qos_data->supported; 7050 supported = qos_data->supported;
6885
6886 spin_unlock_irqrestore(&priv->ieee->lock, flags);
6887
6888 IPW_DEBUG_QOS("QoS %d network is QoS active %d supported %d " 7051 IPW_DEBUG_QOS("QoS %d network is QoS active %d supported %d "
6889 "unicast %d\n", 7052 "unicast %d\n",
6890 priv->qos_data.qos_enable, active, supported, unicast); 7053 priv->qos_data.qos_enable, active, supported, unicast);
6891 if (active && priv->qos_data.qos_enable) { 7054 if (active && priv->qos_data.qos_enable)
6892 ret = from_priority_to_tx_queue[priority]; 7055 return 1;
6893 tx_queue_id = ret - 1;
6894 IPW_DEBUG_QOS("QoS packet priority is %d \n", priority);
6895 if (priority <= 7) {
6896 tfd->tx_flags_ext |= DCT_FLAG_EXT_QOS_ENABLED;
6897 tfd->tfd.tfd_26.mchdr.qos_ctrl = priority;
6898 tfd->tfd.tfd_26.mchdr.frame_ctl |=
6899 IEEE80211_STYPE_QOS_DATA;
6900
6901 if (priv->qos_data.qos_no_ack_mask &
6902 (1UL << tx_queue_id)) {
6903 tfd->tx_flags &= ~DCT_FLAG_ACK_REQD;
6904 tfd->tfd.tfd_26.mchdr.qos_ctrl |=
6905 CTRL_QOS_NO_ACK;
6906 }
6907 }
6908 }
6909 7056
6910 return ret; 7057 return 0;
7058
7059}
7060/*
7061* add QoS parameter to the TX command
7062*/
7063static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
7064 u16 priority,
7065 struct tfd_data *tfd)
7066{
7067 int tx_queue_id = 0;
7068
7069
7070 tx_queue_id = from_priority_to_tx_queue[priority] - 1;
7071 tfd->tx_flags_ext |= DCT_FLAG_EXT_QOS_ENABLED;
7072
7073 if (priv->qos_data.qos_no_ack_mask & (1UL << tx_queue_id)) {
7074 tfd->tx_flags &= ~DCT_FLAG_ACK_REQD;
7075 tfd->tfd.tfd_26.mchdr.qos_ctrl |= CTRL_QOS_NO_ACK;
7076 }
7077 return 0;
6911} 7078}
6912 7079
6913/* 7080/*
@@ -6977,7 +7144,7 @@ static int ipw_send_qos_info_command(struct ipw_priv *priv, struct ieee80211_qos
6977 qos_param); 7144 qos_param);
6978} 7145}
6979 7146
6980#endif /* CONFIG_IPW_QOS */ 7147#endif /* CONFIG_IPW2200_QOS */
6981 7148
6982static int ipw_associate_network(struct ipw_priv *priv, 7149static int ipw_associate_network(struct ipw_priv *priv,
6983 struct ieee80211_network *network, 7150 struct ieee80211_network *network,
@@ -7116,7 +7283,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
7116 else 7283 else
7117 priv->sys_config.answer_broadcast_ssid_probe = 0; 7284 priv->sys_config.answer_broadcast_ssid_probe = 0;
7118 7285
7119 err = ipw_send_system_config(priv, &priv->sys_config); 7286 err = ipw_send_system_config(priv);
7120 if (err) { 7287 if (err) {
7121 IPW_DEBUG_HC("Attempt to send sys config command failed.\n"); 7288 IPW_DEBUG_HC("Attempt to send sys config command failed.\n");
7122 return err; 7289 return err;
@@ -7141,7 +7308,7 @@ static int ipw_associate_network(struct ipw_priv *priv,
7141 7308
7142 priv->assoc_network = network; 7309 priv->assoc_network = network;
7143 7310
7144#ifdef CONFIG_IPW_QOS 7311#ifdef CONFIG_IPW2200_QOS
7145 ipw_qos_association(priv, network); 7312 ipw_qos_association(priv, network);
7146#endif 7313#endif
7147 7314
@@ -7415,7 +7582,7 @@ static void ipw_handle_data_packet(struct ipw_priv *priv,
7415 } 7582 }
7416} 7583}
7417 7584
7418#ifdef CONFIG_IEEE80211_RADIOTAP 7585#ifdef CONFIG_IPW2200_RADIOTAP
7419static void ipw_handle_data_packet_monitor(struct ipw_priv *priv, 7586static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7420 struct ipw_rx_mem_buffer *rxb, 7587 struct ipw_rx_mem_buffer *rxb,
7421 struct ieee80211_rx_stats *stats) 7588 struct ieee80211_rx_stats *stats)
@@ -7432,15 +7599,7 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7432 /* Magic struct that slots into the radiotap header -- no reason 7599 /* Magic struct that slots into the radiotap header -- no reason
7433 * to build this manually element by element, we can write it much 7600 * to build this manually element by element, we can write it much
7434 * more efficiently than we can parse it. ORDER MATTERS HERE */ 7601 * more efficiently than we can parse it. ORDER MATTERS HERE */
7435 struct ipw_rt_hdr { 7602 struct ipw_rt_hdr *ipw_rt;
7436 struct ieee80211_radiotap_header rt_hdr;
7437 u8 rt_flags; /* radiotap packet flags */
7438 u8 rt_rate; /* rate in 500kb/s */
7439 u16 rt_channel; /* channel in mhz */
7440 u16 rt_chbitmask; /* channel bitfield */
7441 s8 rt_dbmsignal; /* signal in dbM, kluged to signed */
7442 u8 rt_antenna; /* antenna number */
7443 } *ipw_rt;
7444 7603
7445 short len = le16_to_cpu(pkt->u.frame.length); 7604 short len = le16_to_cpu(pkt->u.frame.length);
7446 7605
@@ -7494,9 +7653,11 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7494 /* Big bitfield of all the fields we provide in radiotap */ 7653 /* Big bitfield of all the fields we provide in radiotap */
7495 ipw_rt->rt_hdr.it_present = 7654 ipw_rt->rt_hdr.it_present =
7496 ((1 << IEEE80211_RADIOTAP_FLAGS) | 7655 ((1 << IEEE80211_RADIOTAP_FLAGS) |
7656 (1 << IEEE80211_RADIOTAP_TSFT) |
7497 (1 << IEEE80211_RADIOTAP_RATE) | 7657 (1 << IEEE80211_RADIOTAP_RATE) |
7498 (1 << IEEE80211_RADIOTAP_CHANNEL) | 7658 (1 << IEEE80211_RADIOTAP_CHANNEL) |
7499 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | 7659 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
7660 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |
7500 (1 << IEEE80211_RADIOTAP_ANTENNA)); 7661 (1 << IEEE80211_RADIOTAP_ANTENNA));
7501 7662
7502 /* Zero the flags, we'll add to them as we go */ 7663 /* Zero the flags, we'll add to them as we go */
@@ -7582,6 +7743,217 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7582} 7743}
7583#endif 7744#endif
7584 7745
7746#ifdef CONFIG_IPW2200_PROMISCUOUS
7747#define ieee80211_is_probe_response(fc) \
7748 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT && \
7749 (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP )
7750
7751#define ieee80211_is_management(fc) \
7752 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)
7753
7754#define ieee80211_is_control(fc) \
7755 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL)
7756
7757#define ieee80211_is_data(fc) \
7758 ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
7759
7760#define ieee80211_is_assoc_request(fc) \
7761 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_ASSOC_REQ)
7762
7763#define ieee80211_is_reassoc_request(fc) \
7764 ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_REASSOC_REQ)
7765
7766static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7767 struct ipw_rx_mem_buffer *rxb,
7768 struct ieee80211_rx_stats *stats)
7769{
7770 struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data;
7771 struct ipw_rx_frame *frame = &pkt->u.frame;
7772 struct ipw_rt_hdr *ipw_rt;
7773
7774 /* First cache any information we need before we overwrite
7775 * the information provided in the skb from the hardware */
7776 struct ieee80211_hdr *hdr;
7777 u16 channel = frame->received_channel;
7778 u8 phy_flags = frame->antennaAndPhy;
7779 s8 signal = frame->rssi_dbm - IPW_RSSI_TO_DBM;
7780 s8 noise = frame->noise;
7781 u8 rate = frame->rate;
7782 short len = le16_to_cpu(pkt->u.frame.length);
7783 u64 tsf = 0;
7784 struct sk_buff *skb;
7785 int hdr_only = 0;
7786 u16 filter = priv->prom_priv->filter;
7787
7788 /* If the filter is set to not include Rx frames then return */
7789 if (filter & IPW_PROM_NO_RX)
7790 return;
7791
7792 /* We received data from the HW, so stop the watchdog */
7793 priv->prom_net_dev->trans_start = jiffies;
7794
7795 if (unlikely((len + IPW_RX_FRAME_SIZE) > skb_tailroom(rxb->skb))) {
7796 priv->prom_priv->ieee->stats.rx_errors++;
7797 IPW_DEBUG_DROP("Corruption detected! Oh no!\n");
7798 return;
7799 }
7800
7801 /* We only process data packets if the interface is open */
7802 if (unlikely(!netif_running(priv->prom_net_dev))) {
7803 priv->prom_priv->ieee->stats.rx_dropped++;
7804 IPW_DEBUG_DROP("Dropping packet while interface is not up.\n");
7805 return;
7806 }
7807
7808 /* Libpcap 0.9.3+ can handle variable length radiotap, so we'll use
7809 * that now */
7810 if (len > IPW_RX_BUF_SIZE - sizeof(struct ipw_rt_hdr)) {
7811 /* FIXME: Should alloc bigger skb instead */
7812 priv->prom_priv->ieee->stats.rx_dropped++;
7813 IPW_DEBUG_DROP("Dropping too large packet in monitor\n");
7814 return;
7815 }
7816
7817 hdr = (void *)rxb->skb->data + IPW_RX_FRAME_SIZE;
7818 if (ieee80211_is_management(hdr->frame_ctl)) {
7819 if (filter & IPW_PROM_NO_MGMT)
7820 return;
7821 if (filter & IPW_PROM_MGMT_HEADER_ONLY)
7822 hdr_only = 1;
7823 } else if (ieee80211_is_control(hdr->frame_ctl)) {
7824 if (filter & IPW_PROM_NO_CTL)
7825 return;
7826 if (filter & IPW_PROM_CTL_HEADER_ONLY)
7827 hdr_only = 1;
7828 } else if (ieee80211_is_data(hdr->frame_ctl)) {
7829 if (filter & IPW_PROM_NO_DATA)
7830 return;
7831 if (filter & IPW_PROM_DATA_HEADER_ONLY)
7832 hdr_only = 1;
7833 }
7834
7835 /* Copy the SKB since this is for the promiscuous side */
7836 skb = skb_copy(rxb->skb, GFP_ATOMIC);
7837 if (skb == NULL) {
7838 IPW_ERROR("skb_clone failed for promiscuous copy.\n");
7839 return;
7840 }
7841
7842 /* copy the frame data to write after where the radiotap header goes */
7843 ipw_rt = (void *)skb->data;
7844
7845 if (hdr_only)
7846 len = ieee80211_get_hdrlen(hdr->frame_ctl);
7847
7848 memcpy(ipw_rt->payload, hdr, len);
7849
7850 /* Zero the radiotap static buffer ... We only need to zero the bytes
7851 * NOT part of our real header, saves a little time.
7852 *
7853 * No longer necessary since we fill in all our data. Purge before
7854 * merging patch officially.
7855 * memset(rxb->skb->data + sizeof(struct ipw_rt_hdr), 0,
7856 * IEEE80211_RADIOTAP_HDRLEN - sizeof(struct ipw_rt_hdr));
7857 */
7858
7859 ipw_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
7860 ipw_rt->rt_hdr.it_pad = 0; /* always good to zero */
7861 ipw_rt->rt_hdr.it_len = sizeof(*ipw_rt); /* total header+data */
7862
7863 /* Set the size of the skb to the size of the frame */
7864 skb_put(skb, ipw_rt->rt_hdr.it_len + len);
7865
7866 /* Big bitfield of all the fields we provide in radiotap */
7867 ipw_rt->rt_hdr.it_present =
7868 ((1 << IEEE80211_RADIOTAP_FLAGS) |
7869 (1 << IEEE80211_RADIOTAP_TSFT) |
7870 (1 << IEEE80211_RADIOTAP_RATE) |
7871 (1 << IEEE80211_RADIOTAP_CHANNEL) |
7872 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
7873 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |
7874 (1 << IEEE80211_RADIOTAP_ANTENNA));
7875
7876 /* Zero the flags, we'll add to them as we go */
7877 ipw_rt->rt_flags = 0;
7878
7879 ipw_rt->rt_tsf = tsf;
7880
7881 /* Convert to DBM */
7882 ipw_rt->rt_dbmsignal = signal;
7883 ipw_rt->rt_dbmnoise = noise;
7884
7885 /* Convert the channel data and set the flags */
7886 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(channel));
7887 if (channel > 14) { /* 802.11a */
7888 ipw_rt->rt_chbitmask =
7889 cpu_to_le16((IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ));
7890 } else if (phy_flags & (1 << 5)) { /* 802.11b */
7891 ipw_rt->rt_chbitmask =
7892 cpu_to_le16((IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ));
7893 } else { /* 802.11g */
7894 ipw_rt->rt_chbitmask =
7895 (IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ);
7896 }
7897
7898 /* set the rate in multiples of 500k/s */
7899 switch (rate) {
7900 case IPW_TX_RATE_1MB:
7901 ipw_rt->rt_rate = 2;
7902 break;
7903 case IPW_TX_RATE_2MB:
7904 ipw_rt->rt_rate = 4;
7905 break;
7906 case IPW_TX_RATE_5MB:
7907 ipw_rt->rt_rate = 10;
7908 break;
7909 case IPW_TX_RATE_6MB:
7910 ipw_rt->rt_rate = 12;
7911 break;
7912 case IPW_TX_RATE_9MB:
7913 ipw_rt->rt_rate = 18;
7914 break;
7915 case IPW_TX_RATE_11MB:
7916 ipw_rt->rt_rate = 22;
7917 break;
7918 case IPW_TX_RATE_12MB:
7919 ipw_rt->rt_rate = 24;
7920 break;
7921 case IPW_TX_RATE_18MB:
7922 ipw_rt->rt_rate = 36;
7923 break;
7924 case IPW_TX_RATE_24MB:
7925 ipw_rt->rt_rate = 48;
7926 break;
7927 case IPW_TX_RATE_36MB:
7928 ipw_rt->rt_rate = 72;
7929 break;
7930 case IPW_TX_RATE_48MB:
7931 ipw_rt->rt_rate = 96;
7932 break;
7933 case IPW_TX_RATE_54MB:
7934 ipw_rt->rt_rate = 108;
7935 break;
7936 default:
7937 ipw_rt->rt_rate = 0;
7938 break;
7939 }
7940
7941 /* antenna number */
7942 ipw_rt->rt_antenna = (phy_flags & 3);
7943
7944 /* set the preamble flag if we have it */
7945 if (phy_flags & (1 << 6))
7946 ipw_rt->rt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
7947
7948 IPW_DEBUG_RX("Rx packet of %d bytes.\n", skb->len);
7949
7950 if (!ieee80211_rx(priv->prom_priv->ieee, skb, stats)) {
7951 priv->prom_priv->ieee->stats.rx_errors++;
7952 dev_kfree_skb_any(skb);
7953 }
7954}
7955#endif
7956
7585static int is_network_packet(struct ipw_priv *priv, 7957static int is_network_packet(struct ipw_priv *priv,
7586 struct ieee80211_hdr_4addr *header) 7958 struct ieee80211_hdr_4addr *header)
7587{ 7959{
@@ -7808,15 +8180,21 @@ static void ipw_rx(struct ipw_priv *priv)
7808 8180
7809 priv->rx_packets++; 8181 priv->rx_packets++;
7810 8182
8183#ifdef CONFIG_IPW2200_PROMISCUOUS
8184 if (priv->prom_net_dev && netif_running(priv->prom_net_dev))
8185 ipw_handle_promiscuous_rx(priv, rxb, &stats);
8186#endif
8187
7811#ifdef CONFIG_IPW2200_MONITOR 8188#ifdef CONFIG_IPW2200_MONITOR
7812 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { 8189 if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
7813#ifdef CONFIG_IEEE80211_RADIOTAP 8190#ifdef CONFIG_IPW2200_RADIOTAP
7814 ipw_handle_data_packet_monitor(priv, 8191
7815 rxb, 8192 ipw_handle_data_packet_monitor(priv,
7816 &stats); 8193 rxb,
8194 &stats);
7817#else 8195#else
7818 ipw_handle_data_packet(priv, rxb, 8196 ipw_handle_data_packet(priv, rxb,
7819 &stats); 8197 &stats);
7820#endif 8198#endif
7821 break; 8199 break;
7822 } 8200 }
@@ -7837,9 +8215,9 @@ static void ipw_rx(struct ipw_priv *priv)
7837 if (network_packet && priv->assoc_network) { 8215 if (network_packet && priv->assoc_network) {
7838 priv->assoc_network->stats.rssi = 8216 priv->assoc_network->stats.rssi =
7839 stats.rssi; 8217 stats.rssi;
7840 average_add(&priv->average_rssi, 8218 priv->exp_avg_rssi =
7841 stats.rssi); 8219 exponential_average(priv->exp_avg_rssi,
7842 priv->last_rx_rssi = stats.rssi; 8220 stats.rssi, DEPTH_RSSI);
7843 } 8221 }
7844 8222
7845 IPW_DEBUG_RX("Frame: len=%u\n", 8223 IPW_DEBUG_RX("Frame: len=%u\n",
@@ -7982,10 +8360,10 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
7982 IPW_DEBUG_INFO("Bind to static channel %d\n", channel); 8360 IPW_DEBUG_INFO("Bind to static channel %d\n", channel);
7983 /* TODO: Validate that provided channel is in range */ 8361 /* TODO: Validate that provided channel is in range */
7984 } 8362 }
7985#ifdef CONFIG_IPW_QOS 8363#ifdef CONFIG_IPW2200_QOS
7986 ipw_qos_init(priv, qos_enable, qos_burst_enable, 8364 ipw_qos_init(priv, qos_enable, qos_burst_enable,
7987 burst_duration_CCK, burst_duration_OFDM); 8365 burst_duration_CCK, burst_duration_OFDM);
7988#endif /* CONFIG_IPW_QOS */ 8366#endif /* CONFIG_IPW2200_QOS */
7989 8367
7990 switch (mode) { 8368 switch (mode) {
7991 case 1: 8369 case 1:
@@ -7996,7 +8374,7 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option)
7996#ifdef CONFIG_IPW2200_MONITOR 8374#ifdef CONFIG_IPW2200_MONITOR
7997 case 2: 8375 case 2:
7998 priv->ieee->iw_mode = IW_MODE_MONITOR; 8376 priv->ieee->iw_mode = IW_MODE_MONITOR;
7999#ifdef CONFIG_IEEE80211_RADIOTAP 8377#ifdef CONFIG_IPW2200_RADIOTAP
8000 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; 8378 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
8001#else 8379#else
8002 priv->net_dev->type = ARPHRD_IEEE80211; 8380 priv->net_dev->type = ARPHRD_IEEE80211;
@@ -8251,7 +8629,7 @@ static int ipw_wx_set_mode(struct net_device *dev,
8251 priv->net_dev->type = ARPHRD_ETHER; 8629 priv->net_dev->type = ARPHRD_ETHER;
8252 8630
8253 if (wrqu->mode == IW_MODE_MONITOR) 8631 if (wrqu->mode == IW_MODE_MONITOR)
8254#ifdef CONFIG_IEEE80211_RADIOTAP 8632#ifdef CONFIG_IPW2200_RADIOTAP
8255 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; 8633 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
8256#else 8634#else
8257 priv->net_dev->type = ARPHRD_IEEE80211; 8635 priv->net_dev->type = ARPHRD_IEEE80211;
@@ -8379,7 +8757,8 @@ static int ipw_wx_get_range(struct net_device *dev,
8379 /* Event capability (kernel + driver) */ 8757 /* Event capability (kernel + driver) */
8380 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | 8758 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
8381 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) | 8759 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
8382 IW_EVENT_CAPA_MASK(SIOCGIWAP)); 8760 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
8761 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
8383 range->event_capa[1] = IW_EVENT_CAPA_K_1; 8762 range->event_capa[1] = IW_EVENT_CAPA_K_1;
8384 8763
8385 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | 8764 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
@@ -8734,6 +9113,7 @@ static int ipw_wx_get_rate(struct net_device *dev,
8734 struct ipw_priv *priv = ieee80211_priv(dev); 9113 struct ipw_priv *priv = ieee80211_priv(dev);
8735 mutex_lock(&priv->mutex); 9114 mutex_lock(&priv->mutex);
8736 wrqu->bitrate.value = priv->last_rate; 9115 wrqu->bitrate.value = priv->last_rate;
9116 wrqu->bitrate.fixed = (priv->config & CFG_FIXED_RATE) ? 1 : 0;
8737 mutex_unlock(&priv->mutex); 9117 mutex_unlock(&priv->mutex);
8738 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); 9118 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value);
8739 return 0; 9119 return 0;
@@ -9351,7 +9731,7 @@ static int ipw_wx_set_monitor(struct net_device *dev,
9351 IPW_DEBUG_WX("SET MONITOR: %d %d\n", enable, parms[1]); 9731 IPW_DEBUG_WX("SET MONITOR: %d %d\n", enable, parms[1]);
9352 if (enable) { 9732 if (enable) {
9353 if (priv->ieee->iw_mode != IW_MODE_MONITOR) { 9733 if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
9354#ifdef CONFIG_IEEE80211_RADIOTAP 9734#ifdef CONFIG_IPW2200_RADIOTAP
9355 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP; 9735 priv->net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
9356#else 9736#else
9357 priv->net_dev->type = ARPHRD_IEEE80211; 9737 priv->net_dev->type = ARPHRD_IEEE80211;
@@ -9579,8 +9959,8 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev)
9579 } 9959 }
9580 9960
9581 wstats->qual.qual = priv->quality; 9961 wstats->qual.qual = priv->quality;
9582 wstats->qual.level = average_value(&priv->average_rssi); 9962 wstats->qual.level = priv->exp_avg_rssi;
9583 wstats->qual.noise = average_value(&priv->average_noise); 9963 wstats->qual.noise = priv->exp_avg_noise;
9584 wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | 9964 wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
9585 IW_QUAL_NOISE_UPDATED | IW_QUAL_DBM; 9965 IW_QUAL_NOISE_UPDATED | IW_QUAL_DBM;
9586 9966
@@ -9608,7 +9988,9 @@ static void init_sys_config(struct ipw_sys_config *sys_config)
9608 sys_config->disable_unicast_decryption = 1; 9988 sys_config->disable_unicast_decryption = 1;
9609 sys_config->exclude_multicast_unencrypted = 0; 9989 sys_config->exclude_multicast_unencrypted = 0;
9610 sys_config->disable_multicast_decryption = 1; 9990 sys_config->disable_multicast_decryption = 1;
9611 sys_config->antenna_diversity = CFG_SYS_ANTENNA_SLOW_DIV; 9991 if (antenna < CFG_SYS_ANTENNA_BOTH || antenna > CFG_SYS_ANTENNA_B)
9992 antenna = CFG_SYS_ANTENNA_BOTH;
9993 sys_config->antenna_diversity = antenna;
9612 sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ 9994 sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */
9613 sys_config->dot11g_auto_detection = 0; 9995 sys_config->dot11g_auto_detection = 0;
9614 sys_config->enable_cts_to_self = 0; 9996 sys_config->enable_cts_to_self = 0;
@@ -9647,11 +10029,11 @@ we need to heavily modify the ieee80211_skb_to_txb.
9647static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb, 10029static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9648 int pri) 10030 int pri)
9649{ 10031{
9650 struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *) 10032 struct ieee80211_hdr_3addrqos *hdr = (struct ieee80211_hdr_3addrqos *)
9651 txb->fragments[0]->data; 10033 txb->fragments[0]->data;
9652 int i = 0; 10034 int i = 0;
9653 struct tfd_frame *tfd; 10035 struct tfd_frame *tfd;
9654#ifdef CONFIG_IPW_QOS 10036#ifdef CONFIG_IPW2200_QOS
9655 int tx_id = ipw_get_tx_queue_number(priv, pri); 10037 int tx_id = ipw_get_tx_queue_number(priv, pri);
9656 struct clx2_tx_queue *txq = &priv->txq[tx_id]; 10038 struct clx2_tx_queue *txq = &priv->txq[tx_id];
9657#else 10039#else
@@ -9662,9 +10044,9 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9662 u16 remaining_bytes; 10044 u16 remaining_bytes;
9663 int fc; 10045 int fc;
9664 10046
10047 hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
9665 switch (priv->ieee->iw_mode) { 10048 switch (priv->ieee->iw_mode) {
9666 case IW_MODE_ADHOC: 10049 case IW_MODE_ADHOC:
9667 hdr_len = IEEE80211_3ADDR_LEN;
9668 unicast = !is_multicast_ether_addr(hdr->addr1); 10050 unicast = !is_multicast_ether_addr(hdr->addr1);
9669 id = ipw_find_station(priv, hdr->addr1); 10051 id = ipw_find_station(priv, hdr->addr1);
9670 if (id == IPW_INVALID_STATION) { 10052 if (id == IPW_INVALID_STATION) {
@@ -9681,7 +10063,6 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9681 case IW_MODE_INFRA: 10063 case IW_MODE_INFRA:
9682 default: 10064 default:
9683 unicast = !is_multicast_ether_addr(hdr->addr3); 10065 unicast = !is_multicast_ether_addr(hdr->addr3);
9684 hdr_len = IEEE80211_3ADDR_LEN;
9685 id = 0; 10066 id = 0;
9686 break; 10067 break;
9687 } 10068 }
@@ -9759,9 +10140,10 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9759 /* No hardware encryption */ 10140 /* No hardware encryption */
9760 tfd->u.data.tx_flags |= DCT_FLAG_NO_WEP; 10141 tfd->u.data.tx_flags |= DCT_FLAG_NO_WEP;
9761 10142
9762#ifdef CONFIG_IPW_QOS 10143#ifdef CONFIG_IPW2200_QOS
9763 ipw_qos_set_tx_queue_command(priv, pri, &(tfd->u.data), unicast); 10144 if (fc & IEEE80211_STYPE_QOS_DATA)
9764#endif /* CONFIG_IPW_QOS */ 10145 ipw_qos_set_tx_queue_command(priv, pri, &(tfd->u.data));
10146#endif /* CONFIG_IPW2200_QOS */
9765 10147
9766 /* payload */ 10148 /* payload */
9767 tfd->u.data.num_chunks = cpu_to_le32(min((u8) (NUM_TFD_CHUNKS - 2), 10149 tfd->u.data.num_chunks = cpu_to_le32(min((u8) (NUM_TFD_CHUNKS - 2),
@@ -9841,12 +10223,12 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9841static int ipw_net_is_queue_full(struct net_device *dev, int pri) 10223static int ipw_net_is_queue_full(struct net_device *dev, int pri)
9842{ 10224{
9843 struct ipw_priv *priv = ieee80211_priv(dev); 10225 struct ipw_priv *priv = ieee80211_priv(dev);
9844#ifdef CONFIG_IPW_QOS 10226#ifdef CONFIG_IPW2200_QOS
9845 int tx_id = ipw_get_tx_queue_number(priv, pri); 10227 int tx_id = ipw_get_tx_queue_number(priv, pri);
9846 struct clx2_tx_queue *txq = &priv->txq[tx_id]; 10228 struct clx2_tx_queue *txq = &priv->txq[tx_id];
9847#else 10229#else
9848 struct clx2_tx_queue *txq = &priv->txq[0]; 10230 struct clx2_tx_queue *txq = &priv->txq[0];
9849#endif /* CONFIG_IPW_QOS */ 10231#endif /* CONFIG_IPW2200_QOS */
9850 10232
9851 if (ipw_queue_space(&txq->q) < txq->q.high_mark) 10233 if (ipw_queue_space(&txq->q) < txq->q.high_mark)
9852 return 1; 10234 return 1;
@@ -9854,6 +10236,88 @@ static int ipw_net_is_queue_full(struct net_device *dev, int pri)
9854 return 0; 10236 return 0;
9855} 10237}
9856 10238
10239#ifdef CONFIG_IPW2200_PROMISCUOUS
10240static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10241 struct ieee80211_txb *txb)
10242{
10243 struct ieee80211_rx_stats dummystats;
10244 struct ieee80211_hdr *hdr;
10245 u8 n;
10246 u16 filter = priv->prom_priv->filter;
10247 int hdr_only = 0;
10248
10249 if (filter & IPW_PROM_NO_TX)
10250 return;
10251
10252 memset(&dummystats, 0, sizeof(dummystats));
10253
10254 /* Filtering of fragment chains is done agains the first fragment */
10255 hdr = (void *)txb->fragments[0]->data;
10256 if (ieee80211_is_management(hdr->frame_ctl)) {
10257 if (filter & IPW_PROM_NO_MGMT)
10258 return;
10259 if (filter & IPW_PROM_MGMT_HEADER_ONLY)
10260 hdr_only = 1;
10261 } else if (ieee80211_is_control(hdr->frame_ctl)) {
10262 if (filter & IPW_PROM_NO_CTL)
10263 return;
10264 if (filter & IPW_PROM_CTL_HEADER_ONLY)
10265 hdr_only = 1;
10266 } else if (ieee80211_is_data(hdr->frame_ctl)) {
10267 if (filter & IPW_PROM_NO_DATA)
10268 return;
10269 if (filter & IPW_PROM_DATA_HEADER_ONLY)
10270 hdr_only = 1;
10271 }
10272
10273 for(n=0; n<txb->nr_frags; ++n) {
10274 struct sk_buff *src = txb->fragments[n];
10275 struct sk_buff *dst;
10276 struct ieee80211_radiotap_header *rt_hdr;
10277 int len;
10278
10279 if (hdr_only) {
10280 hdr = (void *)src->data;
10281 len = ieee80211_get_hdrlen(hdr->frame_ctl);
10282 } else
10283 len = src->len;
10284
10285 dst = alloc_skb(
10286 len + IEEE80211_RADIOTAP_HDRLEN, GFP_ATOMIC);
10287 if (!dst) continue;
10288
10289 rt_hdr = (void *)skb_put(dst, sizeof(*rt_hdr));
10290
10291 rt_hdr->it_version = PKTHDR_RADIOTAP_VERSION;
10292 rt_hdr->it_pad = 0;
10293 rt_hdr->it_present = 0; /* after all, it's just an idea */
10294 rt_hdr->it_present |= (1 << IEEE80211_RADIOTAP_CHANNEL);
10295
10296 *(u16*)skb_put(dst, sizeof(u16)) = cpu_to_le16(
10297 ieee80211chan2mhz(priv->channel));
10298 if (priv->channel > 14) /* 802.11a */
10299 *(u16*)skb_put(dst, sizeof(u16)) =
10300 cpu_to_le16(IEEE80211_CHAN_OFDM |
10301 IEEE80211_CHAN_5GHZ);
10302 else if (priv->ieee->mode == IEEE_B) /* 802.11b */
10303 *(u16*)skb_put(dst, sizeof(u16)) =
10304 cpu_to_le16(IEEE80211_CHAN_CCK |
10305 IEEE80211_CHAN_2GHZ);
10306 else /* 802.11g */
10307 *(u16*)skb_put(dst, sizeof(u16)) =
10308 cpu_to_le16(IEEE80211_CHAN_OFDM |
10309 IEEE80211_CHAN_2GHZ);
10310
10311 rt_hdr->it_len = dst->len;
10312
10313 memcpy(skb_put(dst, len), src->data, len);
10314
10315 if (!ieee80211_rx(priv->prom_priv->ieee, dst, &dummystats))
10316 dev_kfree_skb_any(dst);
10317 }
10318}
10319#endif
10320
9857static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb, 10321static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
9858 struct net_device *dev, int pri) 10322 struct net_device *dev, int pri)
9859{ 10323{
@@ -9871,6 +10335,11 @@ static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
9871 goto fail_unlock; 10335 goto fail_unlock;
9872 } 10336 }
9873 10337
10338#ifdef CONFIG_IPW2200_PROMISCUOUS
10339 if (rtap_iface && netif_running(priv->prom_net_dev))
10340 ipw_handle_promiscuous_tx(priv, txb);
10341#endif
10342
9874 ret = ipw_tx_skb(priv, txb, pri); 10343 ret = ipw_tx_skb(priv, txb, pri);
9875 if (ret == NETDEV_TX_OK) 10344 if (ret == NETDEV_TX_OK)
9876 __ipw_led_activity_on(priv); 10345 __ipw_led_activity_on(priv);
@@ -10169,10 +10638,10 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
10169 INIT_WORK(&priv->merge_networks, 10638 INIT_WORK(&priv->merge_networks,
10170 (void (*)(void *))ipw_merge_adhoc_network, priv); 10639 (void (*)(void *))ipw_merge_adhoc_network, priv);
10171 10640
10172#ifdef CONFIG_IPW_QOS 10641#ifdef CONFIG_IPW2200_QOS
10173 INIT_WORK(&priv->qos_activate, (void (*)(void *))ipw_bg_qos_activate, 10642 INIT_WORK(&priv->qos_activate, (void (*)(void *))ipw_bg_qos_activate,
10174 priv); 10643 priv);
10175#endif /* CONFIG_IPW_QOS */ 10644#endif /* CONFIG_IPW2200_QOS */
10176 10645
10177 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 10646 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
10178 ipw_irq_tasklet, (unsigned long)priv); 10647 ipw_irq_tasklet, (unsigned long)priv);
@@ -10318,12 +10787,21 @@ static int ipw_config(struct ipw_priv *priv)
10318 |= CFG_BT_COEXISTENCE_OOB; 10787 |= CFG_BT_COEXISTENCE_OOB;
10319 } 10788 }
10320 10789
10790#ifdef CONFIG_IPW2200_PROMISCUOUS
10791 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
10792 priv->sys_config.accept_all_data_frames = 1;
10793 priv->sys_config.accept_non_directed_frames = 1;
10794 priv->sys_config.accept_all_mgmt_bcpr = 1;
10795 priv->sys_config.accept_all_mgmt_frames = 1;
10796 }
10797#endif
10798
10321 if (priv->ieee->iw_mode == IW_MODE_ADHOC) 10799 if (priv->ieee->iw_mode == IW_MODE_ADHOC)
10322 priv->sys_config.answer_broadcast_ssid_probe = 1; 10800 priv->sys_config.answer_broadcast_ssid_probe = 1;
10323 else 10801 else
10324 priv->sys_config.answer_broadcast_ssid_probe = 0; 10802 priv->sys_config.answer_broadcast_ssid_probe = 0;
10325 10803
10326 if (ipw_send_system_config(priv, &priv->sys_config)) 10804 if (ipw_send_system_config(priv))
10327 goto error; 10805 goto error;
10328 10806
10329 init_supported_rates(priv, &priv->rates); 10807 init_supported_rates(priv, &priv->rates);
@@ -10335,10 +10813,10 @@ static int ipw_config(struct ipw_priv *priv)
10335 if (ipw_send_rts_threshold(priv, priv->rts_threshold)) 10813 if (ipw_send_rts_threshold(priv, priv->rts_threshold))
10336 goto error; 10814 goto error;
10337 } 10815 }
10338#ifdef CONFIG_IPW_QOS 10816#ifdef CONFIG_IPW2200_QOS
10339 IPW_DEBUG_QOS("QoS: call ipw_qos_activate\n"); 10817 IPW_DEBUG_QOS("QoS: call ipw_qos_activate\n");
10340 ipw_qos_activate(priv, NULL); 10818 ipw_qos_activate(priv, NULL);
10341#endif /* CONFIG_IPW_QOS */ 10819#endif /* CONFIG_IPW2200_QOS */
10342 10820
10343 if (ipw_set_random_seed(priv)) 10821 if (ipw_set_random_seed(priv))
10344 goto error; 10822 goto error;
@@ -10639,6 +11117,7 @@ static int ipw_up(struct ipw_priv *priv)
10639 if (priv->cmdlog == NULL) { 11117 if (priv->cmdlog == NULL) {
10640 IPW_ERROR("Error allocating %d command log entries.\n", 11118 IPW_ERROR("Error allocating %d command log entries.\n",
10641 cmdlog); 11119 cmdlog);
11120 return -ENOMEM;
10642 } else { 11121 } else {
10643 memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog); 11122 memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog);
10644 priv->cmdlog_len = cmdlog; 11123 priv->cmdlog_len = cmdlog;
@@ -10860,6 +11339,10 @@ static struct attribute *ipw_sysfs_entries[] = {
10860 &dev_attr_led.attr, 11339 &dev_attr_led.attr,
10861 &dev_attr_speed_scan.attr, 11340 &dev_attr_speed_scan.attr,
10862 &dev_attr_net_stats.attr, 11341 &dev_attr_net_stats.attr,
11342#ifdef CONFIG_IPW2200_PROMISCUOUS
11343 &dev_attr_rtap_iface.attr,
11344 &dev_attr_rtap_filter.attr,
11345#endif
10863 NULL 11346 NULL
10864}; 11347};
10865 11348
@@ -10868,6 +11351,109 @@ static struct attribute_group ipw_attribute_group = {
10868 .attrs = ipw_sysfs_entries, 11351 .attrs = ipw_sysfs_entries,
10869}; 11352};
10870 11353
11354#ifdef CONFIG_IPW2200_PROMISCUOUS
11355static int ipw_prom_open(struct net_device *dev)
11356{
11357 struct ipw_prom_priv *prom_priv = ieee80211_priv(dev);
11358 struct ipw_priv *priv = prom_priv->priv;
11359
11360 IPW_DEBUG_INFO("prom dev->open\n");
11361 netif_carrier_off(dev);
11362 netif_stop_queue(dev);
11363
11364 if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
11365 priv->sys_config.accept_all_data_frames = 1;
11366 priv->sys_config.accept_non_directed_frames = 1;
11367 priv->sys_config.accept_all_mgmt_bcpr = 1;
11368 priv->sys_config.accept_all_mgmt_frames = 1;
11369
11370 ipw_send_system_config(priv);
11371 }
11372
11373 return 0;
11374}
11375
11376static int ipw_prom_stop(struct net_device *dev)
11377{
11378 struct ipw_prom_priv *prom_priv = ieee80211_priv(dev);
11379 struct ipw_priv *priv = prom_priv->priv;
11380
11381 IPW_DEBUG_INFO("prom dev->stop\n");
11382
11383 if (priv->ieee->iw_mode != IW_MODE_MONITOR) {
11384 priv->sys_config.accept_all_data_frames = 0;
11385 priv->sys_config.accept_non_directed_frames = 0;
11386 priv->sys_config.accept_all_mgmt_bcpr = 0;
11387 priv->sys_config.accept_all_mgmt_frames = 0;
11388
11389 ipw_send_system_config(priv);
11390 }
11391
11392 return 0;
11393}
11394
11395static int ipw_prom_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
11396{
11397 IPW_DEBUG_INFO("prom dev->xmit\n");
11398 netif_stop_queue(dev);
11399 return -EOPNOTSUPP;
11400}
11401
11402static struct net_device_stats *ipw_prom_get_stats(struct net_device *dev)
11403{
11404 struct ipw_prom_priv *prom_priv = ieee80211_priv(dev);
11405 return &prom_priv->ieee->stats;
11406}
11407
11408static int ipw_prom_alloc(struct ipw_priv *priv)
11409{
11410 int rc = 0;
11411
11412 if (priv->prom_net_dev)
11413 return -EPERM;
11414
11415 priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv));
11416 if (priv->prom_net_dev == NULL)
11417 return -ENOMEM;
11418
11419 priv->prom_priv = ieee80211_priv(priv->prom_net_dev);
11420 priv->prom_priv->ieee = netdev_priv(priv->prom_net_dev);
11421 priv->prom_priv->priv = priv;
11422
11423 strcpy(priv->prom_net_dev->name, "rtap%d");
11424
11425 priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
11426 priv->prom_net_dev->open = ipw_prom_open;
11427 priv->prom_net_dev->stop = ipw_prom_stop;
11428 priv->prom_net_dev->get_stats = ipw_prom_get_stats;
11429 priv->prom_net_dev->hard_start_xmit = ipw_prom_hard_start_xmit;
11430
11431 priv->prom_priv->ieee->iw_mode = IW_MODE_MONITOR;
11432
11433 rc = register_netdev(priv->prom_net_dev);
11434 if (rc) {
11435 free_ieee80211(priv->prom_net_dev);
11436 priv->prom_net_dev = NULL;
11437 return rc;
11438 }
11439
11440 return 0;
11441}
11442
11443static void ipw_prom_free(struct ipw_priv *priv)
11444{
11445 if (!priv->prom_net_dev)
11446 return;
11447
11448 unregister_netdev(priv->prom_net_dev);
11449 free_ieee80211(priv->prom_net_dev);
11450
11451 priv->prom_net_dev = NULL;
11452}
11453
11454#endif
11455
11456
10871static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 11457static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10872{ 11458{
10873 int err = 0; 11459 int err = 0;
@@ -10959,11 +11545,12 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10959 priv->ieee->set_security = shim__set_security; 11545 priv->ieee->set_security = shim__set_security;
10960 priv->ieee->is_queue_full = ipw_net_is_queue_full; 11546 priv->ieee->is_queue_full = ipw_net_is_queue_full;
10961 11547
10962#ifdef CONFIG_IPW_QOS 11548#ifdef CONFIG_IPW2200_QOS
11549 priv->ieee->is_qos_active = ipw_is_qos_active;
10963 priv->ieee->handle_probe_response = ipw_handle_beacon; 11550 priv->ieee->handle_probe_response = ipw_handle_beacon;
10964 priv->ieee->handle_beacon = ipw_handle_probe_response; 11551 priv->ieee->handle_beacon = ipw_handle_probe_response;
10965 priv->ieee->handle_assoc_response = ipw_handle_assoc_response; 11552 priv->ieee->handle_assoc_response = ipw_handle_assoc_response;
10966#endif /* CONFIG_IPW_QOS */ 11553#endif /* CONFIG_IPW2200_QOS */
10967 11554
10968 priv->ieee->perfect_rssi = -20; 11555 priv->ieee->perfect_rssi = -20;
10969 priv->ieee->worst_rssi = -85; 11556 priv->ieee->worst_rssi = -85;
@@ -10997,6 +11584,18 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10997 goto out_remove_sysfs; 11584 goto out_remove_sysfs;
10998 } 11585 }
10999 11586
11587#ifdef CONFIG_IPW2200_PROMISCUOUS
11588 if (rtap_iface) {
11589 err = ipw_prom_alloc(priv);
11590 if (err) {
11591 IPW_ERROR("Failed to register promiscuous network "
11592 "device (error %d).\n", err);
11593 unregister_netdev(priv->net_dev);
11594 goto out_remove_sysfs;
11595 }
11596 }
11597#endif
11598
11000 printk(KERN_INFO DRV_NAME ": Detected geography %s (%d 802.11bg " 11599 printk(KERN_INFO DRV_NAME ": Detected geography %s (%d 802.11bg "
11001 "channels, %d 802.11a channels)\n", 11600 "channels, %d 802.11a channels)\n",
11002 priv->ieee->geo.name, priv->ieee->geo.bg_channels, 11601 priv->ieee->geo.name, priv->ieee->geo.bg_channels,
@@ -11076,6 +11675,10 @@ static void ipw_pci_remove(struct pci_dev *pdev)
11076 priv->error = NULL; 11675 priv->error = NULL;
11077 } 11676 }
11078 11677
11678#ifdef CONFIG_IPW2200_PROMISCUOUS
11679 ipw_prom_free(priv);
11680#endif
11681
11079 free_irq(pdev->irq, priv); 11682 free_irq(pdev->irq, priv);
11080 iounmap(priv->hw_base); 11683 iounmap(priv->hw_base);
11081 pci_release_regions(pdev); 11684 pci_release_regions(pdev);
@@ -11200,7 +11803,12 @@ MODULE_PARM_DESC(debug, "debug output mask");
11200module_param(channel, int, 0444); 11803module_param(channel, int, 0444);
11201MODULE_PARM_DESC(channel, "channel to limit associate to (default 0 [ANY])"); 11804MODULE_PARM_DESC(channel, "channel to limit associate to (default 0 [ANY])");
11202 11805
11203#ifdef CONFIG_IPW_QOS 11806#ifdef CONFIG_IPW2200_PROMISCUOUS
11807module_param(rtap_iface, int, 0444);
11808MODULE_PARM_DESC(rtap_iface, "create the rtap interface (1 - create, default 0)");
11809#endif
11810
11811#ifdef CONFIG_IPW2200_QOS
11204module_param(qos_enable, int, 0444); 11812module_param(qos_enable, int, 0444);
11205MODULE_PARM_DESC(qos_enable, "enable all QoS functionalitis"); 11813MODULE_PARM_DESC(qos_enable, "enable all QoS functionalitis");
11206 11814
@@ -11215,7 +11823,7 @@ MODULE_PARM_DESC(burst_duration_CCK, "set CCK burst value");
11215 11823
11216module_param(burst_duration_OFDM, int, 0444); 11824module_param(burst_duration_OFDM, int, 0444);
11217MODULE_PARM_DESC(burst_duration_OFDM, "set OFDM burst value"); 11825MODULE_PARM_DESC(burst_duration_OFDM, "set OFDM burst value");
11218#endif /* CONFIG_IPW_QOS */ 11826#endif /* CONFIG_IPW2200_QOS */
11219 11827
11220#ifdef CONFIG_IPW2200_MONITOR 11828#ifdef CONFIG_IPW2200_MONITOR
11221module_param(mode, int, 0444); 11829module_param(mode, int, 0444);
@@ -11238,5 +11846,8 @@ MODULE_PARM_DESC(cmdlog,
11238module_param(roaming, int, 0444); 11846module_param(roaming, int, 0444);
11239MODULE_PARM_DESC(roaming, "enable roaming support (default on)"); 11847MODULE_PARM_DESC(roaming, "enable roaming support (default on)");
11240 11848
11849module_param(antenna, int, 0444);
11850MODULE_PARM_DESC(antenna, "select antenna 1=Main, 3=Aux, default 0 [both], 2=slow_diversity (choose the one with lower background noise)");
11851
11241module_exit(ipw_exit); 11852module_exit(ipw_exit);
11242module_init(ipw_init); 11853module_init(ipw_init);
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index 4b9804900702..6044c0be2c80 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -789,7 +789,7 @@ struct ipw_sys_config {
789 u8 bt_coexist_collision_thr; 789 u8 bt_coexist_collision_thr;
790 u8 silence_threshold; 790 u8 silence_threshold;
791 u8 accept_all_mgmt_bcpr; 791 u8 accept_all_mgmt_bcpr;
792 u8 accept_all_mgtm_frames; 792 u8 accept_all_mgmt_frames;
793 u8 pass_noise_stats_to_host; 793 u8 pass_noise_stats_to_host;
794 u8 reserved3; 794 u8 reserved3;
795} __attribute__ ((packed)); 795} __attribute__ ((packed));
@@ -1122,6 +1122,52 @@ struct ipw_fw_error {
1122 u8 payload[0]; 1122 u8 payload[0];
1123} __attribute__ ((packed)); 1123} __attribute__ ((packed));
1124 1124
1125#ifdef CONFIG_IPW2200_PROMISCUOUS
1126
1127enum ipw_prom_filter {
1128 IPW_PROM_CTL_HEADER_ONLY = (1 << 0),
1129 IPW_PROM_MGMT_HEADER_ONLY = (1 << 1),
1130 IPW_PROM_DATA_HEADER_ONLY = (1 << 2),
1131 IPW_PROM_ALL_HEADER_ONLY = 0xf, /* bits 0..3 */
1132 IPW_PROM_NO_TX = (1 << 4),
1133 IPW_PROM_NO_RX = (1 << 5),
1134 IPW_PROM_NO_CTL = (1 << 6),
1135 IPW_PROM_NO_MGMT = (1 << 7),
1136 IPW_PROM_NO_DATA = (1 << 8),
1137};
1138
1139struct ipw_priv;
1140struct ipw_prom_priv {
1141 struct ipw_priv *priv;
1142 struct ieee80211_device *ieee;
1143 enum ipw_prom_filter filter;
1144 int tx_packets;
1145 int rx_packets;
1146};
1147#endif
1148
1149#if defined(CONFIG_IPW2200_RADIOTAP) || defined(CONFIG_IPW2200_PROMISCUOUS)
1150/* Magic struct that slots into the radiotap header -- no reason
1151 * to build this manually element by element, we can write it much
1152 * more efficiently than we can parse it. ORDER MATTERS HERE
1153 *
1154 * When sent to us via the simulated Rx interface in sysfs, the entire
1155 * structure is provided regardless of any bits unset.
1156 */
1157struct ipw_rt_hdr {
1158 struct ieee80211_radiotap_header rt_hdr;
1159 u64 rt_tsf; /* TSF */
1160 u8 rt_flags; /* radiotap packet flags */
1161 u8 rt_rate; /* rate in 500kb/s */
1162 u16 rt_channel; /* channel in mhz */
1163 u16 rt_chbitmask; /* channel bitfield */
1164 s8 rt_dbmsignal; /* signal in dbM, kluged to signed */
1165 s8 rt_dbmnoise;
1166 u8 rt_antenna; /* antenna number */
1167 u8 payload[0]; /* payload... */
1168} __attribute__ ((packed));
1169#endif
1170
1125struct ipw_priv { 1171struct ipw_priv {
1126 /* ieee device used by generic ieee processing code */ 1172 /* ieee device used by generic ieee processing code */
1127 struct ieee80211_device *ieee; 1173 struct ieee80211_device *ieee;
@@ -1133,6 +1179,12 @@ struct ipw_priv {
1133 struct pci_dev *pci_dev; 1179 struct pci_dev *pci_dev;
1134 struct net_device *net_dev; 1180 struct net_device *net_dev;
1135 1181
1182#ifdef CONFIG_IPW2200_PROMISCUOUS
1183 /* Promiscuous mode */
1184 struct ipw_prom_priv *prom_priv;
1185 struct net_device *prom_net_dev;
1186#endif
1187
1136 /* pci hardware address support */ 1188 /* pci hardware address support */
1137 void __iomem *hw_base; 1189 void __iomem *hw_base;
1138 unsigned long hw_len; 1190 unsigned long hw_len;
@@ -1153,11 +1205,9 @@ struct ipw_priv {
1153 u32 config; 1205 u32 config;
1154 u32 capability; 1206 u32 capability;
1155 1207
1156 u8 last_rx_rssi;
1157 u8 last_noise;
1158 struct average average_missed_beacons; 1208 struct average average_missed_beacons;
1159 struct average average_rssi; 1209 s16 exp_avg_rssi;
1160 struct average average_noise; 1210 s16 exp_avg_noise;
1161 u32 port_type; 1211 u32 port_type;
1162 int rx_bufs_min; /**< minimum number of bufs in Rx queue */ 1212 int rx_bufs_min; /**< minimum number of bufs in Rx queue */
1163 int rx_pend_max; /**< maximum pending buffers for one IRQ */ 1213 int rx_pend_max; /**< maximum pending buffers for one IRQ */
@@ -1308,6 +1358,29 @@ struct ipw_priv {
1308 1358
1309/* debug macros */ 1359/* debug macros */
1310 1360
1361/* Debug and printf string expansion helpers for printing bitfields */
1362#define BIT_FMT8 "%c%c%c%c-%c%c%c%c"
1363#define BIT_FMT16 BIT_FMT8 ":" BIT_FMT8
1364#define BIT_FMT32 BIT_FMT16 " " BIT_FMT16
1365
1366#define BITC(x,y) (((x>>y)&1)?'1':'0')
1367#define BIT_ARG8(x) \
1368BITC(x,7),BITC(x,6),BITC(x,5),BITC(x,4),\
1369BITC(x,3),BITC(x,2),BITC(x,1),BITC(x,0)
1370
1371#define BIT_ARG16(x) \
1372BITC(x,15),BITC(x,14),BITC(x,13),BITC(x,12),\
1373BITC(x,11),BITC(x,10),BITC(x,9),BITC(x,8),\
1374BIT_ARG8(x)
1375
1376#define BIT_ARG32(x) \
1377BITC(x,31),BITC(x,30),BITC(x,29),BITC(x,28),\
1378BITC(x,27),BITC(x,26),BITC(x,25),BITC(x,24),\
1379BITC(x,23),BITC(x,22),BITC(x,21),BITC(x,20),\
1380BITC(x,19),BITC(x,18),BITC(x,17),BITC(x,16),\
1381BIT_ARG16(x)
1382
1383
1311#ifdef CONFIG_IPW2200_DEBUG 1384#ifdef CONFIG_IPW2200_DEBUG
1312#define IPW_DEBUG(level, fmt, args...) \ 1385#define IPW_DEBUG(level, fmt, args...) \
1313do { if (ipw_debug_level & (level)) \ 1386do { if (ipw_debug_level & (level)) \
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index c2d0b09e0418..8a31b591a901 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -201,41 +201,12 @@ static struct {
201/* Data types */ 201/* Data types */
202/********************************************************************/ 202/********************************************************************/
203 203
204/* Used in Event handling. 204/* Beginning of the Tx descriptor, used in TxExc handling */
205 * We avoid nested structures as they break on ARM -- Moustafa */ 205struct hermes_txexc_data {
206struct hermes_tx_descriptor_802_11 { 206 struct hermes_tx_descriptor desc;
207 /* hermes_tx_descriptor */
208 __le16 status;
209 __le16 reserved1;
210 __le16 reserved2;
211 __le32 sw_support;
212 u8 retry_count;
213 u8 tx_rate;
214 __le16 tx_control;
215
216 /* ieee80211_hdr */
217 __le16 frame_ctl; 207 __le16 frame_ctl;
218 __le16 duration_id; 208 __le16 duration_id;
219 u8 addr1[ETH_ALEN]; 209 u8 addr1[ETH_ALEN];
220 u8 addr2[ETH_ALEN];
221 u8 addr3[ETH_ALEN];
222 __le16 seq_ctl;
223 u8 addr4[ETH_ALEN];
224
225 __le16 data_len;
226
227 /* ethhdr */
228 u8 h_dest[ETH_ALEN]; /* destination eth addr */
229 u8 h_source[ETH_ALEN]; /* source ether addr */
230 __be16 h_proto; /* packet type ID field */
231
232 /* p8022_hdr */
233 u8 dsap;
234 u8 ssap;
235 u8 ctrl;
236 u8 oui[3];
237
238 __be16 ethertype;
239} __attribute__ ((packed)); 210} __attribute__ ((packed));
240 211
241/* Rx frame header except compatibility 802.3 header */ 212/* Rx frame header except compatibility 802.3 header */
@@ -450,53 +421,39 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
450 hermes_t *hw = &priv->hw; 421 hermes_t *hw = &priv->hw;
451 int err = 0; 422 int err = 0;
452 u16 txfid = priv->txfid; 423 u16 txfid = priv->txfid;
453 char *p;
454 struct ethhdr *eh; 424 struct ethhdr *eh;
455 int len, data_len, data_off; 425 int data_off;
456 struct hermes_tx_descriptor desc; 426 struct hermes_tx_descriptor desc;
457 unsigned long flags; 427 unsigned long flags;
458 428
459 TRACE_ENTER(dev->name);
460
461 if (! netif_running(dev)) { 429 if (! netif_running(dev)) {
462 printk(KERN_ERR "%s: Tx on stopped device!\n", 430 printk(KERN_ERR "%s: Tx on stopped device!\n",
463 dev->name); 431 dev->name);
464 TRACE_EXIT(dev->name); 432 return NETDEV_TX_BUSY;
465 return 1;
466 } 433 }
467 434
468 if (netif_queue_stopped(dev)) { 435 if (netif_queue_stopped(dev)) {
469 printk(KERN_DEBUG "%s: Tx while transmitter busy!\n", 436 printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
470 dev->name); 437 dev->name);
471 TRACE_EXIT(dev->name); 438 return NETDEV_TX_BUSY;
472 return 1;
473 } 439 }
474 440
475 if (orinoco_lock(priv, &flags) != 0) { 441 if (orinoco_lock(priv, &flags) != 0) {
476 printk(KERN_ERR "%s: orinoco_xmit() called while hw_unavailable\n", 442 printk(KERN_ERR "%s: orinoco_xmit() called while hw_unavailable\n",
477 dev->name); 443 dev->name);
478 TRACE_EXIT(dev->name); 444 return NETDEV_TX_BUSY;
479 return 1;
480 } 445 }
481 446
482 if (! netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) { 447 if (! netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) {
483 /* Oops, the firmware hasn't established a connection, 448 /* Oops, the firmware hasn't established a connection,
484 silently drop the packet (this seems to be the 449 silently drop the packet (this seems to be the
485 safest approach). */ 450 safest approach). */
486 stats->tx_errors++; 451 goto drop;
487 orinoco_unlock(priv, &flags);
488 dev_kfree_skb(skb);
489 TRACE_EXIT(dev->name);
490 return 0;
491 } 452 }
492 453
493 /* Length of the packet body */ 454 /* Check packet length */
494 /* FIXME: what if the skb is smaller than this? */ 455 if (skb->len < ETH_HLEN)
495 len = max_t(int, ALIGN(skb->len, 2), ETH_ZLEN); 456 goto drop;
496 skb = skb_padto(skb, len);
497 if (skb == NULL)
498 goto fail;
499 len -= ETH_HLEN;
500 457
501 eh = (struct ethhdr *)skb->data; 458 eh = (struct ethhdr *)skb->data;
502 459
@@ -507,8 +464,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
507 if (net_ratelimit()) 464 if (net_ratelimit())
508 printk(KERN_ERR "%s: Error %d writing Tx descriptor " 465 printk(KERN_ERR "%s: Error %d writing Tx descriptor "
509 "to BAP\n", dev->name, err); 466 "to BAP\n", dev->name, err);
510 stats->tx_errors++; 467 goto busy;
511 goto fail;
512 } 468 }
513 469
514 /* Clear the 802.11 header and data length fields - some 470 /* Clear the 802.11 header and data length fields - some
@@ -519,50 +475,38 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
519 475
520 /* Encapsulate Ethernet-II frames */ 476 /* Encapsulate Ethernet-II frames */
521 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */ 477 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */
522 struct header_struct hdr; 478 struct header_struct {
523 data_len = len; 479 struct ethhdr eth; /* 802.3 header */
524 data_off = HERMES_802_3_OFFSET + sizeof(hdr); 480 u8 encap[6]; /* 802.2 header */
525 p = skb->data + ETH_HLEN; 481 } __attribute__ ((packed)) hdr;
526 482
527 /* 802.3 header */ 483 /* Strip destination and source from the data */
528 memcpy(hdr.dest, eh->h_dest, ETH_ALEN); 484 skb_pull(skb, 2 * ETH_ALEN);
529 memcpy(hdr.src, eh->h_source, ETH_ALEN); 485 data_off = HERMES_802_2_OFFSET + sizeof(encaps_hdr);
530 hdr.len = htons(data_len + ENCAPS_OVERHEAD); 486
531 487 /* And move them to a separate header */
532 /* 802.2 header */ 488 memcpy(&hdr.eth, eh, 2 * ETH_ALEN);
533 memcpy(&hdr.dsap, &encaps_hdr, sizeof(encaps_hdr)); 489 hdr.eth.h_proto = htons(sizeof(encaps_hdr) + skb->len);
534 490 memcpy(hdr.encap, encaps_hdr, sizeof(encaps_hdr));
535 hdr.ethertype = eh->h_proto; 491
536 err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr), 492 err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr),
537 txfid, HERMES_802_3_OFFSET); 493 txfid, HERMES_802_3_OFFSET);
538 if (err) { 494 if (err) {
539 if (net_ratelimit()) 495 if (net_ratelimit())
540 printk(KERN_ERR "%s: Error %d writing packet " 496 printk(KERN_ERR "%s: Error %d writing packet "
541 "header to BAP\n", dev->name, err); 497 "header to BAP\n", dev->name, err);
542 stats->tx_errors++; 498 goto busy;
543 goto fail;
544 } 499 }
545 /* Actual xfer length - allow for padding */
546 len = ALIGN(data_len, 2);
547 if (len < ETH_ZLEN - ETH_HLEN)
548 len = ETH_ZLEN - ETH_HLEN;
549 } else { /* IEEE 802.3 frame */ 500 } else { /* IEEE 802.3 frame */
550 data_len = len + ETH_HLEN;
551 data_off = HERMES_802_3_OFFSET; 501 data_off = HERMES_802_3_OFFSET;
552 p = skb->data;
553 /* Actual xfer length - round up for odd length packets */
554 len = ALIGN(data_len, 2);
555 if (len < ETH_ZLEN)
556 len = ETH_ZLEN;
557 } 502 }
558 503
559 err = hermes_bap_pwrite_pad(hw, USER_BAP, p, data_len, len, 504 err = hermes_bap_pwrite(hw, USER_BAP, skb->data, skb->len,
560 txfid, data_off); 505 txfid, data_off);
561 if (err) { 506 if (err) {
562 printk(KERN_ERR "%s: Error %d writing packet to BAP\n", 507 printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
563 dev->name, err); 508 dev->name, err);
564 stats->tx_errors++; 509 goto busy;
565 goto fail;
566 } 510 }
567 511
568 /* Finally, we actually initiate the send */ 512 /* Finally, we actually initiate the send */
@@ -575,25 +519,27 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
575 if (net_ratelimit()) 519 if (net_ratelimit())
576 printk(KERN_ERR "%s: Error %d transmitting packet\n", 520 printk(KERN_ERR "%s: Error %d transmitting packet\n",
577 dev->name, err); 521 dev->name, err);
578 stats->tx_errors++; 522 goto busy;
579 goto fail;
580 } 523 }
581 524
582 dev->trans_start = jiffies; 525 dev->trans_start = jiffies;
583 stats->tx_bytes += data_off + data_len; 526 stats->tx_bytes += data_off + skb->len;
527 goto ok;
584 528
585 orinoco_unlock(priv, &flags); 529 drop:
530 stats->tx_errors++;
531 stats->tx_dropped++;
586 532
533 ok:
534 orinoco_unlock(priv, &flags);
587 dev_kfree_skb(skb); 535 dev_kfree_skb(skb);
536 return NETDEV_TX_OK;
588 537
589 TRACE_EXIT(dev->name); 538 busy:
590 539 if (err == -EIO)
591 return 0; 540 schedule_work(&priv->reset_work);
592 fail:
593 TRACE_EXIT(dev->name);
594
595 orinoco_unlock(priv, &flags); 541 orinoco_unlock(priv, &flags);
596 return err; 542 return NETDEV_TX_BUSY;
597} 543}
598 544
599static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw) 545static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw)
@@ -629,7 +575,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
629 struct net_device_stats *stats = &priv->stats; 575 struct net_device_stats *stats = &priv->stats;
630 u16 fid = hermes_read_regn(hw, TXCOMPLFID); 576 u16 fid = hermes_read_regn(hw, TXCOMPLFID);
631 u16 status; 577 u16 status;
632 struct hermes_tx_descriptor_802_11 hdr; 578 struct hermes_txexc_data hdr;
633 int err = 0; 579 int err = 0;
634 580
635 if (fid == DUMMY_FID) 581 if (fid == DUMMY_FID)
@@ -637,8 +583,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
637 583
638 /* Read part of the frame header - we need status and addr1 */ 584 /* Read part of the frame header - we need status and addr1 */
639 err = hermes_bap_pread(hw, IRQ_BAP, &hdr, 585 err = hermes_bap_pread(hw, IRQ_BAP, &hdr,
640 offsetof(struct hermes_tx_descriptor_802_11, 586 sizeof(struct hermes_txexc_data),
641 addr2),
642 fid, 0); 587 fid, 0);
643 588
644 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID); 589 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
@@ -658,7 +603,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
658 * exceeded, because that's the only status that really mean 603 * exceeded, because that's the only status that really mean
659 * that this particular node went away. 604 * that this particular node went away.
660 * Other errors means that *we* screwed up. - Jean II */ 605 * Other errors means that *we* screwed up. - Jean II */
661 status = le16_to_cpu(hdr.status); 606 status = le16_to_cpu(hdr.desc.status);
662 if (status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) { 607 if (status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
663 union iwreq_data wrqu; 608 union iwreq_data wrqu;
664 609
@@ -1398,16 +1343,12 @@ int __orinoco_down(struct net_device *dev)
1398 return 0; 1343 return 0;
1399} 1344}
1400 1345
1401int orinoco_reinit_firmware(struct net_device *dev) 1346static int orinoco_allocate_fid(struct net_device *dev)
1402{ 1347{
1403 struct orinoco_private *priv = netdev_priv(dev); 1348 struct orinoco_private *priv = netdev_priv(dev);
1404 struct hermes *hw = &priv->hw; 1349 struct hermes *hw = &priv->hw;
1405 int err; 1350 int err;
1406 1351
1407 err = hermes_init(hw);
1408 if (err)
1409 return err;
1410
1411 err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); 1352 err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid);
1412 if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) { 1353 if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) {
1413 /* Try workaround for old Symbol firmware bug */ 1354 /* Try workaround for old Symbol firmware bug */
@@ -1426,6 +1367,19 @@ int orinoco_reinit_firmware(struct net_device *dev)
1426 return err; 1367 return err;
1427} 1368}
1428 1369
1370int orinoco_reinit_firmware(struct net_device *dev)
1371{
1372 struct orinoco_private *priv = netdev_priv(dev);
1373 struct hermes *hw = &priv->hw;
1374 int err;
1375
1376 err = hermes_init(hw);
1377 if (!err)
1378 err = orinoco_allocate_fid(dev);
1379
1380 return err;
1381}
1382
1429static int __orinoco_hw_set_bitrate(struct orinoco_private *priv) 1383static int __orinoco_hw_set_bitrate(struct orinoco_private *priv)
1430{ 1384{
1431 hermes_t *hw = &priv->hw; 1385 hermes_t *hw = &priv->hw;
@@ -1833,7 +1787,9 @@ static int __orinoco_program_rids(struct net_device *dev)
1833 /* Set promiscuity / multicast*/ 1787 /* Set promiscuity / multicast*/
1834 priv->promiscuous = 0; 1788 priv->promiscuous = 0;
1835 priv->mc_count = 0; 1789 priv->mc_count = 0;
1836 __orinoco_set_multicast_list(dev); /* FIXME: what about the xmit_lock */ 1790
1791 /* FIXME: what about netif_tx_lock */
1792 __orinoco_set_multicast_list(dev);
1837 1793
1838 return 0; 1794 return 0;
1839} 1795}
@@ -2272,14 +2228,12 @@ static int orinoco_init(struct net_device *dev)
2272 u16 reclen; 2228 u16 reclen;
2273 int len; 2229 int len;
2274 2230
2275 TRACE_ENTER(dev->name);
2276
2277 /* No need to lock, the hw_unavailable flag is already set in 2231 /* No need to lock, the hw_unavailable flag is already set in
2278 * alloc_orinocodev() */ 2232 * alloc_orinocodev() */
2279 priv->nicbuf_size = IEEE80211_FRAME_LEN + ETH_HLEN; 2233 priv->nicbuf_size = IEEE80211_FRAME_LEN + ETH_HLEN;
2280 2234
2281 /* Initialize the firmware */ 2235 /* Initialize the firmware */
2282 err = orinoco_reinit_firmware(dev); 2236 err = hermes_init(hw);
2283 if (err != 0) { 2237 if (err != 0) {
2284 printk(KERN_ERR "%s: failed to initialize firmware (err = %d)\n", 2238 printk(KERN_ERR "%s: failed to initialize firmware (err = %d)\n",
2285 dev->name, err); 2239 dev->name, err);
@@ -2337,6 +2291,13 @@ static int orinoco_init(struct net_device *dev)
2337 2291
2338 printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick); 2292 printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick);
2339 2293
2294 err = orinoco_allocate_fid(dev);
2295 if (err) {
2296 printk(KERN_ERR "%s: failed to allocate NIC buffer!\n",
2297 dev->name);
2298 goto out;
2299 }
2300
2340 /* Get allowed channels */ 2301 /* Get allowed channels */
2341 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, 2302 err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST,
2342 &priv->channel_mask); 2303 &priv->channel_mask);
@@ -2427,7 +2388,6 @@ static int orinoco_init(struct net_device *dev)
2427 printk(KERN_DEBUG "%s: ready\n", dev->name); 2388 printk(KERN_DEBUG "%s: ready\n", dev->name);
2428 2389
2429 out: 2390 out:
2430 TRACE_EXIT(dev->name);
2431 return err; 2391 return err;
2432} 2392}
2433 2393
@@ -2795,8 +2755,6 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
2795 int numrates; 2755 int numrates;
2796 int i, k; 2756 int i, k;
2797 2757
2798 TRACE_ENTER(dev->name);
2799
2800 rrq->length = sizeof(struct iw_range); 2758 rrq->length = sizeof(struct iw_range);
2801 memset(range, 0, sizeof(struct iw_range)); 2759 memset(range, 0, sizeof(struct iw_range));
2802 2760
@@ -2886,8 +2844,6 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
2886 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); 2844 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
2887 IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP); 2845 IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
2888 2846
2889 TRACE_EXIT(dev->name);
2890
2891 return 0; 2847 return 0;
2892} 2848}
2893 2849
@@ -3069,8 +3025,6 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3069 int err = 0; 3025 int err = 0;
3070 unsigned long flags; 3026 unsigned long flags;
3071 3027
3072 TRACE_ENTER(dev->name);
3073
3074 if (netif_running(dev)) { 3028 if (netif_running(dev)) {
3075 err = orinoco_hw_get_essid(priv, &active, essidbuf); 3029 err = orinoco_hw_get_essid(priv, &active, essidbuf);
3076 if (err) 3030 if (err)
@@ -3085,8 +3039,6 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3085 erq->flags = 1; 3039 erq->flags = 1;
3086 erq->length = strlen(essidbuf) + 1; 3040 erq->length = strlen(essidbuf) + 1;
3087 3041
3088 TRACE_EXIT(dev->name);
3089
3090 return 0; 3042 return 0;
3091} 3043}
3092 3044
@@ -4347,69 +4299,6 @@ static struct ethtool_ops orinoco_ethtool_ops = {
4347}; 4299};
4348 4300
4349/********************************************************************/ 4301/********************************************************************/
4350/* Debugging */
4351/********************************************************************/
4352
4353#if 0
4354static void show_rx_frame(struct orinoco_rxframe_hdr *frame)
4355{
4356 printk(KERN_DEBUG "RX descriptor:\n");
4357 printk(KERN_DEBUG " status = 0x%04x\n", frame->desc.status);
4358 printk(KERN_DEBUG " time = 0x%08x\n", frame->desc.time);
4359 printk(KERN_DEBUG " silence = 0x%02x\n", frame->desc.silence);
4360 printk(KERN_DEBUG " signal = 0x%02x\n", frame->desc.signal);
4361 printk(KERN_DEBUG " rate = 0x%02x\n", frame->desc.rate);
4362 printk(KERN_DEBUG " rxflow = 0x%02x\n", frame->desc.rxflow);
4363 printk(KERN_DEBUG " reserved = 0x%08x\n", frame->desc.reserved);
4364
4365 printk(KERN_DEBUG "IEEE 802.11 header:\n");
4366 printk(KERN_DEBUG " frame_ctl = 0x%04x\n",
4367 frame->p80211.frame_ctl);
4368 printk(KERN_DEBUG " duration_id = 0x%04x\n",
4369 frame->p80211.duration_id);
4370 printk(KERN_DEBUG " addr1 = %02x:%02x:%02x:%02x:%02x:%02x\n",
4371 frame->p80211.addr1[0], frame->p80211.addr1[1],
4372 frame->p80211.addr1[2], frame->p80211.addr1[3],
4373 frame->p80211.addr1[4], frame->p80211.addr1[5]);
4374 printk(KERN_DEBUG " addr2 = %02x:%02x:%02x:%02x:%02x:%02x\n",
4375 frame->p80211.addr2[0], frame->p80211.addr2[1],
4376 frame->p80211.addr2[2], frame->p80211.addr2[3],
4377 frame->p80211.addr2[4], frame->p80211.addr2[5]);
4378 printk(KERN_DEBUG " addr3 = %02x:%02x:%02x:%02x:%02x:%02x\n",
4379 frame->p80211.addr3[0], frame->p80211.addr3[1],
4380 frame->p80211.addr3[2], frame->p80211.addr3[3],
4381 frame->p80211.addr3[4], frame->p80211.addr3[5]);
4382 printk(KERN_DEBUG " seq_ctl = 0x%04x\n",
4383 frame->p80211.seq_ctl);
4384 printk(KERN_DEBUG " addr4 = %02x:%02x:%02x:%02x:%02x:%02x\n",
4385 frame->p80211.addr4[0], frame->p80211.addr4[1],
4386 frame->p80211.addr4[2], frame->p80211.addr4[3],
4387 frame->p80211.addr4[4], frame->p80211.addr4[5]);
4388 printk(KERN_DEBUG " data_len = 0x%04x\n",
4389 frame->p80211.data_len);
4390
4391 printk(KERN_DEBUG "IEEE 802.3 header:\n");
4392 printk(KERN_DEBUG " dest = %02x:%02x:%02x:%02x:%02x:%02x\n",
4393 frame->p8023.h_dest[0], frame->p8023.h_dest[1],
4394 frame->p8023.h_dest[2], frame->p8023.h_dest[3],
4395 frame->p8023.h_dest[4], frame->p8023.h_dest[5]);
4396 printk(KERN_DEBUG " src = %02x:%02x:%02x:%02x:%02x:%02x\n",
4397 frame->p8023.h_source[0], frame->p8023.h_source[1],
4398 frame->p8023.h_source[2], frame->p8023.h_source[3],
4399 frame->p8023.h_source[4], frame->p8023.h_source[5]);
4400 printk(KERN_DEBUG " len = 0x%04x\n", frame->p8023.h_proto);
4401
4402 printk(KERN_DEBUG "IEEE 802.2 LLC/SNAP header:\n");
4403 printk(KERN_DEBUG " DSAP = 0x%02x\n", frame->p8022.dsap);
4404 printk(KERN_DEBUG " SSAP = 0x%02x\n", frame->p8022.ssap);
4405 printk(KERN_DEBUG " ctrl = 0x%02x\n", frame->p8022.ctrl);
4406 printk(KERN_DEBUG " OUI = %02x:%02x:%02x\n",
4407 frame->p8022.oui[0], frame->p8022.oui[1], frame->p8022.oui[2]);
4408 printk(KERN_DEBUG " ethertype = 0x%04x\n", frame->ethertype);
4409}
4410#endif /* 0 */
4411
4412/********************************************************************/
4413/* Module initialization */ 4302/* Module initialization */
4414/********************************************************************/ 4303/********************************************************************/
4415 4304
diff --git a/drivers/net/wireless/orinoco.h b/drivers/net/wireless/orinoco.h
index f5d856db92a1..16db3e14b7d2 100644
--- a/drivers/net/wireless/orinoco.h
+++ b/drivers/net/wireless/orinoco.h
@@ -7,7 +7,7 @@
7#ifndef _ORINOCO_H 7#ifndef _ORINOCO_H
8#define _ORINOCO_H 8#define _ORINOCO_H
9 9
10#define DRIVER_VERSION "0.15rc3" 10#define DRIVER_VERSION "0.15"
11 11
12#include <linux/netdevice.h> 12#include <linux/netdevice.h>
13#include <linux/wireless.h> 13#include <linux/wireless.h>
@@ -30,20 +30,6 @@ struct orinoco_key {
30 char data[ORINOCO_MAX_KEY_SIZE]; 30 char data[ORINOCO_MAX_KEY_SIZE];
31} __attribute__ ((packed)); 31} __attribute__ ((packed));
32 32
33struct header_struct {
34 /* 802.3 */
35 u8 dest[ETH_ALEN];
36 u8 src[ETH_ALEN];
37 __be16 len;
38 /* 802.2 */
39 u8 dsap;
40 u8 ssap;
41 u8 ctrl;
42 /* SNAP */
43 u8 oui[3];
44 unsigned short ethertype;
45} __attribute__ ((packed));
46
47typedef enum { 33typedef enum {
48 FIRMWARE_TYPE_AGERE, 34 FIRMWARE_TYPE_AGERE,
49 FIRMWARE_TYPE_INTERSIL, 35 FIRMWARE_TYPE_INTERSIL,
@@ -132,9 +118,6 @@ extern int orinoco_debug;
132#define DEBUG(n, args...) do { } while (0) 118#define DEBUG(n, args...) do { } while (0)
133#endif /* ORINOCO_DEBUG */ 119#endif /* ORINOCO_DEBUG */
134 120
135#define TRACE_ENTER(devname) DEBUG(2, "%s: -> %s()\n", devname, __FUNCTION__);
136#define TRACE_EXIT(devname) DEBUG(2, "%s: <- %s()\n", devname, __FUNCTION__);
137
138/********************************************************************/ 121/********************************************************************/
139/* Exported prototypes */ 122/* Exported prototypes */
140/********************************************************************/ 123/********************************************************************/
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 434f7d7ad841..b2aec4d9fbb1 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -147,14 +147,11 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
147{ 147{
148 struct net_device *dev = link->priv; 148 struct net_device *dev = link->priv;
149 149
150 if (link->dev_node)
151 unregister_netdev(dev);
152
150 orinoco_cs_release(link); 153 orinoco_cs_release(link);
151 154
152 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
153 if (link->dev_node) {
154 DEBUG(0, PFX "About to unregister net device %p\n",
155 dev);
156 unregister_netdev(dev);
157 }
158 free_orinocodev(dev); 155 free_orinocodev(dev);
159} /* orinoco_cs_detach */ 156} /* orinoco_cs_detach */
160 157
@@ -178,13 +175,10 @@ orinoco_cs_config(struct pcmcia_device *link)
178 int last_fn, last_ret; 175 int last_fn, last_ret;
179 u_char buf[64]; 176 u_char buf[64];
180 config_info_t conf; 177 config_info_t conf;
181 cisinfo_t info;
182 tuple_t tuple; 178 tuple_t tuple;
183 cisparse_t parse; 179 cisparse_t parse;
184 void __iomem *mem; 180 void __iomem *mem;
185 181
186 CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info));
187
188 /* 182 /*
189 * This reads the card's CONFIG tuple to find its 183 * This reads the card's CONFIG tuple to find its
190 * configuration registers. 184 * configuration registers.
@@ -234,12 +228,6 @@ orinoco_cs_config(struct pcmcia_device *link)
234 goto next_entry; 228 goto next_entry;
235 link->conf.ConfigIndex = cfg->index; 229 link->conf.ConfigIndex = cfg->index;
236 230
237 /* Does this card need audio output? */
238 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
239 link->conf.Attributes |= CONF_ENABLE_SPKR;
240 link->conf.Status = CCSR_AUDIO_ENA;
241 }
242
243 /* Use power settings for Vcc and Vpp if present */ 231 /* Use power settings for Vcc and Vpp if present */
244 /* Note that the CIS values need to be rescaled */ 232 /* Note that the CIS values need to be rescaled */
245 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 233 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
@@ -355,19 +343,10 @@ orinoco_cs_config(struct pcmcia_device *link)
355 net_device has been registered */ 343 net_device has been registered */
356 344
357 /* Finally, report what we've done */ 345 /* Finally, report what we've done */
358 printk(KERN_DEBUG "%s: index 0x%02x: ", 346 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
359 dev->name, link->conf.ConfigIndex); 347 "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id,
360 if (link->conf.Vpp) 348 link->irq.AssignedIRQ, link->io.BasePort1,
361 printk(", Vpp %d.%d", link->conf.Vpp / 10, 349 link->io.BasePort1 + link->io.NumPorts1 - 1);
362 link->conf.Vpp % 10);
363 printk(", irq %d", link->irq.AssignedIRQ);
364 if (link->io.NumPorts1)
365 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
366 link->io.BasePort1 + link->io.NumPorts1 - 1);
367 if (link->io.NumPorts2)
368 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
369 link->io.BasePort2 + link->io.NumPorts2 - 1);
370 printk("\n");
371 350
372 return 0; 351 return 0;
373 352
@@ -436,7 +415,6 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
436 struct orinoco_private *priv = netdev_priv(dev); 415 struct orinoco_private *priv = netdev_priv(dev);
437 struct orinoco_pccard *card = priv->card; 416 struct orinoco_pccard *card = priv->card;
438 int err = 0; 417 int err = 0;
439 unsigned long flags;
440 418
441 if (! test_bit(0, &card->hard_reset_in_progress)) { 419 if (! test_bit(0, &card->hard_reset_in_progress)) {
442 err = orinoco_reinit_firmware(dev); 420 err = orinoco_reinit_firmware(dev);
@@ -446,7 +424,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
446 return -EIO; 424 return -EIO;
447 } 425 }
448 426
449 spin_lock_irqsave(&priv->lock, flags); 427 spin_lock(&priv->lock);
450 428
451 netif_device_attach(dev); 429 netif_device_attach(dev);
452 priv->hw_unavailable--; 430 priv->hw_unavailable--;
@@ -458,10 +436,10 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
458 dev->name, err); 436 dev->name, err);
459 } 437 }
460 438
461 spin_unlock_irqrestore(&priv->lock, flags); 439 spin_unlock(&priv->lock);
462 } 440 }
463 441
464 return 0; 442 return err;
465} 443}
466 444
467 445
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
index d1a670b35338..74b9d5b2ba9e 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco_nortel.c
@@ -1,9 +1,8 @@
1/* orinoco_nortel.c 1/* orinoco_nortel.c
2 * 2 *
3 * Driver for Prism II devices which would usually be driven by orinoco_cs, 3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a PCI-to-PCMCIA adapter used in 4 * but are connected to the PCI bus by a PCI-to-PCMCIA adapter used in
5 * Nortel emobility, Symbol LA-4113 and Symbol LA-4123. 5 * Nortel emobility, Symbol LA-4113 and Symbol LA-4123.
6 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter.
7 * 6 *
8 * Copyright (C) 2002 Tobias Hoffmann 7 * Copyright (C) 2002 Tobias Hoffmann
9 * (C) 2003 Christoph Jungegger <disdos@traum404.de> 8 * (C) 2003 Christoph Jungegger <disdos@traum404.de>
@@ -50,67 +49,62 @@
50#include <pcmcia/cisreg.h> 49#include <pcmcia/cisreg.h>
51 50
52#include "orinoco.h" 51#include "orinoco.h"
52#include "orinoco_pci.h"
53 53
54#define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */ 54#define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */
55#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */ 55#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
56 56
57 57
58/* Nortel specific data */
59struct nortel_pci_card {
60 unsigned long iobase1;
61 unsigned long iobase2;
62};
63
64/* 58/*
65 * Do a soft reset of the PCI card using the Configuration Option Register 59 * Do a soft reset of the card using the Configuration Option Register
66 * We need this to get going... 60 * We need this to get going...
67 * This is the part of the code that is strongly inspired from wlan-ng 61 * This is the part of the code that is strongly inspired from wlan-ng
68 * 62 *
69 * Note bis : Don't try to access HERMES_CMD during the reset phase. 63 * Note bis : Don't try to access HERMES_CMD during the reset phase.
70 * It just won't work ! 64 * It just won't work !
71 */ 65 */
72static int nortel_pci_cor_reset(struct orinoco_private *priv) 66static int orinoco_nortel_cor_reset(struct orinoco_private *priv)
73{ 67{
74 struct nortel_pci_card *card = priv->card; 68 struct orinoco_pci_card *card = priv->card;
75 69
76 /* Assert the reset until the card notice */ 70 /* Assert the reset until the card notices */
77 outw_p(8, card->iobase1 + 2); 71 iowrite16(8, card->bridge_io + 2);
78 inw(card->iobase2 + COR_OFFSET); 72 ioread16(card->attr_io + COR_OFFSET);
79 outw_p(0x80, card->iobase2 + COR_OFFSET); 73 iowrite16(0x80, card->attr_io + COR_OFFSET);
80 mdelay(1); 74 mdelay(1);
81 75
82 /* Give time for the card to recover from this hard effort */ 76 /* Give time for the card to recover from this hard effort */
83 outw_p(0, card->iobase2 + COR_OFFSET); 77 iowrite16(0, card->attr_io + COR_OFFSET);
84 outw_p(0, card->iobase2 + COR_OFFSET); 78 iowrite16(0, card->attr_io + COR_OFFSET);
85 mdelay(1); 79 mdelay(1);
86 80
87 /* set COR as usual */ 81 /* Set COR as usual */
88 outw_p(COR_VALUE, card->iobase2 + COR_OFFSET); 82 iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
89 outw_p(COR_VALUE, card->iobase2 + COR_OFFSET); 83 iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
90 mdelay(1); 84 mdelay(1);
91 85
92 outw_p(0x228, card->iobase1 + 2); 86 iowrite16(0x228, card->bridge_io + 2);
93 87
94 return 0; 88 return 0;
95} 89}
96 90
97static int nortel_pci_hw_init(struct nortel_pci_card *card) 91static int orinoco_nortel_hw_init(struct orinoco_pci_card *card)
98{ 92{
99 int i; 93 int i;
100 u32 reg; 94 u32 reg;
101 95
102 /* setup bridge */ 96 /* Setup bridge */
103 if (inw(card->iobase1) & 1) { 97 if (ioread16(card->bridge_io) & 1) {
104 printk(KERN_ERR PFX "brg1 answer1 wrong\n"); 98 printk(KERN_ERR PFX "brg1 answer1 wrong\n");
105 return -EBUSY; 99 return -EBUSY;
106 } 100 }
107 outw_p(0x118, card->iobase1 + 2); 101 iowrite16(0x118, card->bridge_io + 2);
108 outw_p(0x108, card->iobase1 + 2); 102 iowrite16(0x108, card->bridge_io + 2);
109 mdelay(30); 103 mdelay(30);
110 outw_p(0x8, card->iobase1 + 2); 104 iowrite16(0x8, card->bridge_io + 2);
111 for (i = 0; i < 30; i++) { 105 for (i = 0; i < 30; i++) {
112 mdelay(30); 106 mdelay(30);
113 if (inw(card->iobase1) & 0x10) { 107 if (ioread16(card->bridge_io) & 0x10) {
114 break; 108 break;
115 } 109 }
116 } 110 }
@@ -118,42 +112,42 @@ static int nortel_pci_hw_init(struct nortel_pci_card *card)
118 printk(KERN_ERR PFX "brg1 timed out\n"); 112 printk(KERN_ERR PFX "brg1 timed out\n");
119 return -EBUSY; 113 return -EBUSY;
120 } 114 }
121 if (inw(card->iobase2 + 0xe0) & 1) { 115 if (ioread16(card->attr_io + COR_OFFSET) & 1) {
122 printk(KERN_ERR PFX "brg2 answer1 wrong\n"); 116 printk(KERN_ERR PFX "brg2 answer1 wrong\n");
123 return -EBUSY; 117 return -EBUSY;
124 } 118 }
125 if (inw(card->iobase2 + 0xe2) & 1) { 119 if (ioread16(card->attr_io + COR_OFFSET + 2) & 1) {
126 printk(KERN_ERR PFX "brg2 answer2 wrong\n"); 120 printk(KERN_ERR PFX "brg2 answer2 wrong\n");
127 return -EBUSY; 121 return -EBUSY;
128 } 122 }
129 if (inw(card->iobase2 + 0xe4) & 1) { 123 if (ioread16(card->attr_io + COR_OFFSET + 4) & 1) {
130 printk(KERN_ERR PFX "brg2 answer3 wrong\n"); 124 printk(KERN_ERR PFX "brg2 answer3 wrong\n");
131 return -EBUSY; 125 return -EBUSY;
132 } 126 }
133 127
134 /* set the PCMCIA COR-Register */ 128 /* Set the PCMCIA COR register */
135 outw_p(COR_VALUE, card->iobase2 + COR_OFFSET); 129 iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
136 mdelay(1); 130 mdelay(1);
137 reg = inw(card->iobase2 + COR_OFFSET); 131 reg = ioread16(card->attr_io + COR_OFFSET);
138 if (reg != COR_VALUE) { 132 if (reg != COR_VALUE) {
139 printk(KERN_ERR PFX "Error setting COR value (reg=%x)\n", 133 printk(KERN_ERR PFX "Error setting COR value (reg=%x)\n",
140 reg); 134 reg);
141 return -EBUSY; 135 return -EBUSY;
142 } 136 }
143 137
144 /* set leds */ 138 /* Set LEDs */
145 outw_p(1, card->iobase1 + 10); 139 iowrite16(1, card->bridge_io + 10);
146 return 0; 140 return 0;
147} 141}
148 142
149static int nortel_pci_init_one(struct pci_dev *pdev, 143static int orinoco_nortel_init_one(struct pci_dev *pdev,
150 const struct pci_device_id *ent) 144 const struct pci_device_id *ent)
151{ 145{
152 int err; 146 int err;
153 struct orinoco_private *priv; 147 struct orinoco_private *priv;
154 struct nortel_pci_card *card; 148 struct orinoco_pci_card *card;
155 struct net_device *dev; 149 struct net_device *dev;
156 void __iomem *iomem; 150 void __iomem *hermes_io, *bridge_io, *attr_io;
157 151
158 err = pci_enable_device(pdev); 152 err = pci_enable_device(pdev);
159 if (err) { 153 if (err) {
@@ -162,19 +156,34 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
162 } 156 }
163 157
164 err = pci_request_regions(pdev, DRIVER_NAME); 158 err = pci_request_regions(pdev, DRIVER_NAME);
165 if (err != 0) { 159 if (err) {
166 printk(KERN_ERR PFX "Cannot obtain PCI resources\n"); 160 printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
167 goto fail_resources; 161 goto fail_resources;
168 } 162 }
169 163
170 iomem = pci_iomap(pdev, 2, 0); 164 bridge_io = pci_iomap(pdev, 0, 0);
171 if (!iomem) { 165 if (!bridge_io) {
172 err = -ENOMEM; 166 printk(KERN_ERR PFX "Cannot map bridge registers\n");
173 goto fail_map_io; 167 err = -EIO;
168 goto fail_map_bridge;
169 }
170
171 attr_io = pci_iomap(pdev, 1, 0);
172 if (!attr_io) {
173 printk(KERN_ERR PFX "Cannot map PCMCIA attributes\n");
174 err = -EIO;
175 goto fail_map_attr;
176 }
177
178 hermes_io = pci_iomap(pdev, 2, 0);
179 if (!hermes_io) {
180 printk(KERN_ERR PFX "Cannot map chipset registers\n");
181 err = -EIO;
182 goto fail_map_hermes;
174 } 183 }
175 184
176 /* Allocate network device */ 185 /* Allocate network device */
177 dev = alloc_orinocodev(sizeof(*card), nortel_pci_cor_reset); 186 dev = alloc_orinocodev(sizeof(*card), orinoco_nortel_cor_reset);
178 if (!dev) { 187 if (!dev) {
179 printk(KERN_ERR PFX "Cannot allocate network device\n"); 188 printk(KERN_ERR PFX "Cannot allocate network device\n");
180 err = -ENOMEM; 189 err = -ENOMEM;
@@ -183,16 +192,12 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
183 192
184 priv = netdev_priv(dev); 193 priv = netdev_priv(dev);
185 card = priv->card; 194 card = priv->card;
186 card->iobase1 = pci_resource_start(pdev, 0); 195 card->bridge_io = bridge_io;
187 card->iobase2 = pci_resource_start(pdev, 1); 196 card->attr_io = attr_io;
188 dev->base_addr = pci_resource_start(pdev, 2);
189 SET_MODULE_OWNER(dev); 197 SET_MODULE_OWNER(dev);
190 SET_NETDEV_DEV(dev, &pdev->dev); 198 SET_NETDEV_DEV(dev, &pdev->dev);
191 199
192 hermes_struct_init(&priv->hw, iomem, HERMES_16BIT_REGSPACING); 200 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
193
194 printk(KERN_DEBUG PFX "Detected Nortel PCI device at %s irq:%d, "
195 "io addr:0x%lx\n", pci_name(pdev), pdev->irq, dev->base_addr);
196 201
197 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 202 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
198 dev->name, dev); 203 dev->name, dev);
@@ -201,21 +206,19 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
201 err = -EBUSY; 206 err = -EBUSY;
202 goto fail_irq; 207 goto fail_irq;
203 } 208 }
204 dev->irq = pdev->irq;
205 209
206 err = nortel_pci_hw_init(card); 210 err = orinoco_nortel_hw_init(card);
207 if (err) { 211 if (err) {
208 printk(KERN_ERR PFX "Hardware initialization failed\n"); 212 printk(KERN_ERR PFX "Hardware initialization failed\n");
209 goto fail; 213 goto fail;
210 } 214 }
211 215
212 err = nortel_pci_cor_reset(priv); 216 err = orinoco_nortel_cor_reset(priv);
213 if (err) { 217 if (err) {
214 printk(KERN_ERR PFX "Initial reset failed\n"); 218 printk(KERN_ERR PFX "Initial reset failed\n");
215 goto fail; 219 goto fail;
216 } 220 }
217 221
218
219 err = register_netdev(dev); 222 err = register_netdev(dev);
220 if (err) { 223 if (err) {
221 printk(KERN_ERR PFX "Cannot register network device\n"); 224 printk(KERN_ERR PFX "Cannot register network device\n");
@@ -223,6 +226,8 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
223 } 226 }
224 227
225 pci_set_drvdata(pdev, dev); 228 pci_set_drvdata(pdev, dev);
229 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
230 pci_name(pdev));
226 231
227 return 0; 232 return 0;
228 233
@@ -234,9 +239,15 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
234 free_orinocodev(dev); 239 free_orinocodev(dev);
235 240
236 fail_alloc: 241 fail_alloc:
237 pci_iounmap(pdev, iomem); 242 pci_iounmap(pdev, hermes_io);
238 243
239 fail_map_io: 244 fail_map_hermes:
245 pci_iounmap(pdev, attr_io);
246
247 fail_map_attr:
248 pci_iounmap(pdev, bridge_io);
249
250 fail_map_bridge:
240 pci_release_regions(pdev); 251 pci_release_regions(pdev);
241 252
242 fail_resources: 253 fail_resources:
@@ -245,26 +256,27 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
245 return err; 256 return err;
246} 257}
247 258
248static void __devexit nortel_pci_remove_one(struct pci_dev *pdev) 259static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev)
249{ 260{
250 struct net_device *dev = pci_get_drvdata(pdev); 261 struct net_device *dev = pci_get_drvdata(pdev);
251 struct orinoco_private *priv = netdev_priv(dev); 262 struct orinoco_private *priv = netdev_priv(dev);
252 struct nortel_pci_card *card = priv->card; 263 struct orinoco_pci_card *card = priv->card;
253 264
254 /* clear leds */ 265 /* Clear LEDs */
255 outw_p(0, card->iobase1 + 10); 266 iowrite16(0, card->bridge_io + 10);
256 267
257 unregister_netdev(dev); 268 unregister_netdev(dev);
258 free_irq(dev->irq, dev); 269 free_irq(pdev->irq, dev);
259 pci_set_drvdata(pdev, NULL); 270 pci_set_drvdata(pdev, NULL);
260 free_orinocodev(dev); 271 free_orinocodev(dev);
261 pci_iounmap(pdev, priv->hw.iobase); 272 pci_iounmap(pdev, priv->hw.iobase);
273 pci_iounmap(pdev, card->attr_io);
274 pci_iounmap(pdev, card->bridge_io);
262 pci_release_regions(pdev); 275 pci_release_regions(pdev);
263 pci_disable_device(pdev); 276 pci_disable_device(pdev);
264} 277}
265 278
266 279static struct pci_device_id orinoco_nortel_id_table[] = {
267static struct pci_device_id nortel_pci_id_table[] = {
268 /* Nortel emobility PCI */ 280 /* Nortel emobility PCI */
269 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,}, 281 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,},
270 /* Symbol LA-4123 PCI */ 282 /* Symbol LA-4123 PCI */
@@ -272,13 +284,15 @@ static struct pci_device_id nortel_pci_id_table[] = {
272 {0,}, 284 {0,},
273}; 285};
274 286
275MODULE_DEVICE_TABLE(pci, nortel_pci_id_table); 287MODULE_DEVICE_TABLE(pci, orinoco_nortel_id_table);
276 288
277static struct pci_driver nortel_pci_driver = { 289static struct pci_driver orinoco_nortel_driver = {
278 .name = DRIVER_NAME, 290 .name = DRIVER_NAME,
279 .id_table = nortel_pci_id_table, 291 .id_table = orinoco_nortel_id_table,
280 .probe = nortel_pci_init_one, 292 .probe = orinoco_nortel_init_one,
281 .remove = __devexit_p(nortel_pci_remove_one), 293 .remove = __devexit_p(orinoco_nortel_remove_one),
294 .suspend = orinoco_pci_suspend,
295 .resume = orinoco_pci_resume,
282}; 296};
283 297
284static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION 298static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
@@ -288,20 +302,19 @@ MODULE_DESCRIPTION
288 ("Driver for wireless LAN cards using the Nortel PCI bridge"); 302 ("Driver for wireless LAN cards using the Nortel PCI bridge");
289MODULE_LICENSE("Dual MPL/GPL"); 303MODULE_LICENSE("Dual MPL/GPL");
290 304
291static int __init nortel_pci_init(void) 305static int __init orinoco_nortel_init(void)
292{ 306{
293 printk(KERN_DEBUG "%s\n", version); 307 printk(KERN_DEBUG "%s\n", version);
294 return pci_module_init(&nortel_pci_driver); 308 return pci_module_init(&orinoco_nortel_driver);
295} 309}
296 310
297static void __exit nortel_pci_exit(void) 311static void __exit orinoco_nortel_exit(void)
298{ 312{
299 pci_unregister_driver(&nortel_pci_driver); 313 pci_unregister_driver(&orinoco_nortel_driver);
300 ssleep(1);
301} 314}
302 315
303module_init(nortel_pci_init); 316module_init(orinoco_nortel_init);
304module_exit(nortel_pci_exit); 317module_exit(orinoco_nortel_exit);
305 318
306/* 319/*
307 * Local variables: 320 * Local variables:
diff --git a/drivers/net/wireless/orinoco_pci.c b/drivers/net/wireless/orinoco_pci.c
index 5362c214fc8e..1c105f40f8d5 100644
--- a/drivers/net/wireless/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco_pci.c
@@ -1,11 +1,11 @@
1/* orinoco_pci.c 1/* orinoco_pci.c
2 * 2 *
3 * Driver for Prism II devices that have a direct PCI interface 3 * Driver for Prism 2.5/3 devices that have a direct PCI interface
4 * (i.e., not in a Pcmcia or PLX bridge) 4 * (i.e. these are not PCMCIA cards in a PCMCIA-to-PCI bridge).
5 * 5 * The card contains only one PCI region, which contains all the usual
6 * Specifically here we're talking about the Linksys WMP11 6 * hermes registers, as well as the COR register.
7 * 7 *
8 * Current maintainers (as of 29 September 2003) are: 8 * Current maintainers are:
9 * Pavel Roskin <proski AT gnu.org> 9 * Pavel Roskin <proski AT gnu.org>
10 * and David Gibson <hermes AT gibson.dropbear.id.au> 10 * and David Gibson <hermes AT gibson.dropbear.id.au>
11 * 11 *
@@ -41,54 +41,6 @@
41 * under either the MPL or the GPL. 41 * under either the MPL or the GPL.
42 */ 42 */
43 43
44/*
45 * Theory of operation...
46 * -------------------
47 * Maybe you had a look in orinoco_plx. Well, this is totally different...
48 *
49 * The card contains only one PCI region, which contains all the usual
50 * hermes registers.
51 *
52 * The driver will memory map this region in normal memory. Because
53 * the hermes registers are mapped in normal memory and not in ISA I/O
54 * post space, we can't use the usual inw/outw macros and we need to
55 * use readw/writew.
56 * This slight difference force us to compile our own version of
57 * hermes.c with the register access macro changed. That's a bit
58 * hackish but works fine.
59 *
60 * Note that the PCI region is pretty big (4K). That's much more than
61 * the usual set of hermes register (0x0 -> 0x3E). I've got a strong
62 * suspicion that the whole memory space of the adapter is in fact in
63 * this region. Accessing directly the adapter memory instead of going
64 * through the usual register would speed up significantely the
65 * operations...
66 *
67 * Finally, the card looks like this :
68-----------------------
69 Bus 0, device 14, function 0:
70 Network controller: PCI device 1260:3873 (Harris Semiconductor) (rev 1).
71 IRQ 11.
72 Master Capable. Latency=248.
73 Prefetchable 32 bit memory at 0xffbcc000 [0xffbccfff].
74-----------------------
7500:0e.0 Network controller: Harris Semiconductor: Unknown device 3873 (rev 01)
76 Subsystem: Unknown device 1737:3874
77 Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-
78 Status: Cap+ 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-
79 Latency: 248 set, cache line size 08
80 Interrupt: pin A routed to IRQ 11
81 Region 0: Memory at ffbcc000 (32-bit, prefetchable) [size=4K]
82 Capabilities: [dc] Power Management version 2
83 Flags: PMEClk- AuxPwr- DSI- D1+ D2+ PME+
84 Status: D0 PME-Enable- DSel=0 DScale=0 PME-
85-----------------------
86 *
87 * That's all..
88 *
89 * Jean II
90 */
91
92#define DRIVER_NAME "orinoco_pci" 44#define DRIVER_NAME "orinoco_pci"
93#define PFX DRIVER_NAME ": " 45#define PFX DRIVER_NAME ": "
94 46
@@ -100,12 +52,14 @@
100#include <linux/pci.h> 52#include <linux/pci.h>
101 53
102#include "orinoco.h" 54#include "orinoco.h"
55#include "orinoco_pci.h"
103 56
104/* All the magic there is from wlan-ng */ 57/* Offset of the COR register of the PCI card */
105/* Magic offset of the reset register of the PCI card */
106#define HERMES_PCI_COR (0x26) 58#define HERMES_PCI_COR (0x26)
107/* Magic bitmask to reset the card */ 59
60/* Bitmask to reset the card */
108#define HERMES_PCI_COR_MASK (0x0080) 61#define HERMES_PCI_COR_MASK (0x0080)
62
109/* Magic timeouts for doing the reset. 63/* Magic timeouts for doing the reset.
110 * Those times are straight from wlan-ng, and it is claimed that they 64 * Those times are straight from wlan-ng, and it is claimed that they
111 * are necessary. Alan will kill me. Take your time and grab a coffee. */ 65 * are necessary. Alan will kill me. Take your time and grab a coffee. */
@@ -113,13 +67,8 @@
113#define HERMES_PCI_COR_OFFT (500) /* ms */ 67#define HERMES_PCI_COR_OFFT (500) /* ms */
114#define HERMES_PCI_COR_BUSYT (500) /* ms */ 68#define HERMES_PCI_COR_BUSYT (500) /* ms */
115 69
116/* Orinoco PCI specific data */
117struct orinoco_pci_card {
118 void __iomem *pci_ioaddr;
119};
120
121/* 70/*
122 * Do a soft reset of the PCI card using the Configuration Option Register 71 * Do a soft reset of the card using the Configuration Option Register
123 * We need this to get going... 72 * We need this to get going...
124 * This is the part of the code that is strongly inspired from wlan-ng 73 * This is the part of the code that is strongly inspired from wlan-ng
125 * 74 *
@@ -131,14 +80,13 @@ struct orinoco_pci_card {
131 * Note bis : Don't try to access HERMES_CMD during the reset phase. 80 * Note bis : Don't try to access HERMES_CMD during the reset phase.
132 * It just won't work ! 81 * It just won't work !
133 */ 82 */
134static int 83static int orinoco_pci_cor_reset(struct orinoco_private *priv)
135orinoco_pci_cor_reset(struct orinoco_private *priv)
136{ 84{
137 hermes_t *hw = &priv->hw; 85 hermes_t *hw = &priv->hw;
138 unsigned long timeout; 86 unsigned long timeout;
139 u16 reg; 87 u16 reg;
140 88
141 /* Assert the reset until the card notice */ 89 /* Assert the reset until the card notices */
142 hermes_write_regn(hw, PCI_COR, HERMES_PCI_COR_MASK); 90 hermes_write_regn(hw, PCI_COR, HERMES_PCI_COR_MASK);
143 mdelay(HERMES_PCI_COR_ONT); 91 mdelay(HERMES_PCI_COR_ONT);
144 92
@@ -163,19 +111,14 @@ orinoco_pci_cor_reset(struct orinoco_private *priv)
163 return 0; 111 return 0;
164} 112}
165 113
166/*
167 * Initialise a card. Mostly similar to PLX code.
168 */
169static int orinoco_pci_init_one(struct pci_dev *pdev, 114static int orinoco_pci_init_one(struct pci_dev *pdev,
170 const struct pci_device_id *ent) 115 const struct pci_device_id *ent)
171{ 116{
172 int err = 0; 117 int err;
173 unsigned long pci_iorange; 118 struct orinoco_private *priv;
174 u16 __iomem *pci_ioaddr = NULL;
175 unsigned long pci_iolen;
176 struct orinoco_private *priv = NULL;
177 struct orinoco_pci_card *card; 119 struct orinoco_pci_card *card;
178 struct net_device *dev = NULL; 120 struct net_device *dev;
121 void __iomem *hermes_io;
179 122
180 err = pci_enable_device(pdev); 123 err = pci_enable_device(pdev);
181 if (err) { 124 if (err) {
@@ -184,39 +127,32 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
184 } 127 }
185 128
186 err = pci_request_regions(pdev, DRIVER_NAME); 129 err = pci_request_regions(pdev, DRIVER_NAME);
187 if (err != 0) { 130 if (err) {
188 printk(KERN_ERR PFX "Cannot obtain PCI resources\n"); 131 printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
189 goto fail_resources; 132 goto fail_resources;
190 } 133 }
191 134
192 /* Resource 0 is mapped to the hermes registers */ 135 hermes_io = pci_iomap(pdev, 0, 0);
193 pci_iorange = pci_resource_start(pdev, 0); 136 if (!hermes_io) {
194 pci_iolen = pci_resource_len(pdev, 0); 137 printk(KERN_ERR PFX "Cannot remap chipset registers\n");
195 pci_ioaddr = ioremap(pci_iorange, pci_iolen); 138 err = -EIO;
196 if (!pci_iorange) { 139 goto fail_map_hermes;
197 printk(KERN_ERR PFX "Cannot remap hardware registers\n");
198 goto fail_map;
199 } 140 }
200 141
201 /* Allocate network device */ 142 /* Allocate network device */
202 dev = alloc_orinocodev(sizeof(*card), orinoco_pci_cor_reset); 143 dev = alloc_orinocodev(sizeof(*card), orinoco_pci_cor_reset);
203 if (! dev) { 144 if (!dev) {
145 printk(KERN_ERR PFX "Cannot allocate network device\n");
204 err = -ENOMEM; 146 err = -ENOMEM;
205 goto fail_alloc; 147 goto fail_alloc;
206 } 148 }
207 149
208 priv = netdev_priv(dev); 150 priv = netdev_priv(dev);
209 card = priv->card; 151 card = priv->card;
210 card->pci_ioaddr = pci_ioaddr;
211 dev->mem_start = pci_iorange;
212 dev->mem_end = pci_iorange + pci_iolen - 1;
213 SET_MODULE_OWNER(dev); 152 SET_MODULE_OWNER(dev);
214 SET_NETDEV_DEV(dev, &pdev->dev); 153 SET_NETDEV_DEV(dev, &pdev->dev);
215 154
216 hermes_struct_init(&priv->hw, pci_ioaddr, HERMES_32BIT_REGSPACING); 155 hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING);
217
218 printk(KERN_DEBUG PFX "Detected device %s, mem:0x%lx-0x%lx, irq %d\n",
219 pci_name(pdev), dev->mem_start, dev->mem_end, pdev->irq);
220 156
221 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 157 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
222 dev->name, dev); 158 dev->name, dev);
@@ -225,9 +161,7 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
225 err = -EBUSY; 161 err = -EBUSY;
226 goto fail_irq; 162 goto fail_irq;
227 } 163 }
228 dev->irq = pdev->irq;
229 164
230 /* Perform a COR reset to start the card */
231 err = orinoco_pci_cor_reset(priv); 165 err = orinoco_pci_cor_reset(priv);
232 if (err) { 166 if (err) {
233 printk(KERN_ERR PFX "Initial reset failed\n"); 167 printk(KERN_ERR PFX "Initial reset failed\n");
@@ -236,11 +170,13 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
236 170
237 err = register_netdev(dev); 171 err = register_netdev(dev);
238 if (err) { 172 if (err) {
239 printk(KERN_ERR PFX "Failed to register net device\n"); 173 printk(KERN_ERR PFX "Cannot register network device\n");
240 goto fail; 174 goto fail;
241 } 175 }
242 176
243 pci_set_drvdata(pdev, dev); 177 pci_set_drvdata(pdev, dev);
178 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
179 pci_name(pdev));
244 180
245 return 0; 181 return 0;
246 182
@@ -252,9 +188,9 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
252 free_orinocodev(dev); 188 free_orinocodev(dev);
253 189
254 fail_alloc: 190 fail_alloc:
255 iounmap(pci_ioaddr); 191 pci_iounmap(pdev, hermes_io);
256 192
257 fail_map: 193 fail_map_hermes:
258 pci_release_regions(pdev); 194 pci_release_regions(pdev);
259 195
260 fail_resources: 196 fail_resources:
@@ -267,87 +203,17 @@ static void __devexit orinoco_pci_remove_one(struct pci_dev *pdev)
267{ 203{
268 struct net_device *dev = pci_get_drvdata(pdev); 204 struct net_device *dev = pci_get_drvdata(pdev);
269 struct orinoco_private *priv = netdev_priv(dev); 205 struct orinoco_private *priv = netdev_priv(dev);
270 struct orinoco_pci_card *card = priv->card;
271 206
272 unregister_netdev(dev); 207 unregister_netdev(dev);
273 free_irq(dev->irq, dev); 208 free_irq(pdev->irq, dev);
274 pci_set_drvdata(pdev, NULL); 209 pci_set_drvdata(pdev, NULL);
275 free_orinocodev(dev); 210 free_orinocodev(dev);
276 iounmap(card->pci_ioaddr); 211 pci_iounmap(pdev, priv->hw.iobase);
277 pci_release_regions(pdev); 212 pci_release_regions(pdev);
278 pci_disable_device(pdev); 213 pci_disable_device(pdev);
279} 214}
280 215
281static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state) 216static struct pci_device_id orinoco_pci_id_table[] = {
282{
283 struct net_device *dev = pci_get_drvdata(pdev);
284 struct orinoco_private *priv = netdev_priv(dev);
285 unsigned long flags;
286 int err;
287
288
289 err = orinoco_lock(priv, &flags);
290 if (err) {
291 printk(KERN_ERR "%s: hw_unavailable on orinoco_pci_suspend\n",
292 dev->name);
293 return err;
294 }
295
296 err = __orinoco_down(dev);
297 if (err)
298 printk(KERN_WARNING "%s: orinoco_pci_suspend(): Error %d downing interface\n",
299 dev->name, err);
300
301 netif_device_detach(dev);
302
303 priv->hw_unavailable++;
304
305 orinoco_unlock(priv, &flags);
306
307 pci_save_state(pdev);
308 pci_set_power_state(pdev, PCI_D3hot);
309
310 return 0;
311}
312
313static int orinoco_pci_resume(struct pci_dev *pdev)
314{
315 struct net_device *dev = pci_get_drvdata(pdev);
316 struct orinoco_private *priv = netdev_priv(dev);
317 unsigned long flags;
318 int err;
319
320 printk(KERN_DEBUG "%s: Orinoco-PCI waking up\n", dev->name);
321
322 pci_set_power_state(pdev, 0);
323 pci_restore_state(pdev);
324
325 err = orinoco_reinit_firmware(dev);
326 if (err) {
327 printk(KERN_ERR "%s: Error %d re-initializing firmware on orinoco_pci_resume()\n",
328 dev->name, err);
329 return err;
330 }
331
332 spin_lock_irqsave(&priv->lock, flags);
333
334 netif_device_attach(dev);
335
336 priv->hw_unavailable--;
337
338 if (priv->open && (! priv->hw_unavailable)) {
339 err = __orinoco_up(dev);
340 if (err)
341 printk(KERN_ERR "%s: Error %d restarting card on orinoco_pci_resume()\n",
342 dev->name, err);
343 }
344
345 spin_unlock_irqrestore(&priv->lock, flags);
346
347 return 0;
348}
349
350static struct pci_device_id orinoco_pci_pci_id_table[] = {
351 /* Intersil Prism 3 */ 217 /* Intersil Prism 3 */
352 {0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,}, 218 {0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,},
353 /* Intersil Prism 2.5 */ 219 /* Intersil Prism 2.5 */
@@ -357,11 +223,11 @@ static struct pci_device_id orinoco_pci_pci_id_table[] = {
357 {0,}, 223 {0,},
358}; 224};
359 225
360MODULE_DEVICE_TABLE(pci, orinoco_pci_pci_id_table); 226MODULE_DEVICE_TABLE(pci, orinoco_pci_id_table);
361 227
362static struct pci_driver orinoco_pci_driver = { 228static struct pci_driver orinoco_pci_driver = {
363 .name = DRIVER_NAME, 229 .name = DRIVER_NAME,
364 .id_table = orinoco_pci_pci_id_table, 230 .id_table = orinoco_pci_id_table,
365 .probe = orinoco_pci_init_one, 231 .probe = orinoco_pci_init_one,
366 .remove = __devexit_p(orinoco_pci_remove_one), 232 .remove = __devexit_p(orinoco_pci_remove_one),
367 .suspend = orinoco_pci_suspend, 233 .suspend = orinoco_pci_suspend,
diff --git a/drivers/net/wireless/orinoco_pci.h b/drivers/net/wireless/orinoco_pci.h
new file mode 100644
index 000000000000..7eb1e08113e0
--- /dev/null
+++ b/drivers/net/wireless/orinoco_pci.h
@@ -0,0 +1,104 @@
1/* orinoco_pci.h
2 *
3 * Common code for all Orinoco drivers for PCI devices, including
4 * both native PCI and PCMCIA-to-PCI bridges.
5 *
6 * Copyright (C) 2005, Pavel Roskin.
7 * See orinoco.c for license.
8 */
9
10#ifndef _ORINOCO_PCI_H
11#define _ORINOCO_PCI_H
12
13#include <linux/netdevice.h>
14
15/* Driver specific data */
16struct orinoco_pci_card {
17 void __iomem *bridge_io;
18 void __iomem *attr_io;
19};
20
21#ifdef CONFIG_PM
22static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
23{
24 struct net_device *dev = pci_get_drvdata(pdev);
25 struct orinoco_private *priv = netdev_priv(dev);
26 unsigned long flags;
27 int err;
28
29 err = orinoco_lock(priv, &flags);
30 if (err) {
31 printk(KERN_ERR "%s: cannot lock hardware for suspend\n",
32 dev->name);
33 return err;
34 }
35
36 err = __orinoco_down(dev);
37 if (err)
38 printk(KERN_WARNING "%s: error %d bringing interface down "
39 "for suspend\n", dev->name, err);
40
41 netif_device_detach(dev);
42
43 priv->hw_unavailable++;
44
45 orinoco_unlock(priv, &flags);
46
47 free_irq(pdev->irq, dev);
48 pci_save_state(pdev);
49 pci_disable_device(pdev);
50 pci_set_power_state(pdev, PCI_D3hot);
51
52 return 0;
53}
54
55static int orinoco_pci_resume(struct pci_dev *pdev)
56{
57 struct net_device *dev = pci_get_drvdata(pdev);
58 struct orinoco_private *priv = netdev_priv(dev);
59 unsigned long flags;
60 int err;
61
62 pci_set_power_state(pdev, 0);
63 pci_enable_device(pdev);
64 pci_restore_state(pdev);
65
66 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
67 dev->name, dev);
68 if (err) {
69 printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
70 dev->name);
71 pci_disable_device(pdev);
72 return -EBUSY;
73 }
74
75 err = orinoco_reinit_firmware(dev);
76 if (err) {
77 printk(KERN_ERR "%s: error %d re-initializing firmware "
78 "on resume\n", dev->name, err);
79 return err;
80 }
81
82 spin_lock_irqsave(&priv->lock, flags);
83
84 netif_device_attach(dev);
85
86 priv->hw_unavailable--;
87
88 if (priv->open && (! priv->hw_unavailable)) {
89 err = __orinoco_up(dev);
90 if (err)
91 printk(KERN_ERR "%s: Error %d restarting card on resume\n",
92 dev->name, err);
93 }
94
95 spin_unlock_irqrestore(&priv->lock, flags);
96
97 return 0;
98}
99#else
100#define orinoco_pci_suspend NULL
101#define orinoco_pci_resume NULL
102#endif
103
104#endif /* _ORINOCO_PCI_H */
diff --git a/drivers/net/wireless/orinoco_plx.c b/drivers/net/wireless/orinoco_plx.c
index 210e73776545..84f696c77551 100644
--- a/drivers/net/wireless/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco_plx.c
@@ -3,7 +3,7 @@
3 * Driver for Prism II devices which would usually be driven by orinoco_cs, 3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a PLX9052. 4 * but are connected to the PCI bus by a PLX9052.
5 * 5 *
6 * Current maintainers (as of 29 September 2003) are: 6 * Current maintainers are:
7 * Pavel Roskin <proski AT gnu.org> 7 * Pavel Roskin <proski AT gnu.org>
8 * and David Gibson <hermes AT gibson.dropbear.id.au> 8 * and David Gibson <hermes AT gibson.dropbear.id.au>
9 * 9 *
@@ -30,38 +30,18 @@
30 * other provisions required by the GPL. If you do not delete the 30 * other provisions required by the GPL. If you do not delete the
31 * provisions above, a recipient may use your version of this file 31 * provisions above, a recipient may use your version of this file
32 * under either the MPL or the GPL. 32 * under either the MPL or the GPL.
33
34 * Caution: this is experimental and probably buggy. For success and
35 * failure reports for different cards and adaptors, see
36 * orinoco_plx_pci_id_table near the end of the file. If you have a
37 * card we don't have the PCI id for, and looks like it should work,
38 * drop me mail with the id and "it works"/"it doesn't work".
39 *
40 * Note: if everything gets detected fine but it doesn't actually send
41 * or receive packets, your first port of call should probably be to
42 * try newer firmware in the card. Especially if you're doing Ad-Hoc
43 * modes.
44 *
45 * The actual driving is done by orinoco.c, this is just resource
46 * allocation stuff. The explanation below is courtesy of Ryan Niemi
47 * on the linux-wlan-ng list at
48 * http://archives.neohapsis.com/archives/dev/linux-wlan/2001-q1/0026.html
49 * 33 *
50 * The PLX9052-based cards (WL11000 and several others) are a 34 * Here's the general details on how the PLX9052 adapter works:
51 * different beast than the usual PCMCIA-based PRISM2 configuration
52 * expected by wlan-ng. Here's the general details on how the WL11000
53 * PCI adapter works:
54 * 35 *
55 * - Two PCI I/O address spaces, one 0x80 long which contains the 36 * - Two PCI I/O address spaces, one 0x80 long which contains the
56 * PLX9052 registers, and one that's 0x40 long mapped to the PCMCIA 37 * PLX9052 registers, and one that's 0x40 long mapped to the PCMCIA
57 * slot I/O address space. 38 * slot I/O address space.
58 * 39 *
59 * - One PCI memory address space, mapped to the PCMCIA memory space 40 * - One PCI memory address space, mapped to the PCMCIA attribute space
60 * (containing the CIS). 41 * (containing the CIS).
61 * 42 *
62 * After identifying the I/O and memory space, you can read through 43 * Using the later, you can read through the CIS data to make sure the
63 * the memory space to confirm the CIS's device ID or manufacturer ID 44 * card is compatible with the driver. Keep in mind that the PCMCIA
64 * to make sure it's the expected card. qKeep in mind that the PCMCIA
65 * spec specifies the CIS as the lower 8 bits of each word read from 45 * spec specifies the CIS as the lower 8 bits of each word read from
66 * the CIS, so to read the bytes of the CIS, read every other byte 46 * the CIS, so to read the bytes of the CIS, read every other byte
67 * (0,2,4,...). Passing that test, you need to enable the I/O address 47 * (0,2,4,...). Passing that test, you need to enable the I/O address
@@ -71,7 +51,7 @@
71 * within the PCI memory space. Write 0x41 to the COR register to 51 * within the PCI memory space. Write 0x41 to the COR register to
72 * enable I/O mode and to select level triggered interrupts. To 52 * enable I/O mode and to select level triggered interrupts. To
73 * confirm you actually succeeded, read the COR register back and make 53 * confirm you actually succeeded, read the COR register back and make
74 * sure it actually got set to 0x41, incase you have an unexpected 54 * sure it actually got set to 0x41, in case you have an unexpected
75 * card inserted. 55 * card inserted.
76 * 56 *
77 * Following that, you can treat the second PCI I/O address space (the 57 * Following that, you can treat the second PCI I/O address space (the
@@ -101,16 +81,6 @@
101 * that, I've hot-swapped a number of times during debugging and 81 * that, I've hot-swapped a number of times during debugging and
102 * driver development for various reasons (stuck WAIT# line after the 82 * driver development for various reasons (stuck WAIT# line after the
103 * radio card's firmware locks up). 83 * radio card's firmware locks up).
104 *
105 * Hope this is enough info for someone to add PLX9052 support to the
106 * wlan-ng card. In the case of the WL11000, the PCI ID's are
107 * 0x1639/0x0200, with matching subsystem ID's. Other PLX9052-based
108 * manufacturers other than Eumitcom (or on cards other than the
109 * WL11000) may have different PCI ID's.
110 *
111 * If anyone needs any more specific info, let me know. I haven't had
112 * time to implement support myself yet, and with the way things are
113 * going, might not have time for a while..
114 */ 84 */
115 85
116#define DRIVER_NAME "orinoco_plx" 86#define DRIVER_NAME "orinoco_plx"
@@ -125,6 +95,7 @@
125#include <pcmcia/cisreg.h> 95#include <pcmcia/cisreg.h>
126 96
127#include "orinoco.h" 97#include "orinoco.h"
98#include "orinoco_pci.h"
128 99
129#define COR_OFFSET (0x3e0) /* COR attribute offset of Prism2 PC card */ 100#define COR_OFFSET (0x3e0) /* COR attribute offset of Prism2 PC card */
130#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */ 101#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
@@ -134,30 +105,20 @@
134#define PLX_INTCSR 0x4c /* Interrupt Control & Status Register */ 105#define PLX_INTCSR 0x4c /* Interrupt Control & Status Register */
135#define PLX_INTCSR_INTEN (1<<6) /* Interrupt Enable bit */ 106#define PLX_INTCSR_INTEN (1<<6) /* Interrupt Enable bit */
136 107
137static const u8 cis_magic[] = {
138 0x01, 0x03, 0x00, 0x00, 0xff, 0x17, 0x04, 0x67
139};
140
141/* Orinoco PLX specific data */
142struct orinoco_plx_card {
143 void __iomem *attr_mem;
144};
145
146/* 108/*
147 * Do a soft reset of the card using the Configuration Option Register 109 * Do a soft reset of the card using the Configuration Option Register
148 */ 110 */
149static int orinoco_plx_cor_reset(struct orinoco_private *priv) 111static int orinoco_plx_cor_reset(struct orinoco_private *priv)
150{ 112{
151 hermes_t *hw = &priv->hw; 113 hermes_t *hw = &priv->hw;
152 struct orinoco_plx_card *card = priv->card; 114 struct orinoco_pci_card *card = priv->card;
153 u8 __iomem *attr_mem = card->attr_mem;
154 unsigned long timeout; 115 unsigned long timeout;
155 u16 reg; 116 u16 reg;
156 117
157 writeb(COR_VALUE | COR_RESET, attr_mem + COR_OFFSET); 118 iowrite8(COR_VALUE | COR_RESET, card->attr_io + COR_OFFSET);
158 mdelay(1); 119 mdelay(1);
159 120
160 writeb(COR_VALUE, attr_mem + COR_OFFSET); 121 iowrite8(COR_VALUE, card->attr_io + COR_OFFSET);
161 mdelay(1); 122 mdelay(1);
162 123
163 /* Just in case, wait more until the card is no longer busy */ 124 /* Just in case, wait more until the card is no longer busy */
@@ -168,7 +129,7 @@ static int orinoco_plx_cor_reset(struct orinoco_private *priv)
168 reg = hermes_read_regn(hw, CMD); 129 reg = hermes_read_regn(hw, CMD);
169 } 130 }
170 131
171 /* Did we timeout ? */ 132 /* Still busy? */
172 if (reg & HERMES_CMD_BUSY) { 133 if (reg & HERMES_CMD_BUSY) {
173 printk(KERN_ERR PFX "Busy timeout\n"); 134 printk(KERN_ERR PFX "Busy timeout\n");
174 return -ETIMEDOUT; 135 return -ETIMEDOUT;
@@ -177,20 +138,55 @@ static int orinoco_plx_cor_reset(struct orinoco_private *priv)
177 return 0; 138 return 0;
178} 139}
179 140
141static int orinoco_plx_hw_init(struct orinoco_pci_card *card)
142{
143 int i;
144 u32 csr_reg;
145 static const u8 cis_magic[] = {
146 0x01, 0x03, 0x00, 0x00, 0xff, 0x17, 0x04, 0x67
147 };
148
149 printk(KERN_DEBUG PFX "CIS: ");
150 for (i = 0; i < 16; i++) {
151 printk("%02X:", ioread8(card->attr_io + (i << 1)));
152 }
153 printk("\n");
154
155 /* Verify whether a supported PC card is present */
156 /* FIXME: we probably need to be smarted about this */
157 for (i = 0; i < sizeof(cis_magic); i++) {
158 if (cis_magic[i] != ioread8(card->attr_io + (i << 1))) {
159 printk(KERN_ERR PFX "The CIS value of Prism2 PC "
160 "card is unexpected\n");
161 return -ENODEV;
162 }
163 }
164
165 /* bjoern: We need to tell the card to enable interrupts, in
166 case the serial eprom didn't do this already. See the
167 PLX9052 data book, p8-1 and 8-24 for reference. */
168 csr_reg = ioread32(card->bridge_io + PLX_INTCSR);
169 if (!(csr_reg & PLX_INTCSR_INTEN)) {
170 csr_reg |= PLX_INTCSR_INTEN;
171 iowrite32(csr_reg, card->bridge_io + PLX_INTCSR);
172 csr_reg = ioread32(card->bridge_io + PLX_INTCSR);
173 if (!(csr_reg & PLX_INTCSR_INTEN)) {
174 printk(KERN_ERR PFX "Cannot enable interrupts\n");
175 return -EIO;
176 }
177 }
178
179 return 0;
180}
180 181
181static int orinoco_plx_init_one(struct pci_dev *pdev, 182static int orinoco_plx_init_one(struct pci_dev *pdev,
182 const struct pci_device_id *ent) 183 const struct pci_device_id *ent)
183{ 184{
184 int err = 0; 185 int err;
185 u8 __iomem *attr_mem = NULL; 186 struct orinoco_private *priv;
186 u32 csr_reg, plx_addr; 187 struct orinoco_pci_card *card;
187 struct orinoco_private *priv = NULL; 188 struct net_device *dev;
188 struct orinoco_plx_card *card; 189 void __iomem *hermes_io, *attr_io, *bridge_io;
189 unsigned long pccard_ioaddr = 0;
190 unsigned long pccard_iolen = 0;
191 struct net_device *dev = NULL;
192 void __iomem *mem;
193 int i;
194 190
195 err = pci_enable_device(pdev); 191 err = pci_enable_device(pdev);
196 if (err) { 192 if (err) {
@@ -199,30 +195,30 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
199 } 195 }
200 196
201 err = pci_request_regions(pdev, DRIVER_NAME); 197 err = pci_request_regions(pdev, DRIVER_NAME);
202 if (err != 0) { 198 if (err) {
203 printk(KERN_ERR PFX "Cannot obtain PCI resources\n"); 199 printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
204 goto fail_resources; 200 goto fail_resources;
205 } 201 }
206 202
207 /* Resource 1 is mapped to PLX-specific registers */ 203 bridge_io = pci_iomap(pdev, 1, 0);
208 plx_addr = pci_resource_start(pdev, 1); 204 if (!bridge_io) {
205 printk(KERN_ERR PFX "Cannot map bridge registers\n");
206 err = -EIO;
207 goto fail_map_bridge;
208 }
209 209
210 /* Resource 2 is mapped to the PCMCIA attribute memory */ 210 attr_io = pci_iomap(pdev, 2, 0);
211 attr_mem = ioremap(pci_resource_start(pdev, 2), 211 if (!attr_io) {
212 pci_resource_len(pdev, 2)); 212 printk(KERN_ERR PFX "Cannot map PCMCIA attributes\n");
213 if (!attr_mem) { 213 err = -EIO;
214 printk(KERN_ERR PFX "Cannot remap PCMCIA space\n");
215 goto fail_map_attr; 214 goto fail_map_attr;
216 } 215 }
217 216
218 /* Resource 3 is mapped to the PCMCIA I/O address space */ 217 hermes_io = pci_iomap(pdev, 3, 0);
219 pccard_ioaddr = pci_resource_start(pdev, 3); 218 if (!hermes_io) {
220 pccard_iolen = pci_resource_len(pdev, 3); 219 printk(KERN_ERR PFX "Cannot map chipset registers\n");
221 220 err = -EIO;
222 mem = pci_iomap(pdev, 3, 0); 221 goto fail_map_hermes;
223 if (!mem) {
224 err = -ENOMEM;
225 goto fail_map_io;
226 } 222 }
227 223
228 /* Allocate network device */ 224 /* Allocate network device */
@@ -235,16 +231,12 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
235 231
236 priv = netdev_priv(dev); 232 priv = netdev_priv(dev);
237 card = priv->card; 233 card = priv->card;
238 card->attr_mem = attr_mem; 234 card->bridge_io = bridge_io;
239 dev->base_addr = pccard_ioaddr; 235 card->attr_io = attr_io;
240 SET_MODULE_OWNER(dev); 236 SET_MODULE_OWNER(dev);
241 SET_NETDEV_DEV(dev, &pdev->dev); 237 SET_NETDEV_DEV(dev, &pdev->dev);
242 238
243 hermes_struct_init(&priv->hw, mem, HERMES_16BIT_REGSPACING); 239 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
244
245 printk(KERN_DEBUG PFX "Detected Orinoco/Prism2 PLX device "
246 "at %s irq:%d, io addr:0x%lx\n", pci_name(pdev), pdev->irq,
247 pccard_ioaddr);
248 240
249 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 241 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
250 dev->name, dev); 242 dev->name, dev);
@@ -253,20 +245,11 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
253 err = -EBUSY; 245 err = -EBUSY;
254 goto fail_irq; 246 goto fail_irq;
255 } 247 }
256 dev->irq = pdev->irq;
257 248
258 /* bjoern: We need to tell the card to enable interrupts, in 249 err = orinoco_plx_hw_init(card);
259 case the serial eprom didn't do this already. See the 250 if (err) {
260 PLX9052 data book, p8-1 and 8-24 for reference. */ 251 printk(KERN_ERR PFX "Hardware initialization failed\n");
261 csr_reg = inl(plx_addr + PLX_INTCSR); 252 goto fail;
262 if (!(csr_reg & PLX_INTCSR_INTEN)) {
263 csr_reg |= PLX_INTCSR_INTEN;
264 outl(csr_reg, plx_addr + PLX_INTCSR);
265 csr_reg = inl(plx_addr + PLX_INTCSR);
266 if (!(csr_reg & PLX_INTCSR_INTEN)) {
267 printk(KERN_ERR PFX "Cannot enable interrupts\n");
268 goto fail;
269 }
270 } 253 }
271 254
272 err = orinoco_plx_cor_reset(priv); 255 err = orinoco_plx_cor_reset(priv);
@@ -275,23 +258,6 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
275 goto fail; 258 goto fail;
276 } 259 }
277 260
278 printk(KERN_DEBUG PFX "CIS: ");
279 for (i = 0; i < 16; i++) {
280 printk("%02X:", readb(attr_mem + 2*i));
281 }
282 printk("\n");
283
284 /* Verify whether a supported PC card is present */
285 /* FIXME: we probably need to be smarted about this */
286 for (i = 0; i < sizeof(cis_magic); i++) {
287 if (cis_magic[i] != readb(attr_mem +2*i)) {
288 printk(KERN_ERR PFX "The CIS value of Prism2 PC "
289 "card is unexpected\n");
290 err = -EIO;
291 goto fail;
292 }
293 }
294
295 err = register_netdev(dev); 261 err = register_netdev(dev);
296 if (err) { 262 if (err) {
297 printk(KERN_ERR PFX "Cannot register network device\n"); 263 printk(KERN_ERR PFX "Cannot register network device\n");
@@ -299,6 +265,8 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
299 } 265 }
300 266
301 pci_set_drvdata(pdev, dev); 267 pci_set_drvdata(pdev, dev);
268 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
269 pci_name(pdev));
302 270
303 return 0; 271 return 0;
304 272
@@ -310,12 +278,15 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
310 free_orinocodev(dev); 278 free_orinocodev(dev);
311 279
312 fail_alloc: 280 fail_alloc:
313 pci_iounmap(pdev, mem); 281 pci_iounmap(pdev, hermes_io);
314 282
315 fail_map_io: 283 fail_map_hermes:
316 iounmap(attr_mem); 284 pci_iounmap(pdev, attr_io);
317 285
318 fail_map_attr: 286 fail_map_attr:
287 pci_iounmap(pdev, bridge_io);
288
289 fail_map_bridge:
319 pci_release_regions(pdev); 290 pci_release_regions(pdev);
320 291
321 fail_resources: 292 fail_resources:
@@ -328,23 +299,20 @@ static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev)
328{ 299{
329 struct net_device *dev = pci_get_drvdata(pdev); 300 struct net_device *dev = pci_get_drvdata(pdev);
330 struct orinoco_private *priv = netdev_priv(dev); 301 struct orinoco_private *priv = netdev_priv(dev);
331 struct orinoco_plx_card *card = priv->card; 302 struct orinoco_pci_card *card = priv->card;
332 u8 __iomem *attr_mem = card->attr_mem;
333
334 BUG_ON(! dev);
335 303
336 unregister_netdev(dev); 304 unregister_netdev(dev);
337 free_irq(dev->irq, dev); 305 free_irq(pdev->irq, dev);
338 pci_set_drvdata(pdev, NULL); 306 pci_set_drvdata(pdev, NULL);
339 free_orinocodev(dev); 307 free_orinocodev(dev);
340 pci_iounmap(pdev, priv->hw.iobase); 308 pci_iounmap(pdev, priv->hw.iobase);
341 iounmap(attr_mem); 309 pci_iounmap(pdev, card->attr_io);
310 pci_iounmap(pdev, card->bridge_io);
342 pci_release_regions(pdev); 311 pci_release_regions(pdev);
343 pci_disable_device(pdev); 312 pci_disable_device(pdev);
344} 313}
345 314
346 315static struct pci_device_id orinoco_plx_id_table[] = {
347static struct pci_device_id orinoco_plx_pci_id_table[] = {
348 {0x111a, 0x1023, PCI_ANY_ID, PCI_ANY_ID,}, /* Siemens SpeedStream SS1023 */ 316 {0x111a, 0x1023, PCI_ANY_ID, PCI_ANY_ID,}, /* Siemens SpeedStream SS1023 */
349 {0x1385, 0x4100, PCI_ANY_ID, PCI_ANY_ID,}, /* Netgear MA301 */ 317 {0x1385, 0x4100, PCI_ANY_ID, PCI_ANY_ID,}, /* Netgear MA301 */
350 {0x15e8, 0x0130, PCI_ANY_ID, PCI_ANY_ID,}, /* Correga - does this work? */ 318 {0x15e8, 0x0130, PCI_ANY_ID, PCI_ANY_ID,}, /* Correga - does this work? */
@@ -362,13 +330,15 @@ static struct pci_device_id orinoco_plx_pci_id_table[] = {
362 {0,}, 330 {0,},
363}; 331};
364 332
365MODULE_DEVICE_TABLE(pci, orinoco_plx_pci_id_table); 333MODULE_DEVICE_TABLE(pci, orinoco_plx_id_table);
366 334
367static struct pci_driver orinoco_plx_driver = { 335static struct pci_driver orinoco_plx_driver = {
368 .name = DRIVER_NAME, 336 .name = DRIVER_NAME,
369 .id_table = orinoco_plx_pci_id_table, 337 .id_table = orinoco_plx_id_table,
370 .probe = orinoco_plx_init_one, 338 .probe = orinoco_plx_init_one,
371 .remove = __devexit_p(orinoco_plx_remove_one), 339 .remove = __devexit_p(orinoco_plx_remove_one),
340 .suspend = orinoco_pci_suspend,
341 .resume = orinoco_pci_resume,
372}; 342};
373 343
374static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION 344static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
@@ -388,7 +358,6 @@ static int __init orinoco_plx_init(void)
388static void __exit orinoco_plx_exit(void) 358static void __exit orinoco_plx_exit(void)
389{ 359{
390 pci_unregister_driver(&orinoco_plx_driver); 360 pci_unregister_driver(&orinoco_plx_driver);
391 ssleep(1);
392} 361}
393 362
394module_init(orinoco_plx_init); 363module_init(orinoco_plx_init);
diff --git a/drivers/net/wireless/orinoco_tmd.c b/drivers/net/wireless/orinoco_tmd.c
index 5e68b7026186..d2b4decb7a7d 100644
--- a/drivers/net/wireless/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco_tmd.c
@@ -1,5 +1,5 @@
1/* orinoco_tmd.c 1/* orinoco_tmd.c
2 * 2 *
3 * Driver for Prism II devices which would usually be driven by orinoco_cs, 3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a TMD7160. 4 * but are connected to the PCI bus by a TMD7160.
5 * 5 *
@@ -26,25 +26,13 @@
26 * other provisions required by the GPL. If you do not delete the 26 * other provisions required by the GPL. If you do not delete the
27 * provisions above, a recipient may use your version of this file 27 * provisions above, a recipient may use your version of this file
28 * under either the MPL or the GPL. 28 * under either the MPL or the GPL.
29
30 * Caution: this is experimental and probably buggy. For success and
31 * failure reports for different cards and adaptors, see
32 * orinoco_tmd_pci_id_table near the end of the file. If you have a
33 * card we don't have the PCI id for, and looks like it should work,
34 * drop me mail with the id and "it works"/"it doesn't work".
35 *
36 * Note: if everything gets detected fine but it doesn't actually send
37 * or receive packets, your first port of call should probably be to
38 * try newer firmware in the card. Especially if you're doing Ad-Hoc
39 * modes
40 * 29 *
41 * The actual driving is done by orinoco.c, this is just resource 30 * The actual driving is done by orinoco.c, this is just resource
42 * allocation stuff. 31 * allocation stuff.
43 * 32 *
44 * This driver is modeled after the orinoco_plx driver. The main 33 * This driver is modeled after the orinoco_plx driver. The main
45 * difference is that the TMD chip has only IO port ranges and no 34 * difference is that the TMD chip has only IO port ranges and doesn't
46 * memory space, i.e. no access to the CIS. Compared to the PLX chip, 35 * provide access to the PCMCIA attribute space.
47 * the io range functionalities are exchanged.
48 * 36 *
49 * Pheecom sells cards with the TMD chip as "ASIC version" 37 * Pheecom sells cards with the TMD chip as "ASIC version"
50 */ 38 */
@@ -61,32 +49,26 @@
61#include <pcmcia/cisreg.h> 49#include <pcmcia/cisreg.h>
62 50
63#include "orinoco.h" 51#include "orinoco.h"
52#include "orinoco_pci.h"
64 53
65#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */ 54#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
66#define COR_RESET (0x80) /* reset bit in the COR register */ 55#define COR_RESET (0x80) /* reset bit in the COR register */
67#define TMD_RESET_TIME (500) /* milliseconds */ 56#define TMD_RESET_TIME (500) /* milliseconds */
68 57
69/* Orinoco TMD specific data */
70struct orinoco_tmd_card {
71 u32 tmd_io;
72};
73
74
75/* 58/*
76 * Do a soft reset of the card using the Configuration Option Register 59 * Do a soft reset of the card using the Configuration Option Register
77 */ 60 */
78static int orinoco_tmd_cor_reset(struct orinoco_private *priv) 61static int orinoco_tmd_cor_reset(struct orinoco_private *priv)
79{ 62{
80 hermes_t *hw = &priv->hw; 63 hermes_t *hw = &priv->hw;
81 struct orinoco_tmd_card *card = priv->card; 64 struct orinoco_pci_card *card = priv->card;
82 u32 addr = card->tmd_io;
83 unsigned long timeout; 65 unsigned long timeout;
84 u16 reg; 66 u16 reg;
85 67
86 outb(COR_VALUE | COR_RESET, addr); 68 iowrite8(COR_VALUE | COR_RESET, card->bridge_io);
87 mdelay(1); 69 mdelay(1);
88 70
89 outb(COR_VALUE, addr); 71 iowrite8(COR_VALUE, card->bridge_io);
90 mdelay(1); 72 mdelay(1);
91 73
92 /* Just in case, wait more until the card is no longer busy */ 74 /* Just in case, wait more until the card is no longer busy */
@@ -97,7 +79,7 @@ static int orinoco_tmd_cor_reset(struct orinoco_private *priv)
97 reg = hermes_read_regn(hw, CMD); 79 reg = hermes_read_regn(hw, CMD);
98 } 80 }
99 81
100 /* Did we timeout ? */ 82 /* Still busy? */
101 if (reg & HERMES_CMD_BUSY) { 83 if (reg & HERMES_CMD_BUSY) {
102 printk(KERN_ERR PFX "Busy timeout\n"); 84 printk(KERN_ERR PFX "Busy timeout\n");
103 return -ETIMEDOUT; 85 return -ETIMEDOUT;
@@ -110,11 +92,11 @@ static int orinoco_tmd_cor_reset(struct orinoco_private *priv)
110static int orinoco_tmd_init_one(struct pci_dev *pdev, 92static int orinoco_tmd_init_one(struct pci_dev *pdev,
111 const struct pci_device_id *ent) 93 const struct pci_device_id *ent)
112{ 94{
113 int err = 0; 95 int err;
114 struct orinoco_private *priv = NULL; 96 struct orinoco_private *priv;
115 struct orinoco_tmd_card *card; 97 struct orinoco_pci_card *card;
116 struct net_device *dev = NULL; 98 struct net_device *dev;
117 void __iomem *mem; 99 void __iomem *hermes_io, *bridge_io;
118 100
119 err = pci_enable_device(pdev); 101 err = pci_enable_device(pdev);
120 if (err) { 102 if (err) {
@@ -123,20 +105,28 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
123 } 105 }
124 106
125 err = pci_request_regions(pdev, DRIVER_NAME); 107 err = pci_request_regions(pdev, DRIVER_NAME);
126 if (err != 0) { 108 if (err) {
127 printk(KERN_ERR PFX "Cannot obtain PCI resources\n"); 109 printk(KERN_ERR PFX "Cannot obtain PCI resources\n");
128 goto fail_resources; 110 goto fail_resources;
129 } 111 }
130 112
131 mem = pci_iomap(pdev, 2, 0); 113 bridge_io = pci_iomap(pdev, 1, 0);
132 if (! mem) { 114 if (!bridge_io) {
133 err = -ENOMEM; 115 printk(KERN_ERR PFX "Cannot map bridge registers\n");
134 goto fail_iomap; 116 err = -EIO;
117 goto fail_map_bridge;
118 }
119
120 hermes_io = pci_iomap(pdev, 2, 0);
121 if (!hermes_io) {
122 printk(KERN_ERR PFX "Cannot map chipset registers\n");
123 err = -EIO;
124 goto fail_map_hermes;
135 } 125 }
136 126
137 /* Allocate network device */ 127 /* Allocate network device */
138 dev = alloc_orinocodev(sizeof(*card), orinoco_tmd_cor_reset); 128 dev = alloc_orinocodev(sizeof(*card), orinoco_tmd_cor_reset);
139 if (! dev) { 129 if (!dev) {
140 printk(KERN_ERR PFX "Cannot allocate network device\n"); 130 printk(KERN_ERR PFX "Cannot allocate network device\n");
141 err = -ENOMEM; 131 err = -ENOMEM;
142 goto fail_alloc; 132 goto fail_alloc;
@@ -144,16 +134,11 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
144 134
145 priv = netdev_priv(dev); 135 priv = netdev_priv(dev);
146 card = priv->card; 136 card = priv->card;
147 card->tmd_io = pci_resource_start(pdev, 1); 137 card->bridge_io = bridge_io;
148 dev->base_addr = pci_resource_start(pdev, 2);
149 SET_MODULE_OWNER(dev); 138 SET_MODULE_OWNER(dev);
150 SET_NETDEV_DEV(dev, &pdev->dev); 139 SET_NETDEV_DEV(dev, &pdev->dev);
151 140
152 hermes_struct_init(&priv->hw, mem, HERMES_16BIT_REGSPACING); 141 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
153
154 printk(KERN_DEBUG PFX "Detected Orinoco/Prism2 TMD device "
155 "at %s irq:%d, io addr:0x%lx\n", pci_name(pdev), pdev->irq,
156 dev->base_addr);
157 142
158 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 143 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ,
159 dev->name, dev); 144 dev->name, dev);
@@ -162,7 +147,6 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
162 err = -EBUSY; 147 err = -EBUSY;
163 goto fail_irq; 148 goto fail_irq;
164 } 149 }
165 dev->irq = pdev->irq;
166 150
167 err = orinoco_tmd_cor_reset(priv); 151 err = orinoco_tmd_cor_reset(priv);
168 if (err) { 152 if (err) {
@@ -177,6 +161,8 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
177 } 161 }
178 162
179 pci_set_drvdata(pdev, dev); 163 pci_set_drvdata(pdev, dev);
164 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
165 pci_name(pdev));
180 166
181 return 0; 167 return 0;
182 168
@@ -188,9 +174,12 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
188 free_orinocodev(dev); 174 free_orinocodev(dev);
189 175
190 fail_alloc: 176 fail_alloc:
191 pci_iounmap(pdev, mem); 177 pci_iounmap(pdev, hermes_io);
178
179 fail_map_hermes:
180 pci_iounmap(pdev, bridge_io);
192 181
193 fail_iomap: 182 fail_map_bridge:
194 pci_release_regions(pdev); 183 pci_release_regions(pdev);
195 184
196 fail_resources: 185 fail_resources:
@@ -203,31 +192,32 @@ static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev)
203{ 192{
204 struct net_device *dev = pci_get_drvdata(pdev); 193 struct net_device *dev = pci_get_drvdata(pdev);
205 struct orinoco_private *priv = dev->priv; 194 struct orinoco_private *priv = dev->priv;
206 195 struct orinoco_pci_card *card = priv->card;
207 BUG_ON(! dev);
208 196
209 unregister_netdev(dev); 197 unregister_netdev(dev);
210 free_irq(dev->irq, dev); 198 free_irq(pdev->irq, dev);
211 pci_set_drvdata(pdev, NULL); 199 pci_set_drvdata(pdev, NULL);
212 free_orinocodev(dev); 200 free_orinocodev(dev);
213 pci_iounmap(pdev, priv->hw.iobase); 201 pci_iounmap(pdev, priv->hw.iobase);
202 pci_iounmap(pdev, card->bridge_io);
214 pci_release_regions(pdev); 203 pci_release_regions(pdev);
215 pci_disable_device(pdev); 204 pci_disable_device(pdev);
216} 205}
217 206
218 207static struct pci_device_id orinoco_tmd_id_table[] = {
219static struct pci_device_id orinoco_tmd_pci_id_table[] = {
220 {0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,}, /* NDC and OEMs, e.g. pheecom */ 208 {0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,}, /* NDC and OEMs, e.g. pheecom */
221 {0,}, 209 {0,},
222}; 210};
223 211
224MODULE_DEVICE_TABLE(pci, orinoco_tmd_pci_id_table); 212MODULE_DEVICE_TABLE(pci, orinoco_tmd_id_table);
225 213
226static struct pci_driver orinoco_tmd_driver = { 214static struct pci_driver orinoco_tmd_driver = {
227 .name = DRIVER_NAME, 215 .name = DRIVER_NAME,
228 .id_table = orinoco_tmd_pci_id_table, 216 .id_table = orinoco_tmd_id_table,
229 .probe = orinoco_tmd_init_one, 217 .probe = orinoco_tmd_init_one,
230 .remove = __devexit_p(orinoco_tmd_remove_one), 218 .remove = __devexit_p(orinoco_tmd_remove_one),
219 .suspend = orinoco_pci_suspend,
220 .resume = orinoco_pci_resume,
231}; 221};
232 222
233static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION 223static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
@@ -245,7 +235,6 @@ static int __init orinoco_tmd_init(void)
245static void __exit orinoco_tmd_exit(void) 235static void __exit orinoco_tmd_exit(void)
246{ 236{
247 pci_unregister_driver(&orinoco_tmd_driver); 237 pci_unregister_driver(&orinoco_tmd_driver);
248 ssleep(1);
249} 238}
250 239
251module_init(orinoco_tmd_init); 240module_init(orinoco_tmd_init);
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index f7b77ce54d7b..7f9aa139c347 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as 2 * Driver for 802.11b cards using RAM-loadable Symbol firmware, such as
3 * Symbol Wireless Networker LA4100, CompactFlash cards by Socket 3 * Symbol Wireless Networker LA4137, CompactFlash cards by Socket
4 * Communications and Intel PRO/Wireless 2011B. 4 * Communications and Intel PRO/Wireless 2011B.
5 * 5 *
6 * The driver implements Symbol firmware download. The rest is handled 6 * The driver implements Symbol firmware download. The rest is handled
@@ -120,8 +120,8 @@ static void spectrum_cs_release(struct pcmcia_device *link);
120 * Each block has the following structure. 120 * Each block has the following structure.
121 */ 121 */
122struct dblock { 122struct dblock {
123 __le32 _addr; /* adapter address where to write the block */ 123 __le32 addr; /* adapter address where to write the block */
124 __le16 _len; /* length of the data only, in bytes */ 124 __le16 len; /* length of the data only, in bytes */
125 char data[0]; /* data to be written */ 125 char data[0]; /* data to be written */
126} __attribute__ ((packed)); 126} __attribute__ ((packed));
127 127
@@ -131,9 +131,9 @@ struct dblock {
131 * items with matching ID should be written. 131 * items with matching ID should be written.
132 */ 132 */
133struct pdr { 133struct pdr {
134 __le32 _id; /* record ID */ 134 __le32 id; /* record ID */
135 __le32 _addr; /* adapter address where to write the data */ 135 __le32 addr; /* adapter address where to write the data */
136 __le32 _len; /* expected length of the data, in bytes */ 136 __le32 len; /* expected length of the data, in bytes */
137 char next[0]; /* next PDR starts here */ 137 char next[0]; /* next PDR starts here */
138} __attribute__ ((packed)); 138} __attribute__ ((packed));
139 139
@@ -144,8 +144,8 @@ struct pdr {
144 * be plugged into the secondary firmware. 144 * be plugged into the secondary firmware.
145 */ 145 */
146struct pdi { 146struct pdi {
147 __le16 _len; /* length of ID and data, in words */ 147 __le16 len; /* length of ID and data, in words */
148 __le16 _id; /* record ID */ 148 __le16 id; /* record ID */
149 char data[0]; /* plug data */ 149 char data[0]; /* plug data */
150} __attribute__ ((packed)); 150} __attribute__ ((packed));
151 151
@@ -154,44 +154,44 @@ struct pdi {
154static inline u32 154static inline u32
155dblock_addr(const struct dblock *blk) 155dblock_addr(const struct dblock *blk)
156{ 156{
157 return le32_to_cpu(blk->_addr); 157 return le32_to_cpu(blk->addr);
158} 158}
159 159
160static inline u32 160static inline u32
161dblock_len(const struct dblock *blk) 161dblock_len(const struct dblock *blk)
162{ 162{
163 return le16_to_cpu(blk->_len); 163 return le16_to_cpu(blk->len);
164} 164}
165 165
166static inline u32 166static inline u32
167pdr_id(const struct pdr *pdr) 167pdr_id(const struct pdr *pdr)
168{ 168{
169 return le32_to_cpu(pdr->_id); 169 return le32_to_cpu(pdr->id);
170} 170}
171 171
172static inline u32 172static inline u32
173pdr_addr(const struct pdr *pdr) 173pdr_addr(const struct pdr *pdr)
174{ 174{
175 return le32_to_cpu(pdr->_addr); 175 return le32_to_cpu(pdr->addr);
176} 176}
177 177
178static inline u32 178static inline u32
179pdr_len(const struct pdr *pdr) 179pdr_len(const struct pdr *pdr)
180{ 180{
181 return le32_to_cpu(pdr->_len); 181 return le32_to_cpu(pdr->len);
182} 182}
183 183
184static inline u32 184static inline u32
185pdi_id(const struct pdi *pdi) 185pdi_id(const struct pdi *pdi)
186{ 186{
187 return le16_to_cpu(pdi->_id); 187 return le16_to_cpu(pdi->id);
188} 188}
189 189
190/* Return length of the data only, in bytes */ 190/* Return length of the data only, in bytes */
191static inline u32 191static inline u32
192pdi_len(const struct pdi *pdi) 192pdi_len(const struct pdi *pdi)
193{ 193{
194 return 2 * (le16_to_cpu(pdi->_len) - 1); 194 return 2 * (le16_to_cpu(pdi->len) - 1);
195} 195}
196 196
197 197
@@ -343,8 +343,7 @@ spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
343 343
344 /* do the actual plugging */ 344 /* do the actual plugging */
345 spectrum_aux_setaddr(hw, pdr_addr(pdr)); 345 spectrum_aux_setaddr(hw, pdr_addr(pdr));
346 hermes_write_words(hw, HERMES_AUXDATA, pdi->data, 346 hermes_write_bytes(hw, HERMES_AUXDATA, pdi->data, pdi_len(pdi));
347 pdi_len(pdi) / 2);
348 347
349 return 0; 348 return 0;
350} 349}
@@ -424,8 +423,8 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
424 423
425 while (dblock_addr(blk) != BLOCK_END) { 424 while (dblock_addr(blk) != BLOCK_END) {
426 spectrum_aux_setaddr(hw, blkaddr); 425 spectrum_aux_setaddr(hw, blkaddr);
427 hermes_write_words(hw, HERMES_AUXDATA, blk->data, 426 hermes_write_bytes(hw, HERMES_AUXDATA, blk->data,
428 blklen / 2); 427 blklen);
429 428
430 blk = (struct dblock *) &blk->data[blklen]; 429 blk = (struct dblock *) &blk->data[blklen];
431 blkaddr = dblock_addr(blk); 430 blkaddr = dblock_addr(blk);
@@ -626,14 +625,11 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
626{ 625{
627 struct net_device *dev = link->priv; 626 struct net_device *dev = link->priv;
628 627
628 if (link->dev_node)
629 unregister_netdev(dev);
630
629 spectrum_cs_release(link); 631 spectrum_cs_release(link);
630 632
631 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
632 if (link->dev_node) {
633 DEBUG(0, PFX "About to unregister net device %p\n",
634 dev);
635 unregister_netdev(dev);
636 }
637 free_orinocodev(dev); 633 free_orinocodev(dev);
638} /* spectrum_cs_detach */ 634} /* spectrum_cs_detach */
639 635
@@ -653,13 +649,10 @@ spectrum_cs_config(struct pcmcia_device *link)
653 int last_fn, last_ret; 649 int last_fn, last_ret;
654 u_char buf[64]; 650 u_char buf[64];
655 config_info_t conf; 651 config_info_t conf;
656 cisinfo_t info;
657 tuple_t tuple; 652 tuple_t tuple;
658 cisparse_t parse; 653 cisparse_t parse;
659 void __iomem *mem; 654 void __iomem *mem;
660 655
661 CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info));
662
663 /* 656 /*
664 * This reads the card's CONFIG tuple to find its 657 * This reads the card's CONFIG tuple to find its
665 * configuration registers. 658 * configuration registers.
@@ -709,12 +702,6 @@ spectrum_cs_config(struct pcmcia_device *link)
709 goto next_entry; 702 goto next_entry;
710 link->conf.ConfigIndex = cfg->index; 703 link->conf.ConfigIndex = cfg->index;
711 704
712 /* Does this card need audio output? */
713 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
714 link->conf.Attributes |= CONF_ENABLE_SPKR;
715 link->conf.Status = CCSR_AUDIO_ENA;
716 }
717
718 /* Use power settings for Vcc and Vpp if present */ 705 /* Use power settings for Vcc and Vpp if present */
719 /* Note that the CIS values need to be rescaled */ 706 /* Note that the CIS values need to be rescaled */
720 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 707 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
@@ -835,19 +822,10 @@ spectrum_cs_config(struct pcmcia_device *link)
835 net_device has been registered */ 822 net_device has been registered */
836 823
837 /* Finally, report what we've done */ 824 /* Finally, report what we've done */
838 printk(KERN_DEBUG "%s: index 0x%02x: ", 825 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
839 dev->name, link->conf.ConfigIndex); 826 "0x%04x-0x%04x\n", dev->name, dev->class_dev.dev->bus_id,
840 if (link->conf.Vpp) 827 link->irq.AssignedIRQ, link->io.BasePort1,
841 printk(", Vpp %d.%d", link->conf.Vpp / 10, 828 link->io.BasePort1 + link->io.NumPorts1 - 1);
842 link->conf.Vpp % 10);
843 printk(", irq %d", link->irq.AssignedIRQ);
844 if (link->io.NumPorts1)
845 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
846 link->io.BasePort1 + link->io.NumPorts1 - 1);
847 if (link->io.NumPorts2)
848 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
849 link->io.BasePort2 + link->io.NumPorts2 - 1);
850 printk("\n");
851 829
852 return 0; 830 return 0;
853 831
@@ -888,11 +866,10 @@ spectrum_cs_suspend(struct pcmcia_device *link)
888{ 866{
889 struct net_device *dev = link->priv; 867 struct net_device *dev = link->priv;
890 struct orinoco_private *priv = netdev_priv(dev); 868 struct orinoco_private *priv = netdev_priv(dev);
891 unsigned long flags;
892 int err = 0; 869 int err = 0;
893 870
894 /* Mark the device as stopped, to block IO until later */ 871 /* Mark the device as stopped, to block IO until later */
895 spin_lock_irqsave(&priv->lock, flags); 872 spin_lock(&priv->lock);
896 873
897 err = __orinoco_down(dev); 874 err = __orinoco_down(dev);
898 if (err) 875 if (err)
@@ -902,9 +879,9 @@ spectrum_cs_suspend(struct pcmcia_device *link)
902 netif_device_detach(dev); 879 netif_device_detach(dev);
903 priv->hw_unavailable++; 880 priv->hw_unavailable++;
904 881
905 spin_unlock_irqrestore(&priv->lock, flags); 882 spin_unlock(&priv->lock);
906 883
907 return 0; 884 return err;
908} 885}
909 886
910static int 887static int
@@ -932,7 +909,7 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
932 " David Gibson <hermes@gibson.dropbear.id.au>, et al)"; 909 " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
933 910
934static struct pcmcia_device_id spectrum_cs_ids[] = { 911static struct pcmcia_device_id spectrum_cs_ids[] = {
935 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */ 912 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */
936 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */ 913 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
937 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */ 914 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
938 PCMCIA_DEVICE_NULL, 915 PCMCIA_DEVICE_NULL,
diff --git a/drivers/usb/net/zd1201.c b/drivers/net/wireless/zd1201.c
index 9b1e4ed1d07e..662ecc8a33ff 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -33,7 +33,7 @@ static struct usb_device_id zd1201_table[] = {
33 {} 33 {}
34}; 34};
35 35
36static int ap = 0; /* Are we an AP or a normal station? */ 36static int ap; /* Are we an AP or a normal station? */
37 37
38#define ZD1201_VERSION "0.15" 38#define ZD1201_VERSION "0.15"
39 39
@@ -49,7 +49,7 @@ MODULE_DEVICE_TABLE(usb, zd1201_table);
49static int zd1201_fw_upload(struct usb_device *dev, int apfw) 49static int zd1201_fw_upload(struct usb_device *dev, int apfw)
50{ 50{
51 const struct firmware *fw_entry; 51 const struct firmware *fw_entry;
52 char* data; 52 char *data;
53 unsigned long len; 53 unsigned long len;
54 int err; 54 int err;
55 unsigned char ret; 55 unsigned char ret;
@@ -65,7 +65,7 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw)
65 if (err) { 65 if (err) {
66 dev_err(&dev->dev, "Failed to load %s firmware file!\n", fwfile); 66 dev_err(&dev->dev, "Failed to load %s firmware file!\n", fwfile);
67 dev_err(&dev->dev, "Make sure the hotplug firmware loader is installed.\n"); 67 dev_err(&dev->dev, "Make sure the hotplug firmware loader is installed.\n");
68 dev_err(&dev->dev, "Goto http://linux-lc100020.sourceforge.net for more info\n"); 68 dev_err(&dev->dev, "Goto http://linux-lc100020.sourceforge.net for more info.\n");
69 return err; 69 return err;
70 } 70 }
71 71
@@ -94,12 +94,12 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw)
94 USB_DIR_OUT | 0x40, 0, 0, NULL, 0, ZD1201_FW_TIMEOUT); 94 USB_DIR_OUT | 0x40, 0, 0, NULL, 0, ZD1201_FW_TIMEOUT);
95 if (err < 0) 95 if (err < 0)
96 goto exit; 96 goto exit;
97 97
98 err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4, 98 err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4,
99 USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT); 99 USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT);
100 if (err < 0) 100 if (err < 0)
101 goto exit; 101 goto exit;
102 102
103 if (ret & 0x80) { 103 if (ret & 0x80) {
104 err = -EIO; 104 err = -EIO;
105 goto exit; 105 goto exit;
@@ -166,13 +166,13 @@ static int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0,
166 return -ENOMEM; 166 return -ENOMEM;
167 } 167 }
168 usb_fill_bulk_urb(urb, zd->usb, usb_sndbulkpipe(zd->usb, zd->endp_out2), 168 usb_fill_bulk_urb(urb, zd->usb, usb_sndbulkpipe(zd->usb, zd->endp_out2),
169 command, 16, zd1201_usbfree, zd); 169 command, 16, zd1201_usbfree, zd);
170 ret = usb_submit_urb(urb, GFP_ATOMIC); 170 ret = usb_submit_urb(urb, GFP_ATOMIC);
171 if (ret) { 171 if (ret) {
172 kfree(command); 172 kfree(command);
173 usb_free_urb(urb); 173 usb_free_urb(urb);
174 } 174 }
175 175
176 return ret; 176 return ret;
177} 177}
178 178
@@ -316,7 +316,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
316 fc = le16_to_cpu(*(__le16 *)&data[datalen-16]); 316 fc = le16_to_cpu(*(__le16 *)&data[datalen-16]);
317 seq = le16_to_cpu(*(__le16 *)&data[datalen-24]); 317 seq = le16_to_cpu(*(__le16 *)&data[datalen-24]);
318 318
319 if(zd->monitor) { 319 if (zd->monitor) {
320 if (datalen < 24) 320 if (datalen < 24)
321 goto resubmit; 321 goto resubmit;
322 if (!(skb = dev_alloc_skb(datalen+24))) 322 if (!(skb = dev_alloc_skb(datalen+24)))
@@ -364,7 +364,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
364 goto resubmit; 364 goto resubmit;
365 } 365 }
366 hlist_for_each_entry(frag, node, &zd->fraglist, fnode) 366 hlist_for_each_entry(frag, node, &zd->fraglist, fnode)
367 if(frag->seq == (seq&IEEE80211_SCTL_SEQ)) 367 if (frag->seq == (seq&IEEE80211_SCTL_SEQ))
368 break; 368 break;
369 if (!frag) 369 if (!frag)
370 goto resubmit; 370 goto resubmit;
@@ -376,7 +376,6 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
376 goto resubmit; 376 goto resubmit;
377 hlist_del_init(&frag->fnode); 377 hlist_del_init(&frag->fnode);
378 kfree(frag); 378 kfree(frag);
379 /* Fallthrough */
380 } else { 379 } else {
381 if (datalen<14) 380 if (datalen<14)
382 goto resubmit; 381 goto resubmit;
@@ -422,7 +421,7 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
422 int rid_fid; 421 int rid_fid;
423 int length; 422 int length;
424 unsigned char *pdata; 423 unsigned char *pdata;
425 424
426 zd->rxdatas = 0; 425 zd->rxdatas = 0;
427 err = zd1201_docmd(zd, ZD1201_CMDCODE_ACCESS, rid, 0, 0); 426 err = zd1201_docmd(zd, ZD1201_CMDCODE_ACCESS, rid, 0, 0);
428 if (err) 427 if (err)
@@ -471,11 +470,11 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
471 length = zd->rxlen; 470 length = zd->rxlen;
472 471
473 do { 472 do {
474 int actual_length; 473 int actual_length;
475 474
476 actual_length = (length > 64) ? 64 : length; 475 actual_length = (length > 64) ? 64 : length;
477 476
478 if(pdata[0] != 0x3) { 477 if (pdata[0] != 0x3) {
479 dev_dbg(&zd->usb->dev, "Rx Resource packet type error: %02X\n", 478 dev_dbg(&zd->usb->dev, "Rx Resource packet type error: %02X\n",
480 pdata[0]); 479 pdata[0]);
481 return -EINVAL; 480 return -EINVAL;
@@ -487,11 +486,10 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,
487 } 486 }
488 487
489 /* Skip the 4 bytes header (RID length and RID) */ 488 /* Skip the 4 bytes header (RID length and RID) */
490 if(i == 0) { 489 if (i == 0) {
491 pdata += 8; 490 pdata += 8;
492 actual_length -= 8; 491 actual_length -= 8;
493 } 492 } else {
494 else {
495 pdata += 4; 493 pdata += 4;
496 actual_length -= 4; 494 actual_length -= 4;
497 } 495 }
@@ -620,7 +618,7 @@ static int zd1201_drvr_start(struct zd1201 *zd)
620 short max; 618 short max;
621 __le16 zdmax; 619 __le16 zdmax;
622 unsigned char *buffer; 620 unsigned char *buffer;
623 621
624 buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL); 622 buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL);
625 if (!buffer) 623 if (!buffer)
626 return -ENOMEM; 624 return -ENOMEM;
@@ -632,7 +630,7 @@ static int zd1201_drvr_start(struct zd1201 *zd)
632 err = usb_submit_urb(zd->rx_urb, GFP_KERNEL); 630 err = usb_submit_urb(zd->rx_urb, GFP_KERNEL);
633 if (err) 631 if (err)
634 goto err_buffer; 632 goto err_buffer;
635 633
636 err = zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0); 634 err = zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0);
637 if (err) 635 if (err)
638 goto err_urb; 636 goto err_urb;
@@ -684,7 +682,7 @@ static int zd1201_enable(struct zd1201 *zd)
684static int zd1201_disable(struct zd1201 *zd) 682static int zd1201_disable(struct zd1201 *zd)
685{ 683{
686 int err; 684 int err;
687 685
688 if (!zd->mac_enabled) 686 if (!zd->mac_enabled)
689 return 0; 687 return 0;
690 if (zd->monitor) { 688 if (zd->monitor) {
@@ -764,7 +762,6 @@ static int zd1201_net_open(struct net_device *dev)
764static int zd1201_net_stop(struct net_device *dev) 762static int zd1201_net_stop(struct net_device *dev)
765{ 763{
766 netif_stop_queue(dev); 764 netif_stop_queue(dev);
767
768 return 0; 765 return 0;
769} 766}
770 767
@@ -915,7 +912,6 @@ static int zd1201_get_name(struct net_device *dev,
915 struct iw_request_info *info, char *name, char *extra) 912 struct iw_request_info *info, char *name, char *extra)
916{ 913{
917 strcpy(name, "IEEE 802.11b"); 914 strcpy(name, "IEEE 802.11b");
918
919 return 0; 915 return 0;
920} 916}
921 917
@@ -1013,11 +1009,10 @@ static int zd1201_set_mode(struct net_device *dev,
1013 if (err) 1009 if (err)
1014 return err; 1010 return err;
1015 } 1011 }
1016 zd->monitor=monitor; 1012 zd->monitor = monitor;
1017 /* If monitor mode is set we don't actually turn it on here since it 1013 /* If monitor mode is set we don't actually turn it on here since it
1018 * is done during mac reset anyway (see zd1201_mac_enable). 1014 * is done during mac reset anyway (see zd1201_mac_enable).
1019 */ 1015 */
1020
1021 zd1201_mac_reset(zd); 1016 zd1201_mac_reset(zd);
1022 1017
1023 return 0; 1018 return 0;
@@ -1117,7 +1112,7 @@ static int zd1201_get_wap(struct net_device *dev,
1117 zd->iwstats.qual.updated = 2; 1112 zd->iwstats.qual.updated = 2;
1118 } 1113 }
1119 1114
1120 return zd1201_getconfig(zd,ZD1201_RID_CURRENTBSSID,ap_addr->sa_data,6); 1115 return zd1201_getconfig(zd, ZD1201_RID_CURRENTBSSID, ap_addr->sa_data, 6);
1121} 1116}
1122 1117
1123static int zd1201_set_scan(struct net_device *dev, 1118static int zd1201_set_scan(struct net_device *dev,
@@ -1275,7 +1270,7 @@ static int zd1201_set_rate(struct net_device *dev,
1275 if (!rrq->fixed) { /* Also enable all lower bitrates */ 1270 if (!rrq->fixed) { /* Also enable all lower bitrates */
1276 rate |= rate-1; 1271 rate |= rate-1;
1277 } 1272 }
1278 1273
1279 err = zd1201_setconfig16(zd, ZD1201_RID_TXRATECNTL, rate); 1274 err = zd1201_setconfig16(zd, ZD1201_RID_TXRATECNTL, rate);
1280 if (err) 1275 if (err)
1281 return err; 1276 return err;
@@ -1486,7 +1481,7 @@ static int zd1201_get_encode(struct net_device *dev,
1486 return -EINVAL; 1481 return -EINVAL;
1487 1482
1488 erq->flags |= i+1; 1483 erq->flags |= i+1;
1489 1484
1490 erq->length = zd->encode_keylen[i]; 1485 erq->length = zd->encode_keylen[i];
1491 memcpy(key, zd->encode_keys[i], erq->length); 1486 memcpy(key, zd->encode_keys[i], erq->length);
1492 1487
@@ -1529,11 +1524,7 @@ static int zd1201_set_power(struct net_device *dev,
1529 return -EINVAL; 1524 return -EINVAL;
1530 } 1525 }
1531out: 1526out:
1532 err = zd1201_setconfig16(zd, ZD1201_RID_CNFPMENABLED, enabled); 1527 return zd1201_setconfig16(zd, ZD1201_RID_CNFPMENABLED, enabled);
1533 if (err)
1534 return err;
1535
1536 return 0;
1537} 1528}
1538 1529
1539static int zd1201_get_power(struct net_device *dev, 1530static int zd1201_get_power(struct net_device *dev,
@@ -1627,15 +1618,11 @@ static int zd1201_set_hostauth(struct net_device *dev,
1627 struct iw_request_info *info, struct iw_param *rrq, char *extra) 1618 struct iw_request_info *info, struct iw_param *rrq, char *extra)
1628{ 1619{
1629 struct zd1201 *zd = (struct zd1201 *)dev->priv; 1620 struct zd1201 *zd = (struct zd1201 *)dev->priv;
1630 int err;
1631 1621
1632 if (!zd->ap) 1622 if (!zd->ap)
1633 return -EOPNOTSUPP; 1623 return -EOPNOTSUPP;
1634 1624
1635 err = zd1201_setconfig16(zd, ZD1201_RID_CNFHOSTAUTH, rrq->value); 1625 return zd1201_setconfig16(zd, ZD1201_RID_CNFHOSTAUTH, rrq->value);
1636 if (err)
1637 return err;
1638 return 0;
1639} 1626}
1640 1627
1641static int zd1201_get_hostauth(struct net_device *dev, 1628static int zd1201_get_hostauth(struct net_device *dev,
@@ -1744,7 +1731,7 @@ static int zd1201_probe(struct usb_interface *interface,
1744{ 1731{
1745 struct zd1201 *zd; 1732 struct zd1201 *zd;
1746 struct usb_device *usb; 1733 struct usb_device *usb;
1747 int i, err; 1734 int err;
1748 short porttype; 1735 short porttype;
1749 char buf[IW_ESSID_MAX_SIZE+2]; 1736 char buf[IW_ESSID_MAX_SIZE+2];
1750 1737
@@ -1773,9 +1760,7 @@ static int zd1201_probe(struct usb_interface *interface,
1773 if (!zd->rx_urb || !zd->tx_urb) 1760 if (!zd->rx_urb || !zd->tx_urb)
1774 goto err_zd; 1761 goto err_zd;
1775 1762
1776 for(i = 0; i<100; i++) 1763 mdelay(100);
1777 udelay(1000);
1778
1779 err = zd1201_drvr_start(zd); 1764 err = zd1201_drvr_start(zd);
1780 if (err) 1765 if (err)
1781 goto err_zd; 1766 goto err_zd;
@@ -1833,7 +1818,7 @@ static int zd1201_probe(struct usb_interface *interface,
1833 goto err_net; 1818 goto err_net;
1834 dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n", 1819 dev_info(&usb->dev, "%s: ZD1201 USB Wireless interface\n",
1835 zd->dev->name); 1820 zd->dev->name);
1836 1821
1837 usb_set_intfdata(interface, zd); 1822 usb_set_intfdata(interface, zd);
1838 return 0; 1823 return 0;
1839 1824
diff --git a/drivers/usb/net/zd1201.h b/drivers/net/wireless/zd1201.h
index 235f0ee34b24..235f0ee34b24 100644
--- a/drivers/usb/net/zd1201.h
+++ b/drivers/net/wireless/zd1201.h
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 1456759936c5..10e1a905c144 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -285,9 +285,9 @@ static int pci_device_suspend(struct device * dev, pm_message_t state)
285 * Default resume method for devices that have no driver provided resume, 285 * Default resume method for devices that have no driver provided resume,
286 * or not even a driver at all. 286 * or not even a driver at all.
287 */ 287 */
288static void pci_default_resume(struct pci_dev *pci_dev) 288static int pci_default_resume(struct pci_dev *pci_dev)
289{ 289{
290 int retval; 290 int retval = 0;
291 291
292 /* restore the PCI config space */ 292 /* restore the PCI config space */
293 pci_restore_state(pci_dev); 293 pci_restore_state(pci_dev);
@@ -297,18 +297,21 @@ static void pci_default_resume(struct pci_dev *pci_dev)
297 /* if the device was busmaster before the suspend, make it busmaster again */ 297 /* if the device was busmaster before the suspend, make it busmaster again */
298 if (pci_dev->is_busmaster) 298 if (pci_dev->is_busmaster)
299 pci_set_master(pci_dev); 299 pci_set_master(pci_dev);
300
301 return retval;
300} 302}
301 303
302static int pci_device_resume(struct device * dev) 304static int pci_device_resume(struct device * dev)
303{ 305{
306 int error;
304 struct pci_dev * pci_dev = to_pci_dev(dev); 307 struct pci_dev * pci_dev = to_pci_dev(dev);
305 struct pci_driver * drv = pci_dev->driver; 308 struct pci_driver * drv = pci_dev->driver;
306 309
307 if (drv && drv->resume) 310 if (drv && drv->resume)
308 drv->resume(pci_dev); 311 error = drv->resume(pci_dev);
309 else 312 else
310 pci_default_resume(pci_dev); 313 error = pci_default_resume(pci_dev);
311 return 0; 314 return error;
312} 315}
313 316
314static void pci_device_shutdown(struct device *dev) 317static void pci_device_shutdown(struct device *dev)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2329f941a0dc..fde41cc14734 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -164,7 +164,6 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
164 return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap); 164 return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap);
165} 165}
166 166
167#if 0
168/** 167/**
169 * pci_find_ext_capability - Find an extended capability 168 * pci_find_ext_capability - Find an extended capability
170 * @dev: PCI device to query 169 * @dev: PCI device to query
@@ -212,7 +211,7 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap)
212 211
213 return 0; 212 return 0;
214} 213}
215#endif /* 0 */ 214EXPORT_SYMBOL_GPL(pci_find_ext_capability);
216 215
217/** 216/**
218 * pci_find_parent_resource - return resource region of parent bus of given region 217 * pci_find_parent_resource - return resource region of parent bus of given region
@@ -461,9 +460,23 @@ int
461pci_restore_state(struct pci_dev *dev) 460pci_restore_state(struct pci_dev *dev)
462{ 461{
463 int i; 462 int i;
463 int val;
464 464
465 for (i = 0; i < 16; i++) 465 /*
466 pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]); 466 * The Base Address register should be programmed before the command
467 * register(s)
468 */
469 for (i = 15; i >= 0; i--) {
470 pci_read_config_dword(dev, i * 4, &val);
471 if (val != dev->saved_config_space[i]) {
472 printk(KERN_DEBUG "PM: Writing back config space on "
473 "device %s at offset %x (was %x, writing %x)\n",
474 pci_name(dev), i,
475 val, (int)dev->saved_config_space[i]);
476 pci_write_config_dword(dev,i * 4,
477 dev->saved_config_space[i]);
478 }
479 }
467 pci_restore_msi_state(dev); 480 pci_restore_msi_state(dev);
468 pci_restore_msix_state(dev); 481 pci_restore_msix_state(dev);
469 return 0; 482 return 0;
diff --git a/drivers/s390/net/Makefile b/drivers/s390/net/Makefile
index 90d4d0ef3dd4..6775a837d646 100644
--- a/drivers/s390/net/Makefile
+++ b/drivers/s390/net/Makefile
@@ -2,7 +2,7 @@
2# S/390 network devices 2# S/390 network devices
3# 3#
4 4
5ctc-objs := ctcmain.o ctctty.o ctcdbug.o 5ctc-objs := ctcmain.o ctcdbug.o
6 6
7obj-$(CONFIG_IUCV) += iucv.o 7obj-$(CONFIG_IUCV) += iucv.o
8obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o 8obj-$(CONFIG_NETIUCV) += netiucv.o fsm.o
@@ -10,6 +10,7 @@ obj-$(CONFIG_SMSGIUCV) += smsgiucv.o
10obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o 10obj-$(CONFIG_CTC) += ctc.o fsm.o cu3088.o
11obj-$(CONFIG_LCS) += lcs.o cu3088.o 11obj-$(CONFIG_LCS) += lcs.o cu3088.o
12obj-$(CONFIG_CLAW) += claw.o cu3088.o 12obj-$(CONFIG_CLAW) += claw.o cu3088.o
13obj-$(CONFIG_MPC) += ctcmpc.o fsm.o cu3088.o
13qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o 14qeth-y := qeth_main.o qeth_mpc.o qeth_sys.o qeth_eddp.o
14qeth-$(CONFIG_PROC_FS) += qeth_proc.o 15qeth-$(CONFIG_PROC_FS) += qeth_proc.o
15obj-$(CONFIG_QETH) += qeth.o 16obj-$(CONFIG_QETH) += qeth.o
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index fe986af884f8..20c8eb16f464 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -6,7 +6,7 @@
6 * Fixes by : Jochen Röhrig (roehrig@de.ibm.com) 6 * Fixes by : Jochen Röhrig (roehrig@de.ibm.com)
7 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> 7 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
8 Peter Tiedemann (ptiedem@de.ibm.com) 8 Peter Tiedemann (ptiedem@de.ibm.com)
9 * Driver Model stuff by : Cornelia Huck <huckc@de.ibm.com> 9 * Driver Model stuff by : Cornelia Huck <cornelia.huck@de.ibm.com>
10 * 10 *
11 * Documentation used: 11 * Documentation used:
12 * - Principles of Operation (IBM doc#: SA22-7201-06) 12 * - Principles of Operation (IBM doc#: SA22-7201-06)
@@ -65,7 +65,6 @@
65 65
66#include <asm/idals.h> 66#include <asm/idals.h>
67 67
68#include "ctctty.h"
69#include "fsm.h" 68#include "fsm.h"
70#include "cu3088.h" 69#include "cu3088.h"
71 70
@@ -479,10 +478,7 @@ ctc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
479 skb->dev = pskb->dev; 478 skb->dev = pskb->dev;
480 skb->protocol = pskb->protocol; 479 skb->protocol = pskb->protocol;
481 pskb->ip_summed = CHECKSUM_UNNECESSARY; 480 pskb->ip_summed = CHECKSUM_UNNECESSARY;
482 if (ch->protocol == CTC_PROTO_LINUX_TTY) 481 netif_rx_ni(skb);
483 ctc_tty_netif_rx(skb);
484 else
485 netif_rx_ni(skb);
486 /** 482 /**
487 * Successful rx; reset logflags 483 * Successful rx; reset logflags
488 */ 484 */
@@ -557,8 +553,7 @@ ccw_unit_check(struct channel *ch, unsigned char sense)
557 DBF_TEXT(trace, 5, __FUNCTION__); 553 DBF_TEXT(trace, 5, __FUNCTION__);
558 if (sense & SNS0_INTERVENTION_REQ) { 554 if (sense & SNS0_INTERVENTION_REQ) {
559 if (sense & 0x01) { 555 if (sense & 0x01) {
560 if (ch->protocol != CTC_PROTO_LINUX_TTY) 556 ctc_pr_debug("%s: Interface disc. or Sel. reset "
561 ctc_pr_debug("%s: Interface disc. or Sel. reset "
562 "(remote)\n", ch->id); 557 "(remote)\n", ch->id);
563 fsm_event(ch->fsm, CH_EVENT_UC_RCRESET, ch); 558 fsm_event(ch->fsm, CH_EVENT_UC_RCRESET, ch);
564 } else { 559 } else {
@@ -2034,7 +2029,6 @@ static void
2034dev_action_chup(fsm_instance * fi, int event, void *arg) 2029dev_action_chup(fsm_instance * fi, int event, void *arg)
2035{ 2030{
2036 struct net_device *dev = (struct net_device *) arg; 2031 struct net_device *dev = (struct net_device *) arg;
2037 struct ctc_priv *privptr = dev->priv;
2038 2032
2039 DBF_TEXT(trace, 3, __FUNCTION__); 2033 DBF_TEXT(trace, 3, __FUNCTION__);
2040 switch (fsm_getstate(fi)) { 2034 switch (fsm_getstate(fi)) {
@@ -2049,8 +2043,6 @@ dev_action_chup(fsm_instance * fi, int event, void *arg)
2049 fsm_newstate(fi, DEV_STATE_RUNNING); 2043 fsm_newstate(fi, DEV_STATE_RUNNING);
2050 ctc_pr_info("%s: connected with remote side\n", 2044 ctc_pr_info("%s: connected with remote side\n",
2051 dev->name); 2045 dev->name);
2052 if (privptr->protocol == CTC_PROTO_LINUX_TTY)
2053 ctc_tty_setcarrier(dev, 1);
2054 ctc_clear_busy(dev); 2046 ctc_clear_busy(dev);
2055 } 2047 }
2056 break; 2048 break;
@@ -2059,8 +2051,6 @@ dev_action_chup(fsm_instance * fi, int event, void *arg)
2059 fsm_newstate(fi, DEV_STATE_RUNNING); 2051 fsm_newstate(fi, DEV_STATE_RUNNING);
2060 ctc_pr_info("%s: connected with remote side\n", 2052 ctc_pr_info("%s: connected with remote side\n",
2061 dev->name); 2053 dev->name);
2062 if (privptr->protocol == CTC_PROTO_LINUX_TTY)
2063 ctc_tty_setcarrier(dev, 1);
2064 ctc_clear_busy(dev); 2054 ctc_clear_busy(dev);
2065 } 2055 }
2066 break; 2056 break;
@@ -2086,14 +2076,10 @@ dev_action_chup(fsm_instance * fi, int event, void *arg)
2086static void 2076static void
2087dev_action_chdown(fsm_instance * fi, int event, void *arg) 2077dev_action_chdown(fsm_instance * fi, int event, void *arg)
2088{ 2078{
2089 struct net_device *dev = (struct net_device *) arg;
2090 struct ctc_priv *privptr = dev->priv;
2091 2079
2092 DBF_TEXT(trace, 3, __FUNCTION__); 2080 DBF_TEXT(trace, 3, __FUNCTION__);
2093 switch (fsm_getstate(fi)) { 2081 switch (fsm_getstate(fi)) {
2094 case DEV_STATE_RUNNING: 2082 case DEV_STATE_RUNNING:
2095 if (privptr->protocol == CTC_PROTO_LINUX_TTY)
2096 ctc_tty_setcarrier(dev, 0);
2097 if (event == DEV_EVENT_TXDOWN) 2083 if (event == DEV_EVENT_TXDOWN)
2098 fsm_newstate(fi, DEV_STATE_STARTWAIT_TX); 2084 fsm_newstate(fi, DEV_STATE_STARTWAIT_TX);
2099 else 2085 else
@@ -2397,8 +2383,6 @@ ctc_tx(struct sk_buff *skb, struct net_device * dev)
2397 */ 2383 */
2398 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) { 2384 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
2399 fsm_event(privptr->fsm, DEV_EVENT_START, dev); 2385 fsm_event(privptr->fsm, DEV_EVENT_START, dev);
2400 if (privptr->protocol == CTC_PROTO_LINUX_TTY)
2401 return -EBUSY;
2402 dev_kfree_skb(skb); 2386 dev_kfree_skb(skb);
2403 privptr->stats.tx_dropped++; 2387 privptr->stats.tx_dropped++;
2404 privptr->stats.tx_errors++; 2388 privptr->stats.tx_errors++;
@@ -2608,20 +2592,13 @@ ctc_netdev_unregister(struct net_device * dev)
2608 if (!dev) 2592 if (!dev)
2609 return; 2593 return;
2610 privptr = (struct ctc_priv *) dev->priv; 2594 privptr = (struct ctc_priv *) dev->priv;
2611 if (privptr->protocol != CTC_PROTO_LINUX_TTY) 2595 unregister_netdev(dev);
2612 unregister_netdev(dev);
2613 else
2614 ctc_tty_unregister_netdev(dev);
2615} 2596}
2616 2597
2617static int 2598static int
2618ctc_netdev_register(struct net_device * dev) 2599ctc_netdev_register(struct net_device * dev)
2619{ 2600{
2620 struct ctc_priv *privptr = (struct ctc_priv *) dev->priv; 2601 return register_netdev(dev);
2621 if (privptr->protocol != CTC_PROTO_LINUX_TTY)
2622 return register_netdev(dev);
2623 else
2624 return ctc_tty_register_netdev(dev);
2625} 2602}
2626 2603
2627static void 2604static void
@@ -2667,7 +2644,9 @@ ctc_proto_store(struct device *dev, struct device_attribute *attr, const char *b
2667 if (!priv) 2644 if (!priv)
2668 return -ENODEV; 2645 return -ENODEV;
2669 sscanf(buf, "%u", &value); 2646 sscanf(buf, "%u", &value);
2670 if ((value < 0) || (value > CTC_PROTO_MAX)) 2647 if (!((value == CTC_PROTO_S390) ||
2648 (value == CTC_PROTO_LINUX) ||
2649 (value == CTC_PROTO_OS390)))
2671 return -EINVAL; 2650 return -EINVAL;
2672 priv->protocol = value; 2651 priv->protocol = value;
2673 2652
@@ -2897,10 +2876,7 @@ ctc_new_device(struct ccwgroup_device *cgdev)
2897 goto out; 2876 goto out;
2898 } 2877 }
2899 2878
2900 if (privptr->protocol == CTC_PROTO_LINUX_TTY) 2879 strlcpy(dev->name, "ctc%d", IFNAMSIZ);
2901 strlcpy(dev->name, "ctctty%d", IFNAMSIZ);
2902 else
2903 strlcpy(dev->name, "ctc%d", IFNAMSIZ);
2904 2880
2905 for (direction = READ; direction <= WRITE; direction++) { 2881 for (direction = READ; direction <= WRITE; direction++) {
2906 privptr->channel[direction] = 2882 privptr->channel[direction] =
@@ -3046,7 +3022,6 @@ ctc_exit(void)
3046{ 3022{
3047 DBF_TEXT(setup, 3, __FUNCTION__); 3023 DBF_TEXT(setup, 3, __FUNCTION__);
3048 unregister_cu3088_discipline(&ctc_group_driver); 3024 unregister_cu3088_discipline(&ctc_group_driver);
3049 ctc_tty_cleanup();
3050 ctc_unregister_dbf_views(); 3025 ctc_unregister_dbf_views();
3051 ctc_pr_info("CTC driver unloaded\n"); 3026 ctc_pr_info("CTC driver unloaded\n");
3052} 3027}
@@ -3073,10 +3048,8 @@ ctc_init(void)
3073 ctc_pr_crit("ctc_init failed with ctc_register_dbf_views rc = %d\n", ret); 3048 ctc_pr_crit("ctc_init failed with ctc_register_dbf_views rc = %d\n", ret);
3074 return ret; 3049 return ret;
3075 } 3050 }
3076 ctc_tty_init();
3077 ret = register_cu3088_discipline(&ctc_group_driver); 3051 ret = register_cu3088_discipline(&ctc_group_driver);
3078 if (ret) { 3052 if (ret) {
3079 ctc_tty_cleanup();
3080 ctc_unregister_dbf_views(); 3053 ctc_unregister_dbf_views();
3081 } 3054 }
3082 return ret; 3055 return ret;
diff --git a/drivers/s390/net/ctcmain.h b/drivers/s390/net/ctcmain.h
index d2e835c0c134..7f305d119f3d 100644
--- a/drivers/s390/net/ctcmain.h
+++ b/drivers/s390/net/ctcmain.h
@@ -35,7 +35,9 @@
35#include <asm/ccwdev.h> 35#include <asm/ccwdev.h>
36#include <asm/ccwgroup.h> 36#include <asm/ccwgroup.h>
37 37
38#include "ctctty.h" 38#include <linux/skbuff.h>
39#include <linux/netdevice.h>
40
39#include "fsm.h" 41#include "fsm.h"
40#include "cu3088.h" 42#include "cu3088.h"
41 43
@@ -50,9 +52,7 @@
50 52
51#define CTC_PROTO_S390 0 53#define CTC_PROTO_S390 0
52#define CTC_PROTO_LINUX 1 54#define CTC_PROTO_LINUX 1
53#define CTC_PROTO_LINUX_TTY 2
54#define CTC_PROTO_OS390 3 55#define CTC_PROTO_OS390 3
55#define CTC_PROTO_MAX 3
56 56
57#define CTC_BUFSIZE_LIMIT 65535 57#define CTC_BUFSIZE_LIMIT 65535
58#define CTC_BUFSIZE_DEFAULT 32768 58#define CTC_BUFSIZE_DEFAULT 32768
@@ -257,15 +257,13 @@ static __inline__ void
257ctc_clear_busy(struct net_device * dev) 257ctc_clear_busy(struct net_device * dev)
258{ 258{
259 clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy)); 259 clear_bit(0, &(((struct ctc_priv *) dev->priv)->tbusy));
260 if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY) 260 netif_wake_queue(dev);
261 netif_wake_queue(dev);
262} 261}
263 262
264static __inline__ int 263static __inline__ int
265ctc_test_and_set_busy(struct net_device * dev) 264ctc_test_and_set_busy(struct net_device * dev)
266{ 265{
267 if (((struct ctc_priv *)dev->priv)->protocol != CTC_PROTO_LINUX_TTY) 266 netif_stop_queue(dev);
268 netif_stop_queue(dev);
269 return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy); 267 return test_and_set_bit(0, &((struct ctc_priv *) dev->priv)->tbusy);
270} 268}
271 269
diff --git a/drivers/s390/net/ctctty.c b/drivers/s390/net/ctctty.c
deleted file mode 100644
index af54d1de07bf..000000000000
--- a/drivers/s390/net/ctctty.c
+++ /dev/null
@@ -1,1259 +0,0 @@
1/*
2 * CTC / ESCON network driver, tty interface.
3 *
4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
5 * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include <linux/config.h>
24#include <linux/module.h>
25#include <linux/tty.h>
26#include <linux/tty_flip.h>
27#include <linux/serial_reg.h>
28#include <linux/interrupt.h>
29#include <linux/delay.h>
30#include <asm/uaccess.h>
31#include <linux/devfs_fs_kernel.h>
32#include "ctctty.h"
33#include "ctcdbug.h"
34
35#define CTC_TTY_MAJOR 43
36#define CTC_TTY_MAX_DEVICES 64
37
38#define CTC_ASYNC_MAGIC 0x49344C01 /* for paranoia-checking */
39#define CTC_ASYNC_INITIALIZED 0x80000000 /* port was initialized */
40#define CTC_ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device active */
41#define CTC_ASYNC_CLOSING 0x08000000 /* Serial port is closing */
42#define CTC_ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */
43#define CTC_ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */
44#define CTC_ASYNC_HUP_NOTIFY 0x0001 /* Notify tty on hangups/closes */
45#define CTC_ASYNC_NETDEV_OPEN 0x0002 /* Underlying netdev is open */
46#define CTC_ASYNC_TX_LINESTAT 0x0004 /* Must send line status */
47#define CTC_ASYNC_SPLIT_TERMIOS 0x0008 /* Sep. termios for dialin/out */
48#define CTC_TTY_XMIT_SIZE 1024 /* Default bufsize for write */
49#define CTC_SERIAL_XMIT_MAX 4000 /* Maximum bufsize for write */
50
51/* Private data (similar to async_struct in <linux/serial.h>) */
52typedef struct {
53 int magic;
54 int flags; /* defined in tty.h */
55 int mcr; /* Modem control register */
56 int msr; /* Modem status register */
57 int lsr; /* Line status register */
58 int line;
59 int count; /* # of fd on device */
60 int blocked_open; /* # of blocked opens */
61 struct net_device *netdev;
62 struct sk_buff_head tx_queue; /* transmit queue */
63 struct sk_buff_head rx_queue; /* receive queue */
64 struct tty_struct *tty; /* Pointer to corresponding tty */
65 wait_queue_head_t open_wait;
66 wait_queue_head_t close_wait;
67 struct semaphore write_sem;
68 struct tasklet_struct tasklet;
69 struct timer_list stoptimer;
70} ctc_tty_info;
71
72/* Description of one CTC-tty */
73typedef struct {
74 struct tty_driver *ctc_tty_device; /* tty-device */
75 ctc_tty_info info[CTC_TTY_MAX_DEVICES]; /* Private data */
76} ctc_tty_driver;
77
78static ctc_tty_driver *driver;
79
80/* Leave this unchanged unless you know what you do! */
81#define MODEM_PARANOIA_CHECK
82#define MODEM_DO_RESTART
83
84#define CTC_TTY_NAME "ctctty"
85
86static __u32 ctc_tty_magic = CTC_ASYNC_MAGIC;
87static int ctc_tty_shuttingdown = 0;
88
89static spinlock_t ctc_tty_lock;
90
91/* ctc_tty_try_read() is called from within ctc_tty_rcv_skb()
92 * to stuff incoming data directly into a tty's flip-buffer. If the
93 * flip buffer is full, the packet gets queued up.
94 *
95 * Return:
96 * 1 = Success
97 * 0 = Failure, data has to be buffered and later processed by
98 * ctc_tty_readmodem().
99 */
100static int
101ctc_tty_try_read(ctc_tty_info * info, struct sk_buff *skb)
102{
103 int len;
104 struct tty_struct *tty;
105
106 DBF_TEXT(trace, 5, __FUNCTION__);
107 if ((tty = info->tty)) {
108 if (info->mcr & UART_MCR_RTS) {
109 len = skb->len;
110 tty_insert_flip_string(tty, skb->data, len);
111 tty_flip_buffer_push(tty);
112 kfree_skb(skb);
113 return 1;
114 }
115 }
116 return 0;
117}
118
119/* ctc_tty_readmodem() is called periodically from within timer-interrupt.
120 * It tries getting received data from the receive queue an stuff it into
121 * the tty's flip-buffer.
122 */
123static int
124ctc_tty_readmodem(ctc_tty_info *info)
125{
126 int ret = 1;
127 struct tty_struct *tty;
128
129 DBF_TEXT(trace, 5, __FUNCTION__);
130 if ((tty = info->tty)) {
131 if (info->mcr & UART_MCR_RTS) {
132 struct sk_buff *skb;
133
134 if ((skb = skb_dequeue(&info->rx_queue))) {
135 int len = skb->len;
136 tty_insert_flip_string(tty, skb->data, len);
137 skb_pull(skb, len);
138 tty_flip_buffer_push(tty);
139 if (skb->len > 0)
140 skb_queue_head(&info->rx_queue, skb);
141 else {
142 kfree_skb(skb);
143 ret = !skb_queue_empty(&info->rx_queue);
144 }
145 }
146 }
147 }
148 return ret;
149}
150
151void
152ctc_tty_setcarrier(struct net_device *netdev, int on)
153{
154 int i;
155
156 DBF_TEXT(trace, 4, __FUNCTION__);
157 if ((!driver) || ctc_tty_shuttingdown)
158 return;
159 for (i = 0; i < CTC_TTY_MAX_DEVICES; i++)
160 if (driver->info[i].netdev == netdev) {
161 ctc_tty_info *info = &driver->info[i];
162 if (on)
163 info->msr |= UART_MSR_DCD;
164 else
165 info->msr &= ~UART_MSR_DCD;
166 if ((info->flags & CTC_ASYNC_CHECK_CD) && (!on))
167 tty_hangup(info->tty);
168 }
169}
170
171void
172ctc_tty_netif_rx(struct sk_buff *skb)
173{
174 int i;
175 ctc_tty_info *info = NULL;
176
177 DBF_TEXT(trace, 5, __FUNCTION__);
178 if (!skb)
179 return;
180 if ((!skb->dev) || (!driver) || ctc_tty_shuttingdown) {
181 dev_kfree_skb(skb);
182 return;
183 }
184 for (i = 0; i < CTC_TTY_MAX_DEVICES; i++)
185 if (driver->info[i].netdev == skb->dev) {
186 info = &driver->info[i];
187 break;
188 }
189 if (!info) {
190 dev_kfree_skb(skb);
191 return;
192 }
193 if (skb->len < 6) {
194 dev_kfree_skb(skb);
195 return;
196 }
197 if (memcmp(skb->data, &ctc_tty_magic, sizeof(__u32))) {
198 dev_kfree_skb(skb);
199 return;
200 }
201 skb_pull(skb, sizeof(__u32));
202
203 i = *((int *)skb->data);
204 skb_pull(skb, sizeof(info->mcr));
205 if (i & UART_MCR_RTS) {
206 info->msr |= UART_MSR_CTS;
207 if (info->flags & CTC_ASYNC_CTS_FLOW)
208 info->tty->hw_stopped = 0;
209 } else {
210 info->msr &= ~UART_MSR_CTS;
211 if (info->flags & CTC_ASYNC_CTS_FLOW)
212 info->tty->hw_stopped = 1;
213 }
214 if (i & UART_MCR_DTR)
215 info->msr |= UART_MSR_DSR;
216 else
217 info->msr &= ~UART_MSR_DSR;
218 if (skb->len <= 0) {
219 kfree_skb(skb);
220 return;
221 }
222 /* Try to deliver directly via tty-flip-buf if queue is empty */
223 if (skb_queue_empty(&info->rx_queue))
224 if (ctc_tty_try_read(info, skb))
225 return;
226 /* Direct deliver failed or queue wasn't empty.
227 * Queue up for later dequeueing via timer-irq.
228 */
229 skb_queue_tail(&info->rx_queue, skb);
230 /* Schedule dequeuing */
231 tasklet_schedule(&info->tasklet);
232}
233
234static int
235ctc_tty_tint(ctc_tty_info * info)
236{
237 struct sk_buff *skb = skb_dequeue(&info->tx_queue);
238 int stopped = (info->tty->hw_stopped || info->tty->stopped);
239 int wake = 1;
240 int rc;
241
242 DBF_TEXT(trace, 4, __FUNCTION__);
243 if (!info->netdev) {
244 if (skb)
245 kfree_skb(skb);
246 return 0;
247 }
248 if (info->flags & CTC_ASYNC_TX_LINESTAT) {
249 int skb_res = info->netdev->hard_header_len +
250 sizeof(info->mcr) + sizeof(__u32);
251 /* If we must update line status,
252 * create an empty dummy skb and insert it.
253 */
254 if (skb)
255 skb_queue_head(&info->tx_queue, skb);
256
257 skb = dev_alloc_skb(skb_res);
258 if (!skb) {
259 printk(KERN_WARNING
260 "ctc_tty: Out of memory in %s%d tint\n",
261 CTC_TTY_NAME, info->line);
262 return 1;
263 }
264 skb_reserve(skb, skb_res);
265 stopped = 0;
266 wake = 0;
267 }
268 if (!skb)
269 return 0;
270 if (stopped) {
271 skb_queue_head(&info->tx_queue, skb);
272 return 1;
273 }
274#if 0
275 if (skb->len > 0)
276 printk(KERN_DEBUG "tint: %d %02x\n", skb->len, *(skb->data));
277 else
278 printk(KERN_DEBUG "tint: %d STAT\n", skb->len);
279#endif
280 memcpy(skb_push(skb, sizeof(info->mcr)), &info->mcr, sizeof(info->mcr));
281 memcpy(skb_push(skb, sizeof(__u32)), &ctc_tty_magic, sizeof(__u32));
282 rc = info->netdev->hard_start_xmit(skb, info->netdev);
283 if (rc) {
284 skb_pull(skb, sizeof(info->mcr) + sizeof(__u32));
285 if (skb->len > 0)
286 skb_queue_head(&info->tx_queue, skb);
287 else
288 kfree_skb(skb);
289 } else {
290 struct tty_struct *tty = info->tty;
291
292 info->flags &= ~CTC_ASYNC_TX_LINESTAT;
293 if (tty) {
294 tty_wakeup(tty);
295 }
296 }
297 return (skb_queue_empty(&info->tx_queue) ? 0 : 1);
298}
299
300/************************************************************
301 *
302 * Modem-functions
303 *
304 * mostly "stolen" from original Linux-serial.c and friends.
305 *
306 ************************************************************/
307
308static inline int
309ctc_tty_paranoia_check(ctc_tty_info * info, char *name, const char *routine)
310{
311#ifdef MODEM_PARANOIA_CHECK
312 if (!info) {
313 printk(KERN_WARNING "ctc_tty: null info_struct for %s in %s\n",
314 name, routine);
315 return 1;
316 }
317 if (info->magic != CTC_ASYNC_MAGIC) {
318 printk(KERN_WARNING "ctc_tty: bad magic for info struct %s in %s\n",
319 name, routine);
320 return 1;
321 }
322#endif
323 return 0;
324}
325
326static void
327ctc_tty_inject(ctc_tty_info *info, char c)
328{
329 int skb_res;
330 struct sk_buff *skb;
331
332 DBF_TEXT(trace, 4, __FUNCTION__);
333 if (ctc_tty_shuttingdown)
334 return;
335 skb_res = info->netdev->hard_header_len + sizeof(info->mcr) +
336 sizeof(__u32) + 1;
337 skb = dev_alloc_skb(skb_res);
338 if (!skb) {
339 printk(KERN_WARNING
340 "ctc_tty: Out of memory in %s%d tx_inject\n",
341 CTC_TTY_NAME, info->line);
342 return;
343 }
344 skb_reserve(skb, skb_res);
345 *(skb_put(skb, 1)) = c;
346 skb_queue_head(&info->tx_queue, skb);
347 tasklet_schedule(&info->tasklet);
348}
349
350static void
351ctc_tty_transmit_status(ctc_tty_info *info)
352{
353 DBF_TEXT(trace, 5, __FUNCTION__);
354 if (ctc_tty_shuttingdown)
355 return;
356 info->flags |= CTC_ASYNC_TX_LINESTAT;
357 tasklet_schedule(&info->tasklet);
358}
359
360static void
361ctc_tty_change_speed(ctc_tty_info * info)
362{
363 unsigned int cflag;
364 unsigned int quot;
365 int i;
366
367 DBF_TEXT(trace, 3, __FUNCTION__);
368 if (!info->tty || !info->tty->termios)
369 return;
370 cflag = info->tty->termios->c_cflag;
371
372 quot = i = cflag & CBAUD;
373 if (i & CBAUDEX) {
374 i &= ~CBAUDEX;
375 if (i < 1 || i > 2)
376 info->tty->termios->c_cflag &= ~CBAUDEX;
377 else
378 i += 15;
379 }
380 if (quot) {
381 info->mcr |= UART_MCR_DTR;
382 info->mcr |= UART_MCR_RTS;
383 ctc_tty_transmit_status(info);
384 } else {
385 info->mcr &= ~UART_MCR_DTR;
386 info->mcr &= ~UART_MCR_RTS;
387 ctc_tty_transmit_status(info);
388 return;
389 }
390
391 /* CTS flow control flag and modem status interrupts */
392 if (cflag & CRTSCTS) {
393 info->flags |= CTC_ASYNC_CTS_FLOW;
394 } else
395 info->flags &= ~CTC_ASYNC_CTS_FLOW;
396 if (cflag & CLOCAL)
397 info->flags &= ~CTC_ASYNC_CHECK_CD;
398 else {
399 info->flags |= CTC_ASYNC_CHECK_CD;
400 }
401}
402
403static int
404ctc_tty_startup(ctc_tty_info * info)
405{
406 DBF_TEXT(trace, 3, __FUNCTION__);
407 if (info->flags & CTC_ASYNC_INITIALIZED)
408 return 0;
409#ifdef CTC_DEBUG_MODEM_OPEN
410 printk(KERN_DEBUG "starting up %s%d ...\n", CTC_TTY_NAME, info->line);
411#endif
412 /*
413 * Now, initialize the UART
414 */
415 info->mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
416 if (info->tty)
417 clear_bit(TTY_IO_ERROR, &info->tty->flags);
418 /*
419 * and set the speed of the serial port
420 */
421 ctc_tty_change_speed(info);
422
423 info->flags |= CTC_ASYNC_INITIALIZED;
424 if (!(info->flags & CTC_ASYNC_NETDEV_OPEN))
425 info->netdev->open(info->netdev);
426 info->flags |= CTC_ASYNC_NETDEV_OPEN;
427 return 0;
428}
429
430static void
431ctc_tty_stopdev(unsigned long data)
432{
433 ctc_tty_info *info = (ctc_tty_info *)data;
434
435 if ((!info) || (!info->netdev) ||
436 (info->flags & CTC_ASYNC_INITIALIZED))
437 return;
438 info->netdev->stop(info->netdev);
439 info->flags &= ~CTC_ASYNC_NETDEV_OPEN;
440}
441
442/*
443 * This routine will shutdown a serial port; interrupts are disabled, and
444 * DTR is dropped if the hangup on close termio flag is on.
445 */
446static void
447ctc_tty_shutdown(ctc_tty_info * info)
448{
449 DBF_TEXT(trace, 3, __FUNCTION__);
450 if (!(info->flags & CTC_ASYNC_INITIALIZED))
451 return;
452#ifdef CTC_DEBUG_MODEM_OPEN
453 printk(KERN_DEBUG "Shutting down %s%d ....\n", CTC_TTY_NAME, info->line);
454#endif
455 info->msr &= ~UART_MSR_RI;
456 if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
457 info->mcr &= ~(UART_MCR_DTR | UART_MCR_RTS);
458 if (info->tty)
459 set_bit(TTY_IO_ERROR, &info->tty->flags);
460 mod_timer(&info->stoptimer, jiffies + (10 * HZ));
461 skb_queue_purge(&info->tx_queue);
462 skb_queue_purge(&info->rx_queue);
463 info->flags &= ~CTC_ASYNC_INITIALIZED;
464}
465
466/* ctc_tty_write() is the main send-routine. It is called from the upper
467 * levels within the kernel to perform sending data. Depending on the
468 * online-flag it either directs output to the at-command-interpreter or
469 * to the lower level. Additional tasks done here:
470 * - If online, check for escape-sequence (+++)
471 * - If sending audio-data, call ctc_tty_DLEdown() to parse DLE-codes.
472 * - If receiving audio-data, call ctc_tty_end_vrx() to abort if needed.
473 * - If dialing, abort dial.
474 */
475static int
476ctc_tty_write(struct tty_struct *tty, const u_char * buf, int count)
477{
478 int c;
479 int total = 0;
480 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
481
482 DBF_TEXT(trace, 5, __FUNCTION__);
483 if (ctc_tty_shuttingdown)
484 goto ex;
485 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_write"))
486 goto ex;
487 if (!tty)
488 goto ex;
489 if (!info->netdev) {
490 total = -ENODEV;
491 goto ex;
492 }
493 while (1) {
494 struct sk_buff *skb;
495 int skb_res;
496
497 c = (count < CTC_TTY_XMIT_SIZE) ? count : CTC_TTY_XMIT_SIZE;
498 if (c <= 0)
499 break;
500
501 skb_res = info->netdev->hard_header_len + sizeof(info->mcr) +
502 + sizeof(__u32);
503 skb = dev_alloc_skb(skb_res + c);
504 if (!skb) {
505 printk(KERN_WARNING
506 "ctc_tty: Out of memory in %s%d write\n",
507 CTC_TTY_NAME, info->line);
508 break;
509 }
510 skb_reserve(skb, skb_res);
511 memcpy(skb_put(skb, c), buf, c);
512 skb_queue_tail(&info->tx_queue, skb);
513 buf += c;
514 total += c;
515 count -= c;
516 }
517 if (!skb_queue_empty(&info->tx_queue)) {
518 info->lsr &= ~UART_LSR_TEMT;
519 tasklet_schedule(&info->tasklet);
520 }
521ex:
522 DBF_TEXT(trace, 6, __FUNCTION__);
523 return total;
524}
525
526static int
527ctc_tty_write_room(struct tty_struct *tty)
528{
529 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
530
531 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_write_room"))
532 return 0;
533 return CTC_TTY_XMIT_SIZE;
534}
535
536static int
537ctc_tty_chars_in_buffer(struct tty_struct *tty)
538{
539 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
540
541 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_chars_in_buffer"))
542 return 0;
543 return 0;
544}
545
546static void
547ctc_tty_flush_buffer(struct tty_struct *tty)
548{
549 ctc_tty_info *info;
550 unsigned long flags;
551
552 DBF_TEXT(trace, 4, __FUNCTION__);
553 if (!tty)
554 goto ex;
555 spin_lock_irqsave(&ctc_tty_lock, flags);
556 info = (ctc_tty_info *) tty->driver_data;
557 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_buffer")) {
558 spin_unlock_irqrestore(&ctc_tty_lock, flags);
559 goto ex;
560 }
561 skb_queue_purge(&info->tx_queue);
562 info->lsr |= UART_LSR_TEMT;
563 spin_unlock_irqrestore(&ctc_tty_lock, flags);
564 wake_up_interruptible(&tty->write_wait);
565 tty_wakeup(tty);
566ex:
567 DBF_TEXT_(trace, 2, "ex: %s ", __FUNCTION__);
568 return;
569}
570
571static void
572ctc_tty_flush_chars(struct tty_struct *tty)
573{
574 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
575
576 DBF_TEXT(trace, 4, __FUNCTION__);
577 if (ctc_tty_shuttingdown)
578 return;
579 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_chars"))
580 return;
581 if (tty->stopped || tty->hw_stopped || skb_queue_empty(&info->tx_queue))
582 return;
583 tasklet_schedule(&info->tasklet);
584}
585
586/*
587 * ------------------------------------------------------------
588 * ctc_tty_throttle()
589 *
590 * This routine is called by the upper-layer tty layer to signal that
591 * incoming characters should be throttled.
592 * ------------------------------------------------------------
593 */
594static void
595ctc_tty_throttle(struct tty_struct *tty)
596{
597 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
598
599 DBF_TEXT(trace, 4, __FUNCTION__);
600 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_throttle"))
601 return;
602 info->mcr &= ~UART_MCR_RTS;
603 if (I_IXOFF(tty))
604 ctc_tty_inject(info, STOP_CHAR(tty));
605 ctc_tty_transmit_status(info);
606}
607
608static void
609ctc_tty_unthrottle(struct tty_struct *tty)
610{
611 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
612
613 DBF_TEXT(trace, 4, __FUNCTION__);
614 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_unthrottle"))
615 return;
616 info->mcr |= UART_MCR_RTS;
617 if (I_IXOFF(tty))
618 ctc_tty_inject(info, START_CHAR(tty));
619 ctc_tty_transmit_status(info);
620}
621
622/*
623 * ------------------------------------------------------------
624 * ctc_tty_ioctl() and friends
625 * ------------------------------------------------------------
626 */
627
628/*
629 * ctc_tty_get_lsr_info - get line status register info
630 *
631 * Purpose: Let user call ioctl() to get info when the UART physically
632 * is emptied. On bus types like RS485, the transmitter must
633 * release the bus after transmitting. This must be done when
634 * the transmit shift register is empty, not be done when the
635 * transmit holding register is empty. This functionality
636 * allows RS485 driver to be written in user space.
637 */
638static int
639ctc_tty_get_lsr_info(ctc_tty_info * info, uint __user *value)
640{
641 u_char status;
642 uint result;
643 ulong flags;
644
645 DBF_TEXT(trace, 4, __FUNCTION__);
646 spin_lock_irqsave(&ctc_tty_lock, flags);
647 status = info->lsr;
648 spin_unlock_irqrestore(&ctc_tty_lock, flags);
649 result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
650 put_user(result, value);
651 return 0;
652}
653
654
655static int ctc_tty_tiocmget(struct tty_struct *tty, struct file *file)
656{
657 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
658 u_char control,
659 status;
660 uint result;
661 ulong flags;
662
663 DBF_TEXT(trace, 4, __FUNCTION__);
664 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_ioctl"))
665 return -ENODEV;
666 if (tty->flags & (1 << TTY_IO_ERROR))
667 return -EIO;
668
669 control = info->mcr;
670 spin_lock_irqsave(&ctc_tty_lock, flags);
671 status = info->msr;
672 spin_unlock_irqrestore(&ctc_tty_lock, flags);
673 result = ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
674 | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
675 | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
676 | ((status & UART_MSR_RI) ? TIOCM_RNG : 0)
677 | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0)
678 | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
679 return result;
680}
681
682static int
683ctc_tty_tiocmset(struct tty_struct *tty, struct file *file,
684 unsigned int set, unsigned int clear)
685{
686 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
687
688 DBF_TEXT(trace, 4, __FUNCTION__);
689 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_ioctl"))
690 return -ENODEV;
691 if (tty->flags & (1 << TTY_IO_ERROR))
692 return -EIO;
693
694 if (set & TIOCM_RTS)
695 info->mcr |= UART_MCR_RTS;
696 if (set & TIOCM_DTR)
697 info->mcr |= UART_MCR_DTR;
698
699 if (clear & TIOCM_RTS)
700 info->mcr &= ~UART_MCR_RTS;
701 if (clear & TIOCM_DTR)
702 info->mcr &= ~UART_MCR_DTR;
703
704 if ((set | clear) & (TIOCM_RTS|TIOCM_DTR))
705 ctc_tty_transmit_status(info);
706 return 0;
707}
708
709static int
710ctc_tty_ioctl(struct tty_struct *tty, struct file *file,
711 uint cmd, ulong arg)
712{
713 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
714 int error;
715 int retval;
716
717 DBF_TEXT(trace, 4, __FUNCTION__);
718 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_ioctl"))
719 return -ENODEV;
720 if (tty->flags & (1 << TTY_IO_ERROR))
721 return -EIO;
722 switch (cmd) {
723 case TCSBRK: /* SVID version: non-zero arg --> no break */
724#ifdef CTC_DEBUG_MODEM_IOCTL
725 printk(KERN_DEBUG "%s%d ioctl TCSBRK\n", CTC_TTY_NAME, info->line);
726#endif
727 retval = tty_check_change(tty);
728 if (retval)
729 return retval;
730 tty_wait_until_sent(tty, 0);
731 return 0;
732 case TCSBRKP: /* support for POSIX tcsendbreak() */
733#ifdef CTC_DEBUG_MODEM_IOCTL
734 printk(KERN_DEBUG "%s%d ioctl TCSBRKP\n", CTC_TTY_NAME, info->line);
735#endif
736 retval = tty_check_change(tty);
737 if (retval)
738 return retval;
739 tty_wait_until_sent(tty, 0);
740 return 0;
741 case TIOCGSOFTCAR:
742#ifdef CTC_DEBUG_MODEM_IOCTL
743 printk(KERN_DEBUG "%s%d ioctl TIOCGSOFTCAR\n", CTC_TTY_NAME,
744 info->line);
745#endif
746 error = put_user(C_CLOCAL(tty) ? 1 : 0, (ulong __user *) arg);
747 return error;
748 case TIOCSSOFTCAR:
749#ifdef CTC_DEBUG_MODEM_IOCTL
750 printk(KERN_DEBUG "%s%d ioctl TIOCSSOFTCAR\n", CTC_TTY_NAME,
751 info->line);
752#endif
753 error = get_user(arg, (ulong __user *) arg);
754 if (error)
755 return error;
756 tty->termios->c_cflag =
757 ((tty->termios->c_cflag & ~CLOCAL) |
758 (arg ? CLOCAL : 0));
759 return 0;
760 case TIOCSERGETLSR: /* Get line status register */
761#ifdef CTC_DEBUG_MODEM_IOCTL
762 printk(KERN_DEBUG "%s%d ioctl TIOCSERGETLSR\n", CTC_TTY_NAME,
763 info->line);
764#endif
765 if (access_ok(VERIFY_WRITE, (void __user *) arg, sizeof(uint)))
766 return ctc_tty_get_lsr_info(info, (uint __user *) arg);
767 else
768 return -EFAULT;
769 default:
770#ifdef CTC_DEBUG_MODEM_IOCTL
771 printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on %s%d\n", cmd,
772 CTC_TTY_NAME, info->line);
773#endif
774 return -ENOIOCTLCMD;
775 }
776 return 0;
777}
778
779static void
780ctc_tty_set_termios(struct tty_struct *tty, struct termios *old_termios)
781{
782 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
783 unsigned int cflag = tty->termios->c_cflag;
784
785 DBF_TEXT(trace, 4, __FUNCTION__);
786 ctc_tty_change_speed(info);
787
788 /* Handle transition to B0 */
789 if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD)) {
790 info->mcr &= ~(UART_MCR_DTR|UART_MCR_RTS);
791 ctc_tty_transmit_status(info);
792 }
793
794 /* Handle transition from B0 to other */
795 if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
796 info->mcr |= UART_MCR_DTR;
797 if (!(tty->termios->c_cflag & CRTSCTS) ||
798 !test_bit(TTY_THROTTLED, &tty->flags)) {
799 info->mcr |= UART_MCR_RTS;
800 }
801 ctc_tty_transmit_status(info);
802 }
803
804 /* Handle turning off CRTSCTS */
805 if ((old_termios->c_cflag & CRTSCTS) &&
806 !(tty->termios->c_cflag & CRTSCTS))
807 tty->hw_stopped = 0;
808}
809
810/*
811 * ------------------------------------------------------------
812 * ctc_tty_open() and friends
813 * ------------------------------------------------------------
814 */
815static int
816ctc_tty_block_til_ready(struct tty_struct *tty, struct file *filp, ctc_tty_info *info)
817{
818 DECLARE_WAITQUEUE(wait, NULL);
819 int do_clocal = 0;
820 unsigned long flags;
821 int retval;
822
823 DBF_TEXT(trace, 4, __FUNCTION__);
824 /*
825 * If the device is in the middle of being closed, then block
826 * until it's done, and then try again.
827 */
828 if (tty_hung_up_p(filp) ||
829 (info->flags & CTC_ASYNC_CLOSING)) {
830 if (info->flags & CTC_ASYNC_CLOSING)
831 wait_event(info->close_wait,
832 !(info->flags & CTC_ASYNC_CLOSING));
833#ifdef MODEM_DO_RESTART
834 if (info->flags & CTC_ASYNC_HUP_NOTIFY)
835 return -EAGAIN;
836 else
837 return -ERESTARTSYS;
838#else
839 return -EAGAIN;
840#endif
841 }
842 /*
843 * If non-blocking mode is set, then make the check up front
844 * and then exit.
845 */
846 if ((filp->f_flags & O_NONBLOCK) ||
847 (tty->flags & (1 << TTY_IO_ERROR))) {
848 info->flags |= CTC_ASYNC_NORMAL_ACTIVE;
849 return 0;
850 }
851 if (tty->termios->c_cflag & CLOCAL)
852 do_clocal = 1;
853 /*
854 * Block waiting for the carrier detect and the line to become
855 * free (i.e., not in use by the callout). While we are in
856 * this loop, info->count is dropped by one, so that
857 * ctc_tty_close() knows when to free things. We restore it upon
858 * exit, either normal or abnormal.
859 */
860 retval = 0;
861 add_wait_queue(&info->open_wait, &wait);
862#ifdef CTC_DEBUG_MODEM_OPEN
863 printk(KERN_DEBUG "ctc_tty_block_til_ready before block: %s%d, count = %d\n",
864 CTC_TTY_NAME, info->line, info->count);
865#endif
866 spin_lock_irqsave(&ctc_tty_lock, flags);
867 if (!(tty_hung_up_p(filp)))
868 info->count--;
869 spin_unlock_irqrestore(&ctc_tty_lock, flags);
870 info->blocked_open++;
871 while (1) {
872 set_current_state(TASK_INTERRUPTIBLE);
873 if (tty_hung_up_p(filp) ||
874 !(info->flags & CTC_ASYNC_INITIALIZED)) {
875#ifdef MODEM_DO_RESTART
876 if (info->flags & CTC_ASYNC_HUP_NOTIFY)
877 retval = -EAGAIN;
878 else
879 retval = -ERESTARTSYS;
880#else
881 retval = -EAGAIN;
882#endif
883 break;
884 }
885 if (!(info->flags & CTC_ASYNC_CLOSING) &&
886 (do_clocal || (info->msr & UART_MSR_DCD))) {
887 break;
888 }
889 if (signal_pending(current)) {
890 retval = -ERESTARTSYS;
891 break;
892 }
893#ifdef CTC_DEBUG_MODEM_OPEN
894 printk(KERN_DEBUG "ctc_tty_block_til_ready blocking: %s%d, count = %d\n",
895 CTC_TTY_NAME, info->line, info->count);
896#endif
897 schedule();
898 }
899 current->state = TASK_RUNNING;
900 remove_wait_queue(&info->open_wait, &wait);
901 if (!tty_hung_up_p(filp))
902 info->count++;
903 info->blocked_open--;
904#ifdef CTC_DEBUG_MODEM_OPEN
905 printk(KERN_DEBUG "ctc_tty_block_til_ready after blocking: %s%d, count = %d\n",
906 CTC_TTY_NAME, info->line, info->count);
907#endif
908 if (retval)
909 return retval;
910 info->flags |= CTC_ASYNC_NORMAL_ACTIVE;
911 return 0;
912}
913
914/*
915 * This routine is called whenever a serial port is opened. It
916 * enables interrupts for a serial port, linking in its async structure into
917 * the IRQ chain. It also performs the serial-specific
918 * initialization for the tty structure.
919 */
920static int
921ctc_tty_open(struct tty_struct *tty, struct file *filp)
922{
923 ctc_tty_info *info;
924 unsigned long saveflags;
925 int retval,
926 line;
927
928 DBF_TEXT(trace, 3, __FUNCTION__);
929 line = tty->index;
930 if (line < 0 || line > CTC_TTY_MAX_DEVICES)
931 return -ENODEV;
932 info = &driver->info[line];
933 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_open"))
934 return -ENODEV;
935 if (!info->netdev)
936 return -ENODEV;
937#ifdef CTC_DEBUG_MODEM_OPEN
938 printk(KERN_DEBUG "ctc_tty_open %s, count = %d\n", tty->name,
939 info->count);
940#endif
941 spin_lock_irqsave(&ctc_tty_lock, saveflags);
942 info->count++;
943 tty->driver_data = info;
944 info->tty = tty;
945 spin_unlock_irqrestore(&ctc_tty_lock, saveflags);
946 /*
947 * Start up serial port
948 */
949 retval = ctc_tty_startup(info);
950 if (retval) {
951#ifdef CTC_DEBUG_MODEM_OPEN
952 printk(KERN_DEBUG "ctc_tty_open return after startup\n");
953#endif
954 return retval;
955 }
956 retval = ctc_tty_block_til_ready(tty, filp, info);
957 if (retval) {
958#ifdef CTC_DEBUG_MODEM_OPEN
959 printk(KERN_DEBUG "ctc_tty_open return after ctc_tty_block_til_ready \n");
960#endif
961 return retval;
962 }
963#ifdef CTC_DEBUG_MODEM_OPEN
964 printk(KERN_DEBUG "ctc_tty_open %s successful...\n", tty->name);
965#endif
966 return 0;
967}
968
969static void
970ctc_tty_close(struct tty_struct *tty, struct file *filp)
971{
972 ctc_tty_info *info = (ctc_tty_info *) tty->driver_data;
973 ulong flags;
974 ulong timeout;
975 DBF_TEXT(trace, 3, __FUNCTION__);
976 if (!info || ctc_tty_paranoia_check(info, tty->name, "ctc_tty_close"))
977 return;
978 spin_lock_irqsave(&ctc_tty_lock, flags);
979 if (tty_hung_up_p(filp)) {
980 spin_unlock_irqrestore(&ctc_tty_lock, flags);
981#ifdef CTC_DEBUG_MODEM_OPEN
982 printk(KERN_DEBUG "ctc_tty_close return after tty_hung_up_p\n");
983#endif
984 return;
985 }
986 if ((tty->count == 1) && (info->count != 1)) {
987 /*
988 * Uh, oh. tty->count is 1, which means that the tty
989 * structure will be freed. Info->count should always
990 * be one in these conditions. If it's greater than
991 * one, we've got real problems, since it means the
992 * serial port won't be shutdown.
993 */
994 printk(KERN_ERR "ctc_tty_close: bad port count; tty->count is 1, "
995 "info->count is %d\n", info->count);
996 info->count = 1;
997 }
998 if (--info->count < 0) {
999 printk(KERN_ERR "ctc_tty_close: bad port count for %s%d: %d\n",
1000 CTC_TTY_NAME, info->line, info->count);
1001 info->count = 0;
1002 }
1003 if (info->count) {
1004 local_irq_restore(flags);
1005#ifdef CTC_DEBUG_MODEM_OPEN
1006 printk(KERN_DEBUG "ctc_tty_close after info->count != 0\n");
1007#endif
1008 return;
1009 }
1010 info->flags |= CTC_ASYNC_CLOSING;
1011 tty->closing = 1;
1012 /*
1013 * At this point we stop accepting input. To do this, we
1014 * disable the receive line status interrupts, and tell the
1015 * interrupt driver to stop checking the data ready bit in the
1016 * line status register.
1017 */
1018 if (info->flags & CTC_ASYNC_INITIALIZED) {
1019 tty_wait_until_sent(tty, 30*HZ); /* 30 seconds timeout */
1020 /*
1021 * Before we drop DTR, make sure the UART transmitter
1022 * has completely drained; this is especially
1023 * important if there is a transmit FIFO!
1024 */
1025 timeout = jiffies + HZ;
1026 while (!(info->lsr & UART_LSR_TEMT)) {
1027 spin_unlock_irqrestore(&ctc_tty_lock, flags);
1028 msleep(500);
1029 spin_lock_irqsave(&ctc_tty_lock, flags);
1030 if (time_after(jiffies,timeout))
1031 break;
1032 }
1033 }
1034 ctc_tty_shutdown(info);
1035 if (tty->driver->flush_buffer) {
1036 skb_queue_purge(&info->tx_queue);
1037 info->lsr |= UART_LSR_TEMT;
1038 }
1039 tty_ldisc_flush(tty);
1040 info->tty = 0;
1041 tty->closing = 0;
1042 if (info->blocked_open) {
1043 msleep_interruptible(500);
1044 wake_up_interruptible(&info->open_wait);
1045 }
1046 info->flags &= ~(CTC_ASYNC_NORMAL_ACTIVE | CTC_ASYNC_CLOSING);
1047 wake_up_interruptible(&info->close_wait);
1048 spin_unlock_irqrestore(&ctc_tty_lock, flags);
1049#ifdef CTC_DEBUG_MODEM_OPEN
1050 printk(KERN_DEBUG "ctc_tty_close normal exit\n");
1051#endif
1052}
1053
1054/*
1055 * ctc_tty_hangup() --- called by tty_hangup() when a hangup is signaled.
1056 */
1057static void
1058ctc_tty_hangup(struct tty_struct *tty)
1059{
1060 ctc_tty_info *info = (ctc_tty_info *)tty->driver_data;
1061 unsigned long saveflags;
1062 DBF_TEXT(trace, 3, __FUNCTION__);
1063 if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_hangup"))
1064 return;
1065 ctc_tty_shutdown(info);
1066 info->count = 0;
1067 info->flags &= ~CTC_ASYNC_NORMAL_ACTIVE;
1068 spin_lock_irqsave(&ctc_tty_lock, saveflags);
1069 info->tty = 0;
1070 spin_unlock_irqrestore(&ctc_tty_lock, saveflags);
1071 wake_up_interruptible(&info->open_wait);
1072}
1073
1074
1075/*
1076 * For all online tty's, try sending data to
1077 * the lower levels.
1078 */
1079static void
1080ctc_tty_task(unsigned long arg)
1081{
1082 ctc_tty_info *info = (void *)arg;
1083 unsigned long saveflags;
1084 int again;
1085
1086 DBF_TEXT(trace, 3, __FUNCTION__);
1087 spin_lock_irqsave(&ctc_tty_lock, saveflags);
1088 if ((!ctc_tty_shuttingdown) && info) {
1089 again = ctc_tty_tint(info);
1090 if (!again)
1091 info->lsr |= UART_LSR_TEMT;
1092 again |= ctc_tty_readmodem(info);
1093 if (again) {
1094 tasklet_schedule(&info->tasklet);
1095 }
1096 }
1097 spin_unlock_irqrestore(&ctc_tty_lock, saveflags);
1098}
1099
1100static struct tty_operations ctc_ops = {
1101 .open = ctc_tty_open,
1102 .close = ctc_tty_close,
1103 .write = ctc_tty_write,
1104 .flush_chars = ctc_tty_flush_chars,
1105 .write_room = ctc_tty_write_room,
1106 .chars_in_buffer = ctc_tty_chars_in_buffer,
1107 .flush_buffer = ctc_tty_flush_buffer,
1108 .ioctl = ctc_tty_ioctl,
1109 .throttle = ctc_tty_throttle,
1110 .unthrottle = ctc_tty_unthrottle,
1111 .set_termios = ctc_tty_set_termios,
1112 .hangup = ctc_tty_hangup,
1113 .tiocmget = ctc_tty_tiocmget,
1114 .tiocmset = ctc_tty_tiocmset,
1115};
1116
1117int
1118ctc_tty_init(void)
1119{
1120 int i;
1121 ctc_tty_info *info;
1122 struct tty_driver *device;
1123
1124 DBF_TEXT(trace, 2, __FUNCTION__);
1125 driver = kmalloc(sizeof(ctc_tty_driver), GFP_KERNEL);
1126 if (driver == NULL) {
1127 printk(KERN_WARNING "Out of memory in ctc_tty_modem_init\n");
1128 return -ENOMEM;
1129 }
1130 memset(driver, 0, sizeof(ctc_tty_driver));
1131 device = alloc_tty_driver(CTC_TTY_MAX_DEVICES);
1132 if (!device) {
1133 kfree(driver);
1134 printk(KERN_WARNING "Out of memory in ctc_tty_modem_init\n");
1135 return -ENOMEM;
1136 }
1137
1138 device->devfs_name = "ctc/" CTC_TTY_NAME;
1139 device->name = CTC_TTY_NAME;
1140 device->major = CTC_TTY_MAJOR;
1141 device->minor_start = 0;
1142 device->type = TTY_DRIVER_TYPE_SERIAL;
1143 device->subtype = SERIAL_TYPE_NORMAL;
1144 device->init_termios = tty_std_termios;
1145 device->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1146 device->flags = TTY_DRIVER_REAL_RAW;
1147 device->driver_name = "ctc_tty",
1148 tty_set_operations(device, &ctc_ops);
1149 if (tty_register_driver(device)) {
1150 printk(KERN_WARNING "ctc_tty: Couldn't register serial-device\n");
1151 put_tty_driver(device);
1152 kfree(driver);
1153 return -1;
1154 }
1155 driver->ctc_tty_device = device;
1156 for (i = 0; i < CTC_TTY_MAX_DEVICES; i++) {
1157 info = &driver->info[i];
1158 init_MUTEX(&info->write_sem);
1159 tasklet_init(&info->tasklet, ctc_tty_task,
1160 (unsigned long) info);
1161 info->magic = CTC_ASYNC_MAGIC;
1162 info->line = i;
1163 info->tty = 0;
1164 info->count = 0;
1165 info->blocked_open = 0;
1166 init_waitqueue_head(&info->open_wait);
1167 init_waitqueue_head(&info->close_wait);
1168 skb_queue_head_init(&info->tx_queue);
1169 skb_queue_head_init(&info->rx_queue);
1170 init_timer(&info->stoptimer);
1171 info->stoptimer.function = ctc_tty_stopdev;
1172 info->stoptimer.data = (unsigned long)info;
1173 info->mcr = UART_MCR_RTS;
1174 }
1175 return 0;
1176}
1177
1178int
1179ctc_tty_register_netdev(struct net_device *dev) {
1180 int ttynum;
1181 char *err;
1182 char *p;
1183
1184 DBF_TEXT(trace, 2, __FUNCTION__);
1185 if ((!dev) || (!dev->name)) {
1186 printk(KERN_WARNING
1187 "ctc_tty_register_netdev called "
1188 "with NULL dev or NULL dev-name\n");
1189 return -1;
1190 }
1191
1192 /*
1193 * If the name is a format string the caller wants us to
1194 * do a name allocation : format string must end with %d
1195 */
1196 if (strchr(dev->name, '%'))
1197 {
1198 int err = dev_alloc_name(dev, dev->name); // dev->name is changed by this
1199 if (err < 0) {
1200 printk(KERN_DEBUG "dev_alloc returned error %d\n", err);
1201 return err;
1202 }
1203
1204 }
1205
1206 for (p = dev->name; p && ((*p < '0') || (*p > '9')); p++);
1207 ttynum = simple_strtoul(p, &err, 0);
1208 if ((ttynum < 0) || (ttynum >= CTC_TTY_MAX_DEVICES) ||
1209 (err && *err)) {
1210 printk(KERN_WARNING
1211 "ctc_tty_register_netdev called "
1212 "with number in name '%s'\n", dev->name);
1213 return -1;
1214 }
1215 if (driver->info[ttynum].netdev) {
1216 printk(KERN_WARNING
1217 "ctc_tty_register_netdev called "
1218 "for already registered device '%s'\n",
1219 dev->name);
1220 return -1;
1221 }
1222 driver->info[ttynum].netdev = dev;
1223 return 0;
1224}
1225
1226void
1227ctc_tty_unregister_netdev(struct net_device *dev) {
1228 int i;
1229 unsigned long saveflags;
1230 ctc_tty_info *info = NULL;
1231
1232 DBF_TEXT(trace, 2, __FUNCTION__);
1233 spin_lock_irqsave(&ctc_tty_lock, saveflags);
1234 for (i = 0; i < CTC_TTY_MAX_DEVICES; i++)
1235 if (driver->info[i].netdev == dev) {
1236 info = &driver->info[i];
1237 break;
1238 }
1239 if (info) {
1240 info->netdev = NULL;
1241 skb_queue_purge(&info->tx_queue);
1242 skb_queue_purge(&info->rx_queue);
1243 }
1244 spin_unlock_irqrestore(&ctc_tty_lock, saveflags);
1245}
1246
1247void
1248ctc_tty_cleanup(void) {
1249 unsigned long saveflags;
1250
1251 DBF_TEXT(trace, 2, __FUNCTION__);
1252 spin_lock_irqsave(&ctc_tty_lock, saveflags);
1253 ctc_tty_shuttingdown = 1;
1254 spin_unlock_irqrestore(&ctc_tty_lock, saveflags);
1255 tty_unregister_driver(driver->ctc_tty_device);
1256 put_tty_driver(driver->ctc_tty_device);
1257 kfree(driver);
1258 driver = NULL;
1259}
diff --git a/drivers/s390/net/ctctty.h b/drivers/s390/net/ctctty.h
deleted file mode 100644
index 7254dc006311..000000000000
--- a/drivers/s390/net/ctctty.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * CTC / ESCON network driver, tty interface.
3 *
4 * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
5 * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef _CTCTTY_H_
23#define _CTCTTY_H_
24
25#include <linux/skbuff.h>
26#include <linux/netdevice.h>
27
28extern int ctc_tty_register_netdev(struct net_device *);
29extern void ctc_tty_unregister_netdev(struct net_device *);
30extern void ctc_tty_netif_rx(struct sk_buff *);
31extern int ctc_tty_init(void);
32extern void ctc_tty_cleanup(void);
33extern void ctc_tty_setcarrier(struct net_device *, int);
34
35#endif
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index b046ffa22101..de9ba7890b5a 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -4297,6 +4297,7 @@ static int ata_start_drive(struct ata_port *ap, struct ata_device *dev)
4297int ata_device_resume(struct ata_port *ap, struct ata_device *dev) 4297int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
4298{ 4298{
4299 if (ap->flags & ATA_FLAG_SUSPENDED) { 4299 if (ap->flags & ATA_FLAG_SUSPENDED) {
4300 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
4300 ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 200000); 4301 ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 200000);
4301 ap->flags &= ~ATA_FLAG_SUSPENDED; 4302 ap->flags &= ~ATA_FLAG_SUSPENDED;
4302 ata_set_mode(ap); 4303 ata_set_mode(ap);
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 9b8bca1ac1f0..f16f92a6ec0f 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -2035,6 +2035,7 @@ static void mv_phy_reset(struct ata_port *ap)
2035static void mv_eng_timeout(struct ata_port *ap) 2035static void mv_eng_timeout(struct ata_port *ap)
2036{ 2036{
2037 struct ata_queued_cmd *qc; 2037 struct ata_queued_cmd *qc;
2038 unsigned long flags;
2038 2039
2039 printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id); 2040 printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id);
2040 DPRINTK("All regs @ start of eng_timeout\n"); 2041 DPRINTK("All regs @ start of eng_timeout\n");
@@ -2046,8 +2047,10 @@ static void mv_eng_timeout(struct ata_port *ap)
2046 ap->host_set->mmio_base, ap, qc, qc->scsicmd, 2047 ap->host_set->mmio_base, ap, qc, qc->scsicmd,
2047 &qc->scsicmd->cmnd); 2048 &qc->scsicmd->cmnd);
2048 2049
2050 spin_lock_irqsave(&ap->host_set->lock, flags);
2049 mv_err_intr(ap, 0); 2051 mv_err_intr(ap, 0);
2050 mv_stop_and_reset(ap); 2052 mv_stop_and_reset(ap);
2053 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2051 2054
2052 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); 2055 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
2053 if (qc->flags & ATA_QCFLAG_ACTIVE) { 2056 if (qc->flags & ATA_QCFLAG_ACTIVE) {
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index acde8868da21..fafe7c1265b3 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -185,6 +185,9 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
185 /* Select Power Management Mode */ 185 /* Select Power Management Mode */
186 pxa27x_ohci_select_pmm(inf->port_mode); 186 pxa27x_ohci_select_pmm(inf->port_mode);
187 187
188 if (inf->power_budget)
189 hcd->power_budget = inf->power_budget;
190
188 ohci_hcd_init(hcd_to_ohci(hcd)); 191 ohci_hcd_init(hcd_to_ohci(hcd));
189 192
190 retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT); 193 retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT);
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index efd6ca7e4ac5..054059632a21 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -301,21 +301,4 @@ config USB_NET_ZAURUS
301 some cases CDC MDLM) protocol, not "g_ether". 301 some cases CDC MDLM) protocol, not "g_ether".
302 302
303 303
304config USB_ZD1201
305 tristate "USB ZD1201 based Wireless device support"
306 depends on NET_RADIO
307 select FW_LOADER
308 ---help---
309 Say Y if you want to use wireless LAN adapters based on the ZyDAS
310 ZD1201 chip.
311
312 This driver makes the adapter appear as a normal Ethernet interface,
313 typically on wlan0.
314
315 The zd1201 device requires external firmware to be loaded.
316 This can be found at http://linux-lc100020.sourceforge.net/
317
318 To compile this driver as a module, choose M here: the
319 module will be called zd1201.
320
321endmenu 304endmenu
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
index a21e6eaabaf6..160f19dbdf12 100644
--- a/drivers/usb/net/Makefile
+++ b/drivers/usb/net/Makefile
@@ -15,7 +15,6 @@ obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o
15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o 15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o 16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
17obj-$(CONFIG_USB_USBNET) += usbnet.o 17obj-$(CONFIG_USB_USBNET) += usbnet.o
18obj-$(CONFIG_USB_ZD1201) += zd1201.o
19 18
20ifeq ($(CONFIG_USB_DEBUG),y) 19ifeq ($(CONFIG_USB_DEBUG),y)
21EXTRA_CFLAGS += -DDEBUG 20EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4587087d777a..5641498725d0 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -743,7 +743,7 @@ config FB_I810_I2C
743 743
744config FB_INTEL 744config FB_INTEL
745 tristate "Intel 830M/845G/852GM/855GM/865G support (EXPERIMENTAL)" 745 tristate "Intel 830M/845G/852GM/855GM/865G support (EXPERIMENTAL)"
746 depends on FB && EXPERIMENTAL && PCI && X86_32 746 depends on FB && EXPERIMENTAL && PCI && X86
747 select AGP 747 select AGP
748 select AGP_INTEL 748 select AGP_INTEL
749 select FB_MODE_HELPERS 749 select FB_MODE_HELPERS
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
index da29d007f215..469b06c29180 100644
--- a/drivers/video/intelfb/intelfb.h
+++ b/drivers/video/intelfb/intelfb.h
@@ -8,9 +8,9 @@
8 8
9 9
10/*** Version/name ***/ 10/*** Version/name ***/
11#define INTELFB_VERSION "0.9.2" 11#define INTELFB_VERSION "0.9.4"
12#define INTELFB_MODULE_NAME "intelfb" 12#define INTELFB_MODULE_NAME "intelfb"
13#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM" 13#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM"
14 14
15 15
16/*** Debug/feature defines ***/ 16/*** Debug/feature defines ***/
@@ -52,11 +52,14 @@
52#define PCI_DEVICE_ID_INTEL_865G 0x2572 52#define PCI_DEVICE_ID_INTEL_865G 0x2572
53#define PCI_DEVICE_ID_INTEL_915G 0x2582 53#define PCI_DEVICE_ID_INTEL_915G 0x2582
54#define PCI_DEVICE_ID_INTEL_915GM 0x2592 54#define PCI_DEVICE_ID_INTEL_915GM 0x2592
55#define PCI_DEVICE_ID_INTEL_945G 0x2772
56#define PCI_DEVICE_ID_INTEL_945GM 0x27A2
55 57
56/* Size of MMIO region */ 58/* Size of MMIO region */
57#define INTEL_REG_SIZE 0x80000 59#define INTEL_REG_SIZE 0x80000
58 60
59#define STRIDE_ALIGNMENT 16 61#define STRIDE_ALIGNMENT 16
62#define STRIDE_ALIGNMENT_I9XX 64
60 63
61#define PALETTE_8_ENTRIES 256 64#define PALETTE_8_ENTRIES 256
62 65
@@ -125,7 +128,9 @@ enum intel_chips {
125 INTEL_855GME, 128 INTEL_855GME,
126 INTEL_865G, 129 INTEL_865G,
127 INTEL_915G, 130 INTEL_915G,
128 INTEL_915GM 131 INTEL_915GM,
132 INTEL_945G,
133 INTEL_945GM,
129}; 134};
130 135
131struct intelfb_hwstate { 136struct intelfb_hwstate {
@@ -277,8 +282,13 @@ struct intelfb_info {
277 282
278 /* driver registered */ 283 /* driver registered */
279 int registered; 284 int registered;
285
286 /* index into plls */
287 int pll_index;
280}; 288};
281 289
290#define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G)||(dinfo->chipset == INTEL_915GM)||((dinfo)->chipset == INTEL_945G)||(dinfo->chipset==INTEL_945GM))
291
282/*** function prototypes ***/ 292/*** function prototypes ***/
283 293
284extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var); 294extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 995b47c165a7..076fa56be192 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -1,11 +1,12 @@
1/* 1/*
2 * intelfb 2 * intelfb
3 * 3 *
4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM 4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/
5 * integrated graphics chips. 5 * 945G/945GM integrated graphics chips.
6 * 6 *
7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org> 7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
8 * 2004 Sylvain Meyer 8 * 2004 Sylvain Meyer
9 * 2006 David Airlie
9 * 10 *
10 * This driver consists of two parts. The first part (intelfbdrv.c) provides 11 * This driver consists of two parts. The first part (intelfbdrv.c) provides
11 * the basic fbdev interfaces, is derived in part from the radeonfb and 12 * the basic fbdev interfaces, is derived in part from the radeonfb and
@@ -131,6 +132,7 @@
131 132
132#include "intelfb.h" 133#include "intelfb.h"
133#include "intelfbhw.h" 134#include "intelfbhw.h"
135#include "../edid.h"
134 136
135static void __devinit get_initial_mode(struct intelfb_info *dinfo); 137static void __devinit get_initial_mode(struct intelfb_info *dinfo);
136static void update_dinfo(struct intelfb_info *dinfo, 138static void update_dinfo(struct intelfb_info *dinfo,
@@ -182,6 +184,8 @@ static struct pci_device_id intelfb_pci_table[] __devinitdata = {
182 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G }, 184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_865G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_865G },
183 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915G }, 185 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915G },
184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM }, 186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM },
187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G },
188 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM },
185 { 0, } 189 { 0, }
186}; 190};
187 191
@@ -261,7 +265,7 @@ MODULE_PARM_DESC(mode,
261 265
262#ifndef MODULE 266#ifndef MODULE
263#define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name))) 267#define OPT_EQUAL(opt, name) (!strncmp(opt, name, strlen(name)))
264#define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name), NULL, 0) 268#define OPT_INTVAL(opt, name) simple_strtoul(opt + strlen(name) + 1, NULL, 0)
265#define OPT_STRVAL(opt, name) (opt + strlen(name)) 269#define OPT_STRVAL(opt, name) (opt + strlen(name))
266 270
267static __inline__ char * 271static __inline__ char *
@@ -546,11 +550,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
546 550
547 /* Set base addresses. */ 551 /* Set base addresses. */
548 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) || 552 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) ||
549 (ent->device == PCI_DEVICE_ID_INTEL_915GM)) { 553 (ent->device == PCI_DEVICE_ID_INTEL_915GM) ||
554 (ent->device == PCI_DEVICE_ID_INTEL_945G) ||
555 (ent->device == PCI_DEVICE_ID_INTEL_945GM)) {
550 aperture_bar = 2; 556 aperture_bar = 2;
551 mmio_bar = 0; 557 mmio_bar = 0;
552 /* Disable HW cursor on 915G/M (not implemented yet) */
553 hwcursor = 0;
554 } 558 }
555 dinfo->aperture.physical = pci_resource_start(pdev, aperture_bar); 559 dinfo->aperture.physical = pci_resource_start(pdev, aperture_bar);
556 dinfo->aperture.size = pci_resource_len(pdev, aperture_bar); 560 dinfo->aperture.size = pci_resource_len(pdev, aperture_bar);
@@ -584,8 +588,7 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
584 /* Get the chipset info. */ 588 /* Get the chipset info. */
585 dinfo->pci_chipset = pdev->device; 589 dinfo->pci_chipset = pdev->device;
586 590
587 if (intelfbhw_get_chipset(pdev, &dinfo->name, &dinfo->chipset, 591 if (intelfbhw_get_chipset(pdev, dinfo)) {
588 &dinfo->mobile)) {
589 cleanup(dinfo); 592 cleanup(dinfo);
590 return -ENODEV; 593 return -ENODEV;
591 } 594 }
@@ -1029,17 +1032,44 @@ intelfb_init_var(struct intelfb_info *dinfo)
1029 sizeof(struct fb_var_screeninfo)); 1032 sizeof(struct fb_var_screeninfo));
1030 msrc = 5; 1033 msrc = 5;
1031 } else { 1034 } else {
1035 const u8 *edid_s = fb_firmware_edid(&dinfo->pdev->dev);
1036 u8 *edid_d = NULL;
1037
1038 if (edid_s) {
1039 edid_d = kmalloc(EDID_LENGTH, GFP_KERNEL);
1040
1041 if (edid_d) {
1042 memcpy(edid_d, edid_s, EDID_LENGTH);
1043 fb_edid_to_monspecs(edid_d,
1044 &dinfo->info->monspecs);
1045 kfree(edid_d);
1046 }
1047 }
1048
1032 if (mode) { 1049 if (mode) {
1050 printk("intelfb: Looking for mode in private "
1051 "database\n");
1033 msrc = fb_find_mode(var, dinfo->info, mode, 1052 msrc = fb_find_mode(var, dinfo->info, mode,
1034 vesa_modes, VESA_MODEDB_SIZE, 1053 dinfo->info->monspecs.modedb,
1054 dinfo->info->monspecs.modedb_len,
1035 NULL, 0); 1055 NULL, 0);
1036 if (msrc) 1056
1037 msrc |= 8; 1057 if (msrc && msrc > 1) {
1058 printk("intelfb: No mode in private database, "
1059 "intelfb: looking for mode in global "
1060 "database ");
1061 msrc = fb_find_mode(var, dinfo->info, mode,
1062 NULL, 0, NULL, 0);
1063
1064 if (msrc)
1065 msrc |= 8;
1066 }
1067
1038 } 1068 }
1069
1039 if (!msrc) { 1070 if (!msrc) {
1040 msrc = fb_find_mode(var, dinfo->info, PREFERRED_MODE, 1071 msrc = fb_find_mode(var, dinfo->info, PREFERRED_MODE,
1041 vesa_modes, VESA_MODEDB_SIZE, 1072 NULL, 0, NULL, 0);
1042 NULL, 0);
1043 } 1073 }
1044 } 1074 }
1045 1075
@@ -1139,7 +1169,10 @@ update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var)
1139 } 1169 }
1140 1170
1141 /* Make sure the line length is a aligned correctly. */ 1171 /* Make sure the line length is a aligned correctly. */
1142 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT); 1172 if (IS_I9XX(dinfo))
1173 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT_I9XX);
1174 else
1175 dinfo->pitch = ROUND_UP_TO(dinfo->pitch, STRIDE_ALIGNMENT);
1143 1176
1144 if (FIXED_MODE(dinfo)) 1177 if (FIXED_MODE(dinfo))
1145 dinfo->pitch = dinfo->initial_pitch; 1178 dinfo->pitch = dinfo->initial_pitch;
@@ -1162,16 +1195,33 @@ intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
1162 struct fb_var_screeninfo v; 1195 struct fb_var_screeninfo v;
1163 struct intelfb_info *dinfo; 1196 struct intelfb_info *dinfo;
1164 static int first = 1; 1197 static int first = 1;
1198 int i;
1199 /* Good pitches to allow tiling. Don't care about pitches < 1024. */
1200 static const int pitches[] = {
1201 128 * 8,
1202 128 * 16,
1203 128 * 32,
1204 128 * 64,
1205 0
1206 };
1165 1207
1166 DBG_MSG("intelfb_check_var: accel_flags is %d\n", var->accel_flags); 1208 DBG_MSG("intelfb_check_var: accel_flags is %d\n", var->accel_flags);
1167 1209
1168 dinfo = GET_DINFO(info); 1210 dinfo = GET_DINFO(info);
1169 1211
1212 /* update the pitch */
1170 if (intelfbhw_validate_mode(dinfo, var) != 0) 1213 if (intelfbhw_validate_mode(dinfo, var) != 0)
1171 return -EINVAL; 1214 return -EINVAL;
1172 1215
1173 v = *var; 1216 v = *var;
1174 1217
1218 for (i = 0; pitches[i] != 0; i++) {
1219 if (pitches[i] >= v.xres_virtual) {
1220 v.xres_virtual = pitches[i];
1221 break;
1222 }
1223 }
1224
1175 /* Check for a supported bpp. */ 1225 /* Check for a supported bpp. */
1176 if (v.bits_per_pixel <= 8) { 1226 if (v.bits_per_pixel <= 8) {
1177 v.bits_per_pixel = 8; 1227 v.bits_per_pixel = 8;
@@ -1467,7 +1517,7 @@ static int
1467intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) 1517intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1468{ 1518{
1469 struct intelfb_info *dinfo = GET_DINFO(info); 1519 struct intelfb_info *dinfo = GET_DINFO(info);
1470 1520 u32 physical;
1471#if VERBOSE > 0 1521#if VERBOSE > 0
1472 DBG_MSG("intelfb_cursor\n"); 1522 DBG_MSG("intelfb_cursor\n");
1473#endif 1523#endif
@@ -1478,7 +1528,10 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1478 intelfbhw_cursor_hide(dinfo); 1528 intelfbhw_cursor_hide(dinfo);
1479 1529
1480 /* If XFree killed the cursor - restore it */ 1530 /* If XFree killed the cursor - restore it */
1481 if (INREG(CURSOR_A_BASEADDR) != dinfo->cursor.offset << 12) { 1531 physical = (dinfo->mobile || IS_I9XX(dinfo)) ? dinfo->cursor.physical :
1532 (dinfo->cursor.offset << 12);
1533
1534 if (INREG(CURSOR_A_BASEADDR) != physical) {
1482 u32 fg, bg; 1535 u32 fg, bg;
1483 1536
1484 DBG_MSG("the cursor was killed - restore it !!\n"); 1537 DBG_MSG("the cursor was killed - restore it !!\n");
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index 624c4bc96f0d..426b7430b125 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -40,68 +40,110 @@
40#include "intelfb.h" 40#include "intelfb.h"
41#include "intelfbhw.h" 41#include "intelfbhw.h"
42 42
43struct pll_min_max {
44 int min_m, max_m, min_m1, max_m1;
45 int min_m2, max_m2, min_n, max_n;
46 int min_p, max_p, min_p1, max_p1;
47 int min_vco, max_vco, p_transition_clk, ref_clk;
48 int p_inc_lo, p_inc_hi;
49};
50
51#define PLLS_I8xx 0
52#define PLLS_I9xx 1
53#define PLLS_MAX 2
54
55static struct pll_min_max plls[PLLS_MAX] = {
56 { 108, 140, 18, 26,
57 6, 16, 3, 16,
58 4, 128, 0, 31,
59 930000, 1400000, 165000, 48000,
60 4, 2 }, //I8xx
61
62 { 75, 120, 10, 20,
63 5, 9, 4, 7,
64 5, 80, 1, 8,
65 1400000, 2800000, 200000, 96000,
66 10, 5 } //I9xx
67};
68
43int 69int
44intelfbhw_get_chipset(struct pci_dev *pdev, const char **name, int *chipset, 70intelfbhw_get_chipset(struct pci_dev *pdev, struct intelfb_info *dinfo)
45 int *mobile)
46{ 71{
47 u32 tmp; 72 u32 tmp;
48 73 if (!pdev || !dinfo)
49 if (!pdev || !name || !chipset || !mobile)
50 return 1; 74 return 1;
51 75
52 switch (pdev->device) { 76 switch (pdev->device) {
53 case PCI_DEVICE_ID_INTEL_830M: 77 case PCI_DEVICE_ID_INTEL_830M:
54 *name = "Intel(R) 830M"; 78 dinfo->name = "Intel(R) 830M";
55 *chipset = INTEL_830M; 79 dinfo->chipset = INTEL_830M;
56 *mobile = 1; 80 dinfo->mobile = 1;
81 dinfo->pll_index = PLLS_I8xx;
57 return 0; 82 return 0;
58 case PCI_DEVICE_ID_INTEL_845G: 83 case PCI_DEVICE_ID_INTEL_845G:
59 *name = "Intel(R) 845G"; 84 dinfo->name = "Intel(R) 845G";
60 *chipset = INTEL_845G; 85 dinfo->chipset = INTEL_845G;
61 *mobile = 0; 86 dinfo->mobile = 0;
87 dinfo->pll_index = PLLS_I8xx;
62 return 0; 88 return 0;
63 case PCI_DEVICE_ID_INTEL_85XGM: 89 case PCI_DEVICE_ID_INTEL_85XGM:
64 tmp = 0; 90 tmp = 0;
65 *mobile = 1; 91 dinfo->mobile = 1;
92 dinfo->pll_index = PLLS_I8xx;
66 pci_read_config_dword(pdev, INTEL_85X_CAPID, &tmp); 93 pci_read_config_dword(pdev, INTEL_85X_CAPID, &tmp);
67 switch ((tmp >> INTEL_85X_VARIANT_SHIFT) & 94 switch ((tmp >> INTEL_85X_VARIANT_SHIFT) &
68 INTEL_85X_VARIANT_MASK) { 95 INTEL_85X_VARIANT_MASK) {
69 case INTEL_VAR_855GME: 96 case INTEL_VAR_855GME:
70 *name = "Intel(R) 855GME"; 97 dinfo->name = "Intel(R) 855GME";
71 *chipset = INTEL_855GME; 98 dinfo->chipset = INTEL_855GME;
72 return 0; 99 return 0;
73 case INTEL_VAR_855GM: 100 case INTEL_VAR_855GM:
74 *name = "Intel(R) 855GM"; 101 dinfo->name = "Intel(R) 855GM";
75 *chipset = INTEL_855GM; 102 dinfo->chipset = INTEL_855GM;
76 return 0; 103 return 0;
77 case INTEL_VAR_852GME: 104 case INTEL_VAR_852GME:
78 *name = "Intel(R) 852GME"; 105 dinfo->name = "Intel(R) 852GME";
79 *chipset = INTEL_852GME; 106 dinfo->chipset = INTEL_852GME;
80 return 0; 107 return 0;
81 case INTEL_VAR_852GM: 108 case INTEL_VAR_852GM:
82 *name = "Intel(R) 852GM"; 109 dinfo->name = "Intel(R) 852GM";
83 *chipset = INTEL_852GM; 110 dinfo->chipset = INTEL_852GM;
84 return 0; 111 return 0;
85 default: 112 default:
86 *name = "Intel(R) 852GM/855GM"; 113 dinfo->name = "Intel(R) 852GM/855GM";
87 *chipset = INTEL_85XGM; 114 dinfo->chipset = INTEL_85XGM;
88 return 0; 115 return 0;
89 } 116 }
90 break; 117 break;
91 case PCI_DEVICE_ID_INTEL_865G: 118 case PCI_DEVICE_ID_INTEL_865G:
92 *name = "Intel(R) 865G"; 119 dinfo->name = "Intel(R) 865G";
93 *chipset = INTEL_865G; 120 dinfo->chipset = INTEL_865G;
94 *mobile = 0; 121 dinfo->mobile = 0;
122 dinfo->pll_index = PLLS_I8xx;
95 return 0; 123 return 0;
96 case PCI_DEVICE_ID_INTEL_915G: 124 case PCI_DEVICE_ID_INTEL_915G:
97 *name = "Intel(R) 915G"; 125 dinfo->name = "Intel(R) 915G";
98 *chipset = INTEL_915G; 126 dinfo->chipset = INTEL_915G;
99 *mobile = 0; 127 dinfo->mobile = 0;
128 dinfo->pll_index = PLLS_I9xx;
100 return 0; 129 return 0;
101 case PCI_DEVICE_ID_INTEL_915GM: 130 case PCI_DEVICE_ID_INTEL_915GM:
102 *name = "Intel(R) 915GM"; 131 dinfo->name = "Intel(R) 915GM";
103 *chipset = INTEL_915GM; 132 dinfo->chipset = INTEL_915GM;
104 *mobile = 1; 133 dinfo->mobile = 1;
134 dinfo->pll_index = PLLS_I9xx;
135 return 0;
136 case PCI_DEVICE_ID_INTEL_945G:
137 dinfo->name = "Intel(R) 945G";
138 dinfo->chipset = INTEL_945G;
139 dinfo->mobile = 0;
140 dinfo->pll_index = PLLS_I9xx;
141 return 0;
142 case PCI_DEVICE_ID_INTEL_945GM:
143 dinfo->name = "Intel(R) 945GM";
144 dinfo->chipset = INTEL_945GM;
145 dinfo->mobile = 1;
146 dinfo->pll_index = PLLS_I9xx;
105 return 0; 147 return 0;
106 default: 148 default:
107 return 1; 149 return 1;
@@ -114,6 +156,7 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
114{ 156{
115 struct pci_dev *bridge_dev; 157 struct pci_dev *bridge_dev;
116 u16 tmp; 158 u16 tmp;
159 int stolen_overhead;
117 160
118 if (!pdev || !aperture_size || !stolen_size) 161 if (!pdev || !aperture_size || !stolen_size)
119 return 1; 162 return 1;
@@ -128,21 +171,41 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
128 tmp = 0; 171 tmp = 0;
129 pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp); 172 pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp);
130 switch (pdev->device) { 173 switch (pdev->device) {
131 case PCI_DEVICE_ID_INTEL_830M: 174 case PCI_DEVICE_ID_INTEL_915G:
132 case PCI_DEVICE_ID_INTEL_845G: 175 case PCI_DEVICE_ID_INTEL_915GM:
176 case PCI_DEVICE_ID_INTEL_945G:
177 case PCI_DEVICE_ID_INTEL_945GM:
178 /* 915 and 945 chipsets support a 256MB aperture.
179 Aperture size is determined by inspected the
180 base address of the aperture. */
181 if (pci_resource_start(pdev, 2) & 0x08000000)
182 *aperture_size = MB(128);
183 else
184 *aperture_size = MB(256);
185 break;
186 default:
133 if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M) 187 if ((tmp & INTEL_GMCH_MEM_MASK) == INTEL_GMCH_MEM_64M)
134 *aperture_size = MB(64); 188 *aperture_size = MB(64);
135 else 189 else
136 *aperture_size = MB(128); 190 *aperture_size = MB(128);
191 break;
192 }
193
194 /* Stolen memory size is reduced by the GTT and the popup.
195 GTT is 1K per MB of aperture size, and popup is 4K. */
196 stolen_overhead = (*aperture_size / MB(1)) + 4;
197 switch(pdev->device) {
198 case PCI_DEVICE_ID_INTEL_830M:
199 case PCI_DEVICE_ID_INTEL_845G:
137 switch (tmp & INTEL_830_GMCH_GMS_MASK) { 200 switch (tmp & INTEL_830_GMCH_GMS_MASK) {
138 case INTEL_830_GMCH_GMS_STOLEN_512: 201 case INTEL_830_GMCH_GMS_STOLEN_512:
139 *stolen_size = KB(512) - KB(132); 202 *stolen_size = KB(512) - KB(stolen_overhead);
140 return 0; 203 return 0;
141 case INTEL_830_GMCH_GMS_STOLEN_1024: 204 case INTEL_830_GMCH_GMS_STOLEN_1024:
142 *stolen_size = MB(1) - KB(132); 205 *stolen_size = MB(1) - KB(stolen_overhead);
143 return 0; 206 return 0;
144 case INTEL_830_GMCH_GMS_STOLEN_8192: 207 case INTEL_830_GMCH_GMS_STOLEN_8192:
145 *stolen_size = MB(8) - KB(132); 208 *stolen_size = MB(8) - KB(stolen_overhead);
146 return 0; 209 return 0;
147 case INTEL_830_GMCH_GMS_LOCAL: 210 case INTEL_830_GMCH_GMS_LOCAL:
148 ERR_MSG("only local memory found\n"); 211 ERR_MSG("only local memory found\n");
@@ -157,28 +220,27 @@ intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
157 } 220 }
158 break; 221 break;
159 default: 222 default:
160 *aperture_size = MB(128);
161 switch (tmp & INTEL_855_GMCH_GMS_MASK) { 223 switch (tmp & INTEL_855_GMCH_GMS_MASK) {
162 case INTEL_855_GMCH_GMS_STOLEN_1M: 224 case INTEL_855_GMCH_GMS_STOLEN_1M:
163 *stolen_size = MB(1) - KB(132); 225 *stolen_size = MB(1) - KB(stolen_overhead);
164 return 0; 226 return 0;
165 case INTEL_855_GMCH_GMS_STOLEN_4M: 227 case INTEL_855_GMCH_GMS_STOLEN_4M:
166 *stolen_size = MB(4) - KB(132); 228 *stolen_size = MB(4) - KB(stolen_overhead);
167 return 0; 229 return 0;
168 case INTEL_855_GMCH_GMS_STOLEN_8M: 230 case INTEL_855_GMCH_GMS_STOLEN_8M:
169 *stolen_size = MB(8) - KB(132); 231 *stolen_size = MB(8) - KB(stolen_overhead);
170 return 0; 232 return 0;
171 case INTEL_855_GMCH_GMS_STOLEN_16M: 233 case INTEL_855_GMCH_GMS_STOLEN_16M:
172 *stolen_size = MB(16) - KB(132); 234 *stolen_size = MB(16) - KB(stolen_overhead);
173 return 0; 235 return 0;
174 case INTEL_855_GMCH_GMS_STOLEN_32M: 236 case INTEL_855_GMCH_GMS_STOLEN_32M:
175 *stolen_size = MB(32) - KB(132); 237 *stolen_size = MB(32) - KB(stolen_overhead);
176 return 0; 238 return 0;
177 case INTEL_915G_GMCH_GMS_STOLEN_48M: 239 case INTEL_915G_GMCH_GMS_STOLEN_48M:
178 *stolen_size = MB(48) - KB(132); 240 *stolen_size = MB(48) - KB(stolen_overhead);
179 return 0; 241 return 0;
180 case INTEL_915G_GMCH_GMS_STOLEN_64M: 242 case INTEL_915G_GMCH_GMS_STOLEN_64M:
181 *stolen_size = MB(64) - KB(132); 243 *stolen_size = MB(64) - KB(stolen_overhead);
182 return 0; 244 return 0;
183 case INTEL_855_GMCH_GMS_DISABLED: 245 case INTEL_855_GMCH_GMS_DISABLED:
184 ERR_MSG("video memory is disabled\n"); 246 ERR_MSG("video memory is disabled\n");
@@ -529,12 +591,63 @@ intelfbhw_read_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
529} 591}
530 592
531 593
594static int calc_vclock3(int index, int m, int n, int p)
595{
596 if (p == 0 || n == 0)
597 return 0;
598 return plls[index].ref_clk * m / n / p;
599}
600
601static int calc_vclock(int index, int m1, int m2, int n, int p1, int p2, int lvds)
602{
603 struct pll_min_max *pll = &plls[index];
604 u32 m, vco, p;
605
606 m = (5 * (m1 + 2)) + (m2 + 2);
607 n += 2;
608 vco = pll->ref_clk * m / n;
609
610 if (index == PLLS_I8xx) {
611 p = ((p1 + 2) * (1 << (p2 + 1)));
612 } else {
613 p = ((p1) * (p2 ? 5 : 10));
614 }
615 return vco / p;
616}
617
618static void
619intelfbhw_get_p1p2(struct intelfb_info *dinfo, int dpll, int *o_p1, int *o_p2)
620{
621 int p1, p2;
622
623 if (IS_I9XX(dinfo)) {
624 if (dpll & DPLL_P1_FORCE_DIV2)
625 p1 = 1;
626 else
627 p1 = (dpll >> DPLL_P1_SHIFT) & 0xff;
628
629 p1 = ffs(p1);
630
631 p2 = (dpll >> DPLL_I9XX_P2_SHIFT) & DPLL_P2_MASK;
632 } else {
633 if (dpll & DPLL_P1_FORCE_DIV2)
634 p1 = 0;
635 else
636 p1 = (dpll >> DPLL_P1_SHIFT) & DPLL_P1_MASK;
637 p2 = (dpll >> DPLL_P2_SHIFT) & DPLL_P2_MASK;
638 }
639
640 *o_p1 = p1;
641 *o_p2 = p2;
642}
643
644
532void 645void
533intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw) 646intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
534{ 647{
535#if REGDUMP 648#if REGDUMP
536 int i, m1, m2, n, p1, p2; 649 int i, m1, m2, n, p1, p2;
537 650 int index = dinfo->pll_index;
538 DBG_MSG("intelfbhw_print_hw_state\n"); 651 DBG_MSG("intelfbhw_print_hw_state\n");
539 652
540 if (!hw || !dinfo) 653 if (!hw || !dinfo)
@@ -547,26 +660,22 @@ intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
547 n = (hw->vga0_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 660 n = (hw->vga0_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
548 m1 = (hw->vga0_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 661 m1 = (hw->vga0_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
549 m2 = (hw->vga0_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 662 m2 = (hw->vga0_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
550 if (hw->vga_pd & VGAPD_0_P1_FORCE_DIV2) 663
551 p1 = 0; 664 intelfbhw_get_p1p2(dinfo, hw->vga_pd, &p1, &p2);
552 else 665
553 p1 = (hw->vga_pd >> VGAPD_0_P1_SHIFT) & DPLL_P1_MASK;
554 p2 = (hw->vga_pd >> VGAPD_0_P2_SHIFT) & DPLL_P2_MASK;
555 printk(" VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", 666 printk(" VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
556 m1, m2, n, p1, p2); 667 m1, m2, n, p1, p2);
557 printk(" VGA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); 668 printk(" VGA0: clock is %d\n",
669 calc_vclock(index, m1, m2, n, p1, p2, 0));
558 670
559 n = (hw->vga1_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 671 n = (hw->vga1_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
560 m1 = (hw->vga1_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 672 m1 = (hw->vga1_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
561 m2 = (hw->vga1_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 673 m2 = (hw->vga1_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
562 if (hw->vga_pd & VGAPD_1_P1_FORCE_DIV2) 674
563 p1 = 0; 675 intelfbhw_get_p1p2(dinfo, hw->vga_pd, &p1, &p2);
564 else
565 p1 = (hw->vga_pd >> VGAPD_1_P1_SHIFT) & DPLL_P1_MASK;
566 p2 = (hw->vga_pd >> VGAPD_1_P2_SHIFT) & DPLL_P2_MASK;
567 printk(" VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", 676 printk(" VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
568 m1, m2, n, p1, p2); 677 m1, m2, n, p1, p2);
569 printk(" VGA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); 678 printk(" VGA1: clock is %d\n", calc_vclock(index, m1, m2, n, p1, p2, 0));
570 679
571 printk(" DPLL_A: 0x%08x\n", hw->dpll_a); 680 printk(" DPLL_A: 0x%08x\n", hw->dpll_a);
572 printk(" DPLL_B: 0x%08x\n", hw->dpll_b); 681 printk(" DPLL_B: 0x%08x\n", hw->dpll_b);
@@ -578,34 +687,30 @@ intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
578 n = (hw->fpa0 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 687 n = (hw->fpa0 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
579 m1 = (hw->fpa0 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 688 m1 = (hw->fpa0 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
580 m2 = (hw->fpa0 >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 689 m2 = (hw->fpa0 >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
581 if (hw->dpll_a & DPLL_P1_FORCE_DIV2) 690
582 p1 = 0; 691 intelfbhw_get_p1p2(dinfo, hw->dpll_a, &p1, &p2);
583 else 692
584 p1 = (hw->dpll_a >> DPLL_P1_SHIFT) & DPLL_P1_MASK;
585 p2 = (hw->dpll_a >> DPLL_P2_SHIFT) & DPLL_P2_MASK;
586 printk(" PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", 693 printk(" PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
587 m1, m2, n, p1, p2); 694 m1, m2, n, p1, p2);
588 printk(" PLLA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); 695 printk(" PLLA0: clock is %d\n", calc_vclock(index, m1, m2, n, p1, p2, 0));
589 696
590 n = (hw->fpa1 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 697 n = (hw->fpa1 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
591 m1 = (hw->fpa1 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 698 m1 = (hw->fpa1 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
592 m2 = (hw->fpa1 >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK; 699 m2 = (hw->fpa1 >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK;
593 if (hw->dpll_a & DPLL_P1_FORCE_DIV2) 700
594 p1 = 0; 701 intelfbhw_get_p1p2(dinfo, hw->dpll_a, &p1, &p2);
595 else 702
596 p1 = (hw->dpll_a >> DPLL_P1_SHIFT) & DPLL_P1_MASK;
597 p2 = (hw->dpll_a >> DPLL_P2_SHIFT) & DPLL_P2_MASK;
598 printk(" PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", 703 printk(" PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n",
599 m1, m2, n, p1, p2); 704 m1, m2, n, p1, p2);
600 printk(" PLLA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); 705 printk(" PLLA1: clock is %d\n", calc_vclock(index, m1, m2, n, p1, p2, 0));
601 706
602#if 0 707#if 0
603 printk(" PALETTE_A:\n"); 708 printk(" PALETTE_A:\n");
604 for (i = 0; i < PALETTE_8_ENTRIES) 709 for (i = 0; i < PALETTE_8_ENTRIES)
605 printk(" %3d: 0x%08x\n", i, hw->palette_a[i]; 710 printk(" %3d: 0x%08x\n", i, hw->palette_a[i]);
606 printk(" PALETTE_B:\n"); 711 printk(" PALETTE_B:\n");
607 for (i = 0; i < PALETTE_8_ENTRIES) 712 for (i = 0; i < PALETTE_8_ENTRIES)
608 printk(" %3d: 0x%08x\n", i, hw->palette_b[i]; 713 printk(" %3d: 0x%08x\n", i, hw->palette_b[i]);
609#endif 714#endif
610 715
611 printk(" HTOTAL_A: 0x%08x\n", hw->htotal_a); 716 printk(" HTOTAL_A: 0x%08x\n", hw->htotal_a);
@@ -680,11 +785,11 @@ intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
680 } 785 }
681 for (i = 0; i < 3; i++) { 786 for (i = 0; i < 3; i++) {
682 printk(" SWF3%d 0x%08x\n", i, 787 printk(" SWF3%d 0x%08x\n", i,
683 hw->swf3x[i]); 788 hw->swf3x[i]);
684 } 789 }
685 for (i = 0; i < 8; i++) 790 for (i = 0; i < 8; i++)
686 printk(" FENCE%d 0x%08x\n", i, 791 printk(" FENCE%d 0x%08x\n", i,
687 hw->fence[i]); 792 hw->fence[i]);
688 793
689 printk(" INSTPM 0x%08x\n", hw->instpm); 794 printk(" INSTPM 0x%08x\n", hw->instpm);
690 printk(" MEM_MODE 0x%08x\n", hw->mem_mode); 795 printk(" MEM_MODE 0x%08x\n", hw->mem_mode);
@@ -695,43 +800,58 @@ intelfbhw_print_hw_state(struct intelfb_info *dinfo, struct intelfb_hwstate *hw)
695#endif 800#endif
696} 801}
697 802
803
804
698/* Split the M parameter into M1 and M2. */ 805/* Split the M parameter into M1 and M2. */
699static int 806static int
700splitm(unsigned int m, unsigned int *retm1, unsigned int *retm2) 807splitm(int index, unsigned int m, unsigned int *retm1, unsigned int *retm2)
701{ 808{
702 int m1, m2; 809 int m1, m2;
703 810 int testm;
704 m1 = (m - 2 - (MIN_M2 + MAX_M2) / 2) / 5 - 2; 811 struct pll_min_max *pll = &plls[index];
705 if (m1 < MIN_M1) 812
706 m1 = MIN_M1; 813 /* no point optimising too much - brute force m */
707 if (m1 > MAX_M1) 814 for (m1 = pll->min_m1; m1 < pll->max_m1 + 1; m1++) {
708 m1 = MAX_M1; 815 for (m2 = pll->min_m2; m2 < pll->max_m2 + 1; m2++) {
709 m2 = m - 5 * (m1 + 2) - 2; 816 testm = (5 * (m1 + 2)) + (m2 + 2);
710 if (m2 < MIN_M2 || m2 > MAX_M2 || m2 >= m1) { 817 if (testm == m) {
711 return 1; 818 *retm1 = (unsigned int)m1;
712 } else { 819 *retm2 = (unsigned int)m2;
713 *retm1 = (unsigned int)m1; 820 return 0;
714 *retm2 = (unsigned int)m2; 821 }
715 return 0; 822 }
716 } 823 }
824 return 1;
717} 825}
718 826
719/* Split the P parameter into P1 and P2. */ 827/* Split the P parameter into P1 and P2. */
720static int 828static int
721splitp(unsigned int p, unsigned int *retp1, unsigned int *retp2) 829splitp(int index, unsigned int p, unsigned int *retp1, unsigned int *retp2)
722{ 830{
723 int p1, p2; 831 int p1, p2;
832 struct pll_min_max *pll = &plls[index];
833
834 if (index == PLLS_I9xx) {
835 p2 = (p % 10) ? 1 : 0;
836
837 p1 = p / (p2 ? 5 : 10);
838
839 *retp1 = (unsigned int)p1;
840 *retp2 = (unsigned int)p2;
841 return 0;
842 }
724 843
725 if (p % 4 == 0) 844 if (p % 4 == 0)
726 p2 = 1; 845 p2 = 1;
727 else 846 else
728 p2 = 0; 847 p2 = 0;
729 p1 = (p / (1 << (p2 + 1))) - 2; 848 p1 = (p / (1 << (p2 + 1))) - 2;
730 if (p % 4 == 0 && p1 < MIN_P1) { 849 if (p % 4 == 0 && p1 < pll->min_p1) {
731 p2 = 0; 850 p2 = 0;
732 p1 = (p / (1 << (p2 + 1))) - 2; 851 p1 = (p / (1 << (p2 + 1))) - 2;
733 } 852 }
734 if (p1 < MIN_P1 || p1 > MAX_P1 || (p1 + 2) * (1 << (p2 + 1)) != p) { 853 if (p1 < pll->min_p1 || p1 > pll->max_p1 ||
854 (p1 + 2) * (1 << (p2 + 1)) != p) {
735 return 1; 855 return 1;
736 } else { 856 } else {
737 *retp1 = (unsigned int)p1; 857 *retp1 = (unsigned int)p1;
@@ -741,14 +861,15 @@ splitp(unsigned int p, unsigned int *retp1, unsigned int *retp2)
741} 861}
742 862
743static int 863static int
744calc_pll_params(int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *retp1, 864calc_pll_params(int index, int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *retp1,
745 u32 *retp2, u32 *retclock) 865 u32 *retp2, u32 *retclock)
746{ 866{
747 u32 m1, m2, n, p1, p2, n1; 867 u32 m1, m2, n, p1, p2, n1, testm;
748 u32 f_vco, p, p_best = 0, m, f_out; 868 u32 f_vco, p, p_best = 0, m, f_out = 0;
749 u32 err_max, err_target, err_best = 10000000; 869 u32 err_max, err_target, err_best = 10000000;
750 u32 n_best = 0, m_best = 0, f_best, f_err; 870 u32 n_best = 0, m_best = 0, f_best, f_err;
751 u32 p_min, p_max, p_inc, div_min, div_max; 871 u32 p_min, p_max, p_inc, div_max;
872 struct pll_min_max *pll = &plls[index];
752 873
753 /* Accept 0.5% difference, but aim for 0.1% */ 874 /* Accept 0.5% difference, but aim for 0.1% */
754 err_max = 5 * clock / 1000; 875 err_max = 5 * clock / 1000;
@@ -756,58 +877,56 @@ calc_pll_params(int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *retp1,
756 877
757 DBG_MSG("Clock is %d\n", clock); 878 DBG_MSG("Clock is %d\n", clock);
758 879
759 div_max = MAX_VCO_FREQ / clock; 880 div_max = pll->max_vco / clock;
760 div_min = ROUND_UP_TO(MIN_VCO_FREQ, clock) / clock;
761 881
762 if (clock <= P_TRANSITION_CLOCK) 882 p_inc = (clock <= pll->p_transition_clk) ? pll->p_inc_lo : pll->p_inc_hi;
763 p_inc = 4; 883 p_min = p_inc;
764 else
765 p_inc = 2;
766 p_min = ROUND_UP_TO(div_min, p_inc);
767 p_max = ROUND_DOWN_TO(div_max, p_inc); 884 p_max = ROUND_DOWN_TO(div_max, p_inc);
768 if (p_min < MIN_P) 885 if (p_min < pll->min_p)
769 p_min = 4; 886 p_min = pll->min_p;
770 if (p_max > MAX_P) 887 if (p_max > pll->max_p)
771 p_max = 128; 888 p_max = pll->max_p;
772 889
773 DBG_MSG("p range is %d-%d (%d)\n", p_min, p_max, p_inc); 890 DBG_MSG("p range is %d-%d (%d)\n", p_min, p_max, p_inc);
774 891
775 p = p_min; 892 p = p_min;
776 do { 893 do {
777 if (splitp(p, &p1, &p2)) { 894 if (splitp(index, p, &p1, &p2)) {
778 WRN_MSG("cannot split p = %d\n", p); 895 WRN_MSG("cannot split p = %d\n", p);
779 p += p_inc; 896 p += p_inc;
780 continue; 897 continue;
781 } 898 }
782 n = MIN_N; 899 n = pll->min_n;
783 f_vco = clock * p; 900 f_vco = clock * p;
784 901
785 do { 902 do {
786 m = ROUND_UP_TO(f_vco * n, PLL_REFCLK) / PLL_REFCLK; 903 m = ROUND_UP_TO(f_vco * n, pll->ref_clk) / pll->ref_clk;
787 if (m < MIN_M) 904 if (m < pll->min_m)
788 m = MIN_M; 905 m = pll->min_m + 1;
789 if (m > MAX_M) 906 if (m > pll->max_m)
790 m = MAX_M; 907 m = pll->max_m - 1;
791 f_out = CALC_VCLOCK3(m, n, p); 908 for (testm = m - 1; testm <= m; testm++) {
792 if (splitm(m, &m1, &m2)) { 909 f_out = calc_vclock3(index, m, n, p);
793 WRN_MSG("cannot split m = %d\n", m); 910 if (splitm(index, testm, &m1, &m2)) {
794 n++; 911 WRN_MSG("cannot split m = %d\n", m);
795 continue; 912 n++;
796 } 913 continue;
797 if (clock > f_out) 914 }
798 f_err = clock - f_out; 915 if (clock > f_out)
799 else 916 f_err = clock - f_out;
800 f_err = f_out - clock; 917 else/* slightly bias the error for bigger clocks */
801 918 f_err = f_out - clock + 1;
802 if (f_err < err_best) { 919
803 m_best = m; 920 if (f_err < err_best) {
804 n_best = n; 921 m_best = testm;
805 p_best = p; 922 n_best = n;
806 f_best = f_out; 923 p_best = p;
807 err_best = f_err; 924 f_best = f_out;
925 err_best = f_err;
926 }
808 } 927 }
809 n++; 928 n++;
810 } while ((n <= MAX_N) && (f_out >= clock)); 929 } while ((n <= pll->max_n) && (f_out >= clock));
811 p += p_inc; 930 p += p_inc;
812 } while ((p <= p_max)); 931 } while ((p <= p_max));
813 932
@@ -818,21 +937,22 @@ calc_pll_params(int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *retp1,
818 m = m_best; 937 m = m_best;
819 n = n_best; 938 n = n_best;
820 p = p_best; 939 p = p_best;
821 splitm(m, &m1, &m2); 940 splitm(index, m, &m1, &m2);
822 splitp(p, &p1, &p2); 941 splitp(index, p, &p1, &p2);
823 n1 = n - 2; 942 n1 = n - 2;
824 943
825 DBG_MSG("m, n, p: %d (%d,%d), %d (%d), %d (%d,%d), " 944 DBG_MSG("m, n, p: %d (%d,%d), %d (%d), %d (%d,%d), "
826 "f: %d (%d), VCO: %d\n", 945 "f: %d (%d), VCO: %d\n",
827 m, m1, m2, n, n1, p, p1, p2, 946 m, m1, m2, n, n1, p, p1, p2,
828 CALC_VCLOCK3(m, n, p), CALC_VCLOCK(m1, m2, n1, p1, p2), 947 calc_vclock3(index, m, n, p),
829 CALC_VCLOCK3(m, n, p) * p); 948 calc_vclock(index, m1, m2, n1, p1, p2, 0),
949 calc_vclock3(index, m, n, p) * p);
830 *retm1 = m1; 950 *retm1 = m1;
831 *retm2 = m2; 951 *retm2 = m2;
832 *retn = n1; 952 *retn = n1;
833 *retp1 = p1; 953 *retp1 = p1;
834 *retp2 = p2; 954 *retp2 = p2;
835 *retclock = CALC_VCLOCK(m1, m2, n1, p1, p2); 955 *retclock = calc_vclock(index, m1, m2, n1, p1, p2, 0);
836 956
837 return 0; 957 return 0;
838} 958}
@@ -860,6 +980,7 @@ intelfbhw_mode_to_hw(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
860 u32 vsync_start, vsync_end, vblank_start, vblank_end, vtotal, vactive; 980 u32 vsync_start, vsync_end, vblank_start, vblank_end, vtotal, vactive;
861 u32 vsync_pol, hsync_pol; 981 u32 vsync_pol, hsync_pol;
862 u32 *vs, *vb, *vt, *hs, *hb, *ht, *ss, *pipe_conf; 982 u32 *vs, *vb, *vt, *hs, *hb, *ht, *ss, *pipe_conf;
983 u32 stride_alignment;
863 984
864 DBG_MSG("intelfbhw_mode_to_hw\n"); 985 DBG_MSG("intelfbhw_mode_to_hw\n");
865 986
@@ -929,7 +1050,8 @@ intelfbhw_mode_to_hw(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
929 /* Desired clock in kHz */ 1050 /* Desired clock in kHz */
930 clock_target = 1000000000 / var->pixclock; 1051 clock_target = 1000000000 / var->pixclock;
931 1052
932 if (calc_pll_params(clock_target, &m1, &m2, &n, &p1, &p2, &clock)) { 1053 if (calc_pll_params(dinfo->pll_index, clock_target, &m1, &m2,
1054 &n, &p1, &p2, &clock)) {
933 WRN_MSG("calc_pll_params failed\n"); 1055 WRN_MSG("calc_pll_params failed\n");
934 return 1; 1056 return 1;
935 } 1057 }
@@ -949,7 +1071,14 @@ intelfbhw_mode_to_hw(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
949 *dpll &= ~DPLL_P1_FORCE_DIV2; 1071 *dpll &= ~DPLL_P1_FORCE_DIV2;
950 *dpll &= ~((DPLL_P2_MASK << DPLL_P2_SHIFT) | 1072 *dpll &= ~((DPLL_P2_MASK << DPLL_P2_SHIFT) |
951 (DPLL_P1_MASK << DPLL_P1_SHIFT)); 1073 (DPLL_P1_MASK << DPLL_P1_SHIFT));
952 *dpll |= (p2 << DPLL_P2_SHIFT) | (p1 << DPLL_P1_SHIFT); 1074
1075 if (IS_I9XX(dinfo)) {
1076 *dpll |= (p2 << DPLL_I9XX_P2_SHIFT);
1077 *dpll |= (1 << (p1 - 1)) << DPLL_P1_SHIFT;
1078 } else {
1079 *dpll |= (p2 << DPLL_P2_SHIFT) | (p1 << DPLL_P1_SHIFT);
1080 }
1081
953 *fp0 = (n << FP_N_DIVISOR_SHIFT) | 1082 *fp0 = (n << FP_N_DIVISOR_SHIFT) |
954 (m1 << FP_M1_DIVISOR_SHIFT) | 1083 (m1 << FP_M1_DIVISOR_SHIFT) |
955 (m2 << FP_M2_DIVISOR_SHIFT); 1084 (m2 << FP_M2_DIVISOR_SHIFT);
@@ -1054,7 +1183,7 @@ intelfbhw_mode_to_hw(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
1054 *ss = (hactive << SRC_SIZE_HORIZ_SHIFT) | 1183 *ss = (hactive << SRC_SIZE_HORIZ_SHIFT) |
1055 (vactive << SRC_SIZE_VERT_SHIFT); 1184 (vactive << SRC_SIZE_VERT_SHIFT);
1056 1185
1057 hw->disp_a_stride = var->xres_virtual * var->bits_per_pixel / 8; 1186 hw->disp_a_stride = dinfo->pitch;
1058 DBG_MSG("pitch is %d\n", hw->disp_a_stride); 1187 DBG_MSG("pitch is %d\n", hw->disp_a_stride);
1059 1188
1060 hw->disp_a_base = hw->disp_a_stride * var->yoffset + 1189 hw->disp_a_base = hw->disp_a_stride * var->yoffset +
@@ -1063,9 +1192,11 @@ intelfbhw_mode_to_hw(struct intelfb_info *dinfo, struct intelfb_hwstate *hw,
1063 hw->disp_a_base += dinfo->fb.offset << 12; 1192 hw->disp_a_base += dinfo->fb.offset << 12;
1064 1193
1065 /* Check stride alignment. */ 1194 /* Check stride alignment. */
1066 if (hw->disp_a_stride % STRIDE_ALIGNMENT != 0) { 1195 stride_alignment = IS_I9XX(dinfo) ? STRIDE_ALIGNMENT_I9XX :
1196 STRIDE_ALIGNMENT;
1197 if (hw->disp_a_stride % stride_alignment != 0) {
1067 WRN_MSG("display stride %d has bad alignment %d\n", 1198 WRN_MSG("display stride %d has bad alignment %d\n",
1068 hw->disp_a_stride, STRIDE_ALIGNMENT); 1199 hw->disp_a_stride, stride_alignment);
1069 return 1; 1200 return 1;
1070 } 1201 }
1071 1202
@@ -1087,6 +1218,7 @@ intelfbhw_program_mode(struct intelfb_info *dinfo,
1087 u32 hsync_reg, htotal_reg, hblank_reg; 1218 u32 hsync_reg, htotal_reg, hblank_reg;
1088 u32 vsync_reg, vtotal_reg, vblank_reg; 1219 u32 vsync_reg, vtotal_reg, vblank_reg;
1089 u32 src_size_reg; 1220 u32 src_size_reg;
1221 u32 count, tmp_val[3];
1090 1222
1091 /* Assume single pipe, display plane A, analog CRT. */ 1223 /* Assume single pipe, display plane A, analog CRT. */
1092 1224
@@ -1155,6 +1287,27 @@ intelfbhw_program_mode(struct intelfb_info *dinfo,
1155 src_size_reg = SRC_SIZE_A; 1287 src_size_reg = SRC_SIZE_A;
1156 } 1288 }
1157 1289
1290 /* turn off pipe */
1291 tmp = INREG(pipe_conf_reg);
1292 tmp &= ~PIPECONF_ENABLE;
1293 OUTREG(pipe_conf_reg, tmp);
1294
1295 count = 0;
1296 do {
1297 tmp_val[count%3] = INREG(0x70000);
1298 if ((tmp_val[0] == tmp_val[1]) && (tmp_val[1]==tmp_val[2]))
1299 break;
1300 count++;
1301 udelay(1);
1302 if (count % 200 == 0) {
1303 tmp = INREG(pipe_conf_reg);
1304 tmp &= ~PIPECONF_ENABLE;
1305 OUTREG(pipe_conf_reg, tmp);
1306 }
1307 } while(count < 2000);
1308
1309 OUTREG(ADPA, INREG(ADPA) & ~ADPA_DAC_ENABLE);
1310
1158 /* Disable planes A and B. */ 1311 /* Disable planes A and B. */
1159 tmp = INREG(DSPACNTR); 1312 tmp = INREG(DSPACNTR);
1160 tmp &= ~DISPPLANE_PLANE_ENABLE; 1313 tmp &= ~DISPPLANE_PLANE_ENABLE;
@@ -1163,19 +1316,21 @@ intelfbhw_program_mode(struct intelfb_info *dinfo,
1163 tmp &= ~DISPPLANE_PLANE_ENABLE; 1316 tmp &= ~DISPPLANE_PLANE_ENABLE;
1164 OUTREG(DSPBCNTR, tmp); 1317 OUTREG(DSPBCNTR, tmp);
1165 1318
1166 /* Wait for vblank. For now, just wait for a 50Hz cycle (20ms)) */ 1319 /* Wait for vblank. For now, just wait for a 50Hz cycle (20ms)) */
1167 mdelay(20); 1320 mdelay(20);
1168 1321
1322 OUTREG(DVOB, INREG(DVOB) & ~PORT_ENABLE);
1323 OUTREG(DVOC, INREG(DVOC) & ~PORT_ENABLE);
1324 OUTREG(ADPA, INREG(ADPA) & ~ADPA_DAC_ENABLE);
1325
1169 /* Disable Sync */ 1326 /* Disable Sync */
1170 tmp = INREG(ADPA); 1327 tmp = INREG(ADPA);
1171 tmp &= ~ADPA_DPMS_CONTROL_MASK; 1328 tmp &= ~ADPA_DPMS_CONTROL_MASK;
1172 tmp |= ADPA_DPMS_D3; 1329 tmp |= ADPA_DPMS_D3;
1173 OUTREG(ADPA, tmp); 1330 OUTREG(ADPA, tmp);
1174 1331
1175 /* turn off pipe */ 1332 /* do some funky magic - xyzzy */
1176 tmp = INREG(pipe_conf_reg); 1333 OUTREG(0x61204, 0xabcd0000);
1177 tmp &= ~PIPECONF_ENABLE;
1178 OUTREG(pipe_conf_reg, tmp);
1179 1334
1180 /* turn off PLL */ 1335 /* turn off PLL */
1181 tmp = INREG(dpll_reg); 1336 tmp = INREG(dpll_reg);
@@ -1183,30 +1338,31 @@ intelfbhw_program_mode(struct intelfb_info *dinfo,
1183 OUTREG(dpll_reg, tmp); 1338 OUTREG(dpll_reg, tmp);
1184 1339
1185 /* Set PLL parameters */ 1340 /* Set PLL parameters */
1186 OUTREG(dpll_reg, *dpll & ~DPLL_VCO_ENABLE);
1187 OUTREG(fp0_reg, *fp0); 1341 OUTREG(fp0_reg, *fp0);
1188 OUTREG(fp1_reg, *fp1); 1342 OUTREG(fp1_reg, *fp1);
1189 1343
1190 /* Set pipe parameters */ 1344 /* Enable PLL */
1191 OUTREG(hsync_reg, *hs); 1345 OUTREG(dpll_reg, *dpll);
1192 OUTREG(hblank_reg, *hb);
1193 OUTREG(htotal_reg, *ht);
1194 OUTREG(vsync_reg, *vs);
1195 OUTREG(vblank_reg, *vb);
1196 OUTREG(vtotal_reg, *vt);
1197 OUTREG(src_size_reg, *ss);
1198 1346
1199 /* Set DVOs B/C */ 1347 /* Set DVOs B/C */
1200 OUTREG(DVOB, hw->dvob); 1348 OUTREG(DVOB, hw->dvob);
1201 OUTREG(DVOC, hw->dvoc); 1349 OUTREG(DVOC, hw->dvoc);
1202 1350
1351 /* undo funky magic */
1352 OUTREG(0x61204, 0x00000000);
1353
1203 /* Set ADPA */ 1354 /* Set ADPA */
1355 OUTREG(ADPA, INREG(ADPA) | ADPA_DAC_ENABLE);
1204 OUTREG(ADPA, (hw->adpa & ~(ADPA_DPMS_CONTROL_MASK)) | ADPA_DPMS_D3); 1356 OUTREG(ADPA, (hw->adpa & ~(ADPA_DPMS_CONTROL_MASK)) | ADPA_DPMS_D3);
1205 1357
1206 /* Enable PLL */ 1358 /* Set pipe parameters */
1207 tmp = INREG(dpll_reg); 1359 OUTREG(hsync_reg, *hs);
1208 tmp |= DPLL_VCO_ENABLE; 1360 OUTREG(hblank_reg, *hb);
1209 OUTREG(dpll_reg, tmp); 1361 OUTREG(htotal_reg, *ht);
1362 OUTREG(vsync_reg, *vs);
1363 OUTREG(vblank_reg, *vb);
1364 OUTREG(vtotal_reg, *vt);
1365 OUTREG(src_size_reg, *ss);
1210 1366
1211 /* Enable pipe */ 1367 /* Enable pipe */
1212 OUTREG(pipe_conf_reg, *pipe_conf | PIPECONF_ENABLE); 1368 OUTREG(pipe_conf_reg, *pipe_conf | PIPECONF_ENABLE);
@@ -1231,7 +1387,7 @@ intelfbhw_program_mode(struct intelfb_info *dinfo,
1231 OUTREG(DSPACNTR, 1387 OUTREG(DSPACNTR,
1232 hw->disp_a_ctrl|DISPPLANE_PLANE_ENABLE); 1388 hw->disp_a_ctrl|DISPPLANE_PLANE_ENABLE);
1233 mdelay(1); 1389 mdelay(1);
1234 } 1390 }
1235 } 1391 }
1236 1392
1237 OUTREG(DSPACNTR, hw->disp_a_ctrl & ~DISPPLANE_PLANE_ENABLE); 1393 OUTREG(DSPACNTR, hw->disp_a_ctrl & ~DISPPLANE_PLANE_ENABLE);
@@ -1616,7 +1772,7 @@ intelfbhw_cursor_init(struct intelfb_info *dinfo)
1616 DBG_MSG("intelfbhw_cursor_init\n"); 1772 DBG_MSG("intelfbhw_cursor_init\n");
1617#endif 1773#endif
1618 1774
1619 if (dinfo->mobile) { 1775 if (dinfo->mobile || IS_I9XX(dinfo)) {
1620 if (!dinfo->cursor.physical) 1776 if (!dinfo->cursor.physical)
1621 return; 1777 return;
1622 tmp = INREG(CURSOR_A_CONTROL); 1778 tmp = INREG(CURSOR_A_CONTROL);
@@ -1649,7 +1805,7 @@ intelfbhw_cursor_hide(struct intelfb_info *dinfo)
1649#endif 1805#endif
1650 1806
1651 dinfo->cursor_on = 0; 1807 dinfo->cursor_on = 0;
1652 if (dinfo->mobile) { 1808 if (dinfo->mobile || IS_I9XX(dinfo)) {
1653 if (!dinfo->cursor.physical) 1809 if (!dinfo->cursor.physical)
1654 return; 1810 return;
1655 tmp = INREG(CURSOR_A_CONTROL); 1811 tmp = INREG(CURSOR_A_CONTROL);
@@ -1679,7 +1835,7 @@ intelfbhw_cursor_show(struct intelfb_info *dinfo)
1679 if (dinfo->cursor_blanked) 1835 if (dinfo->cursor_blanked)
1680 return; 1836 return;
1681 1837
1682 if (dinfo->mobile) { 1838 if (dinfo->mobile || IS_I9XX(dinfo)) {
1683 if (!dinfo->cursor.physical) 1839 if (!dinfo->cursor.physical)
1684 return; 1840 return;
1685 tmp = INREG(CURSOR_A_CONTROL); 1841 tmp = INREG(CURSOR_A_CONTROL);
@@ -1705,14 +1861,18 @@ intelfbhw_cursor_setpos(struct intelfb_info *dinfo, int x, int y)
1705#endif 1861#endif
1706 1862
1707 /* 1863 /*
1708 * Sets the position. The coordinates are assumed to already 1864 * Sets the position. The coordinates are assumed to already
1709 * have any offset adjusted. Assume that the cursor is never 1865 * have any offset adjusted. Assume that the cursor is never
1710 * completely off-screen, and that x, y are always >= 0. 1866 * completely off-screen, and that x, y are always >= 0.
1711 */ 1867 */
1712 1868
1713 tmp = ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT) | 1869 tmp = ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT) |
1714 ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT); 1870 ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT);
1715 OUTREG(CURSOR_A_POSITION, tmp); 1871 OUTREG(CURSOR_A_POSITION, tmp);
1872
1873 if (IS_I9XX(dinfo)) {
1874 OUTREG(CURSOR_A_BASEADDR, dinfo->cursor.physical);
1875 }
1716} 1876}
1717 1877
1718void 1878void
diff --git a/drivers/video/intelfb/intelfbhw.h b/drivers/video/intelfb/intelfbhw.h
index ba1920159f52..10acda098b71 100644
--- a/drivers/video/intelfb/intelfbhw.h
+++ b/drivers/video/intelfb/intelfbhw.h
@@ -133,6 +133,7 @@
133#define DPLL_VGA_MODE_DISABLE (1 << 28) 133#define DPLL_VGA_MODE_DISABLE (1 << 28)
134#define DPLL_P2_MASK 1 134#define DPLL_P2_MASK 1
135#define DPLL_P2_SHIFT 23 135#define DPLL_P2_SHIFT 23
136#define DPLL_I9XX_P2_SHIFT 24
136#define DPLL_P1_FORCE_DIV2 (1 << 21) 137#define DPLL_P1_FORCE_DIV2 (1 << 21)
137#define DPLL_P1_MASK 0x1f 138#define DPLL_P1_MASK 0x1f
138#define DPLL_P1_SHIFT 16 139#define DPLL_P1_SHIFT 16
@@ -155,29 +156,8 @@
155/* PLL parameters (these are for 852GM/855GM/865G, check earlier chips). */ 156/* PLL parameters (these are for 852GM/855GM/865G, check earlier chips). */
156/* Clock values are in units of kHz */ 157/* Clock values are in units of kHz */
157#define PLL_REFCLK 48000 158#define PLL_REFCLK 48000
158#define MIN_VCO_FREQ 930000
159#define MAX_VCO_FREQ 1400000
160#define MIN_CLOCK 25000 159#define MIN_CLOCK 25000
161#define MAX_CLOCK 350000 160#define MAX_CLOCK 350000
162#define P_TRANSITION_CLOCK 165000
163#define MIN_M 108
164#define MAX_M 140
165#define MIN_M1 18
166#define MAX_M1 26
167#define MIN_M2 6
168#define MAX_M2 16
169#define MIN_P 4
170#define MAX_P 128
171#define MIN_P1 0
172#define MAX_P1 31
173#define MIN_N 3
174#define MAX_N 16
175
176#define CALC_VCLOCK(m1, m2, n, p1, p2) \
177 ((PLL_REFCLK * (5 * ((m1) + 2) + ((m2) + 2)) / ((n) + 2)) / \
178 (((p1) + 2) * (1 << (p2 + 1))))
179
180#define CALC_VCLOCK3(m, n, p) ((PLL_REFCLK * (m) / (n)) / (p))
181 161
182/* Two pipes */ 162/* Two pipes */
183#define PIPE_A 0 163#define PIPE_A 0
@@ -522,8 +502,7 @@
522 502
523 503
524/* function protoypes */ 504/* function protoypes */
525extern int intelfbhw_get_chipset(struct pci_dev *pdev, const char **name, 505extern int intelfbhw_get_chipset(struct pci_dev *pdev, struct intelfb_info *dinfo);
526 int *chipset, int *mobile);
527extern int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size, 506extern int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
528 int *stolen_size); 507 int *stolen_size);
529extern int intelfbhw_check_non_crt(struct intelfb_info *dinfo); 508extern int intelfbhw_check_non_crt(struct intelfb_info *dinfo);
diff --git a/fs/bio.c b/fs/bio.c
index 098c12b2d60a..6a0b9ad8f8c9 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -654,9 +654,10 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
654 write_to_vm, 0, &pages[cur_page], NULL); 654 write_to_vm, 0, &pages[cur_page], NULL);
655 up_read(&current->mm->mmap_sem); 655 up_read(&current->mm->mmap_sem);
656 656
657 if (ret < local_nr_pages) 657 if (ret < local_nr_pages) {
658 ret = -EFAULT;
658 goto out_unmap; 659 goto out_unmap;
659 660 }
660 661
661 offset = uaddr & ~PAGE_MASK; 662 offset = uaddr & ~PAGE_MASK;
662 for (j = cur_page; j < page_limit; j++) { 663 for (j = cur_page; j < page_limit; j++) {
diff --git a/fs/locks.c b/fs/locks.c
index 6f99c0a6f836..ab61a8b54829 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -755,6 +755,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
755 if (request->fl_type == F_UNLCK) 755 if (request->fl_type == F_UNLCK)
756 goto out; 756 goto out;
757 757
758 error = -ENOMEM;
758 new_fl = locks_alloc_lock(); 759 new_fl = locks_alloc_lock();
759 if (new_fl == NULL) 760 if (new_fl == NULL)
760 goto out; 761 goto out;
@@ -781,6 +782,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
781 locks_copy_lock(new_fl, request); 782 locks_copy_lock(new_fl, request);
782 locks_insert_lock(&inode->i_flock, new_fl); 783 locks_insert_lock(&inode->i_flock, new_fl);
783 new_fl = NULL; 784 new_fl = NULL;
785 error = 0;
784 786
785out: 787out:
786 unlock_kernel(); 788 unlock_kernel();
diff --git a/include/asm-arm/arch-pxa/ohci.h b/include/asm-arm/arch-pxa/ohci.h
index 7da89569061e..e848a47128cd 100644
--- a/include/asm-arm/arch-pxa/ohci.h
+++ b/include/asm-arm/arch-pxa/ohci.h
@@ -11,6 +11,8 @@ struct pxaohci_platform_data {
11#define PMM_NPS_MODE 1 11#define PMM_NPS_MODE 1
12#define PMM_GLOBAL_MODE 2 12#define PMM_GLOBAL_MODE 2
13#define PMM_PERPORT_MODE 3 13#define PMM_PERPORT_MODE 3
14
15 int power_budget;
14}; 16};
15 17
16extern void pxa_set_ohci_info(struct pxaohci_platform_data *info); 18extern void pxa_set_ohci_info(struct pxaohci_platform_data *info);
diff --git a/include/asm-mips/addrspace.h b/include/asm-mips/addrspace.h
index 1386af1cb7d9..0cc6c7060f3c 100644
--- a/include/asm-mips/addrspace.h
+++ b/include/asm-mips/addrspace.h
@@ -133,57 +133,22 @@
133 || defined (CONFIG_CPU_NEVADA) \ 133 || defined (CONFIG_CPU_NEVADA) \
134 || defined (CONFIG_CPU_TX49XX) \ 134 || defined (CONFIG_CPU_TX49XX) \
135 || defined (CONFIG_CPU_MIPS64) 135 || defined (CONFIG_CPU_MIPS64)
136#define KUSIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
137#define KUSIZE_64 _LLCONST_(0x0000010000000000) /* 2^^40 */
138#define K0SIZE _LLCONST_(0x0000001000000000) /* 2^^36 */
139#define K1SIZE _LLCONST_(0x0000001000000000) /* 2^^36 */
140#define K2SIZE _LLCONST_(0x000000ff80000000)
141#define KSEGSIZE _LLCONST_(0x000000ff80000000) /* max syssegsz */
142#define TO_PHYS_MASK _LLCONST_(0x0000000fffffffff) /* 2^^36 - 1 */ 136#define TO_PHYS_MASK _LLCONST_(0x0000000fffffffff) /* 2^^36 - 1 */
143#endif 137#endif
144 138
145#if defined (CONFIG_CPU_R8000) 139#if defined (CONFIG_CPU_R8000)
146/* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */ 140/* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */
147#define KUSIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
148#define KUSIZE_64 _LLCONST_(0x0000010000000000) /* 2^^40 */
149#define K0SIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
150#define K1SIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
151#define K2SIZE _LLCONST_(0x0001000000000000)
152#define KSEGSIZE _LLCONST_(0x0000010000000000) /* max syssegsz */
153#define TO_PHYS_MASK _LLCONST_(0x000000ffffffffff) /* 2^^40 - 1 */ 141#define TO_PHYS_MASK _LLCONST_(0x000000ffffffffff) /* 2^^40 - 1 */
154#endif 142#endif
155 143
156#if defined (CONFIG_CPU_R10000) 144#if defined (CONFIG_CPU_R10000)
157#define KUSIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
158#define KUSIZE_64 _LLCONST_(0x0000010000000000) /* 2^^40 */
159#define K0SIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
160#define K1SIZE _LLCONST_(0x0000010000000000) /* 2^^40 */
161#define K2SIZE _LLCONST_(0x00000fff80000000)
162#define KSEGSIZE _LLCONST_(0x00000fff80000000) /* max syssegsz */
163#define TO_PHYS_MASK _LLCONST_(0x000000ffffffffff) /* 2^^40 - 1 */ 145#define TO_PHYS_MASK _LLCONST_(0x000000ffffffffff) /* 2^^40 - 1 */
164#endif 146#endif
165 147
166#if defined(CONFIG_CPU_SB1) || defined(CONFIG_CPU_SB1A) 148#if defined(CONFIG_CPU_SB1) || defined(CONFIG_CPU_SB1A)
167#define KUSIZE _LLCONST_(0x0000100000000000) /* 2^^44 */
168#define KUSIZE_64 _LLCONST_(0x0000100000000000) /* 2^^44 */
169#define K0SIZE _LLCONST_(0x0000100000000000) /* 2^^44 */
170#define K1SIZE _LLCONST_(0x0000100000000000) /* 2^^44 */
171#define K2SIZE _LLCONST_(0x0000ffff80000000)
172#define KSEGSIZE _LLCONST_(0x0000ffff80000000) /* max syssegsz */
173#define TO_PHYS_MASK _LLCONST_(0x00000fffffffffff) /* 2^^44 - 1 */ 149#define TO_PHYS_MASK _LLCONST_(0x00000fffffffffff) /* 2^^44 - 1 */
174#endif 150#endif
175 151
176/*
177 * Further names for SGI source compatibility. These are stolen from
178 * IRIX's <sys/mips_addrspace.h>.
179 */
180#define KUBASE _LLCONST_(0)
181#define KUSIZE_32 _LLCONST_(0x0000000080000000) /* KUSIZE
182 for a 32 bit proc */
183#define K0BASE_EXL_WR _LLCONST_(0xa800000000000000) /* exclusive on write */
184#define K0BASE_NONCOH _LLCONST_(0x9800000000000000) /* noncoherent */
185#define K0BASE_EXL _LLCONST_(0xa000000000000000) /* exclusive */
186
187#ifndef CONFIG_CPU_R8000 152#ifndef CONFIG_CPU_R8000
188 153
189/* 154/*
diff --git a/include/asm-mips/apm.h b/include/asm-mips/apm.h
new file mode 100644
index 000000000000..e8c69208f63a
--- /dev/null
+++ b/include/asm-mips/apm.h
@@ -0,0 +1,65 @@
1/* -*- linux-c -*-
2 *
3 * (C) 2003 zecke@handhelds.org
4 *
5 * GPL version 2
6 *
7 * based on arch/arm/kernel/apm.c
8 * factor out the information needed by architectures to provide
9 * apm status
10 *
11 *
12 */
13#ifndef MIPS_ASM_SA1100_APM_H
14#define MIPS_ASM_SA1100_APM_H
15
16#include <linux/config.h>
17#include <linux/apm_bios.h>
18
19/*
20 * This structure gets filled in by the machine specific 'get_power_status'
21 * implementation. Any fields which are not set default to a safe value.
22 */
23struct apm_power_info {
24 unsigned char ac_line_status;
25#define APM_AC_OFFLINE 0
26#define APM_AC_ONLINE 1
27#define APM_AC_BACKUP 2
28#define APM_AC_UNKNOWN 0xff
29
30 unsigned char battery_status;
31#define APM_BATTERY_STATUS_HIGH 0
32#define APM_BATTERY_STATUS_LOW 1
33#define APM_BATTERY_STATUS_CRITICAL 2
34#define APM_BATTERY_STATUS_CHARGING 3
35#define APM_BATTERY_STATUS_NOT_PRESENT 4
36#define APM_BATTERY_STATUS_UNKNOWN 0xff
37
38 unsigned char battery_flag;
39#define APM_BATTERY_FLAG_HIGH (1 << 0)
40#define APM_BATTERY_FLAG_LOW (1 << 1)
41#define APM_BATTERY_FLAG_CRITICAL (1 << 2)
42#define APM_BATTERY_FLAG_CHARGING (1 << 3)
43#define APM_BATTERY_FLAG_NOT_PRESENT (1 << 7)
44#define APM_BATTERY_FLAG_UNKNOWN 0xff
45
46 int battery_life;
47 int time;
48 int units;
49#define APM_UNITS_MINS 0
50#define APM_UNITS_SECS 1
51#define APM_UNITS_UNKNOWN -1
52
53};
54
55/*
56 * This allows machines to provide their own "apm get power status" function.
57 */
58extern void (*apm_get_power_status)(struct apm_power_info *);
59
60/*
61 * Queue an event (APM_SYS_SUSPEND or APM_CRITICAL_SUSPEND)
62 */
63void apm_queue_event(apm_event_t event);
64
65#endif
diff --git a/include/asm-mips/asmmacro-32.h b/include/asm-mips/asmmacro-32.h
index 11daf5ceb7b4..5de3963f511e 100644
--- a/include/asm-mips/asmmacro-32.h
+++ b/include/asm-mips/asmmacro-32.h
@@ -12,7 +12,7 @@
12#include <asm/fpregdef.h> 12#include <asm/fpregdef.h>
13#include <asm/mipsregs.h> 13#include <asm/mipsregs.h>
14 14
15 .macro fpu_save_double thread status tmp1=t0 tmp2 15 .macro fpu_save_double thread status tmp1=t0
16 cfc1 \tmp1, fcr31 16 cfc1 \tmp1, fcr31
17 sdc1 $f0, THREAD_FPR0(\thread) 17 sdc1 $f0, THREAD_FPR0(\thread)
18 sdc1 $f2, THREAD_FPR2(\thread) 18 sdc1 $f2, THREAD_FPR2(\thread)
@@ -70,7 +70,7 @@
70 sw \tmp, THREAD_FCR31(\thread) 70 sw \tmp, THREAD_FCR31(\thread)
71 .endm 71 .endm
72 72
73 .macro fpu_restore_double thread tmp=t0 73 .macro fpu_restore_double thread status tmp=t0
74 lw \tmp, THREAD_FCR31(\thread) 74 lw \tmp, THREAD_FCR31(\thread)
75 ldc1 $f0, THREAD_FPR0(\thread) 75 ldc1 $f0, THREAD_FPR0(\thread)
76 ldc1 $f2, THREAD_FPR2(\thread) 76 ldc1 $f2, THREAD_FPR2(\thread)
diff --git a/include/asm-mips/asmmacro-64.h b/include/asm-mips/asmmacro-64.h
index 559c355b9b86..225feefcb25d 100644
--- a/include/asm-mips/asmmacro-64.h
+++ b/include/asm-mips/asmmacro-64.h
@@ -53,12 +53,12 @@
53 sdc1 $f31, THREAD_FPR31(\thread) 53 sdc1 $f31, THREAD_FPR31(\thread)
54 .endm 54 .endm
55 55
56 .macro fpu_save_double thread status tmp1 tmp2 56 .macro fpu_save_double thread status tmp
57 sll \tmp2, \tmp1, 5 57 sll \tmp, \status, 5
58 bgez \tmp2, 2f 58 bgez \tmp, 2f
59 fpu_save_16odd \thread 59 fpu_save_16odd \thread
602: 602:
61 fpu_save_16even \thread \tmp1 # clobbers t1 61 fpu_save_16even \thread \tmp
62 .endm 62 .endm
63 63
64 .macro fpu_restore_16even thread tmp=t0 64 .macro fpu_restore_16even thread tmp=t0
@@ -101,13 +101,12 @@
101 ldc1 $f31, THREAD_FPR31(\thread) 101 ldc1 $f31, THREAD_FPR31(\thread)
102 .endm 102 .endm
103 103
104 .macro fpu_restore_double thread tmp 104 .macro fpu_restore_double thread status tmp
105 mfc0 t0, CP0_STATUS 105 sll \tmp, \status, 5
106 sll t1, t0, 5 106 bgez \tmp, 1f # 16 register mode?
107 bgez t1, 1f # 16 register mode?
108 107
109 fpu_restore_16odd a0 108 fpu_restore_16odd \thread
1101: fpu_restore_16even a0, t0 # clobbers t0 1091: fpu_restore_16even \thread \tmp
111 .endm 110 .endm
112 111
113 .macro cpu_save_nonscratch thread 112 .macro cpu_save_nonscratch thread
diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
index 14fc88f27226..3b745e76f429 100644
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -217,6 +217,13 @@
217 */ 217 */
218#define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */ 218#define MACH_GROUP_TITAN 22 /* PMC-Sierra Titan */
219#define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */ 219#define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
220#define MACH_TITAN_EXCITE 2 /* Basler eXcite */
221
222/*
223 * Valid machtype for group NEC EMMA2RH
224 */
225#define MACH_GROUP_NEC_EMMA2RH 25 /* NEC EMMA2RH (was 23) */
226#define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */
220 227
221#define CL_SIZE COMMAND_LINE_SIZE 228#define CL_SIZE COMMAND_LINE_SIZE
222 229
@@ -258,4 +265,10 @@ extern char arcs_cmdline[CL_SIZE];
258 * Registers a0, a1, a3 and a4 as passed to the kenrel entry by firmware 265 * Registers a0, a1, a3 and a4 as passed to the kenrel entry by firmware
259 */ 266 */
260extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3; 267extern unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;
268
269/*
270 * Platform memory detection hook called by setup_arch
271 */
272extern void plat_mem_setup(void);
273
261#endif /* _ASM_BOOTINFO_H */ 274#endif /* _ASM_BOOTINFO_H */
diff --git a/include/asm-mips/ddb5074.h b/include/asm-mips/ddb5074.h
deleted file mode 100644
index 0d09ac27f9a5..000000000000
--- a/include/asm-mips/ddb5074.h
+++ /dev/null
@@ -1,11 +0,0 @@
1/*
2 * include/asm-mips/ddb5074.h -- NEC DDB Vrc-5074 definitions
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 */
7
8extern void ddb5074_led_hex(int hex);
9extern void ddb5074_led_d2(int on);
10extern void ddb5074_led_d3(int on);
11
diff --git a/include/asm-mips/ddb5xxx/ddb5074.h b/include/asm-mips/ddb5xxx/ddb5074.h
deleted file mode 100644
index 58d88306af65..000000000000
--- a/include/asm-mips/ddb5xxx/ddb5074.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * include/asm-mips/ddb5074.h -- NEC DDB Vrc-5074 definitions
3 *
4 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
5 * Sony Software Development Center Europe (SDCE), Brussels
6 */
7
8#ifndef _ASM_DDB5XXX_DDB5074_H
9#define _ASM_DDB5XXX_DDB5074_H
10
11#include <asm/nile4.h>
12
13#define DDB_SDRAM_SIZE 0x04000000 /* 64MB */
14
15#define DDB_PCI_IO_BASE 0x06000000
16#define DDB_PCI_IO_SIZE 0x02000000 /* 32 MB */
17
18#define DDB_PCI_MEM_BASE 0x08000000
19#define DDB_PCI_MEM_SIZE 0x08000000 /* 128 MB */
20
21#define DDB_PCI_CONFIG_BASE DDB_PCI_MEM_BASE
22#define DDB_PCI_CONFIG_SIZE DDB_PCI_MEM_SIZE
23
24#define NILE4_PCI_IO_BASE 0xa6000000
25#define NILE4_PCI_MEM_BASE 0xa8000000
26#define NILE4_PCI_CFG_BASE NILE4_PCI_MEM_BASE
27#define DDB_PCI_IACK_BASE NILE4_PCI_IO_BASE
28
29#define NILE4_IRQ_BASE NUM_I8259_INTERRUPTS
30#define CPU_IRQ_BASE (NUM_NILE4_INTERRUPTS + NILE4_IRQ_BASE)
31#define CPU_NILE4_CASCADE 2
32
33extern void ddb5074_led_hex(int hex);
34extern void ddb5074_led_d2(int on);
35extern void ddb5074_led_d3(int on);
36
37extern void nile4_irq_setup(u32 base);
38#endif
diff --git a/include/asm-mips/ddb5xxx/ddb5476.h b/include/asm-mips/ddb5xxx/ddb5476.h
deleted file mode 100644
index 4c23390d9354..000000000000
--- a/include/asm-mips/ddb5xxx/ddb5476.h
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 * header file specific for ddb5476
3 *
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14/*
15 * Memory map (physical address)
16 *
17 * Note most of the following address must be properly aligned by the
18 * corresponding size. For example, if PCI_IO_SIZE is 16MB, then
19 * PCI_IO_BASE must be aligned along 16MB boundary.
20 */
21#define DDB_SDRAM_BASE 0x00000000
22#define DDB_SDRAM_SIZE 0x04000000 /* 64MB */
23
24#define DDB_DCS3_BASE 0x04000000 /* flash 1 */
25#define DDB_DCS3_SIZE 0x01000000 /* 16MB */
26
27#define DDB_DCS2_BASE 0x05000000 /* flash 2 */
28#define DDB_DCS2_SIZE 0x01000000 /* 16MB */
29
30#define DDB_PCI_IO_BASE 0x06000000
31#define DDB_PCI_IO_SIZE 0x02000000 /* 32 MB */
32
33#define DDB_PCI_MEM_BASE 0x08000000
34#define DDB_PCI_MEM_SIZE 0x08000000 /* 128 MB */
35
36#define DDB_DCS5_BASE 0x13000000 /* DDB status regs */
37#define DDB_DCS5_SIZE 0x00200000 /* 2MB, 8-bit */
38
39#define DDB_DCS4_BASE 0x14000000 /* DDB control regs */
40#define DDB_DCS4_SIZE 0x00200000 /* 2MB, 8-bit */
41
42#define DDB_INTCS_BASE 0x1fa00000 /* VRC5476 control regs */
43#define DDB_INTCS_SIZE 0x00200000 /* 2MB */
44
45#define DDB_BOOTCS_BASE 0x1fc00000 /* Boot ROM / EPROM /Flash */
46#define DDB_BOOTCS_SIZE 0x00200000 /* 2 MB - doc says 4MB */
47
48
49/* aliases */
50#define DDB_PCI_CONFIG_BASE DDB_PCI_MEM_BASE
51#define DDB_PCI_CONFIG_SIZE DDB_PCI_MEM_SIZE
52
53/* PCI intr ack share PCIW0 with PCI IO */
54#define DDB_PCI_IACK_BASE DDB_PCI_IO_BASE
55
56/*
57 * Interrupt mapping
58 *
59 * We have three interrupt controllers:
60 *
61 * . CPU itself - 8 sources
62 * . i8259 - 16 sources
63 * . vrc5476 - 16 sources
64 *
65 * They connected as follows:
66 * all vrc5476 interrupts are routed to cpu IP2 (by software setting)
67 * all i2869 are routed to INTC in vrc5476 (by hardware connection)
68 *
69 * All VRC5476 PCI interrupts are level-triggered (no ack needed).
70 * All PCI irq but INTC are active low.
71 */
72
73/*
74 * irq number block assignment
75 */
76
77#define NUM_CPU_IRQ 8
78#define NUM_I8259_IRQ 16
79#define NUM_VRC5476_IRQ 16
80
81#define DDB_IRQ_BASE 0
82
83#define I8259_IRQ_BASE DDB_IRQ_BASE
84#define VRC5476_IRQ_BASE (I8259_IRQ_BASE + NUM_I8259_IRQ)
85#define CPU_IRQ_BASE (VRC5476_IRQ_BASE + NUM_VRC5476_IRQ)
86
87/*
88 * vrc5476 irq defs, see page 52-64 of Vrc5074 system controller manual
89 */
90
91#define VRC5476_IRQ_CPCE 0 /* cpu parity error */
92#define VRC5476_IRQ_CNTD 1 /* cpu no target */
93#define VRC5476_IRQ_MCE 2 /* memory check error */
94#define VRC5476_IRQ_DMA 3 /* DMA */
95#define VRC5476_IRQ_UART 4 /* vrc5476 builtin UART, not used */
96#define VRC5476_IRQ_WDOG 5 /* watchdog timer */
97#define VRC5476_IRQ_GPT 6 /* general purpose timer */
98#define VRC5476_IRQ_LBRT 7 /* local bus read timeout */
99#define VRC5476_IRQ_INTA 8 /* PCI INT #A */
100#define VRC5476_IRQ_INTB 9 /* PCI INT #B */
101#define VRC5476_IRQ_INTC 10 /* PCI INT #C */
102#define VRC5476_IRQ_INTD 11 /* PCI INT #D */
103#define VRC5476_IRQ_INTE 12 /* PCI INT #E */
104#define VRC5476_IRQ_RESERVED_13 13 /* reserved */
105#define VRC5476_IRQ_PCIS 14 /* PCI SERR # */
106#define VRC5476_IRQ_PCI 15 /* PCI internal error */
107
108/*
109 * i2859 irq assignment
110 */
111#define I8259_IRQ_RESERVED_0 0
112#define I8259_IRQ_KEYBOARD 1 /* M1543 default */
113#define I8259_IRQ_CASCADE 2
114#define I8259_IRQ_UART_B 3 /* M1543 default, may conflict with RTC according to schematic diagram */
115#define I8259_IRQ_UART_A 4 /* M1543 default */
116#define I8259_IRQ_PARALLEL 5 /* M1543 default */
117#define I8259_IRQ_RESERVED_6 6
118#define I8259_IRQ_RESERVED_7 7
119#define I8259_IRQ_RTC 8 /* who set this? */
120#define I8259_IRQ_USB 9 /* ddb_setup */
121#define I8259_IRQ_PMU 10 /* ddb_setup */
122#define I8259_IRQ_RESERVED_11 11
123#define I8259_IRQ_RESERVED_12 12 /* m1543_irq_setup */
124#define I8259_IRQ_RESERVED_13 13
125#define I8259_IRQ_HDC1 14 /* default and ddb_setup */
126#define I8259_IRQ_HDC2 15 /* default */
127
128
129/*
130 * misc
131 */
132#define VRC5476_I8259_CASCADE VRC5476_IRQ_INTC
133#define CPU_VRC5476_CASCADE 2
134
135#define is_i8259_irq(irq) ((irq) < NUM_I8259_IRQ)
136#define nile4_to_irq(n) ((n)+NUM_I8259_IRQ)
137#define irq_to_nile4(n) ((n)-NUM_I8259_IRQ)
138
139/*
140 * low-level irq functions
141 */
142#ifndef __ASSEMBLY__
143extern void nile4_map_irq(int nile4_irq, int cpu_irq);
144extern void nile4_map_irq_all(int cpu_irq);
145extern void nile4_enable_irq(int nile4_irq);
146extern void nile4_disable_irq(int nile4_irq);
147extern void nile4_disable_irq_all(void);
148extern u16 nile4_get_irq_stat(int cpu_irq);
149extern void nile4_enable_irq_output(int cpu_irq);
150extern void nile4_disable_irq_output(int cpu_irq);
151extern void nile4_set_pci_irq_polarity(int pci_irq, int high);
152extern void nile4_set_pci_irq_level_or_edge(int pci_irq, int level);
153extern void nile4_clear_irq(int nile4_irq);
154extern void nile4_clear_irq_mask(u32 mask);
155extern u8 nile4_i8259_iack(void);
156extern void nile4_dump_irq_status(void); /* Debug */
157#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-mips/ddb5xxx/ddb5xxx.h b/include/asm-mips/ddb5xxx/ddb5xxx.h
index 873c03f2c5fe..2f1b191c6fff 100644
--- a/include/asm-mips/ddb5xxx/ddb5xxx.h
+++ b/include/asm-mips/ddb5xxx/ddb5xxx.h
@@ -174,13 +174,8 @@
174 174
175static inline void ddb_sync(void) 175static inline void ddb_sync(void)
176{ 176{
177/* The DDB5074 doesn't seem to like these accesses. They kill the board on
178 * interrupt load
179 */
180#ifndef CONFIG_DDB5074
181 volatile u32 *p = (volatile u32 *)0xbfc00000; 177 volatile u32 *p = (volatile u32 *)0xbfc00000;
182 (void)(*p); 178 (void)(*p);
183#endif
184} 179}
185 180
186static inline void ddb_out32(u32 offset, u32 val) 181static inline void ddb_out32(u32 offset, u32 val)
@@ -260,11 +255,7 @@ extern void ddb_pci_reset_bus(void);
260/* 255/*
261 * include the board dependent part 256 * include the board dependent part
262 */ 257 */
263#if defined(CONFIG_DDB5074) 258#if defined(CONFIG_DDB5477)
264#include <asm/ddb5xxx/ddb5074.h>
265#elif defined(CONFIG_DDB5476)
266#include <asm/ddb5xxx/ddb5476.h>
267#elif defined(CONFIG_DDB5477)
268#include <asm/ddb5xxx/ddb5477.h> 259#include <asm/ddb5xxx/ddb5477.h>
269#else 260#else
270#error "Unknown DDB board!" 261#error "Unknown DDB board!"
diff --git a/include/asm-mips/emma2rh/emma2rh.h b/include/asm-mips/emma2rh/emma2rh.h
new file mode 100644
index 000000000000..4fb8df71caa9
--- /dev/null
+++ b/include/asm-mips/emma2rh/emma2rh.h
@@ -0,0 +1,330 @@
1/*
2 * include/asm-mips/emma2rh/emma2rh.h
3 * This file is EMMA2RH common header.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h
8 * Copyright 2001 MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24#ifndef __ASM_EMMA2RH_EMMA2RH_H
25#define __ASM_EMMA2RH_EMMA2RH_H
26
27/*
28 * EMMA2RH registers
29 */
30#define REGBASE 0x10000000
31
32#define EMMA2RH_BHIF_STRAP_0 (0x000010+REGBASE)
33#define EMMA2RH_BHIF_INT_ST_0 (0x000030+REGBASE)
34#define EMMA2RH_BHIF_INT_ST_1 (0x000034+REGBASE)
35#define EMMA2RH_BHIF_INT_ST_2 (0x000038+REGBASE)
36#define EMMA2RH_BHIF_INT_EN_0 (0x000040+REGBASE)
37#define EMMA2RH_BHIF_INT_EN_1 (0x000044+REGBASE)
38#define EMMA2RH_BHIF_INT_EN_2 (0x000048+REGBASE)
39#define EMMA2RH_BHIF_INT1_EN_0 (0x000050+REGBASE)
40#define EMMA2RH_BHIF_INT1_EN_1 (0x000054+REGBASE)
41#define EMMA2RH_BHIF_INT1_EN_2 (0x000058+REGBASE)
42#define EMMA2RH_BHIF_SW_INT (0x000070+REGBASE)
43#define EMMA2RH_BHIF_SW_INT_EN (0x000080+REGBASE)
44#define EMMA2RH_BHIF_SW_INT_CLR (0x000090+REGBASE)
45#define EMMA2RH_BHIF_MAIN_CTRL (0x0000b4+REGBASE)
46#define EMMA2RH_BHIF_EXCEPT_VECT_BASE_ADDRESS (0x0000c0+REGBASE)
47#define EMMA2RH_GPIO_DIR (0x110d20+REGBASE)
48#define EMMA2RH_GPIO_INT_ST (0x110d30+REGBASE)
49#define EMMA2RH_GPIO_INT_MASK (0x110d3c+REGBASE)
50#define EMMA2RH_GPIO_INT_MODE (0x110d48+REGBASE)
51#define EMMA2RH_GPIO_INT_CND_A (0x110d54+REGBASE)
52#define EMMA2RH_GPIO_INT_CND_B (0x110d60+REGBASE)
53#define EMMA2RH_PBRD_INT_EN (0x100010+REGBASE)
54#define EMMA2RH_PBRD_CLKSEL (0x100028+REGBASE)
55#define EMMA2RH_PFUR0_BASE (0x101000+REGBASE)
56#define EMMA2RH_PFUR1_BASE (0x102000+REGBASE)
57#define EMMA2RH_PFUR2_BASE (0x103000+REGBASE)
58#define EMMA2RH_PIIC0_BASE (0x107000+REGBASE)
59#define EMMA2RH_PIIC1_BASE (0x108000+REGBASE)
60#define EMMA2RH_PIIC2_BASE (0x109000+REGBASE)
61#define EMMA2RH_PCI_CONTROL (0x200000+REGBASE)
62#define EMMA2RH_PCI_ARBIT_CTR (0x200004+REGBASE)
63#define EMMA2RH_PCI_IWIN0_CTR (0x200010+REGBASE)
64#define EMMA2RH_PCI_IWIN1_CTR (0x200014+REGBASE)
65#define EMMA2RH_PCI_INIT_ESWP (0x200018+REGBASE)
66#define EMMA2RH_PCI_INT (0x200020+REGBASE)
67#define EMMA2RH_PCI_INT_EN (0x200024+REGBASE)
68#define EMMA2RH_PCI_TWIN_CTR (0x200030+REGBASE)
69#define EMMA2RH_PCI_TWIN_BADR (0x200034+REGBASE)
70#define EMMA2RH_PCI_TWIN0_DADR (0x200038+REGBASE)
71#define EMMA2RH_PCI_TWIN1_DADR (0x20003c+REGBASE)
72
73/*
74 * Memory map (physical address)
75 *
76 * Note most of the following address must be properly aligned by the
77 * corresponding size. For example, if PCI_IO_SIZE is 16MB, then
78 * PCI_IO_BASE must be aligned along 16MB boundary.
79 */
80
81/* the actual ram size is detected at run-time */
82#define EMMA2RH_RAM_BASE 0x00000000
83#define EMMA2RH_RAM_SIZE 0x10000000 /* less than 256MB */
84
85#define EMMA2RH_IO_BASE 0x10000000
86#define EMMA2RH_IO_SIZE 0x01000000 /* 16 MB */
87
88#define EMMA2RH_GENERALIO_BASE 0x11000000
89#define EMMA2RH_GENERALIO_SIZE 0x01000000 /* 16 MB */
90
91#define EMMA2RH_PCI_IO_BASE 0x12000000
92#define EMMA2RH_PCI_IO_SIZE 0x02000000 /* 32 MB */
93
94#define EMMA2RH_PCI_MEM_BASE 0x14000000
95#define EMMA2RH_PCI_MEM_SIZE 0x08000000 /* 128 MB */
96
97#define EMMA2RH_ROM_BASE 0x1c000000
98#define EMMA2RH_ROM_SIZE 0x04000000 /* 64 MB */
99
100#define EMMA2RH_PCI_CONFIG_BASE EMMA2RH_PCI_IO_BASE
101#define EMMA2RH_PCI_CONFIG_SIZE EMMA2RH_PCI_IO_SIZE
102
103#define NUM_CPU_IRQ 8
104#define NUM_EMMA2RH_IRQ 96
105
106#define CPU_EMMA2RH_CASCADE 2
107#define EMMA2RH_IRQ_BASE 0
108
109/*
110 * emma2rh irq defs
111 */
112
113#define EMMA2RH_IRQ_INT0 (0 + EMMA2RH_IRQ_BASE)
114#define EMMA2RH_IRQ_INT1 (1 + EMMA2RH_IRQ_BASE)
115#define EMMA2RH_IRQ_INT2 (2 + EMMA2RH_IRQ_BASE)
116#define EMMA2RH_IRQ_INT3 (3 + EMMA2RH_IRQ_BASE)
117#define EMMA2RH_IRQ_INT4 (4 + EMMA2RH_IRQ_BASE)
118#define EMMA2RH_IRQ_INT5 (5 + EMMA2RH_IRQ_BASE)
119#define EMMA2RH_IRQ_INT6 (6 + EMMA2RH_IRQ_BASE)
120#define EMMA2RH_IRQ_INT7 (7 + EMMA2RH_IRQ_BASE)
121#define EMMA2RH_IRQ_INT8 (8 + EMMA2RH_IRQ_BASE)
122#define EMMA2RH_IRQ_INT9 (9 + EMMA2RH_IRQ_BASE)
123#define EMMA2RH_IRQ_INT10 (10 + EMMA2RH_IRQ_BASE)
124#define EMMA2RH_IRQ_INT11 (11 + EMMA2RH_IRQ_BASE)
125#define EMMA2RH_IRQ_INT12 (12 + EMMA2RH_IRQ_BASE)
126#define EMMA2RH_IRQ_INT13 (13 + EMMA2RH_IRQ_BASE)
127#define EMMA2RH_IRQ_INT14 (14 + EMMA2RH_IRQ_BASE)
128#define EMMA2RH_IRQ_INT15 (15 + EMMA2RH_IRQ_BASE)
129#define EMMA2RH_IRQ_INT16 (16 + EMMA2RH_IRQ_BASE)
130#define EMMA2RH_IRQ_INT17 (17 + EMMA2RH_IRQ_BASE)
131#define EMMA2RH_IRQ_INT18 (18 + EMMA2RH_IRQ_BASE)
132#define EMMA2RH_IRQ_INT19 (19 + EMMA2RH_IRQ_BASE)
133#define EMMA2RH_IRQ_INT20 (20 + EMMA2RH_IRQ_BASE)
134#define EMMA2RH_IRQ_INT21 (21 + EMMA2RH_IRQ_BASE)
135#define EMMA2RH_IRQ_INT22 (22 + EMMA2RH_IRQ_BASE)
136#define EMMA2RH_IRQ_INT23 (23 + EMMA2RH_IRQ_BASE)
137#define EMMA2RH_IRQ_INT24 (24 + EMMA2RH_IRQ_BASE)
138#define EMMA2RH_IRQ_INT25 (25 + EMMA2RH_IRQ_BASE)
139#define EMMA2RH_IRQ_INT26 (26 + EMMA2RH_IRQ_BASE)
140#define EMMA2RH_IRQ_INT27 (27 + EMMA2RH_IRQ_BASE)
141#define EMMA2RH_IRQ_INT28 (28 + EMMA2RH_IRQ_BASE)
142#define EMMA2RH_IRQ_INT29 (29 + EMMA2RH_IRQ_BASE)
143#define EMMA2RH_IRQ_INT30 (30 + EMMA2RH_IRQ_BASE)
144#define EMMA2RH_IRQ_INT31 (31 + EMMA2RH_IRQ_BASE)
145#define EMMA2RH_IRQ_INT32 (32 + EMMA2RH_IRQ_BASE)
146#define EMMA2RH_IRQ_INT33 (33 + EMMA2RH_IRQ_BASE)
147#define EMMA2RH_IRQ_INT34 (34 + EMMA2RH_IRQ_BASE)
148#define EMMA2RH_IRQ_INT35 (35 + EMMA2RH_IRQ_BASE)
149#define EMMA2RH_IRQ_INT36 (36 + EMMA2RH_IRQ_BASE)
150#define EMMA2RH_IRQ_INT37 (37 + EMMA2RH_IRQ_BASE)
151#define EMMA2RH_IRQ_INT38 (38 + EMMA2RH_IRQ_BASE)
152#define EMMA2RH_IRQ_INT39 (39 + EMMA2RH_IRQ_BASE)
153#define EMMA2RH_IRQ_INT40 (40 + EMMA2RH_IRQ_BASE)
154#define EMMA2RH_IRQ_INT41 (41 + EMMA2RH_IRQ_BASE)
155#define EMMA2RH_IRQ_INT42 (42 + EMMA2RH_IRQ_BASE)
156#define EMMA2RH_IRQ_INT43 (43 + EMMA2RH_IRQ_BASE)
157#define EMMA2RH_IRQ_INT44 (44 + EMMA2RH_IRQ_BASE)
158#define EMMA2RH_IRQ_INT45 (45 + EMMA2RH_IRQ_BASE)
159#define EMMA2RH_IRQ_INT46 (46 + EMMA2RH_IRQ_BASE)
160#define EMMA2RH_IRQ_INT47 (47 + EMMA2RH_IRQ_BASE)
161#define EMMA2RH_IRQ_INT48 (48 + EMMA2RH_IRQ_BASE)
162#define EMMA2RH_IRQ_INT49 (49 + EMMA2RH_IRQ_BASE)
163#define EMMA2RH_IRQ_INT50 (50 + EMMA2RH_IRQ_BASE)
164#define EMMA2RH_IRQ_INT51 (51 + EMMA2RH_IRQ_BASE)
165#define EMMA2RH_IRQ_INT52 (52 + EMMA2RH_IRQ_BASE)
166#define EMMA2RH_IRQ_INT53 (53 + EMMA2RH_IRQ_BASE)
167#define EMMA2RH_IRQ_INT54 (54 + EMMA2RH_IRQ_BASE)
168#define EMMA2RH_IRQ_INT55 (55 + EMMA2RH_IRQ_BASE)
169#define EMMA2RH_IRQ_INT56 (56 + EMMA2RH_IRQ_BASE)
170#define EMMA2RH_IRQ_INT57 (57 + EMMA2RH_IRQ_BASE)
171#define EMMA2RH_IRQ_INT58 (58 + EMMA2RH_IRQ_BASE)
172#define EMMA2RH_IRQ_INT59 (59 + EMMA2RH_IRQ_BASE)
173#define EMMA2RH_IRQ_INT60 (60 + EMMA2RH_IRQ_BASE)
174#define EMMA2RH_IRQ_INT61 (61 + EMMA2RH_IRQ_BASE)
175#define EMMA2RH_IRQ_INT62 (62 + EMMA2RH_IRQ_BASE)
176#define EMMA2RH_IRQ_INT63 (63 + EMMA2RH_IRQ_BASE)
177
178#define EMMA2RH_IRQ_PFUR0 EMMA2RH_IRQ_INT49
179#define EMMA2RH_IRQ_PFUR1 EMMA2RH_IRQ_INT50
180#define EMMA2RH_IRQ_PFUR2 EMMA2RH_IRQ_INT51
181#define EMMA2RH_IRQ_PIIC0 EMMA2RH_IRQ_INT56
182#define EMMA2RH_IRQ_PIIC1 EMMA2RH_IRQ_INT57
183#define EMMA2RH_IRQ_PIIC2 EMMA2RH_IRQ_INT58
184
185/*
186 * EMMA2RH Register Access
187 */
188
189#define EMMA2RH_BASE (0xa0000000)
190
191static inline void emma2rh_sync(void)
192{
193 volatile u32 *p = (volatile u32 *)0xbfc00000;
194 (void)(*p);
195}
196
197static inline void emma2rh_out32(u32 offset, u32 val)
198{
199 *(volatile u32 *)(EMMA2RH_BASE | offset) = val;
200 emma2rh_sync();
201}
202
203static inline u32 emma2rh_in32(u32 offset)
204{
205 u32 val = *(volatile u32 *)(EMMA2RH_BASE | offset);
206 emma2rh_sync();
207 return val;
208}
209
210static inline void emma2rh_out16(u32 offset, u16 val)
211{
212 *(volatile u16 *)(EMMA2RH_BASE | offset) = val;
213 emma2rh_sync();
214}
215
216static inline u16 emma2rh_in16(u32 offset)
217{
218 u16 val = *(volatile u16 *)(EMMA2RH_BASE | offset);
219 emma2rh_sync();
220 return val;
221}
222
223static inline void emma2rh_out8(u32 offset, u8 val)
224{
225 *(volatile u8 *)(EMMA2RH_BASE | offset) = val;
226 emma2rh_sync();
227}
228
229static inline u8 emma2rh_in8(u32 offset)
230{
231 u8 val = *(volatile u8 *)(EMMA2RH_BASE | offset);
232 emma2rh_sync();
233 return val;
234}
235
236/**
237 * IIC registers map
238 **/
239
240/*---------------------------------------------------------------------------*/
241/* CNT - Control register (00H R/W) */
242/*---------------------------------------------------------------------------*/
243#define SPT 0x00000001
244#define STT 0x00000002
245#define ACKE 0x00000004
246#define WTIM 0x00000008
247#define SPIE 0x00000010
248#define WREL 0x00000020
249#define LREL 0x00000040
250#define IICE 0x00000080
251#define CNT_RESERVED 0x000000ff /* reserved bit 0 */
252
253#define I2C_EMMA_START (IICE | STT)
254#define I2C_EMMA_STOP (IICE | SPT)
255#define I2C_EMMA_REPSTART I2C_EMMA_START
256
257/*---------------------------------------------------------------------------*/
258/* STA - Status register (10H Read) */
259/*---------------------------------------------------------------------------*/
260#define MSTS 0x00000080
261#define ALD 0x00000040
262#define EXC 0x00000020
263#define COI 0x00000010
264#define TRC 0x00000008
265#define ACKD 0x00000004
266#define STD 0x00000002
267#define SPD 0x00000001
268
269/*---------------------------------------------------------------------------*/
270/* CSEL - Clock select register (20H R/W) */
271/*---------------------------------------------------------------------------*/
272#define FCL 0x00000080
273#define ND50 0x00000040
274#define CLD 0x00000020
275#define DAD 0x00000010
276#define SMC 0x00000008
277#define DFC 0x00000004
278#define CL 0x00000003
279#define CSEL_RESERVED 0x000000ff /* reserved bit 0 */
280
281#define FAST397 0x0000008b
282#define FAST297 0x0000008a
283#define FAST347 0x0000000b
284#define FAST260 0x0000000a
285#define FAST130 0x00000008
286#define STANDARD108 0x00000083
287#define STANDARD83 0x00000082
288#define STANDARD95 0x00000003
289#define STANDARD73 0x00000002
290#define STANDARD36 0x00000001
291#define STANDARD71 0x00000000
292
293/*---------------------------------------------------------------------------*/
294/* SVA - Slave address register (30H R/W) */
295/*---------------------------------------------------------------------------*/
296#define SVA 0x000000fe
297
298/*---------------------------------------------------------------------------*/
299/* SHR - Shift register (40H R/W) */
300/*---------------------------------------------------------------------------*/
301#define SR 0x000000ff
302
303/*---------------------------------------------------------------------------*/
304/* INT - Interrupt register (50H R/W) */
305/* INTM - Interrupt mask register (60H R/W) */
306/*---------------------------------------------------------------------------*/
307#define INTE0 0x00000001
308
309/***********************************************************************
310 * I2C registers
311 ***********************************************************************
312 */
313#define I2C_EMMA_CNT 0x00
314#define I2C_EMMA_STA 0x10
315#define I2C_EMMA_CSEL 0x20
316#define I2C_EMMA_SVA 0x30
317#define I2C_EMMA_SHR 0x40
318#define I2C_EMMA_INT 0x50
319#define I2C_EMMA_INTM 0x60
320
321/*
322 * include the board dependent part
323 */
324#if defined(CONFIG_MARKEINS)
325#include <asm/emma2rh/markeins.h>
326#else
327#error "Unknown EMMA2RH board!"
328#endif
329
330#endif /* __ASM_EMMA2RH_EMMA2RH_H */
diff --git a/include/asm-mips/emma2rh/markeins.h b/include/asm-mips/emma2rh/markeins.h
new file mode 100644
index 000000000000..8fa766795078
--- /dev/null
+++ b/include/asm-mips/emma2rh/markeins.h
@@ -0,0 +1,76 @@
1/*
2 * include/asm-mips/emma2rh/markeins.h
3 * This file is EMMA2RH board depended header.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006
6 *
7 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h
8 * Copyright 2001 MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#ifndef MARKEINS_H
26#define MARKEINS_H
27
28#define NUM_EMMA2RH_IRQ_SW 32
29#define NUM_EMMA2RH_IRQ_GPIO 32
30
31#define EMMA2RH_SW_CASCADE (EMMA2RH_IRQ_INT7 - EMMA2RH_IRQ_INT0)
32#define EMMA2RH_GPIO_CASCADE (EMMA2RH_IRQ_INT46 - EMMA2RH_IRQ_INT0)
33
34#define EMMA2RH_SW_IRQ_BASE (EMMA2RH_IRQ_BASE + NUM_EMMA2RH_IRQ)
35#define EMMA2RH_GPIO_IRQ_BASE (EMMA2RH_SW_IRQ_BASE + NUM_EMMA2RH_IRQ_SW)
36#define CPU_IRQ_BASE (EMMA2RH_GPIO_IRQ_BASE + NUM_EMMA2RH_IRQ_GPIO)
37
38#define EMMA2RH_SW_IRQ_INT0 (0+EMMA2RH_SW_IRQ_BASE)
39#define EMMA2RH_SW_IRQ_INT1 (1+EMMA2RH_SW_IRQ_BASE)
40#define EMMA2RH_SW_IRQ_INT2 (2+EMMA2RH_SW_IRQ_BASE)
41#define EMMA2RH_SW_IRQ_INT3 (3+EMMA2RH_SW_IRQ_BASE)
42#define EMMA2RH_SW_IRQ_INT4 (4+EMMA2RH_SW_IRQ_BASE)
43#define EMMA2RH_SW_IRQ_INT5 (5+EMMA2RH_SW_IRQ_BASE)
44#define EMMA2RH_SW_IRQ_INT6 (6+EMMA2RH_SW_IRQ_BASE)
45#define EMMA2RH_SW_IRQ_INT7 (7+EMMA2RH_SW_IRQ_BASE)
46#define EMMA2RH_SW_IRQ_INT8 (8+EMMA2RH_SW_IRQ_BASE)
47#define EMMA2RH_SW_IRQ_INT9 (9+EMMA2RH_SW_IRQ_BASE)
48#define EMMA2RH_SW_IRQ_INT10 (10+EMMA2RH_SW_IRQ_BASE)
49#define EMMA2RH_SW_IRQ_INT11 (11+EMMA2RH_SW_IRQ_BASE)
50#define EMMA2RH_SW_IRQ_INT12 (12+EMMA2RH_SW_IRQ_BASE)
51#define EMMA2RH_SW_IRQ_INT13 (13+EMMA2RH_SW_IRQ_BASE)
52#define EMMA2RH_SW_IRQ_INT14 (14+EMMA2RH_SW_IRQ_BASE)
53#define EMMA2RH_SW_IRQ_INT15 (15+EMMA2RH_SW_IRQ_BASE)
54#define EMMA2RH_SW_IRQ_INT16 (16+EMMA2RH_SW_IRQ_BASE)
55#define EMMA2RH_SW_IRQ_INT17 (17+EMMA2RH_SW_IRQ_BASE)
56#define EMMA2RH_SW_IRQ_INT18 (18+EMMA2RH_SW_IRQ_BASE)
57#define EMMA2RH_SW_IRQ_INT19 (19+EMMA2RH_SW_IRQ_BASE)
58#define EMMA2RH_SW_IRQ_INT20 (20+EMMA2RH_SW_IRQ_BASE)
59#define EMMA2RH_SW_IRQ_INT21 (21+EMMA2RH_SW_IRQ_BASE)
60#define EMMA2RH_SW_IRQ_INT22 (22+EMMA2RH_SW_IRQ_BASE)
61#define EMMA2RH_SW_IRQ_INT23 (23+EMMA2RH_SW_IRQ_BASE)
62#define EMMA2RH_SW_IRQ_INT24 (24+EMMA2RH_SW_IRQ_BASE)
63#define EMMA2RH_SW_IRQ_INT25 (25+EMMA2RH_SW_IRQ_BASE)
64#define EMMA2RH_SW_IRQ_INT26 (26+EMMA2RH_SW_IRQ_BASE)
65#define EMMA2RH_SW_IRQ_INT27 (27+EMMA2RH_SW_IRQ_BASE)
66#define EMMA2RH_SW_IRQ_INT28 (28+EMMA2RH_SW_IRQ_BASE)
67#define EMMA2RH_SW_IRQ_INT29 (29+EMMA2RH_SW_IRQ_BASE)
68#define EMMA2RH_SW_IRQ_INT30 (30+EMMA2RH_SW_IRQ_BASE)
69#define EMMA2RH_SW_IRQ_INT31 (31+EMMA2RH_SW_IRQ_BASE)
70
71#define MARKEINS_PCI_IRQ_INTA EMMA2RH_GPIO_IRQ_BASE+15
72#define MARKEINS_PCI_IRQ_INTB EMMA2RH_GPIO_IRQ_BASE+16
73#define MARKEINS_PCI_IRQ_INTC EMMA2RH_GPIO_IRQ_BASE+17
74#define MARKEINS_PCI_IRQ_INTD EMMA2RH_GPIO_IRQ_BASE+18
75
76#endif /* CONFIG_MARKEINS */
diff --git a/include/asm-mips/fpu.h b/include/asm-mips/fpu.h
index b0f50015e252..8bf510a27c64 100644
--- a/include/asm-mips/fpu.h
+++ b/include/asm-mips/fpu.h
@@ -138,10 +138,9 @@ static inline fpureg_t *get_fpu_regs(struct task_struct *tsk)
138 if (cpu_has_fpu) { 138 if (cpu_has_fpu) {
139 if ((tsk == current) && __is_fpu_owner()) 139 if ((tsk == current) && __is_fpu_owner())
140 _save_fp(current); 140 _save_fp(current);
141 return tsk->thread.fpu.hard.fpr;
142 } 141 }
143 142
144 return tsk->thread.fpu.soft.fpr; 143 return tsk->thread.fpu.fpr;
145} 144}
146 145
147#endif /* _ASM_FPU_H */ 146#endif /* _ASM_FPU_H */
diff --git a/include/asm-mips/fpu_emulator.h b/include/asm-mips/fpu_emulator.h
index 16cb4d11dd0b..2731c38bd7ae 100644
--- a/include/asm-mips/fpu_emulator.h
+++ b/include/asm-mips/fpu_emulator.h
@@ -12,8 +12,8 @@
12 * with this program; if not, write to the Free Software Foundation, Inc., 12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 13 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
14 * 14 *
15 * Further private data for which no space exists in mips_fpu_soft_struct. 15 * Further private data for which no space exists in mips_fpu_struct.
16 * This should be subsumed into the mips_fpu_soft_struct structure as 16 * This should be subsumed into the mips_fpu_struct structure as
17 * defined in processor.h as soon as the absurd wired absolute assembler 17 * defined in processor.h as soon as the absurd wired absolute assembler
18 * offsets become dynamic at compile time. 18 * offsets become dynamic at compile time.
19 * 19 *
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index 12d118f1bc9c..1f94640becc4 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -22,51 +22,53 @@
22 " .set push \n" \ 22 " .set push \n" \
23 " .set noat \n" \ 23 " .set noat \n" \
24 " .set mips3 \n" \ 24 " .set mips3 \n" \
25 "1: ll %1, (%3) # __futex_atomic_op \n" \ 25 "1: ll %1, %4 # __futex_atomic_op \n" \
26 " .set mips0 \n" \ 26 " .set mips0 \n" \
27 " " insn " \n" \ 27 " " insn " \n" \
28 " .set mips3 \n" \ 28 " .set mips3 \n" \
29 "2: sc $1, (%3) \n" \ 29 "2: sc $1, %2 \n" \
30 " beqzl $1, 1b \n" \ 30 " beqzl $1, 1b \n" \
31 __FUTEX_SMP_SYNC \ 31 __FUTEX_SMP_SYNC \
32 "3: \n" \ 32 "3: \n" \
33 " .set pop \n" \ 33 " .set pop \n" \
34 " .set mips0 \n" \ 34 " .set mips0 \n" \
35 " .section .fixup,\"ax\" \n" \ 35 " .section .fixup,\"ax\" \n" \
36 "4: li %0, %5 \n" \ 36 "4: li %0, %6 \n" \
37 " j 2b \n" \ 37 " j 2b \n" \
38 " .previous \n" \ 38 " .previous \n" \
39 " .section __ex_table,\"a\" \n" \ 39 " .section __ex_table,\"a\" \n" \
40 " "__UA_ADDR "\t1b, 4b \n" \ 40 " "__UA_ADDR "\t1b, 4b \n" \
41 " "__UA_ADDR "\t2b, 4b \n" \ 41 " "__UA_ADDR "\t2b, 4b \n" \
42 " .previous \n" \ 42 " .previous \n" \
43 : "=r" (ret), "=r" (oldval) \ 43 : "=r" (ret), "=&r" (oldval), "=R" (*uaddr) \
44 : "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \ 44 : "0" (0), "R" (*uaddr), "Jr" (oparg), "i" (-EFAULT) \
45 : "memory"); \
45 } else if (cpu_has_llsc) { \ 46 } else if (cpu_has_llsc) { \
46 __asm__ __volatile__( \ 47 __asm__ __volatile__( \
47 " .set push \n" \ 48 " .set push \n" \
48 " .set noat \n" \ 49 " .set noat \n" \
49 " .set mips3 \n" \ 50 " .set mips3 \n" \
50 "1: ll %1, (%3) # __futex_atomic_op \n" \ 51 "1: ll %1, %4 # __futex_atomic_op \n" \
51 " .set mips0 \n" \ 52 " .set mips0 \n" \
52 " " insn " \n" \ 53 " " insn " \n" \
53 " .set mips3 \n" \ 54 " .set mips3 \n" \
54 "2: sc $1, (%3) \n" \ 55 "2: sc $1, %2 \n" \
55 " beqz $1, 1b \n" \ 56 " beqz $1, 1b \n" \
56 __FUTEX_SMP_SYNC \ 57 __FUTEX_SMP_SYNC \
57 "3: \n" \ 58 "3: \n" \
58 " .set pop \n" \ 59 " .set pop \n" \
59 " .set mips0 \n" \ 60 " .set mips0 \n" \
60 " .section .fixup,\"ax\" \n" \ 61 " .section .fixup,\"ax\" \n" \
61 "4: li %0, %5 \n" \ 62 "4: li %0, %6 \n" \
62 " j 2b \n" \ 63 " j 2b \n" \
63 " .previous \n" \ 64 " .previous \n" \
64 " .section __ex_table,\"a\" \n" \ 65 " .section __ex_table,\"a\" \n" \
65 " "__UA_ADDR "\t1b, 4b \n" \ 66 " "__UA_ADDR "\t1b, 4b \n" \
66 " "__UA_ADDR "\t2b, 4b \n" \ 67 " "__UA_ADDR "\t2b, 4b \n" \
67 " .previous \n" \ 68 " .previous \n" \
68 : "=r" (ret), "=r" (oldval) \ 69 : "=r" (ret), "=&r" (oldval), "=R" (*uaddr) \
69 : "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \ 70 : "0" (0), "R" (*uaddr), "Jr" (oparg), "i" (-EFAULT) \
71 : "memory"); \
70 } else \ 72 } else \
71 ret = -ENOSYS; \ 73 ret = -ENOSYS; \
72} 74}
@@ -89,23 +91,23 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
89 91
90 switch (op) { 92 switch (op) {
91 case FUTEX_OP_SET: 93 case FUTEX_OP_SET:
92 __futex_atomic_op("move $1, %z4", ret, oldval, uaddr, oparg); 94 __futex_atomic_op("move $1, %z5", ret, oldval, uaddr, oparg);
93 break; 95 break;
94 96
95 case FUTEX_OP_ADD: 97 case FUTEX_OP_ADD:
96 __futex_atomic_op("addu $1, %1, %z4", 98 __futex_atomic_op("addu $1, %1, %z5",
97 ret, oldval, uaddr, oparg); 99 ret, oldval, uaddr, oparg);
98 break; 100 break;
99 case FUTEX_OP_OR: 101 case FUTEX_OP_OR:
100 __futex_atomic_op("or $1, %1, %z4", 102 __futex_atomic_op("or $1, %1, %z5",
101 ret, oldval, uaddr, oparg); 103 ret, oldval, uaddr, oparg);
102 break; 104 break;
103 case FUTEX_OP_ANDN: 105 case FUTEX_OP_ANDN:
104 __futex_atomic_op("and $1, %1, %z4", 106 __futex_atomic_op("and $1, %1, %z5",
105 ret, oldval, uaddr, ~oparg); 107 ret, oldval, uaddr, ~oparg);
106 break; 108 break;
107 case FUTEX_OP_XOR: 109 case FUTEX_OP_XOR:
108 __futex_atomic_op("xor $1, %1, %z4", 110 __futex_atomic_op("xor $1, %1, %z5",
109 ret, oldval, uaddr, oparg); 111 ret, oldval, uaddr, oparg);
110 break; 112 break;
111 default: 113 default:
diff --git a/include/asm-mips/mach-ddb5074/mc146818rtc.h b/include/asm-mips/mach-ddb5074/mc146818rtc.h
deleted file mode 100644
index 2eb9acb10a5a..000000000000
--- a/include/asm-mips/mach-ddb5074/mc146818rtc.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1998, 2001, 03 by Ralf Baechle
7 *
8 * RTC routines for PC style attached Dallas chip.
9 */
10#ifndef __ASM_MACH_DDB5074_MC146818RTC_H
11#define __ASM_MACH_DDB5074_MC146818RTC_H
12
13#include <asm/ddb5xxx/ddb5074.h>
14#include <asm/ddb5xxx/ddb5xxx.h>
15
16#define RTC_PORT(x) (0x70 + (x))
17#define RTC_IRQ 8
18
19static inline unsigned char CMOS_READ(unsigned long addr)
20{
21 return *(volatile unsigned char *)(KSEG1ADDR(DDB_PCI_MEM_BASE)+addr);
22}
23
24static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
25{
26 *(volatile unsigned char *)(KSEG1ADDR(DDB_PCI_MEM_BASE)+addr) = data;
27}
28
29#define RTC_ALWAYS_BCD 1
30
31#endif /* __ASM_MACH_DDB5074_MC146818RTC_H */
diff --git a/include/asm-mips/mach-dec/param.h b/include/asm-mips/mach-dec/param.h
deleted file mode 100644
index 3e4f0e390847..000000000000
--- a/include/asm-mips/mach-dec/param.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_DEC_PARAM_H
9#define __ASM_MACH_DEC_PARAM_H
10
11/*
12 * log2(HZ), change this here if you want another HZ value. This is also
13 * used in dec_time_init. Minimum is 1, Maximum is 15.
14 */
15#define LOG_2_HZ 7
16#define HZ (1 << LOG_2_HZ)
17
18#endif /* __ASM_MACH_DEC_PARAM_H */
diff --git a/include/asm-mips/mach-mips/param.h b/include/asm-mips/mach-emma2rh/irq.h
index 805ef6d27d3c..bce64244b800 100644
--- a/include/asm-mips/mach-mips/param.h
+++ b/include/asm-mips/mach-emma2rh/irq.h
@@ -5,9 +5,9 @@
5 * 5 *
6 * Copyright (C) 2003 by Ralf Baechle 6 * Copyright (C) 2003 by Ralf Baechle
7 */ 7 */
8#ifndef __ASM_MACH_MIPS_PARAM_H 8#ifndef __ASM_MACH_EMMA2RH_IRQ_H
9#define __ASM_MACH_MIPS_PARAM_H 9#define __ASM_MACH_EMMA2RH_IRQ_H
10 10
11#define HZ 100 /* Internal kernel timer frequency */ 11#define NR_IRQS 256
12 12
13#endif /* __ASM_MACH_MIPS_PARAM_H */ 13#endif /* __ASM_MACH_EMMA2RH_IRQ_H */
diff --git a/include/asm-mips/mach-excite/cpu-feature-overrides.h b/include/asm-mips/mach-excite/cpu-feature-overrides.h
new file mode 100644
index 000000000000..abb76b2fd865
--- /dev/null
+++ b/include/asm-mips/mach-excite/cpu-feature-overrides.h
@@ -0,0 +1,40 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2004 Thomas Koeller <thomas.koeller@baslerweb.com>
7 */
8#ifndef __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * Basler eXcite has an RM9122 processor.
13 */
14#define cpu_has_watch 1
15#define cpu_has_mips16 0
16#define cpu_has_divec 0
17#define cpu_has_vce 0
18#define cpu_has_cache_cdex_p 0
19#define cpu_has_cache_cdex_s 0
20#define cpu_has_prefetch 1
21#define cpu_has_mcheck 0
22#define cpu_has_ejtag 0
23
24#define cpu_has_llsc 1
25#define cpu_has_vtag_icache 0
26#define cpu_has_dc_aliases 0
27#define cpu_has_ic_fills_f_dc 0
28#define cpu_has_dsp 0
29#define cpu_icache_snoops_remote_store 0
30
31#define cpu_has_nofpuex 0
32#define cpu_has_64bits 1
33
34#define cpu_has_subset_pcaches 0
35
36#define cpu_dcache_line_size() 32
37#define cpu_icache_line_size() 32
38#define cpu_scache_line_size() 32
39
40#endif /* __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H */
diff --git a/include/asm-mips/mach-excite/excite.h b/include/asm-mips/mach-excite/excite.h
new file mode 100644
index 000000000000..c52610de2b3a
--- /dev/null
+++ b/include/asm-mips/mach-excite/excite.h
@@ -0,0 +1,155 @@
1#ifndef __EXCITE_H__
2#define __EXCITE_H__
3
4#include <linux/config.h>
5#include <linux/init.h>
6#include <asm/addrspace.h>
7#include <asm/types.h>
8
9#define EXCITE_CPU_EXT_CLOCK 100000000
10
11#if !defined(__ASSEMBLER__)
12void __init excite_kgdb_init(void);
13void excite_procfs_init(void);
14extern unsigned long memsize;
15extern char modetty[];
16extern u32 unit_id;
17#endif
18
19/* Base name for XICAP devices */
20#define XICAP_NAME "xicap_gpi"
21
22/* OCD register offsets */
23#define LKB0 0x0038
24#define LKB5 0x0128
25#define LKM5 0x012C
26#define LKB7 0x0138
27#define LKM7 0x013c
28#define LKB8 0x0140
29#define LKM8 0x0144
30#define LKB9 0x0148
31#define LKM9 0x014c
32#define LKB10 0x0150
33#define LKM10 0x0154
34#define LKB11 0x0158
35#define LKM11 0x015c
36#define LKB12 0x0160
37#define LKM12 0x0164
38#define LKB13 0x0168
39#define LKM13 0x016c
40#define LDP0 0x0200
41#define LDP1 0x0210
42#define LDP2 0x0220
43#define LDP3 0x0230
44#define INTPIN0 0x0A40
45#define INTPIN1 0x0A44
46#define INTPIN2 0x0A48
47#define INTPIN3 0x0A4C
48#define INTPIN4 0x0A50
49#define INTPIN5 0x0A54
50#define INTPIN6 0x0A58
51#define INTPIN7 0x0A5C
52
53
54
55
56/* TITAN register offsets */
57#define CPRR 0x0004
58#define CPDSR 0x0008
59#define CPTC0R 0x000c
60#define CPTC1R 0x0010
61#define CPCFG0 0x0020
62#define CPCFG1 0x0024
63#define CPDST0A 0x0028
64#define CPDST0B 0x002c
65#define CPDST1A 0x0030
66#define CPDST1B 0x0034
67#define CPXDSTA 0x0038
68#define CPXDSTB 0x003c
69#define CPXCISRA 0x0048
70#define CPXCISRB 0x004c
71#define CPGIG0ER 0x0050
72#define CPGIG1ER 0x0054
73#define CPGRWL 0x0068
74#define CPURSLMT 0x00f8
75#define UACFG 0x0200
76#define UAINTS 0x0204
77#define SDRXFCIE 0x4828
78#define SDTXFCIE 0x4928
79#define INTP0Status0 0x1B00
80#define INTP0Mask0 0x1B04
81#define INTP0Set0 0x1B08
82#define INTP0Clear0 0x1B0C
83#define GXCFG 0x5000
84#define GXDMADRPFX 0x5018
85#define GXDMA_DESCADR 0x501c
86#define GXCH0TDESSTRT 0x5054
87
88/* IRQ definitions */
89#define NMICONFIG 0xac0
90#define TITAN_MSGINT 0xc4
91#define TITAN_IRQ ((TITAN_MSGINT / 0x20) + 2)
92#define FPGA0_MSGINT 0x5a
93#define FPGA0_IRQ ((FPGA0_MSGINT / 0x20) + 2)
94#define FPGA1_MSGINT 0x7b
95#define FPGA1_IRQ ((FPGA1_MSGINT / 0x20) + 2)
96#define PHY_MSGINT 0x9c
97#define PHY_IRQ ((PHY_MSGINT / 0x20) + 2)
98
99#if defined(CONFIG_BASLER_EXCITE_PROTOTYPE)
100/* Pre-release units used interrupt pin #9 */
101#define USB_IRQ 11
102#else
103/* Re-designed units use interrupt pin #1 */
104#define USB_MSGINT 0x39
105#define USB_IRQ ((USB_MSGINT / 0x20) + 2)
106#endif
107#define TIMER_IRQ 12
108
109
110/* Device address ranges */
111#define EXCITE_OFFS_OCD 0x1fffc000
112#define EXCITE_SIZE_OCD (16 * 1024)
113#define EXCITE_PHYS_OCD CPHYSADDR(EXCITE_OFFS_OCD)
114#define EXCITE_ADDR_OCD CKSEG1ADDR(EXCITE_OFFS_OCD)
115
116#define EXCITE_OFFS_SCRAM 0x1fffa000
117#define EXCITE_SIZE_SCRAM (8 << 10)
118#define EXCITE_PHYS_SCRAM CPHYSADDR(EXCITE_OFFS_SCRAM)
119#define EXCITE_ADDR_SCRAM CKSEG1ADDR(EXCITE_OFFS_SCRAM)
120
121#define EXCITE_OFFS_PCI_IO 0x1fff8000
122#define EXCITE_SIZE_PCI_IO (8 << 10)
123#define EXCITE_PHYS_PCI_IO CPHYSADDR(EXCITE_OFFS_PCI_IO)
124#define EXCITE_ADDR_PCI_IO CKSEG1ADDR(EXCITE_OFFS_PCI_IO)
125
126#define EXCITE_OFFS_TITAN 0x1fff0000
127#define EXCITE_SIZE_TITAN (32 << 10)
128#define EXCITE_PHYS_TITAN CPHYSADDR(EXCITE_OFFS_TITAN)
129#define EXCITE_ADDR_TITAN CKSEG1ADDR(EXCITE_OFFS_TITAN)
130
131#define EXCITE_OFFS_PCI_MEM 0x1ffe0000
132#define EXCITE_SIZE_PCI_MEM (64 << 10)
133#define EXCITE_PHYS_PCI_MEM CPHYSADDR(EXCITE_OFFS_PCI_MEM)
134#define EXCITE_ADDR_PCI_MEM CKSEG1ADDR(EXCITE_OFFS_PCI_MEM)
135
136#define EXCITE_OFFS_FPGA 0x1ffdc000
137#define EXCITE_SIZE_FPGA (16 << 10)
138#define EXCITE_PHYS_FPGA CPHYSADDR(EXCITE_OFFS_FPGA)
139#define EXCITE_ADDR_FPGA CKSEG1ADDR(EXCITE_OFFS_FPGA)
140
141#define EXCITE_OFFS_NAND 0x1ffd8000
142#define EXCITE_SIZE_NAND (16 << 10)
143#define EXCITE_PHYS_NAND CPHYSADDR(EXCITE_OFFS_NAND)
144#define EXCITE_ADDR_NAND CKSEG1ADDR(EXCITE_OFFS_NAND)
145
146#define EXCITE_OFFS_BOOTROM 0x1f000000
147#define EXCITE_SIZE_BOOTROM (8 << 20)
148#define EXCITE_PHYS_BOOTROM CPHYSADDR(EXCITE_OFFS_BOOTROM)
149#define EXCITE_ADDR_BOOTROM CKSEG1ADDR(EXCITE_OFFS_BOOTROM)
150
151/* FPGA address offsets */
152#define EXCITE_FPGA_DPR 0x0104 /* dual-ported ram */
153#define EXCITE_FPGA_SYSCTL 0x0200 /* system control register block */
154
155#endif /* __EXCITE_H__ */
diff --git a/include/asm-mips/mach-excite/excite_nandflash.h b/include/asm-mips/mach-excite/excite_nandflash.h
new file mode 100644
index 000000000000..c4cf6140622e
--- /dev/null
+++ b/include/asm-mips/mach-excite/excite_nandflash.h
@@ -0,0 +1,7 @@
1#ifndef __EXCITE_NANDFLASH_H__
2#define __EXCITE_NANDFLASH_H__
3
4/* Resource names */
5#define EXCITE_NANDFLASH_RESOURCE_REGS "excite_nandflash_regs"
6
7#endif /* __EXCITE_NANDFLASH_H__ */
diff --git a/include/asm-mips/mach-excite/rm9k_eth.h b/include/asm-mips/mach-excite/rm9k_eth.h
new file mode 100644
index 000000000000..94705a46f72e
--- /dev/null
+++ b/include/asm-mips/mach-excite/rm9k_eth.h
@@ -0,0 +1,23 @@
1#if !defined(__RM9K_ETH_H__)
2#define __RM9K_ETH_H__
3
4#define RM9K_GE_NAME "rm9k_ge"
5
6/* Resource names */
7#define RM9K_GE_RESOURCE_MAC "rm9k_ge_mac"
8#define RM9K_GE_RESOURCE_MSTAT "rm9k_ge_mstat"
9#define RM9K_GE_RESOURCE_PKTPROC "rm9k_ge_pktproc"
10#define RM9K_GE_RESOURCE_XDMA "rm9k_ge_xdma"
11#define RM9K_GE_RESOURCE_FIFO_RX "rm9k_ge_fifo_rx"
12#define RM9K_GE_RESOURCE_FIFO_TX "rm9k_ge_fifo_tx"
13#define RM9K_GE_RESOURCE_FIFOMEM_RX "rm9k_ge_fifo_memory_rx"
14#define RM9K_GE_RESOURCE_FIFOMEM_TX "rm9k_ge_fifo_memory_tx"
15#define RM9K_GE_RESOURCE_PHY "rm9k_ge_phy"
16#define RM9K_GE_RESOURCE_DMADESC_RX "rm9k_ge_dmadesc_rx"
17#define RM9K_GE_RESOURCE_DMADESC_TX "rm9k_ge_dmadesc_tx"
18#define RM9K_GE_RESOURCE_IRQ_MAIN "rm9k_ge_irq_main"
19#define RM9K_GE_RESOURCE_IRQ_PHY "rm9k_ge_irq_phy"
20#define RM9K_GE_RESOURCE_GPI_SLICE "rm9k_ge_gpi_slice"
21#define RM9K_GE_RESOURCE_MDIO_CHANNEL "rm9k_ge_mdio_channel"
22
23#endif /* !defined(__RM9K_ETH_H__) */
diff --git a/include/asm-mips/mach-excite/rm9k_wdt.h b/include/asm-mips/mach-excite/rm9k_wdt.h
new file mode 100644
index 000000000000..3fa3c08d2da7
--- /dev/null
+++ b/include/asm-mips/mach-excite/rm9k_wdt.h
@@ -0,0 +1,12 @@
1#ifndef __RM9K_WDT_H__
2#define __RM9K_WDT_H__
3
4/* Device name */
5#define WDT_NAME "wdt_gpi"
6
7/* Resource names */
8#define WDT_RESOURCE_REGS "excite_watchdog_regs"
9#define WDT_RESOURCE_IRQ "excite_watchdog_irq"
10#define WDT_RESOURCE_COUNTER "excite_watchdog_counter"
11
12#endif /* __RM9K_WDT_H__ */
diff --git a/include/asm-mips/mach-excite/rm9k_xicap.h b/include/asm-mips/mach-excite/rm9k_xicap.h
new file mode 100644
index 000000000000..009577734a8d
--- /dev/null
+++ b/include/asm-mips/mach-excite/rm9k_xicap.h
@@ -0,0 +1,16 @@
1#ifndef __EXCITE_XICAP_H__
2#define __EXCITE_XICAP_H__
3
4
5/* Resource names */
6#define XICAP_RESOURCE_FIFO_RX "xicap_fifo_rx"
7#define XICAP_RESOURCE_FIFO_TX "xicap_fifo_tx"
8#define XICAP_RESOURCE_XDMA "xicap_xdma"
9#define XICAP_RESOURCE_DMADESC "xicap_dmadesc"
10#define XICAP_RESOURCE_PKTPROC "xicap_pktproc"
11#define XICAP_RESOURCE_IRQ "xicap_irq"
12#define XICAP_RESOURCE_GPI_SLICE "xicap_gpi_slice"
13#define XICAP_RESOURCE_FIFO_BLK "xicap_fifo_blocks"
14#define XICAP_RESOURCE_PKT_STREAM "xicap_pkt_stream"
15
16#endif /* __EXCITE_XICAP_H__ */
diff --git a/include/asm-mips/mach-generic/param.h b/include/asm-mips/mach-generic/param.h
deleted file mode 100644
index a0d12f964e4f..000000000000
--- a/include/asm-mips/mach-generic/param.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_PARAM_H
9#define __ASM_MACH_GENERIC_PARAM_H
10
11#define HZ 1000 /* Internal kernel timer frequency */
12
13#endif /* __ASM_MACH_GENERIC_PARAM_H */
diff --git a/include/asm-mips/mach-ip22/cpu-feature-overrides.h b/include/asm-mips/mach-ip22/cpu-feature-overrides.h
index 2a37bedb4053..f7c5dc8a5336 100644
--- a/include/asm-mips/mach-ip22/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-ip22/cpu-feature-overrides.h
@@ -13,7 +13,7 @@
13 */ 13 */
14#define cpu_has_tlb 1 14#define cpu_has_tlb 1
15#define cpu_has_4kex 1 15#define cpu_has_4kex 1
16#define cpu_has_4kcache 1 16#define cpu_has_4k_cache 1
17#define cpu_has_fpu 1 17#define cpu_has_fpu 1
18#define cpu_has_32fpr 1 18#define cpu_has_32fpr 1
19#define cpu_has_counter 1 19#define cpu_has_counter 1
diff --git a/include/asm-mips/mach-ip27/cpu-feature-overrides.h b/include/asm-mips/mach-ip27/cpu-feature-overrides.h
index 2d2f5b91e47f..19c2d135985b 100644
--- a/include/asm-mips/mach-ip27/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-ip27/cpu-feature-overrides.h
@@ -31,6 +31,9 @@
31#define cpu_has_nofpuex 0 31#define cpu_has_nofpuex 0
32#define cpu_has_64bits 1 32#define cpu_has_64bits 1
33 33
34#define cpu_has_4kex 1
35#define cpu_has_4k_cache 1
36
34#define cpu_has_subset_pcaches 1 37#define cpu_has_subset_pcaches 1
35 38
36#define cpu_dcache_line_size() 32 39#define cpu_dcache_line_size() 32
diff --git a/include/asm-mips/mach-ip32/cpu-feature-overrides.h b/include/asm-mips/mach-ip32/cpu-feature-overrides.h
index 36070b5654ab..f0ef1ac9ecd7 100644
--- a/include/asm-mips/mach-ip32/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-ip32/cpu-feature-overrides.h
@@ -38,6 +38,8 @@
38#define cpu_has_vtag_icache 0 38#define cpu_has_vtag_icache 0
39#define cpu_has_ic_fills_f_dc 0 39#define cpu_has_ic_fills_f_dc 0
40#define cpu_has_dsp 0 40#define cpu_has_dsp 0
41#define cpu_has_4k_cache 1
42
41 43
42#define cpu_has_mips32r1 0 44#define cpu_has_mips32r1 0
43#define cpu_has_mips32r2 0 45#define cpu_has_mips32r2 0
diff --git a/include/asm-mips/mach-jazz/param.h b/include/asm-mips/mach-jazz/param.h
deleted file mode 100644
index 639763a517bc..000000000000
--- a/include/asm-mips/mach-jazz/param.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_JAZZ_PARAM_H
9#define __ASM_MACH_JAZZ_PARAM_H
10
11/*
12 * Jazz is currently using the internal 100Hz timer of the R4030
13 */
14#define HZ 100 /* Internal kernel timer frequency */
15
16#endif /* __ASM_MACH_JAZZ_PARAM_H */
diff --git a/include/asm-mips/mach-mips/cpu-feature-overrides.h b/include/asm-mips/mach-mips/cpu-feature-overrides.h
index e06af6c86f86..12c937283bb4 100644
--- a/include/asm-mips/mach-mips/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-mips/cpu-feature-overrides.h
@@ -17,7 +17,7 @@
17#ifdef CONFIG_CPU_MIPS32 17#ifdef CONFIG_CPU_MIPS32
18#define cpu_has_tlb 1 18#define cpu_has_tlb 1
19#define cpu_has_4kex 1 19#define cpu_has_4kex 1
20#define cpu_has_4kcache 1 20#define cpu_has_4k_cache 1
21/* #define cpu_has_fpu ? */ 21/* #define cpu_has_fpu ? */
22/* #define cpu_has_32fpr ? */ 22/* #define cpu_has_32fpr ? */
23#define cpu_has_counter 1 23#define cpu_has_counter 1
@@ -47,7 +47,7 @@
47#ifdef CONFIG_CPU_MIPS64 47#ifdef CONFIG_CPU_MIPS64
48#define cpu_has_tlb 1 48#define cpu_has_tlb 1
49#define cpu_has_4kex 1 49#define cpu_has_4kex 1
50#define cpu_has_4kcache 1 50#define cpu_has_4k_cache 1
51/* #define cpu_has_fpu ? */ 51/* #define cpu_has_fpu ? */
52/* #define cpu_has_32fpr ? */ 52/* #define cpu_has_32fpr ? */
53#define cpu_has_counter 1 53#define cpu_has_counter 1
diff --git a/include/asm-mips/mach-qemu/param.h b/include/asm-mips/mach-qemu/param.h
deleted file mode 100644
index cb30ee490ae6..000000000000
--- a/include/asm-mips/mach-qemu/param.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_QEMU_PARAM_H
9#define __ASM_MACH_QEMU_PARAM_H
10
11#define HZ 100 /* Internal kernel timer frequency */
12
13#endif /* __ASM_MACH_QEMU_PARAM_H */
diff --git a/include/asm-mips/mach-rm200/cpu-feature-overrides.h b/include/asm-mips/mach-rm200/cpu-feature-overrides.h
index 91e7cf5f2bfe..11410ae10d36 100644
--- a/include/asm-mips/mach-rm200/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-rm200/cpu-feature-overrides.h
@@ -14,7 +14,7 @@
14 14
15#define cpu_has_tlb 1 15#define cpu_has_tlb 1
16#define cpu_has_4kex 1 16#define cpu_has_4kex 1
17#define cpu_has_4kcache 1 17#define cpu_has_4k_cache 1
18#define cpu_has_fpu 1 18#define cpu_has_fpu 1
19#define cpu_has_32fpr 1 19#define cpu_has_32fpr 1
20#define cpu_has_counter 1 20#define cpu_has_counter 1
@@ -35,10 +35,8 @@
35#define cpu_has_nofpuex 0 35#define cpu_has_nofpuex 0
36#define cpu_has_64bits 1 36#define cpu_has_64bits 1
37 37
38#define cpu_has_subset_pcaches 0 /* No S-cache on R5000 I think ... */
39#define cpu_dcache_line_size() 32 38#define cpu_dcache_line_size() 32
40#define cpu_icache_line_size() 32 39#define cpu_icache_line_size() 32
41#define cpu_scache_line_size() 0 /* No S-cache on R5000 I think ... */
42 40
43#define cpu_has_mips32r1 0 41#define cpu_has_mips32r1 0
44#define cpu_has_mips32r2 0 42#define cpu_has_mips32r2 0
diff --git a/include/asm-mips/mach-sim/cpu-feature-overrides.h b/include/asm-mips/mach-sim/cpu-feature-overrides.h
index cadbe8eda79c..d9653e47d5fc 100644
--- a/include/asm-mips/mach-sim/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-sim/cpu-feature-overrides.h
@@ -16,7 +16,7 @@
16#ifdef CONFIG_CPU_MIPS32 16#ifdef CONFIG_CPU_MIPS32
17#define cpu_has_tlb 1 17#define cpu_has_tlb 1
18#define cpu_has_4kex 1 18#define cpu_has_4kex 1
19#define cpu_has_4kcache 1 19#define cpu_has_4k_cache 1
20#define cpu_has_fpu 0 20#define cpu_has_fpu 0
21/* #define cpu_has_32fpr ? */ 21/* #define cpu_has_32fpr ? */
22#define cpu_has_counter 1 22#define cpu_has_counter 1
@@ -41,7 +41,7 @@
41#ifdef CONFIG_CPU_MIPS64 41#ifdef CONFIG_CPU_MIPS64
42#define cpu_has_tlb 1 42#define cpu_has_tlb 1
43#define cpu_has_4kex 1 43#define cpu_has_4kex 1
44#define cpu_has_4kcache 1 44#define cpu_has_4k_cache 1
45/* #define cpu_has_fpu ? */ 45/* #define cpu_has_fpu ? */
46/* #define cpu_has_32fpr ? */ 46/* #define cpu_has_32fpr ? */
47#define cpu_has_counter 1 47#define cpu_has_counter 1
diff --git a/include/asm-mips/mach-wrppmc/mach-gt64120.h b/include/asm-mips/mach-wrppmc/mach-gt64120.h
new file mode 100644
index 000000000000..ba9205a04582
--- /dev/null
+++ b/include/asm-mips/mach-wrppmc/mach-gt64120.h
@@ -0,0 +1,84 @@
1/*
2 * This is a direct copy of the ev96100.h file, with a global
3 * search and replace. The numbers are the same.
4 *
5 * The reason I'm duplicating this is so that the 64120/96100
6 * defines won't be confusing in the source code.
7 */
8#ifndef __ASM_MIPS_GT64120_H
9#define __ASM_MIPS_GT64120_H
10
11/*
12 * This is the CPU physical memory map of PPMC Board:
13 *
14 * 0x00000000-0x03FFFFFF - 64MB SDRAM (SCS[0]#)
15 * 0x1C000000-0x1C000000 - LED (CS0)
16 * 0x1C800000-0x1C800007 - UART 16550 port (CS1)
17 * 0x1F000000-0x1F000000 - MailBox (CS3)
18 * 0x1FC00000-0x20000000 - 4MB Flash (BOOT CS)
19 */
20
21#define WRPPMC_SDRAM_SCS0_BASE 0x00000000
22#define WRPPMC_SDRAM_SCS0_SIZE 0x04000000
23
24#define WRPPMC_UART16550_BASE 0x1C800000
25#define WRPPMC_UART16550_CLOCK 3686400 /* 3.68MHZ */
26
27#define WRPPMC_LED_BASE 0x1C000000
28#define WRPPMC_MBOX_BASE 0x1F000000
29
30#define WRPPMC_BOOTROM_BASE 0x1FC00000
31#define WRPPMC_BOOTROM_SIZE 0x00400000 /* 4M Flash */
32
33#define WRPPMC_MIPS_TIMER_IRQ 7 /* MIPS compare/count timer interrupt */
34#define WRPPMC_UART16550_IRQ 6
35#define WRPPMC_PCI_INTA_IRQ 3
36
37/*
38 * PCI Bus I/O and Memory resources allocation
39 *
40 * NOTE: We only have PCI_0 hose interface
41 */
42#define GT_PCI_MEM_BASE 0x13000000UL
43#define GT_PCI_MEM_SIZE 0x02000000UL
44#define GT_PCI_IO_BASE 0x11000000UL
45#define GT_PCI_IO_SIZE 0x02000000UL
46#define GT_ISA_IO_BASE PCI_IO_BASE
47
48/*
49 * PCI interrupts will come in on either the INTA or INTD interrups lines,
50 * which are mapped to the #2 and #5 interrupt pins of the MIPS. On our
51 * boards, they all either come in on IntD or they all come in on IntA, they
52 * aren't mixed. There can be numerous PCI interrupts, so we keep a list of the
53 * "requested" interrupt numbers and go through the list whenever we get an
54 * IntA/D.
55 *
56 * Interrupts < 8 are directly wired to the processor; PCI INTA is 8 and
57 * INTD is 11.
58 */
59#define GT_TIMER 4
60#define GT_INTA 2
61#define GT_INTD 5
62
63#ifndef __ASSEMBLY__
64
65/*
66 * GT64120 internal register space base address
67 */
68extern unsigned long gt64120_base;
69
70#define GT64120_BASE (gt64120_base)
71
72/* define WRPPMC_EARLY_DEBUG to enable early output something to UART */
73#undef WRPPMC_EARLY_DEBUG
74
75#ifdef WRPPMC_EARLY_DEBUG
76extern void wrppmc_led_on(int mask);
77extern void wrppmc_led_off(int mask);
78extern void wrppmc_early_printk(const char *fmt, ...);
79#else
80#define wrppmc_early_printk(fmt, ...) do {} while (0)
81#endif /* WRPPMC_EARLY_DEBUG */
82
83#endif /* __ASSEMBLY__ */
84#endif /* __ASM_MIPS_GT64120_H */
diff --git a/include/asm-mips/mipsregs.h b/include/asm-mips/mipsregs.h
index 5af7517fce8a..98b68089aa53 100644
--- a/include/asm-mips/mipsregs.h
+++ b/include/asm-mips/mipsregs.h
@@ -1451,12 +1451,10 @@ static inline void __emt(unsigned int previous)
1451{ 1451{
1452 if ((previous & __EMT_ENABLE)) 1452 if ((previous & __EMT_ENABLE))
1453 __asm__ __volatile__( 1453 __asm__ __volatile__(
1454 " .set noreorder \n"
1455 " .set mips32r2 \n" 1454 " .set mips32r2 \n"
1456 " .word 0x41600be1 # emt \n" 1455 " .word 0x41600be1 # emt \n"
1457 " ehb \n" 1456 " ehb \n"
1458 " .set mips0 \n" 1457 " .set mips0 \n");
1459 " .set reorder \n");
1460} 1458}
1461 1459
1462static inline void __ehb(void) 1460static inline void __ehb(void)
diff --git a/include/asm-mips/mmzone.h b/include/asm-mips/mmzone.h
index 7bde4432092b..f6bd2e0c45a1 100644
--- a/include/asm-mips/mmzone.h
+++ b/include/asm-mips/mmzone.h
@@ -14,17 +14,6 @@
14#define kvaddr_to_nid(kvaddr) pa_to_nid(__pa(kvaddr)) 14#define kvaddr_to_nid(kvaddr) pa_to_nid(__pa(kvaddr))
15#define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT) 15#define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT)
16 16
17#define pfn_valid(pfn) \
18({ \
19 unsigned long __pfn = (pfn); \
20 int __n = pfn_to_nid(__pfn); \
21 ((__n >= 0) ? (__pfn < NODE_DATA(__n)->node_start_pfn + \
22 NODE_DATA(__n)->node_spanned_pages) : 0);\
23})
24
25/* XXX: FIXME -- wli */
26#define kern_addr_valid(addr) (0)
27
28#endif /* CONFIG_DISCONTIGMEM */ 17#endif /* CONFIG_DISCONTIGMEM */
29 18
30#endif /* _ASM_MMZONE_H_ */ 19#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 4035ec79ecd4..3d262c01521c 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -145,6 +145,25 @@ typedef struct { unsigned long pgprot; } pgprot_t;
145#endif 145#endif
146#endif 146#endif
147 147
148#ifdef CONFIG_FLATMEM
149
150#define pfn_valid(pfn) ((pfn) < max_mapnr)
151
152#elif defined(CONFIG_NEED_MULTIPLE_NODES)
153
154#define pfn_valid(pfn) \
155({ \
156 unsigned long __pfn = (pfn); \
157 int __n = pfn_to_nid(__pfn); \
158 ((__n >= 0) ? (__pfn < NODE_DATA(__n)->node_start_pfn + \
159 NODE_DATA(__n)->node_spanned_pages) \
160 : 0); \
161})
162
163#else
164#error Provide a definition of pfn_valid
165#endif
166
148#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 167#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
149#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 168#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
150 169
diff --git a/include/asm-mips/param.h b/include/asm-mips/param.h
index 2bead8273ced..1d9bb8c5ab24 100644
--- a/include/asm-mips/param.h
+++ b/include/asm-mips/param.h
@@ -11,7 +11,7 @@
11 11
12#ifdef __KERNEL__ 12#ifdef __KERNEL__
13 13
14# include <param.h> /* Internal kernel timer frequency */ 14# define HZ CONFIG_HZ /* Internal kernel timer frequency */
15# define USER_HZ 100 /* .. some user interfaces are in "ticks" */ 15# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
16# define CLOCKS_PER_SEC (USER_HZ) /* like times() */ 16# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
17#endif 17#endif
diff --git a/include/asm-mips/pci/bridge.h b/include/asm-mips/pci/bridge.h
index b4ee995c56e6..0c45e7598f3f 100644
--- a/include/asm-mips/pci/bridge.h
+++ b/include/asm-mips/pci/bridge.h
@@ -15,6 +15,7 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <asm/xtalk/xwidget.h> /* generic widget header */ 17#include <asm/xtalk/xwidget.h> /* generic widget header */
18#include <asm/sn/types.h>
18 19
19/* I/O page size */ 20/* I/O page size */
20 21
@@ -848,4 +849,6 @@ struct bridge_controller {
848extern void register_bridge_irq(unsigned int irq); 849extern void register_bridge_irq(unsigned int irq);
849extern int request_bridge_irq(struct bridge_controller *bc); 850extern int request_bridge_irq(struct bridge_controller *bc);
850 851
852extern struct pci_ops bridge_pci_ops;
853
851#endif /* _ASM_PCI_BRIDGE_H */ 854#endif /* _ASM_PCI_BRIDGE_H */
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index d0af2a3b0152..be75cca20e8d 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -379,9 +379,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
379 __update_cache(vma, address, pte); 379 __update_cache(vma, address, pte);
380} 380}
381 381
382#ifndef CONFIG_NEED_MULTIPLE_NODES
383#define kern_addr_valid(addr) (1) 382#define kern_addr_valid(addr) (1)
384#endif
385 383
386#ifdef CONFIG_64BIT_PHYS_ADDR 384#ifdef CONFIG_64BIT_PHYS_ADDR
387extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot); 385extern int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot);
diff --git a/include/asm-mips/processor.h b/include/asm-mips/processor.h
index 0fb75f0762e0..83936469fe87 100644
--- a/include/asm-mips/processor.h
+++ b/include/asm-mips/processor.h
@@ -71,11 +71,6 @@ extern unsigned int vced_count, vcei_count;
71 71
72typedef __u64 fpureg_t; 72typedef __u64 fpureg_t;
73 73
74struct mips_fpu_hard_struct {
75 fpureg_t fpr[NUM_FPU_REGS];
76 unsigned int fcr31;
77};
78
79/* 74/*
80 * It would be nice to add some more fields for emulator statistics, but there 75 * It would be nice to add some more fields for emulator statistics, but there
81 * are a number of fixed offsets in offset.h and elsewhere that would have to 76 * are a number of fixed offsets in offset.h and elsewhere that would have to
@@ -83,18 +78,13 @@ struct mips_fpu_hard_struct {
83 * the FPU emulator for now. See asm-mips/fpu_emulator.h. 78 * the FPU emulator for now. See asm-mips/fpu_emulator.h.
84 */ 79 */
85 80
86struct mips_fpu_soft_struct { 81struct mips_fpu_struct {
87 fpureg_t fpr[NUM_FPU_REGS]; 82 fpureg_t fpr[NUM_FPU_REGS];
88 unsigned int fcr31; 83 unsigned int fcr31;
89}; 84};
90 85
91union mips_fpu_union {
92 struct mips_fpu_hard_struct hard;
93 struct mips_fpu_soft_struct soft;
94};
95
96#define INIT_FPU { \ 86#define INIT_FPU { \
97 {{0,},} \ 87 {0,} \
98} 88}
99 89
100#define NUM_DSP_REGS 6 90#define NUM_DSP_REGS 6
@@ -133,7 +123,7 @@ struct thread_struct {
133 unsigned long cp0_status; 123 unsigned long cp0_status;
134 124
135 /* Saved fpu/fpu emulator stuff. */ 125 /* Saved fpu/fpu emulator stuff. */
136 union mips_fpu_union fpu; 126 struct mips_fpu_struct fpu;
137#ifdef CONFIG_MIPS_MT_FPAFF 127#ifdef CONFIG_MIPS_MT_FPAFF
138 /* Emulated instruction count */ 128 /* Emulated instruction count */
139 unsigned long emulated_fp; 129 unsigned long emulated_fp;
diff --git a/include/asm-mips/qemu.h b/include/asm-mips/qemu.h
index 905c39585903..531caf44560c 100644
--- a/include/asm-mips/qemu.h
+++ b/include/asm-mips/qemu.h
@@ -21,4 +21,10 @@
21 */ 21 */
22#define QEMU_C0_COUNTER_CLOCK 100000000 22#define QEMU_C0_COUNTER_CLOCK 100000000
23 23
24/*
25 * Magic qemu system control location.
26 */
27#define QEMU_RESTART_REG 0xBFBF0000
28#define QEMU_HALT_REG 0xBFBF0004
29
24#endif /* __ASM_QEMU_H */ 30#endif /* __ASM_QEMU_H */
diff --git a/include/asm-mips/rm9k-ocd.h b/include/asm-mips/rm9k-ocd.h
new file mode 100644
index 000000000000..b0b80d9ecf96
--- /dev/null
+++ b/include/asm-mips/rm9k-ocd.h
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2004 by Basler Vision Technologies AG
3 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#if !defined(_ASM_RM9K_OCD_H)
21#define _ASM_RM9K_OCD_H
22
23#include <linux/types.h>
24#include <linux/spinlock.h>
25#include <asm/io.h>
26
27extern volatile void __iomem * const ocd_base;
28extern volatile void __iomem * const titan_base;
29
30#define ocd_addr(__x__) (ocd_base + (__x__))
31#define titan_addr(__x__) (titan_base + (__x__))
32#define scram_addr(__x__) (scram_base + (__x__))
33
34/* OCD register access */
35#define ocd_readl(__offs__) __raw_readl(ocd_addr(__offs__))
36#define ocd_readw(__offs__) __raw_readw(ocd_addr(__offs__))
37#define ocd_readb(__offs__) __raw_readb(ocd_addr(__offs__))
38#define ocd_writel(__val__, __offs__) \
39 __raw_writel((__val__), ocd_addr(__offs__))
40#define ocd_writew(__val__, __offs__) \
41 __raw_writew((__val__), ocd_addr(__offs__))
42#define ocd_writeb(__val__, __offs__) \
43 __raw_writeb((__val__), ocd_addr(__offs__))
44
45/* TITAN register access - 32 bit-wide only */
46#define titan_readl(__offs__) __raw_readl(titan_addr(__offs__))
47#define titan_writel(__val__, __offs__) \
48 __raw_writel((__val__), titan_addr(__offs__))
49
50/* Protect access to shared TITAN registers */
51extern spinlock_t titan_lock;
52extern int titan_irqflags;
53#define lock_titan_regs() spin_lock_irqsave(&titan_lock, titan_irqflags)
54#define unlock_titan_regs() spin_unlock_irqrestore(&titan_lock, titan_irqflags)
55
56#endif /* !defined(_ASM_RM9K_OCD_H) */
diff --git a/include/asm-mips/sn/addrs.h b/include/asm-mips/sn/addrs.h
index 2b5cef1ba37f..6c8a5577ddf1 100644
--- a/include/asm-mips/sn/addrs.h
+++ b/include/asm-mips/sn/addrs.h
@@ -27,13 +27,8 @@
27 27
28#ifndef __ASSEMBLY__ 28#ifndef __ASSEMBLY__
29 29
30#if defined(CONFIG_SGI_IO) /* FIXME */
31#define PS_UINT_CAST (__psunsigned_t)
32#define UINT64_CAST (__uint64_t)
33#else /* CONFIG_SGI_IO */
34#define PS_UINT_CAST (unsigned long) 30#define PS_UINT_CAST (unsigned long)
35#define UINT64_CAST (unsigned long) 31#define UINT64_CAST (unsigned long)
36#endif /* CONFIG_SGI_IO */
37 32
38#define HUBREG_CAST (volatile hubreg_t *) 33#define HUBREG_CAST (volatile hubreg_t *)
39 34
@@ -253,14 +248,6 @@
253 * for _x. 248 * for _x.
254 */ 249 */
255 250
256#ifdef _STANDALONE
257
258/* DO NOT USE THESE DIRECTLY IN THE KERNEL. SEE BELOW. */
259#define LOCAL_HUB(_x) (HUBREG_CAST (IALIAS_BASE + (_x)))
260#define REMOTE_HUB(_n, _x) (HUBREG_CAST (NODE_SWIN_BASE(_n, 1) + \
261 0x800000 + (_x)))
262#endif /* _STANDALONE */
263
264/* 251/*
265 * WARNING: 252 * WARNING:
266 * When certain Hub chip workaround are defined, it's not sufficient 253 * When certain Hub chip workaround are defined, it's not sufficient
@@ -327,20 +314,6 @@
327 PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET) 314 PHYS_TO_K0(NODE_OFFSET(nasid) | ARCS_SPB_OFFSET)
328#define ARCS_SPB_SIZE 0x0400 315#define ARCS_SPB_SIZE 0x0400
329 316
330#ifdef _STANDALONE
331
332#define ARCS_TVECTOR_OFFSET 0x2800
333#define ARCS_PVECTOR_OFFSET 0x2c00
334
335/*
336 * These addresses are used by the master CPU to install the transfer
337 * and private vectors. All others use the SPB to find them.
338 */
339#define TVADDR (NODE_CAC_BASE(get_nasid()) + ARCS_TVECTOR_OFFSET)
340#define PVADDR (NODE_CAC_BASE(get_nasid()) + ARCS_PVECTOR_OFFSET)
341
342#endif /* _STANDALONE */
343
344#define KLDIR_OFFSET 0x2000 317#define KLDIR_OFFSET 0x2000
345#define KLDIR_ADDR(nasid) \ 318#define KLDIR_ADDR(nasid) \
346 TO_NODE_UNCAC((nasid), KLDIR_OFFSET) 319 TO_NODE_UNCAC((nasid), KLDIR_OFFSET)
diff --git a/include/asm-mips/sn/sn0/sn0_fru.h b/include/asm-mips/sn/fru.h
index 82c6377c275a..b3e3606723b7 100644
--- a/include/asm-mips/sn/sn0/sn0_fru.h
+++ b/include/asm-mips/sn/fru.h
@@ -6,10 +6,10 @@
6 * Derived from IRIX <sys/SN/SN0/sn0_fru.h> 6 * Derived from IRIX <sys/SN/SN0/sn0_fru.h>
7 * 7 *
8 * Copyright (C) 1992 - 1997, 1999 Silcon Graphics, Inc. 8 * Copyright (C) 1992 - 1997, 1999 Silcon Graphics, Inc.
9 * Copyright (C) 1999 Ralf Baechle (ralf@gnu.org) 9 * Copyright (C) 1999, 2006 Ralf Baechle (ralf@linux-mips)
10 */ 10 */
11#ifndef _ASM_SN_SN0_SN0_FRU_H 11#ifndef __ASM_SN_FRU_H
12#define _ASM_SN_SN0_SN0_FRU_H 12#define __ASM_SN_FRU_H
13 13
14#define MAX_DIMMS 8 /* max # of dimm banks */ 14#define MAX_DIMMS 8 /* max # of dimm banks */
15#define MAX_PCIDEV 8 /* max # of pci devices on a pci bus */ 15#define MAX_PCIDEV 8 /* max # of pci devices on a pci bus */
@@ -41,4 +41,4 @@ typedef struct kf_pci_bus_s {
41 /* confidence level that the pci dev is bad */ 41 /* confidence level that the pci dev is bad */
42} kf_pci_bus_t; 42} kf_pci_bus_t;
43 43
44#endif /* _ASM_SN_SN0_SN0_FRU_H */ 44#endif /* __ASM_SN_FRU_H */
diff --git a/include/asm-mips/sn/klconfig.h b/include/asm-mips/sn/klconfig.h
index 9709ff701d9b..dc706268d2cf 100644
--- a/include/asm-mips/sn/klconfig.h
+++ b/include/asm-mips/sn/klconfig.h
@@ -37,7 +37,7 @@
37//#include <sys/SN/router.h> 37//#include <sys/SN/router.h>
38// XXX Stolen from <sys/SN/router.h>: 38// XXX Stolen from <sys/SN/router.h>:
39#define MAX_ROUTER_PORTS (6) /* Max. number of ports on a router */ 39#define MAX_ROUTER_PORTS (6) /* Max. number of ports on a router */
40#include <asm/sn/sn0/sn0_fru.h> 40#include <asm/sn/fru.h>
41//#include <sys/graph.h> 41//#include <sys/graph.h>
42//#include <sys/xtalk/xbow.h> 42//#include <sys/xtalk/xbow.h>
43 43
@@ -54,32 +54,21 @@
54#include <asm/sn/agent.h> 54#include <asm/sn/agent.h>
55#include <asm/arc/types.h> 55#include <asm/arc/types.h>
56#include <asm/arc/hinv.h> 56#include <asm/arc/hinv.h>
57#if defined(CONFIG_SGI_IO) || defined(CONFIG_SGI_IP35) 57#if defined(CONFIG_SGI_IP35)
58// The hack file has to be before vector and after sn0_fru.... 58// The hack file has to be before vector and after sn0_fru....
59#include <asm/hack.h> 59#include <asm/hack.h>
60#include <asm/sn/vector.h> 60#include <asm/sn/vector.h>
61#include <asm/xtalk/xtalk.h> 61#include <asm/xtalk/xtalk.h>
62#endif /* CONFIG_SGI_IO || CONFIG_SGI_IP35 */ 62#endif /* CONFIG_SGI_IP35 */
63#endif /* CONFIG_SGI_IP27 || CONFIG_SGI_IP35 */ 63#endif /* CONFIG_SGI_IP27 || CONFIG_SGI_IP35 */
64 64
65#define KLCFGINFO_MAGIC 0xbeedbabe 65#define KLCFGINFO_MAGIC 0xbeedbabe
66 66
67#ifdef FRUTEST
68typedef u64 klconf_off_t;
69#else
70typedef s32 klconf_off_t; 67typedef s32 klconf_off_t;
71#endif
72 68
73/* 69/*
74 * Some IMPORTANT OFFSETS. These are the offsets on all NODES. 70 * Some IMPORTANT OFFSETS. These are the offsets on all NODES.
75 */ 71 */
76#if 0
77#define RAMBASE 0
78#define ARCSSPB_OFF 0x1000 /* shift it to sys/arcs/spb.h */
79
80#define OFF_HWGRAPH 0
81#endif
82
83#define MAX_MODULE_ID 255 72#define MAX_MODULE_ID 255
84#define SIZE_PAD 4096 /* 4k padding for structures */ 73#define SIZE_PAD 4096 /* 4k padding for structures */
85/* 74/*
@@ -134,15 +123,9 @@ typedef s32 klconf_off_t;
134 123
135 124
136typedef struct console_s { 125typedef struct console_s {
137#if defined(CONFIG_SGI_IO) /* FIXME */
138 __psunsigned_t uart_base;
139 __psunsigned_t config_base;
140 __psunsigned_t memory_base;
141#else
142 unsigned long uart_base; 126 unsigned long uart_base;
143 unsigned long config_base; 127 unsigned long config_base;
144 unsigned long memory_base; 128 unsigned long memory_base;
145#endif
146 short baud; 129 short baud;
147 short flag; 130 short flag;
148 int type; 131 int type;
@@ -174,10 +157,6 @@ typedef struct kl_config_hdr {
174 157
175 158
176#define KL_CONFIG_HDR(_nasid) ((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid))) 159#define KL_CONFIG_HDR(_nasid) ((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
177#if 0
178#define KL_CONFIG_MALLOC_HDR(_nasid) \
179 (KL_CONFIG_HDR(_nasid)->ch_malloc_hdr)
180#endif
181#define KL_CONFIG_INFO_OFFSET(_nasid) \ 160#define KL_CONFIG_INFO_OFFSET(_nasid) \
182 (KL_CONFIG_HDR(_nasid)->ch_board_info) 161 (KL_CONFIG_HDR(_nasid)->ch_board_info)
183#define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off) \ 162#define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off) \
@@ -197,23 +176,13 @@ typedef struct kl_config_hdr {
197 176
198/* --- New Macros for the changed kl_config_hdr_t structure --- */ 177/* --- New Macros for the changed kl_config_hdr_t structure --- */
199 178
200#if defined(CONFIG_SGI_IO)
201#define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\
202 ((__psunsigned_t)_k + (_k->ch_malloc_hdr_off)))
203#else
204#define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\ 179#define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\
205 (unsigned long)_k + (_k->ch_malloc_hdr_off))) 180 (unsigned long)_k + (_k->ch_malloc_hdr_off)))
206#endif
207 181
208#define KL_CONFIG_CH_MALLOC_HDR(_n) PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n)) 182#define KL_CONFIG_CH_MALLOC_HDR(_n) PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
209 183
210#if defined(CONFIG_SGI_IO)
211#define PTR_CH_CONS_INFO(_k) ((console_t *)\
212 ((__psunsigned_t)_k + (_k->ch_cons_off)))
213#else
214#define PTR_CH_CONS_INFO(_k) ((console_t *)\ 184#define PTR_CH_CONS_INFO(_k) ((console_t *)\
215 ((unsigned long)_k + (_k->ch_cons_off))) 185 ((unsigned long)_k + (_k->ch_cons_off)))
216#endif
217 186
218#define KL_CONFIG_CH_CONS_INFO(_n) PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n)) 187#define KL_CONFIG_CH_CONS_INFO(_n) PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n))
219 188
@@ -490,14 +459,6 @@ typedef struct lboard_s {
490#define KLCF_NUM_COMPS(_brd) ((_brd)->brd_numcompts) 459#define KLCF_NUM_COMPS(_brd) ((_brd)->brd_numcompts)
491#define KLCF_MODULE_ID(_brd) ((_brd)->brd_module) 460#define KLCF_MODULE_ID(_brd) ((_brd)->brd_module)
492 461
493#ifdef FRUTEST
494
495#define KLCF_NEXT(_brd) ((_brd)->brd_next ? (lboard_t *)((_brd)->brd_next): NULL)
496#define KLCF_COMP(_brd, _ndx) (klinfo_t *)((_brd)->brd_compts[(_ndx)])
497#define KLCF_COMP_ERROR(_brd, _comp) (_brd = _brd , (_comp)->errinfo)
498
499#else
500
501#define KLCF_NEXT(_brd) \ 462#define KLCF_NEXT(_brd) \
502 ((_brd)->brd_next ? \ 463 ((_brd)->brd_next ? \
503 (lboard_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), (_brd)->brd_next)):\ 464 (lboard_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), (_brd)->brd_next)):\
@@ -509,8 +470,6 @@ typedef struct lboard_s {
509#define KLCF_COMP_ERROR(_brd, _comp) \ 470#define KLCF_COMP_ERROR(_brd, _comp) \
510 (NODE_OFFSET_TO_K1(NASID_GET(_brd), (_comp)->errinfo)) 471 (NODE_OFFSET_TO_K1(NASID_GET(_brd), (_comp)->errinfo))
511 472
512#endif
513
514#define KLCF_COMP_TYPE(_comp) ((_comp)->struct_type) 473#define KLCF_COMP_TYPE(_comp) ((_comp)->struct_type)
515#define KLCF_BRIDGE_W_ID(_comp) ((_comp)->physid) /* Widget ID */ 474#define KLCF_BRIDGE_W_ID(_comp) ((_comp)->physid) /* Widget ID */
516 475
@@ -631,18 +590,6 @@ typedef struct klport_s {
631 klconf_off_t port_offset; 590 klconf_off_t port_offset;
632} klport_t; 591} klport_t;
633 592
634#if 0
635/*
636 * This is very similar to the klport_s but instead of having a componant
637 * offset it has a board offset.
638 */
639typedef struct klxbow_port_s {
640 nasid_t port_nasid;
641 unsigned char port_flag;
642 klconf_off_t board_offset;
643} klxbow_port_t;
644#endif
645
646typedef struct klcpu_s { /* CPU */ 593typedef struct klcpu_s { /* CPU */
647 klinfo_t cpu_info; 594 klinfo_t cpu_info;
648 unsigned short cpu_prid; /* Processor PRID value */ 595 unsigned short cpu_prid; /* Processor PRID value */
@@ -945,36 +892,6 @@ extern klcpu_t *nasid_slice_to_cpuinfo(nasid_t, int);
945extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class); 892extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class);
946 893
947 894
948#if defined(CONFIG_SGI_IO)
949extern xwidgetnum_t nodevertex_widgetnum_get(vertex_hdl_t node_vtx);
950extern vertex_hdl_t nodevertex_xbow_peer_get(vertex_hdl_t node_vtx);
951extern lboard_t *find_gfxpipe(int pipenum);
952extern void setup_gfxpipe_link(vertex_hdl_t vhdl,int pipenum);
953extern lboard_t *find_lboard_module_class(lboard_t *start, moduleid_t mod,
954 unsigned char brd_class);
955extern lboard_t *find_nic_lboard(lboard_t *, nic_t);
956extern lboard_t *find_nic_type_lboard(nasid_t, unsigned char, nic_t);
957extern lboard_t *find_lboard_modslot(lboard_t *start, moduleid_t mod, slotid_t slot);
958extern lboard_t *find_lboard_module(lboard_t *start, moduleid_t mod);
959extern lboard_t *get_board_name(nasid_t nasid, moduleid_t mod, slotid_t slot, char *name);
960extern int config_find_nic_router(nasid_t, nic_t, lboard_t **, klrou_t**);
961extern int config_find_nic_hub(nasid_t, nic_t, lboard_t **, klhub_t**);
962extern int config_find_xbow(nasid_t, lboard_t **, klxbow_t**);
963extern klcpu_t *get_cpuinfo(cpuid_t cpu);
964extern int update_klcfg_cpuinfo(nasid_t, int);
965extern void board_to_path(lboard_t *brd, char *path);
966extern moduleid_t get_module_id(nasid_t nasid);
967extern void nic_name_convert(char *old_name, char *new_name);
968extern int module_brds(nasid_t nasid, lboard_t **module_brds, int n);
969extern lboard_t *brd_from_key(ulong_t key);
970extern void device_component_canonical_name_get(lboard_t *,klinfo_t *,
971 char *);
972extern int board_serial_number_get(lboard_t *,char *);
973extern int is_master_baseio(nasid_t,moduleid_t,slotid_t);
974extern nasid_t get_actual_nasid(lboard_t *brd) ;
975extern net_vec_t klcfg_discover_route(lboard_t *, lboard_t *, int);
976#else /* CONFIG_SGI_IO */
977extern klcpu_t *sn_get_cpuinfo(cpuid_t cpu); 895extern klcpu_t *sn_get_cpuinfo(cpuid_t cpu);
978#endif /* CONFIG_SGI_IO */
979 896
980#endif /* _ASM_SN_KLCONFIG_H */ 897#endif /* _ASM_SN_KLCONFIG_H */
diff --git a/include/asm-mips/sn/kldir.h b/include/asm-mips/sn/kldir.h
index f0efab1672ec..97ad52e3cbc7 100644
--- a/include/asm-mips/sn/kldir.h
+++ b/include/asm-mips/sn/kldir.h
@@ -13,10 +13,6 @@
13 13
14#include <linux/config.h> 14#include <linux/config.h>
15 15
16#if defined(CONFIG_SGI_IO)
17#include <asm/hack.h>
18#endif
19
20/* 16/*
21 * The kldir memory area resides at a fixed place in each node's memory and 17 * The kldir memory area resides at a fixed place in each node's memory and
22 * provides pointers to most other IP27 memory areas. This allows us to 18 * provides pointers to most other IP27 memory areas. This allows us to
@@ -136,8 +132,6 @@
136#define KLDIR_OFF_STRIDE 0x28 132#define KLDIR_OFF_STRIDE 0x28
137#endif /* __ASSEMBLY__ */ 133#endif /* __ASSEMBLY__ */
138 134
139#if !defined(CONFIG_SGI_IO)
140
141/* 135/*
142 * This is defined here because IP27_SYMMON_STK_SIZE must be at least what 136 * This is defined here because IP27_SYMMON_STK_SIZE must be at least what
143 * we define here. Since it's set up in the prom. We can't redefine it later 137 * we define here. Since it's set up in the prom. We can't redefine it later
@@ -147,7 +141,7 @@
147 */ 141 */
148#define SYMMON_STACK_SIZE 0x8000 142#define SYMMON_STACK_SIZE 0x8000
149 143
150#if defined (PROM) || defined (SABLE) 144#if defined (PROM)
151 145
152/* 146/*
153 * These defines are prom version dependent. No code other than the IP27 147 * These defines are prom version dependent. No code other than the IP27
@@ -184,7 +178,7 @@
184#define IP27_FREEMEM_COUNT 1 178#define IP27_FREEMEM_COUNT 1
185#define IP27_FREEMEM_STRIDE 0 179#define IP27_FREEMEM_STRIDE 0
186 180
187#endif /* PROM || SABLE*/ 181#endif /* PROM */
188/* 182/*
189 * There will be only one of these in a partition so the IO6 must set it up. 183 * There will be only one of these in a partition so the IO6 must set it up.
190 */ 184 */
@@ -207,17 +201,11 @@
207#define KLDIR_ENT_SIZE 0x40 201#define KLDIR_ENT_SIZE 0x40
208#define KLDIR_MAX_ENTRIES (0x400 / 0x40) 202#define KLDIR_MAX_ENTRIES (0x400 / 0x40)
209 203
210#endif /* !CONFIG_SGI_IO */
211
212#ifndef __ASSEMBLY__ 204#ifndef __ASSEMBLY__
213typedef struct kldir_ent_s { 205typedef struct kldir_ent_s {
214 u64 magic; /* Indicates validity of entry */ 206 u64 magic; /* Indicates validity of entry */
215 off_t offset; /* Offset from start of node space */ 207 off_t offset; /* Offset from start of node space */
216#if defined(CONFIG_SGI_IO) /* FIXME */
217 __psunsigned_t pointer; /* Pointer to area in some cases */
218#else
219 unsigned long pointer; /* Pointer to area in some cases */ 208 unsigned long pointer; /* Pointer to area in some cases */
220#endif
221 size_t size; /* Size in bytes */ 209 size_t size; /* Size in bytes */
222 u64 count; /* Repeat count if array, 1 if not */ 210 u64 count; /* Repeat count if array, 1 if not */
223 size_t stride; /* Stride if array, 0 if not */ 211 size_t stride; /* Stride if array, 0 if not */
@@ -227,22 +215,4 @@ typedef struct kldir_ent_s {
227} kldir_ent_t; 215} kldir_ent_t;
228#endif /* !__ASSEMBLY__ */ 216#endif /* !__ASSEMBLY__ */
229 217
230#if defined(CONFIG_SGI_IO)
231
232#define KLDIR_ENT_SIZE 0x40
233#define KLDIR_MAX_ENTRIES (0x400 / 0x40)
234
235/*
236 * The actual offsets of each memory area are machine-dependent
237 */
238#ifdef CONFIG_SGI_IP27
239// Not yet #include <asm/sn/sn0/kldir.h>
240#elif defined(CONFIG_SGI_IP35)
241#include <asm/sn/sn1/kldir.h>
242#else
243#error "kldir.h is currently defined for IP27 and IP35 platforms only"
244#endif
245
246#endif /* CONFIG_SGI_IO */
247
248#endif /* _ASM_SN_KLDIR_H */ 218#endif /* _ASM_SN_KLDIR_H */
diff --git a/include/asm-mips/sn/sn0/addrs.h b/include/asm-mips/sn/sn0/addrs.h
index 398815639fb8..2c4b758f6736 100644
--- a/include/asm-mips/sn/sn0/addrs.h
+++ b/include/asm-mips/sn/sn0/addrs.h
@@ -49,7 +49,7 @@
49 * so for now we just use defines bracketed by an ifdef. 49 * so for now we just use defines bracketed by an ifdef.
50 */ 50 */
51 51
52#ifdef CONFIG_SGI_SN0_N_MODE 52#ifdef CONFIG_SGI_SN_N_MODE
53 53
54#define NODE_SIZE_BITS 31 54#define NODE_SIZE_BITS 31
55#define BWIN_SIZE_BITS 28 55#define BWIN_SIZE_BITS 28
@@ -63,7 +63,7 @@
63#define BDDIR_UPPER_MASK (UINT64_CAST 0x7ffff << 10) 63#define BDDIR_UPPER_MASK (UINT64_CAST 0x7ffff << 10)
64#define BDECC_UPPER_MASK (UINT64_CAST 0x3ffffff << 3) 64#define BDECC_UPPER_MASK (UINT64_CAST 0x3ffffff << 3)
65 65
66#else /* !defined(CONFIG_SGI_SN0_N_MODE), assume that M-mode is desired */ 66#else /* !defined(CONFIG_SGI_SN_N_MODE), assume that M-mode is desired */
67 67
68#define NODE_SIZE_BITS 32 68#define NODE_SIZE_BITS 32
69#define BWIN_SIZE_BITS 29 69#define BWIN_SIZE_BITS 29
@@ -77,7 +77,7 @@
77#define BDDIR_UPPER_MASK (UINT64_CAST 0xfffff << 10) 77#define BDDIR_UPPER_MASK (UINT64_CAST 0xfffff << 10)
78#define BDECC_UPPER_MASK (UINT64_CAST 0x7ffffff << 3) 78#define BDECC_UPPER_MASK (UINT64_CAST 0x7ffffff << 3)
79 79
80#endif /* !defined(CONFIG_SGI_SN0_N_MODE) */ 80#endif /* !defined(CONFIG_SGI_SN_N_MODE) */
81 81
82#define NODE_ADDRSPACE_SIZE (UINT64_CAST 1 << NODE_SIZE_BITS) 82#define NODE_ADDRSPACE_SIZE (UINT64_CAST 1 << NODE_SIZE_BITS)
83 83
@@ -85,15 +85,15 @@
85#define NASID_GET(_pa) (int) ((UINT64_CAST (_pa) >> \ 85#define NASID_GET(_pa) (int) ((UINT64_CAST (_pa) >> \
86 NASID_SHFT) & NASID_BITMASK) 86 NASID_SHFT) & NASID_BITMASK)
87 87
88#if !defined(__ASSEMBLY__) && !defined(_STANDALONE) 88#if !defined(__ASSEMBLY__)
89 89
90#define NODE_SWIN_BASE(nasid, widget) \ 90#define NODE_SWIN_BASE(nasid, widget) \
91 ((widget == 0) ? NODE_BWIN_BASE((nasid), SWIN0_BIGWIN) \ 91 ((widget == 0) ? NODE_BWIN_BASE((nasid), SWIN0_BIGWIN) \
92 : RAW_NODE_SWIN_BASE(nasid, widget)) 92 : RAW_NODE_SWIN_BASE(nasid, widget))
93#else /* __ASSEMBLY__ || _STANDALONE */ 93#else /* __ASSEMBLY__ */
94#define NODE_SWIN_BASE(nasid, widget) \ 94#define NODE_SWIN_BASE(nasid, widget) \
95 (NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS)) 95 (NODE_IO_BASE(nasid) + (UINT64_CAST (widget) << SWIN_SIZE_BITS))
96#endif /* __ASSEMBLY__ || _STANDALONE */ 96#endif /* __ASSEMBLY__ */
97 97
98/* 98/*
99 * The following definitions pertain to the IO special address 99 * The following definitions pertain to the IO special address
@@ -143,12 +143,7 @@
143#define SN0_WIDGET_BASE(_nasid, _wid) (NODE_SWIN_BASE((_nasid), (_wid))) 143#define SN0_WIDGET_BASE(_nasid, _wid) (NODE_SWIN_BASE((_nasid), (_wid)))
144 144
145/* Turn on sable logging for the processors whose bits are set. */ 145/* Turn on sable logging for the processors whose bits are set. */
146#ifdef SABLE
147#define SABLE_LOG_TRIGGER(_map) \
148 *((volatile hubreg_t *)(IO_BASE + 0x17ffff0)) = (_map)
149#else
150#define SABLE_LOG_TRIGGER(_map) 146#define SABLE_LOG_TRIGGER(_map)
151#endif /* SABLE */
152 147
153#ifndef __ASSEMBLY__ 148#ifndef __ASSEMBLY__
154#define KERN_NMI_ADDR(nasid, slice) \ 149#define KERN_NMI_ADDR(nasid, slice) \
@@ -281,76 +276,6 @@
281 276
282#define _ARCSPROM 277#define _ARCSPROM
283 278
284#ifdef _STANDALONE
285
286/*
287 * The PROM needs to pass the device base address and the
288 * device pci cfg space address to the device drivers during
289 * install. The COMPONENT->Key field is used for this purpose.
290 * Macros needed by SN0 device drivers to convert the
291 * COMPONENT->Key field to the respective base address.
292 * Key field looks as follows:
293 *
294 * +----------------------------------------------------+
295 * |devnasid | widget |pciid |hubwidid|hstnasid | adap |
296 * | 2 | 1 | 1 | 1 | 2 | 1 |
297 * +----------------------------------------------------+
298 * | | | | | | |
299 * 64 48 40 32 24 8 0
300 *
301 * These are used by standalone drivers till the io infrastructure
302 * is in place.
303 */
304
305#ifndef __ASSEMBLY__
306
307#define uchar unsigned char
308
309#define KEY_DEVNASID_SHFT 48
310#define KEY_WIDID_SHFT 40
311#define KEY_PCIID_SHFT 32
312#define KEY_HUBWID_SHFT 24
313#define KEY_HSTNASID_SHFT 8
314
315#define MK_SN0_KEY(nasid, widid, pciid) \
316 ((((__psunsigned_t)nasid)<< KEY_DEVNASID_SHFT |\
317 ((__psunsigned_t)widid) << KEY_WIDID_SHFT) |\
318 ((__psunsigned_t)pciid) << KEY_PCIID_SHFT)
319
320#define ADD_HUBWID_KEY(key,hubwid)\
321 (key|=((__psunsigned_t)hubwid << KEY_HUBWID_SHFT))
322
323#define ADD_HSTNASID_KEY(key,hstnasid)\
324 (key|=((__psunsigned_t)hstnasid << KEY_HSTNASID_SHFT))
325
326#define GET_DEVNASID_FROM_KEY(key) ((short)(key >> KEY_DEVNASID_SHFT))
327#define GET_WIDID_FROM_KEY(key) ((uchar)(key >> KEY_WIDID_SHFT))
328#define GET_PCIID_FROM_KEY(key) ((uchar)(key >> KEY_PCIID_SHFT))
329#define GET_HUBWID_FROM_KEY(key) ((uchar)(key >> KEY_HUBWID_SHFT))
330#define GET_HSTNASID_FROM_KEY(key) ((short)(key >> KEY_HSTNASID_SHFT))
331
332#define PCI_64_TARGID_SHFT 60
333
334#define GET_PCIBASE_FROM_KEY(key) (NODE_SWIN_BASE(GET_DEVNASID_FROM_KEY(key),\
335 GET_WIDID_FROM_KEY(key))\
336 | BRIDGE_DEVIO(GET_PCIID_FROM_KEY(key)))
337
338#define GET_PCICFGBASE_FROM_KEY(key) \
339 (NODE_SWIN_BASE(GET_DEVNASID_FROM_KEY(key),\
340 GET_WIDID_FROM_KEY(key))\
341 | BRIDGE_TYPE0_CFG_DEV(GET_PCIID_FROM_KEY(key)))
342
343#define GET_WIDBASE_FROM_KEY(key) \
344 (NODE_SWIN_BASE(GET_DEVNASID_FROM_KEY(key),\
345 GET_WIDID_FROM_KEY(key)))
346
347#define PUT_INSTALL_STATUS(c,s) c->Revision = s
348#define GET_INSTALL_STATUS(c) c->Revision
349
350#endif /* !__ASSEMBLY__ */
351
352#endif /* _STANDALONE */
353
354#if defined (HUB_ERR_STS_WAR) 279#if defined (HUB_ERR_STS_WAR)
355 280
356#define ERR_STS_WAR_REGISTER IIO_IIBUSERR 281#define ERR_STS_WAR_REGISTER IIO_IIBUSERR
diff --git a/include/asm-mips/sn/sn0/arch.h b/include/asm-mips/sn/sn0/arch.h
index fb78773a5efe..f7c43fa24aa8 100644
--- a/include/asm-mips/sn/sn0/arch.h
+++ b/include/asm-mips/sn/sn0/arch.h
@@ -13,8 +13,6 @@
13 13
14#include <linux/config.h> 14#include <linux/config.h>
15 15
16#ifndef SABLE
17
18#ifndef SN0XXL /* 128 cpu SMP max */ 16#ifndef SN0XXL /* 128 cpu SMP max */
19/* 17/*
20 * This is the maximum number of nodes that can be part of a kernel. 18 * This is the maximum number of nodes that can be part of a kernel.
@@ -54,25 +52,16 @@
54 */ 52 */
55#define MAX_PARTITIONS MAX_REGIONS 53#define MAX_PARTITIONS MAX_REGIONS
56 54
57
58#else
59
60#define MAX_COMPACT_NODES 4
61#define MAX_NASIDS 4
62#define MAXCPUS 8
63
64#endif
65
66#define NASID_MASK_BYTES ((MAX_NASIDS + 7) / 8) 55#define NASID_MASK_BYTES ((MAX_NASIDS + 7) / 8)
67 56
68/* 57/*
69 * Slot constants for SN0 58 * Slot constants for SN0
70 */ 59 */
71#ifdef CONFIG_SGI_SN0_N_MODE 60#ifdef CONFIG_SGI_SN_N_MODE
72#define MAX_MEM_SLOTS 16 /* max slots per node */ 61#define MAX_MEM_SLOTS 16 /* max slots per node */
73#else /* !CONFIG_SGI_SN0_N_MODE, assume M_MODE */ 62#else /* !CONFIG_SGI_SN_N_MODE, assume CONFIG_SGI_SN_M_MODE */
74#define MAX_MEM_SLOTS 32 /* max slots per node */ 63#define MAX_MEM_SLOTS 32 /* max slots per node */
75#endif /* defined(N_MODE) */ 64#endif /* CONFIG_SGI_SN_M_MODE */
76 65
77#define SLOT_SHIFT (27) 66#define SLOT_SHIFT (27)
78#define SLOT_MIN_MEM_SIZE (32*1024*1024) 67#define SLOT_MIN_MEM_SIZE (32*1024*1024)
diff --git a/include/asm-mips/sn/sn0/hub.h b/include/asm-mips/sn/sn0/hub.h
index f5dbba6f4610..3e228f8e7969 100644
--- a/include/asm-mips/sn/sn0/hub.h
+++ b/include/asm-mips/sn/sn0/hub.h
@@ -31,10 +31,6 @@
31#include <asm/sn/sn0/hubni.h> 31#include <asm/sn/sn0/hubni.h>
32//#include <asm/sn/sn0/hubcore.h> 32//#include <asm/sn/sn0/hubcore.h>
33 33
34#ifdef SABLE
35#define IP27_NO_HUBUART_INT 1
36#endif
37
38/* Translation of uncached attributes */ 34/* Translation of uncached attributes */
39#define UATTR_HSPEC 0 35#define UATTR_HSPEC 0
40#define UATTR_IO 1 36#define UATTR_IO 1
diff --git a/include/asm-mips/sn/sn0/hubio.h b/include/asm-mips/sn/sn0/hubio.h
index f314da21b970..ef91b3363554 100644
--- a/include/asm-mips/sn/sn0/hubio.h
+++ b/include/asm-mips/sn/sn0/hubio.h
@@ -486,22 +486,6 @@ typedef union h1_icrba_u {
486#define ICRBN_A_CERR_SHFT 54 486#define ICRBN_A_CERR_SHFT 54
487#define ICRBN_A_ERR_MASK 0x3ff 487#define ICRBN_A_ERR_MASK 0x3ff
488 488
489#if 0 /* Disabled, this causes namespace polution and break allmodconfig */
490/*
491 * Easy access macros.
492 */
493#define a_error icrba_fields_s.error
494#define a_ecode icrba_fields_s.ecode
495#define a_lnetuce icrba_fields_s.lnetuce
496#define a_mark icrba_fields_s.mark
497#define a_xerr icrba_fields_s.xerr
498#define a_sidn icrba_fields_s.sidn
499#define a_tnum icrba_fields_s.tnum
500#define a_addr icrba_fields_s.addr
501#define a_valid icrba_fields_s.valid
502#define a_iow icrba_fields_s.iow
503#endif
504
505#endif /* !__ASSEMBLY__ */ 489#endif /* !__ASSEMBLY__ */
506 490
507#define IIO_ICRB_ADDR_SHFT 2 /* Shift to get proper address */ 491#define IIO_ICRB_ADDR_SHFT 2 /* Shift to get proper address */
diff --git a/include/asm-mips/sn/sn0/hubmd.h b/include/asm-mips/sn/sn0/hubmd.h
index a66def4e0ba0..1006aa26d771 100644
--- a/include/asm-mips/sn/sn0/hubmd.h
+++ b/include/asm-mips/sn/sn0/hubmd.h
@@ -92,7 +92,7 @@
92#define MD_UREG1_14 0x2200f0 /* uController/UART 1 register */ 92#define MD_UREG1_14 0x2200f0 /* uController/UART 1 register */
93#define MD_UREG1_15 0x2200f8 /* uController/UART 1 register */ 93#define MD_UREG1_15 0x2200f8 /* uController/UART 1 register */
94 94
95#ifdef CONFIG_SGI_SN0_N_MODE 95#ifdef CONFIG_SGI_SN_N_MODE
96#define MD_MEM_BANKS 4 /* 4 banks of memory max in N mode */ 96#define MD_MEM_BANKS 4 /* 4 banks of memory max in N mode */
97#else 97#else
98#define MD_MEM_BANKS 8 /* 8 banks of memory max in M mode */ 98#define MD_MEM_BANKS 8 /* 8 banks of memory max in M mode */
diff --git a/include/asm-mips/sn/sn0/hubpi.h b/include/asm-mips/sn/sn0/hubpi.h
index 355bba8552e3..e39f5f9da040 100644
--- a/include/asm-mips/sn/sn0/hubpi.h
+++ b/include/asm-mips/sn/sn0/hubpi.h
@@ -398,24 +398,6 @@ typedef u64 rtc_time_t;
398 398
399/* PI_RT_FILTER_CTRL mask and shift definitions */ 399/* PI_RT_FILTER_CTRL mask and shift definitions */
400 400
401#if 0
402/*
403 * XXX - This register's definition has changed, but it's only implemented
404 * in Hub 2.
405 */
406#define PRFC_DROP_COUNT_SHFT 27
407#define PRFC_DROP_COUNT_MASK (UINT64_CAST 0x3ff << 27)
408#define PRFC_DROP_CTR_SHFT 18
409#define PRFC_DROP_CTR_MASK (UINT64_CAST 0x1ff << 18)
410#define PRFC_MASK_ENABLE_SHFT 10
411#define PRFC_MASK_ENABLE_MASK (UINT64_CAST 0x7f << 10)
412#define PRFC_MASK_CTR_SHFT 2
413#define PRFC_MASK_CTR_MASK (UINT64_CAST 0xff << 2)
414#define PRFC_OFFSET_SHFT 0
415#define PRFC_OFFSET_MASK (UINT64_CAST 3)
416#endif /* 0 */
417
418
419/* 401/*
420 * Bits for NACK_CNT_A/B and NACK_CMP 402 * Bits for NACK_CNT_A/B and NACK_CMP
421 */ 403 */
diff --git a/include/asm-mips/sn/sn0/ip27.h b/include/asm-mips/sn/sn0/ip27.h
index ade0e974dd78..3c97e0855c8d 100644
--- a/include/asm-mips/sn/sn0/ip27.h
+++ b/include/asm-mips/sn/sn0/ip27.h
@@ -6,7 +6,7 @@
6 * Derived from IRIX <sys/SN/SN0/IP27.h>. 6 * Derived from IRIX <sys/SN/SN0/IP27.h>.
7 * 7 *
8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc. 8 * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
9 * Copyright (C) 1999 by Ralf Baechle 9 * Copyright (C) 1999, 2006 by Ralf Baechle
10 */ 10 */
11#ifndef _ASM_SN_SN0_IP27_H 11#ifndef _ASM_SN_SN0_IP27_H
12#define _ASM_SN_SN0_IP27_H 12#define _ASM_SN_SN0_IP27_H
@@ -82,11 +82,4 @@
82#define SEND_NMI(_nasid, _slice) \ 82#define SEND_NMI(_nasid, _slice) \
83 REMOTE_HUB_S((_nasid), (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1) 83 REMOTE_HUB_S((_nasid), (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1)
84 84
85/* Sanity hazzard ... Below all the Origin hacks are following. */
86
87#define SN00_BRIDGE 0x9200000008000000
88#define SN00I_BRIDGE0 0x920000000b000000
89#define SN00I_BRIDGE1 0x920000000e000000
90#define SN00I_BRIDGE2 0x920000000f000000
91
92#endif /* _ASM_SN_SN0_IP27_H */ 85#endif /* _ASM_SN_SN0_IP27_H */
diff --git a/include/asm-mips/sni.h b/include/asm-mips/sni.h
index b3bc698dfdee..b9ba54d0dd35 100644
--- a/include/asm-mips/sni.h
+++ b/include/asm-mips/sni.h
@@ -15,9 +15,6 @@
15/* 15/*
16 * ASIC PCI registers for little endian configuration. 16 * ASIC PCI registers for little endian configuration.
17 */ 17 */
18#ifndef __MIPSEL__
19#error "Fix me for big endian"
20#endif
21#define PCIMT_UCONF 0xbfff0000 18#define PCIMT_UCONF 0xbfff0000
22#define PCIMT_IOADTIMEOUT2 0xbfff0008 19#define PCIMT_IOADTIMEOUT2 0xbfff0008
23#define PCIMT_IOMEMCONF 0xbfff0010 20#define PCIMT_IOMEMCONF 0xbfff0010
@@ -51,9 +48,9 @@
51#define PCIMT_PCI_CONF 0xbfff0100 48#define PCIMT_PCI_CONF 0xbfff0100
52 49
53/* 50/*
54 * Data port for the PCI bus. 51 * Data port for the PCI bus in IO space
55 */ 52 */
56#define PCIMT_CONFIG_DATA 0xb4000cfc 53#define PCIMT_CONFIG_DATA 0x0cfc
57 54
58/* 55/*
59 * Board specific registers 56 * Board specific registers
diff --git a/include/asm-mips/war.h b/include/asm-mips/war.h
index ad374bd3f130..70636b41832c 100644
--- a/include/asm-mips/war.h
+++ b/include/asm-mips/war.h
@@ -172,7 +172,8 @@
172 * On the RM9000 there is a problem which makes the CreateDirtyExclusive 172 * On the RM9000 there is a problem which makes the CreateDirtyExclusive
173 * cache operation unusable on SMP systems. 173 * cache operation unusable on SMP systems.
174 */ 174 */
175#if defined(CONFIG_MOMENCO_JAGUAR_ATX) || defined(CONFIG_PMC_YOSEMITE) 175#if defined(CONFIG_MOMENCO_JAGUAR_ATX) || defined(CONFIG_PMC_YOSEMITE) || \
176 defined(CONFIG_BASLER_EXCITE)
176#define RM9000_CDEX_SMP_WAR 1 177#define RM9000_CDEX_SMP_WAR 1
177#endif 178#endif
178 179
@@ -182,7 +183,7 @@
182 * being fetched may case spurious exceptions. 183 * being fetched may case spurious exceptions.
183 */ 184 */
184#if defined(CONFIG_MOMENCO_JAGUAR_ATX) || defined(CONFIG_MOMENCO_OCELOT_3) || \ 185#if defined(CONFIG_MOMENCO_JAGUAR_ATX) || defined(CONFIG_MOMENCO_OCELOT_3) || \
185 defined(CONFIG_PMC_YOSEMITE) 186 defined(CONFIG_PMC_YOSEMITE) || defined(CONFIG_BASLER_EXCITE)
186#define ICACHE_REFILLS_WORKAROUND_WAR 1 187#define ICACHE_REFILLS_WORKAROUND_WAR 1
187#endif 188#endif
188 189
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 9fcf0162d859..f6265c2a0dd2 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -329,7 +329,7 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
329#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 329#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
330 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \ 330 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \
331 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ 331 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
332 CPU_FTR_CTRL | CPU_FTR_PAUSE_ZERO) 332 CPU_FTR_CTRL | CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE)
333#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 333#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
334 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2) 334 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2)
335#endif 335#endif
diff --git a/include/linux/console.h b/include/linux/console.h
index 721371382ae5..08734e660d41 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -117,6 +117,10 @@ extern void console_stop(struct console *);
117extern void console_start(struct console *); 117extern void console_start(struct console *);
118extern int is_console_locked(void); 118extern int is_console_locked(void);
119 119
120/* Suspend and resume console messages over PM events */
121extern void suspend_console(void);
122extern void resume_console(void);
123
120/* Some debug stub to catch some of the obvious races in the VT code */ 124/* Some debug stub to catch some of the obvious races in the VT code */
121#if 1 125#if 1
122#define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress) 126#define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
new file mode 100644
index 000000000000..78b236ca04f8
--- /dev/null
+++ b/include/linux/dmaengine.h
@@ -0,0 +1,359 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21#ifndef DMAENGINE_H
22#define DMAENGINE_H
23#include <linux/config.h>
24#ifdef CONFIG_DMA_ENGINE
25
26#include <linux/device.h>
27#include <linux/uio.h>
28#include <linux/kref.h>
29#include <linux/completion.h>
30#include <linux/rcupdate.h>
31
32/**
33 * enum dma_event - resource PNP/power managment events
34 * @DMA_RESOURCE_SUSPEND: DMA device going into low power state
35 * @DMA_RESOURCE_RESUME: DMA device returning to full power
36 * @DMA_RESOURCE_ADDED: DMA device added to the system
37 * @DMA_RESOURCE_REMOVED: DMA device removed from the system
38 */
39enum dma_event {
40 DMA_RESOURCE_SUSPEND,
41 DMA_RESOURCE_RESUME,
42 DMA_RESOURCE_ADDED,
43 DMA_RESOURCE_REMOVED,
44};
45
46/**
47 * typedef dma_cookie_t
48 *
49 * if dma_cookie_t is >0 it's a DMA request cookie, <0 it's an error code
50 */
51typedef s32 dma_cookie_t;
52
53#define dma_submit_error(cookie) ((cookie) < 0 ? 1 : 0)
54
55/**
56 * enum dma_status - DMA transaction status
57 * @DMA_SUCCESS: transaction completed successfully
58 * @DMA_IN_PROGRESS: transaction not yet processed
59 * @DMA_ERROR: transaction failed
60 */
61enum dma_status {
62 DMA_SUCCESS,
63 DMA_IN_PROGRESS,
64 DMA_ERROR,
65};
66
67/**
68 * struct dma_chan_percpu - the per-CPU part of struct dma_chan
69 * @refcount: local_t used for open-coded "bigref" counting
70 * @memcpy_count: transaction counter
71 * @bytes_transferred: byte counter
72 */
73
74struct dma_chan_percpu {
75 local_t refcount;
76 /* stats */
77 unsigned long memcpy_count;
78 unsigned long bytes_transferred;
79};
80
81/**
82 * struct dma_chan - devices supply DMA channels, clients use them
83 * @client: ptr to the client user of this chan, will be NULL when unused
84 * @device: ptr to the dma device who supplies this channel, always !NULL
85 * @cookie: last cookie value returned to client
86 * @chan_id:
87 * @class_dev:
88 * @refcount: kref, used in "bigref" slow-mode
89 * @slow_ref:
90 * @rcu:
91 * @client_node: used to add this to the client chan list
92 * @device_node: used to add this to the device chan list
93 * @local: per-cpu pointer to a struct dma_chan_percpu
94 */
95struct dma_chan {
96 struct dma_client *client;
97 struct dma_device *device;
98 dma_cookie_t cookie;
99
100 /* sysfs */
101 int chan_id;
102 struct class_device class_dev;
103
104 struct kref refcount;
105 int slow_ref;
106 struct rcu_head rcu;
107
108 struct list_head client_node;
109 struct list_head device_node;
110 struct dma_chan_percpu *local;
111};
112
113void dma_chan_cleanup(struct kref *kref);
114
115static inline void dma_chan_get(struct dma_chan *chan)
116{
117 if (unlikely(chan->slow_ref))
118 kref_get(&chan->refcount);
119 else {
120 local_inc(&(per_cpu_ptr(chan->local, get_cpu())->refcount));
121 put_cpu();
122 }
123}
124
125static inline void dma_chan_put(struct dma_chan *chan)
126{
127 if (unlikely(chan->slow_ref))
128 kref_put(&chan->refcount, dma_chan_cleanup);
129 else {
130 local_dec(&(per_cpu_ptr(chan->local, get_cpu())->refcount));
131 put_cpu();
132 }
133}
134
135/*
136 * typedef dma_event_callback - function pointer to a DMA event callback
137 */
138typedef void (*dma_event_callback) (struct dma_client *client,
139 struct dma_chan *chan, enum dma_event event);
140
141/**
142 * struct dma_client - info on the entity making use of DMA services
143 * @event_callback: func ptr to call when something happens
144 * @chan_count: number of chans allocated
145 * @chans_desired: number of chans requested. Can be +/- chan_count
146 * @lock: protects access to the channels list
147 * @channels: the list of DMA channels allocated
148 * @global_node: list_head for global dma_client_list
149 */
150struct dma_client {
151 dma_event_callback event_callback;
152 unsigned int chan_count;
153 unsigned int chans_desired;
154
155 spinlock_t lock;
156 struct list_head channels;
157 struct list_head global_node;
158};
159
160/**
161 * struct dma_device - info on the entity supplying DMA services
162 * @chancnt: how many DMA channels are supported
163 * @channels: the list of struct dma_chan
164 * @global_node: list_head for global dma_device_list
165 * @refcount:
166 * @done:
167 * @dev_id:
168 * Other func ptrs: used to make use of this device's capabilities
169 */
170struct dma_device {
171
172 unsigned int chancnt;
173 struct list_head channels;
174 struct list_head global_node;
175
176 struct kref refcount;
177 struct completion done;
178
179 int dev_id;
180
181 int (*device_alloc_chan_resources)(struct dma_chan *chan);
182 void (*device_free_chan_resources)(struct dma_chan *chan);
183 dma_cookie_t (*device_memcpy_buf_to_buf)(struct dma_chan *chan,
184 void *dest, void *src, size_t len);
185 dma_cookie_t (*device_memcpy_buf_to_pg)(struct dma_chan *chan,
186 struct page *page, unsigned int offset, void *kdata,
187 size_t len);
188 dma_cookie_t (*device_memcpy_pg_to_pg)(struct dma_chan *chan,
189 struct page *dest_pg, unsigned int dest_off,
190 struct page *src_pg, unsigned int src_off, size_t len);
191 enum dma_status (*device_memcpy_complete)(struct dma_chan *chan,
192 dma_cookie_t cookie, dma_cookie_t *last,
193 dma_cookie_t *used);
194 void (*device_memcpy_issue_pending)(struct dma_chan *chan);
195};
196
197/* --- public DMA engine API --- */
198
199struct dma_client *dma_async_client_register(dma_event_callback event_callback);
200void dma_async_client_unregister(struct dma_client *client);
201void dma_async_client_chan_request(struct dma_client *client,
202 unsigned int number);
203
204/**
205 * dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses
206 * @chan: DMA channel to offload copy to
207 * @dest: destination address (virtual)
208 * @src: source address (virtual)
209 * @len: length
210 *
211 * Both @dest and @src must be mappable to a bus address according to the
212 * DMA mapping API rules for streaming mappings.
213 * Both @dest and @src must stay memory resident (kernel memory or locked
214 * user space pages)
215 */
216static inline dma_cookie_t dma_async_memcpy_buf_to_buf(struct dma_chan *chan,
217 void *dest, void *src, size_t len)
218{
219 int cpu = get_cpu();
220 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
221 per_cpu_ptr(chan->local, cpu)->memcpy_count++;
222 put_cpu();
223
224 return chan->device->device_memcpy_buf_to_buf(chan, dest, src, len);
225}
226
227/**
228 * dma_async_memcpy_buf_to_pg - offloaded copy
229 * @chan: DMA channel to offload copy to
230 * @page: destination page
231 * @offset: offset in page to copy to
232 * @kdata: source address (virtual)
233 * @len: length
234 *
235 * Both @page/@offset and @kdata must be mappable to a bus address according
236 * to the DMA mapping API rules for streaming mappings.
237 * Both @page/@offset and @kdata must stay memory resident (kernel memory or
238 * locked user space pages)
239 */
240static inline dma_cookie_t dma_async_memcpy_buf_to_pg(struct dma_chan *chan,
241 struct page *page, unsigned int offset, void *kdata, size_t len)
242{
243 int cpu = get_cpu();
244 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
245 per_cpu_ptr(chan->local, cpu)->memcpy_count++;
246 put_cpu();
247
248 return chan->device->device_memcpy_buf_to_pg(chan, page, offset,
249 kdata, len);
250}
251
252/**
253 * dma_async_memcpy_buf_to_pg - offloaded copy
254 * @chan: DMA channel to offload copy to
255 * @dest_page: destination page
256 * @dest_off: offset in page to copy to
257 * @src_page: source page
258 * @src_off: offset in page to copy from
259 * @len: length
260 *
261 * Both @dest_page/@dest_off and @src_page/@src_off must be mappable to a bus
262 * address according to the DMA mapping API rules for streaming mappings.
263 * Both @dest_page/@dest_off and @src_page/@src_off must stay memory resident
264 * (kernel memory or locked user space pages)
265 */
266static inline dma_cookie_t dma_async_memcpy_pg_to_pg(struct dma_chan *chan,
267 struct page *dest_pg, unsigned int dest_off, struct page *src_pg,
268 unsigned int src_off, size_t len)
269{
270 int cpu = get_cpu();
271 per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
272 per_cpu_ptr(chan->local, cpu)->memcpy_count++;
273 put_cpu();
274
275 return chan->device->device_memcpy_pg_to_pg(chan, dest_pg, dest_off,
276 src_pg, src_off, len);
277}
278
279/**
280 * dma_async_memcpy_issue_pending - flush pending copies to HW
281 * @chan:
282 *
283 * This allows drivers to push copies to HW in batches,
284 * reducing MMIO writes where possible.
285 */
286static inline void dma_async_memcpy_issue_pending(struct dma_chan *chan)
287{
288 return chan->device->device_memcpy_issue_pending(chan);
289}
290
291/**
292 * dma_async_memcpy_complete - poll for transaction completion
293 * @chan: DMA channel
294 * @cookie: transaction identifier to check status of
295 * @last: returns last completed cookie, can be NULL
296 * @used: returns last issued cookie, can be NULL
297 *
298 * If @last and @used are passed in, upon return they reflect the driver
299 * internal state and can be used with dma_async_is_complete() to check
300 * the status of multiple cookies without re-checking hardware state.
301 */
302static inline enum dma_status dma_async_memcpy_complete(struct dma_chan *chan,
303 dma_cookie_t cookie, dma_cookie_t *last, dma_cookie_t *used)
304{
305 return chan->device->device_memcpy_complete(chan, cookie, last, used);
306}
307
308/**
309 * dma_async_is_complete - test a cookie against chan state
310 * @cookie: transaction identifier to test status of
311 * @last_complete: last know completed transaction
312 * @last_used: last cookie value handed out
313 *
314 * dma_async_is_complete() is used in dma_async_memcpy_complete()
315 * the test logic is seperated for lightweight testing of multiple cookies
316 */
317static inline enum dma_status dma_async_is_complete(dma_cookie_t cookie,
318 dma_cookie_t last_complete, dma_cookie_t last_used)
319{
320 if (last_complete <= last_used) {
321 if ((cookie <= last_complete) || (cookie > last_used))
322 return DMA_SUCCESS;
323 } else {
324 if ((cookie <= last_complete) && (cookie > last_used))
325 return DMA_SUCCESS;
326 }
327 return DMA_IN_PROGRESS;
328}
329
330
331/* --- DMA device --- */
332
333int dma_async_device_register(struct dma_device *device);
334void dma_async_device_unregister(struct dma_device *device);
335
336/* --- Helper iov-locking functions --- */
337
338struct dma_page_list {
339 char *base_address;
340 int nr_pages;
341 struct page **pages;
342};
343
344struct dma_pinned_list {
345 int nr_iovecs;
346 struct dma_page_list page_list[0];
347};
348
349struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
350void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
351
352dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
353 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
354dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
355 struct dma_pinned_list *pinned_list, struct page *page,
356 unsigned int offset, size_t len);
357
358#endif /* CONFIG_DMA_ENGINE */
359#endif /* DMAENGINE_H */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index dd7d627bf66f..c115e9e840b4 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -1114,8 +1114,11 @@ static inline struct i2o_message *i2o_msg_get(struct i2o_controller *c)
1114 1114
1115 mmsg->mfa = readl(c->in_port); 1115 mmsg->mfa = readl(c->in_port);
1116 if (unlikely(mmsg->mfa >= c->in_queue.len)) { 1116 if (unlikely(mmsg->mfa >= c->in_queue.len)) {
1117 u32 mfa = mmsg->mfa;
1118
1117 mempool_free(mmsg, c->in_msg.mempool); 1119 mempool_free(mmsg, c->in_msg.mempool);
1118 if(mmsg->mfa == I2O_QUEUE_EMPTY) 1120
1121 if (mfa == I2O_QUEUE_EMPTY)
1119 return ERR_PTR(-EBUSY); 1122 return ERR_PTR(-EBUSY);
1120 return ERR_PTR(-EFAULT); 1123 return ERR_PTR(-EFAULT);
1121 } 1124 }
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 28f4f3b36950..899c3d4776f3 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -169,7 +169,7 @@ struct ip_sf_list
169struct ip_mc_list 169struct ip_mc_list
170{ 170{
171 struct in_device *interface; 171 struct in_device *interface;
172 unsigned long multiaddr; 172 __be32 multiaddr;
173 struct ip_sf_list *sources; 173 struct ip_sf_list *sources;
174 struct ip_sf_list *tomb; 174 struct ip_sf_list *tomb;
175 unsigned int sfmode; 175 unsigned int sfmode;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f4169bbb60eb..e432b743dda2 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -37,6 +37,7 @@
37#include <linux/config.h> 37#include <linux/config.h>
38#include <linux/device.h> 38#include <linux/device.h>
39#include <linux/percpu.h> 39#include <linux/percpu.h>
40#include <linux/dmaengine.h>
40 41
41struct divert_blk; 42struct divert_blk;
42struct vlan_group; 43struct vlan_group;
@@ -311,6 +312,9 @@ struct net_device
311#define NETIF_F_LLTX 4096 /* LockLess TX */ 312#define NETIF_F_LLTX 4096 /* LockLess TX */
312#define NETIF_F_UFO 8192 /* Can offload UDP Large Send*/ 313#define NETIF_F_UFO 8192 /* Can offload UDP Large Send*/
313 314
315#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
316#define NETIF_F_ALL_CSUM (NETIF_F_IP_CSUM | NETIF_F_GEN_CSUM)
317
314 struct net_device *next_sched; 318 struct net_device *next_sched;
315 319
316 /* Interface index. Unique device identifier */ 320 /* Interface index. Unique device identifier */
@@ -406,7 +410,7 @@ struct net_device
406 * One part is mostly used on xmit path (device) 410 * One part is mostly used on xmit path (device)
407 */ 411 */
408 /* hard_start_xmit synchronizer */ 412 /* hard_start_xmit synchronizer */
409 spinlock_t xmit_lock ____cacheline_aligned_in_smp; 413 spinlock_t _xmit_lock ____cacheline_aligned_in_smp;
410 /* cpu id of processor entered to hard_start_xmit or -1, 414 /* cpu id of processor entered to hard_start_xmit or -1,
411 if nobody entered there. 415 if nobody entered there.
412 */ 416 */
@@ -593,6 +597,9 @@ struct softnet_data
593 struct sk_buff *completion_queue; 597 struct sk_buff *completion_queue;
594 598
595 struct net_device backlog_dev; /* Sorry. 8) */ 599 struct net_device backlog_dev; /* Sorry. 8) */
600#ifdef CONFIG_NET_DMA
601 struct dma_chan *net_dma;
602#endif
596}; 603};
597 604
598DECLARE_PER_CPU(struct softnet_data,softnet_data); 605DECLARE_PER_CPU(struct softnet_data,softnet_data);
@@ -889,11 +896,43 @@ static inline void __netif_rx_complete(struct net_device *dev)
889 clear_bit(__LINK_STATE_RX_SCHED, &dev->state); 896 clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
890} 897}
891 898
899static inline void netif_tx_lock(struct net_device *dev)
900{
901 spin_lock(&dev->_xmit_lock);
902 dev->xmit_lock_owner = smp_processor_id();
903}
904
905static inline void netif_tx_lock_bh(struct net_device *dev)
906{
907 spin_lock_bh(&dev->_xmit_lock);
908 dev->xmit_lock_owner = smp_processor_id();
909}
910
911static inline int netif_tx_trylock(struct net_device *dev)
912{
913 int err = spin_trylock(&dev->_xmit_lock);
914 if (!err)
915 dev->xmit_lock_owner = smp_processor_id();
916 return err;
917}
918
919static inline void netif_tx_unlock(struct net_device *dev)
920{
921 dev->xmit_lock_owner = -1;
922 spin_unlock(&dev->_xmit_lock);
923}
924
925static inline void netif_tx_unlock_bh(struct net_device *dev)
926{
927 dev->xmit_lock_owner = -1;
928 spin_unlock_bh(&dev->_xmit_lock);
929}
930
892static inline void netif_tx_disable(struct net_device *dev) 931static inline void netif_tx_disable(struct net_device *dev)
893{ 932{
894 spin_lock_bh(&dev->xmit_lock); 933 netif_tx_lock_bh(dev);
895 netif_stop_queue(dev); 934 netif_stop_queue(dev);
896 spin_unlock_bh(&dev->xmit_lock); 935 netif_tx_unlock_bh(dev);
897} 936}
898 937
899/* These functions live elsewhere (drivers/net/net_init.c, but related) */ 938/* These functions live elsewhere (drivers/net/net_init.c, but related) */
diff --git a/include/linux/netfilter/nf_conntrack_common.h b/include/linux/netfilter/nf_conntrack_common.h
index 3ff88c878308..d2e4bd7a7a14 100644
--- a/include/linux/netfilter/nf_conntrack_common.h
+++ b/include/linux/netfilter/nf_conntrack_common.h
@@ -69,6 +69,10 @@ enum ip_conntrack_status {
69 /* Connection is dying (removed from lists), can not be unset. */ 69 /* Connection is dying (removed from lists), can not be unset. */
70 IPS_DYING_BIT = 9, 70 IPS_DYING_BIT = 9,
71 IPS_DYING = (1 << IPS_DYING_BIT), 71 IPS_DYING = (1 << IPS_DYING_BIT),
72
73 /* Connection has fixed timeout. */
74 IPS_FIXED_TIMEOUT_BIT = 10,
75 IPS_FIXED_TIMEOUT = (1 << IPS_FIXED_TIMEOUT_BIT),
72}; 76};
73 77
74/* Connection tracking event bits */ 78/* Connection tracking event bits */
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index 668ec946c8e2..b5883ccee295 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -27,13 +27,15 @@ enum ctattr_type {
27 CTA_STATUS, 27 CTA_STATUS,
28 CTA_PROTOINFO, 28 CTA_PROTOINFO,
29 CTA_HELP, 29 CTA_HELP,
30 CTA_NAT, 30 CTA_NAT_SRC,
31#define CTA_NAT CTA_NAT_SRC /* backwards compatibility */
31 CTA_TIMEOUT, 32 CTA_TIMEOUT,
32 CTA_MARK, 33 CTA_MARK,
33 CTA_COUNTERS_ORIG, 34 CTA_COUNTERS_ORIG,
34 CTA_COUNTERS_REPLY, 35 CTA_COUNTERS_REPLY,
35 CTA_USE, 36 CTA_USE,
36 CTA_ID, 37 CTA_ID,
38 CTA_NAT_DST,
37 __CTA_MAX 39 __CTA_MAX
38}; 40};
39#define CTA_MAX (__CTA_MAX - 1) 41#define CTA_MAX (__CTA_MAX - 1)
diff --git a/include/linux/netfilter/xt_CONNSECMARK.h b/include/linux/netfilter/xt_CONNSECMARK.h
new file mode 100644
index 000000000000..c6bd75469ba2
--- /dev/null
+++ b/include/linux/netfilter/xt_CONNSECMARK.h
@@ -0,0 +1,13 @@
1#ifndef _XT_CONNSECMARK_H_target
2#define _XT_CONNSECMARK_H_target
3
4enum {
5 CONNSECMARK_SAVE = 1,
6 CONNSECMARK_RESTORE,
7};
8
9struct xt_connsecmark_target_info {
10 u_int8_t mode;
11};
12
13#endif /*_XT_CONNSECMARK_H_target */
diff --git a/include/linux/netfilter/xt_SECMARK.h b/include/linux/netfilter/xt_SECMARK.h
new file mode 100644
index 000000000000..c53fbffa997d
--- /dev/null
+++ b/include/linux/netfilter/xt_SECMARK.h
@@ -0,0 +1,26 @@
1#ifndef _XT_SECMARK_H_target
2#define _XT_SECMARK_H_target
3
4/*
5 * This is intended for use by various security subsystems (but not
6 * at the same time).
7 *
8 * 'mode' refers to the specific security subsystem which the
9 * packets are being marked for.
10 */
11#define SECMARK_MODE_SEL 0x01 /* SELinux */
12#define SECMARK_SELCTX_MAX 256
13
14struct xt_secmark_target_selinux_info {
15 u_int32_t selsid;
16 char selctx[SECMARK_SELCTX_MAX];
17};
18
19struct xt_secmark_target_info {
20 u_int8_t mode;
21 union {
22 struct xt_secmark_target_selinux_info sel;
23 } u;
24};
25
26#endif /*_XT_SECMARK_H_target */
diff --git a/include/linux/netfilter/xt_quota.h b/include/linux/netfilter/xt_quota.h
new file mode 100644
index 000000000000..acd7fd77bbee
--- /dev/null
+++ b/include/linux/netfilter/xt_quota.h
@@ -0,0 +1,16 @@
1#ifndef _XT_QUOTA_H
2#define _XT_QUOTA_H
3
4enum xt_quota_flags {
5 XT_QUOTA_INVERT = 0x1,
6};
7#define XT_QUOTA_MASK 0x1
8
9struct xt_quota_info {
10 u_int32_t flags;
11 u_int32_t pad;
12 aligned_u64 quota;
13 struct xt_quota_info *master;
14};
15
16#endif /* _XT_QUOTA_H */
diff --git a/include/linux/netfilter/xt_statistic.h b/include/linux/netfilter/xt_statistic.h
new file mode 100644
index 000000000000..c344e9916e23
--- /dev/null
+++ b/include/linux/netfilter/xt_statistic.h
@@ -0,0 +1,32 @@
1#ifndef _XT_STATISTIC_H
2#define _XT_STATISTIC_H
3
4enum xt_statistic_mode {
5 XT_STATISTIC_MODE_RANDOM,
6 XT_STATISTIC_MODE_NTH,
7 __XT_STATISTIC_MODE_MAX
8};
9#define XT_STATISTIC_MODE_MAX (__XT_STATISTIC_MODE_MAX - 1)
10
11enum xt_statistic_flags {
12 XT_STATISTIC_INVERT = 0x1,
13};
14#define XT_STATISTIC_MASK 0x1
15
16struct xt_statistic_info {
17 u_int16_t mode;
18 u_int16_t flags;
19 union {
20 struct {
21 u_int32_t probability;
22 } random;
23 struct {
24 u_int32_t every;
25 u_int32_t packet;
26 u_int32_t count;
27 } nth;
28 } u;
29 struct xt_statistic_info *master __attribute__((aligned(8)));
30};
31
32#endif /* _XT_STATISTIC_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
index d54d7b278e96..e0e9951eb8c3 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -121,6 +121,10 @@ struct ip_conntrack
121 u_int32_t mark; 121 u_int32_t mark;
122#endif 122#endif
123 123
124#ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
125 u_int32_t secmark;
126#endif
127
124 /* Traversed often, so hopefully in different cacheline to top */ 128 /* Traversed often, so hopefully in different cacheline to top */
125 /* These are my tuples; original and reply */ 129 /* These are my tuples; original and reply */
126 struct ip_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; 130 struct ip_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX];
@@ -154,6 +158,7 @@ struct ip_conntrack_expect
154 unsigned int flags; 158 unsigned int flags;
155 159
156#ifdef CONFIG_IP_NF_NAT_NEEDED 160#ifdef CONFIG_IP_NF_NAT_NEEDED
161 u_int32_t saved_ip;
157 /* This is the original per-proto part, used to map the 162 /* This is the original per-proto part, used to map the
158 * expected connection the way the recipient expects. */ 163 * expected connection the way the recipient expects. */
159 union ip_conntrack_manip_proto saved_proto; 164 union ip_conntrack_manip_proto saved_proto;
@@ -293,6 +298,7 @@ static inline int is_dying(struct ip_conntrack *ct)
293} 298}
294 299
295extern unsigned int ip_conntrack_htable_size; 300extern unsigned int ip_conntrack_htable_size;
301extern int ip_conntrack_checksum;
296 302
297#define CONNTRACK_STAT_INC(count) (__get_cpu_var(ip_conntrack_stat).count++) 303#define CONNTRACK_STAT_INC(count) (__get_cpu_var(ip_conntrack_stat).count++)
298 304
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_h323.h b/include/linux/netfilter_ipv4/ip_conntrack_h323.h
index eace86bd2adb..3cbff7379002 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_h323.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_h323.h
@@ -71,6 +71,13 @@ extern int (*nat_h245_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
71 unsigned char **data, int dataoff, 71 unsigned char **data, int dataoff,
72 TransportAddress * addr, u_int16_t port, 72 TransportAddress * addr, u_int16_t port,
73 struct ip_conntrack_expect * exp); 73 struct ip_conntrack_expect * exp);
74extern int (*nat_callforwarding_hook) (struct sk_buff ** pskb,
75 struct ip_conntrack * ct,
76 enum ip_conntrack_info ctinfo,
77 unsigned char **data, int dataoff,
78 TransportAddress * addr,
79 u_int16_t port,
80 struct ip_conntrack_expect * exp);
74extern int (*nat_q931_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct, 81extern int (*nat_q931_hook) (struct sk_buff ** pskb, struct ip_conntrack * ct,
75 enum ip_conntrack_info ctinfo, 82 enum ip_conntrack_info ctinfo,
76 unsigned char **data, TransportAddress * addr, 83 unsigned char **data, TransportAddress * addr,
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h b/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h
index cc98f7aa5abe..3d4a773799fc 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h
@@ -1,4 +1,4 @@
1/* Generated by Jing Min Zhao's ASN.1 parser, Mar 15 2006 1/* Generated by Jing Min Zhao's ASN.1 parser, Apr 20 2006
2 * 2 *
3 * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net> 3 * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net>
4 * 4 *
@@ -412,6 +412,7 @@ typedef struct Facility_UUIE { /* SEQUENCE */
412 eFacility_UUIE_destinationInfo = (1 << 14), 412 eFacility_UUIE_destinationInfo = (1 << 14),
413 eFacility_UUIE_h245SecurityMode = (1 << 13), 413 eFacility_UUIE_h245SecurityMode = (1 << 13),
414 } options; 414 } options;
415 TransportAddress alternativeAddress;
415 FacilityReason reason; 416 FacilityReason reason;
416 TransportAddress h245Address; 417 TransportAddress h245Address;
417 Facility_UUIE_fastStart fastStart; 418 Facility_UUIE_fastStart fastStart;
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_sip.h b/include/linux/netfilter_ipv4/ip_conntrack_sip.h
new file mode 100644
index 000000000000..913dad66c0fb
--- /dev/null
+++ b/include/linux/netfilter_ipv4/ip_conntrack_sip.h
@@ -0,0 +1,44 @@
1#ifndef __IP_CONNTRACK_SIP_H__
2#define __IP_CONNTRACK_SIP_H__
3#ifdef __KERNEL__
4
5#define SIP_PORT 5060
6#define SIP_TIMEOUT 3600
7
8#define POS_VIA 0
9#define POS_CONTACT 1
10#define POS_CONTENT 2
11#define POS_MEDIA 3
12#define POS_OWNER 4
13#define POS_CONNECTION 5
14#define POS_REQ_HEADER 6
15#define POS_SDP_HEADER 7
16
17struct sip_header_nfo {
18 const char *lname;
19 const char *sname;
20 const char *ln_str;
21 size_t lnlen;
22 size_t snlen;
23 size_t ln_strlen;
24 int (*match_len)(const char *, const char *, int *);
25};
26
27extern unsigned int (*ip_nat_sip_hook)(struct sk_buff **pskb,
28 enum ip_conntrack_info ctinfo,
29 struct ip_conntrack *ct,
30 const char **dptr);
31extern unsigned int (*ip_nat_sdp_hook)(struct sk_buff **pskb,
32 enum ip_conntrack_info ctinfo,
33 struct ip_conntrack_expect *exp,
34 const char *dptr);
35
36extern int ct_sip_get_info(const char *dptr, size_t dlen,
37 unsigned int *matchoff,
38 unsigned int *matchlen,
39 struct sip_header_nfo *hnfo);
40extern int ct_sip_lnlen(const char *line, const char *limit);
41extern const char *ct_sip_search(const char *needle, const char *haystack,
42 size_t needle_len, size_t haystack_len);
43#endif /* __KERNEL__ */
44#endif /* __IP_CONNTRACK_SIP_H__ */
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 4877e35ae202..936ef82ed76a 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -50,7 +50,7 @@
50extern acpi_status pci_osc_control_set(acpi_handle handle, u32 flags); 50extern acpi_status pci_osc_control_set(acpi_handle handle, u32 flags);
51extern acpi_status pci_osc_support_set(u32 flags); 51extern acpi_status pci_osc_support_set(u32 flags);
52#else 52#else
53#if !defined(acpi_status) 53#if !defined(AE_ERROR)
54typedef u32 acpi_status; 54typedef u32 acpi_status;
55#define AE_ERROR (acpi_status) (0x0001) 55#define AE_ERROR (acpi_status) (0x0001)
56#endif 56#endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3a6a4e37a482..6fd36cb09160 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -442,6 +442,7 @@ struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int devic
442struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn); 442struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
443int pci_find_capability (struct pci_dev *dev, int cap); 443int pci_find_capability (struct pci_dev *dev, int cap);
444int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); 444int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap);
445int pci_find_ext_capability (struct pci_dev *dev, int cap);
445struct pci_bus * pci_find_next_bus(const struct pci_bus *from); 446struct pci_bus * pci_find_next_bus(const struct pci_bus *from);
446 447
447struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from); 448struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
@@ -662,6 +663,7 @@ static inline int pci_register_driver(struct pci_driver *drv) { return 0;}
662static inline void pci_unregister_driver(struct pci_driver *drv) { } 663static inline void pci_unregister_driver(struct pci_driver *drv) { }
663static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } 664static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; }
664static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } 665static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; }
666static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; }
665static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; } 667static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; }
666 668
667/* Power management related routines */ 669/* Power management related routines */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 590dc6dca315..bcfe9d4f56ae 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -935,6 +935,7 @@
935#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 935#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151
936#define PCI_DEVICE_ID_PLX_R753 0x1152 936#define PCI_DEVICE_ID_PLX_R753 0x1152
937#define PCI_DEVICE_ID_PLX_OLITEC 0x1187 937#define PCI_DEVICE_ID_PLX_OLITEC 0x1187
938#define PCI_DEVICE_ID_PLX_PCI200SYN 0x3196
938#define PCI_DEVICE_ID_PLX_9050 0x9050 939#define PCI_DEVICE_ID_PLX_9050 0x9050
939#define PCI_DEVICE_ID_PLX_9080 0x9080 940#define PCI_DEVICE_ID_PLX_9080 0x9080
940#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001 941#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001
@@ -1182,6 +1183,14 @@
1182#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E 1183#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E
1183#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372 1184#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372
1184#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 1185#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373
1186#define PCI_DEVICE_ID_NVIDIA_NVENET_16 0x03E5
1187#define PCI_DEVICE_ID_NVIDIA_NVENET_17 0x03E6
1188#define PCI_DEVICE_ID_NVIDIA_NVENET_18 0x03EE
1189#define PCI_DEVICE_ID_NVIDIA_NVENET_19 0x03EF
1190#define PCI_DEVICE_ID_NVIDIA_NVENET_20 0x0450
1191#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451
1192#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452
1193#define PCI_DEVICE_ID_NVIDIA_NVENET_23 0x0453
1185 1194
1186#define PCI_VENDOR_ID_IMS 0x10e0 1195#define PCI_VENDOR_ID_IMS 0x10e0
1187#define PCI_DEVICE_ID_IMS_TT128 0x9128 1196#define PCI_DEVICE_ID_IMS_TT128 0x9128
@@ -1827,6 +1836,7 @@
1827 1836
1828#define PCI_VENDOR_ID_SAMSUNG 0x144d 1837#define PCI_VENDOR_ID_SAMSUNG 0x144d
1829 1838
1839#define PCI_VENDOR_ID_MYRICOM 0x14c1
1830 1840
1831#define PCI_VENDOR_ID_TITAN 0x14D2 1841#define PCI_VENDOR_ID_TITAN 0x14D2
1832#define PCI_DEVICE_ID_TITAN_010L 0x8001 1842#define PCI_DEVICE_ID_TITAN_010L 0x8001
@@ -1887,6 +1897,7 @@
1887#define PCI_DEVICE_ID_TIGON3_5751F 0x167e 1897#define PCI_DEVICE_ID_TIGON3_5751F 0x167e
1888#define PCI_DEVICE_ID_TIGON3_5787M 0x1693 1898#define PCI_DEVICE_ID_TIGON3_5787M 0x1693
1889#define PCI_DEVICE_ID_TIGON3_5782 0x1696 1899#define PCI_DEVICE_ID_TIGON3_5782 0x1696
1900#define PCI_DEVICE_ID_TIGON3_5786 0x169a
1890#define PCI_DEVICE_ID_TIGON3_5787 0x169b 1901#define PCI_DEVICE_ID_TIGON3_5787 0x169b
1891#define PCI_DEVICE_ID_TIGON3_5788 0x169c 1902#define PCI_DEVICE_ID_TIGON3_5788 0x169c
1892#define PCI_DEVICE_ID_TIGON3_5789 0x169d 1903#define PCI_DEVICE_ID_TIGON3_5789 0x169d
@@ -2043,6 +2054,7 @@
2043#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960 2054#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960
2044#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21 2055#define PCI_DEVICE_ID_INTEL_82840_HB 0x1a21
2045#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 2056#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30
2057#define PCI_DEVICE_ID_INTEL_IOAT 0x1a38
2046#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 2058#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
2047#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 2059#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
2048#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 2060#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
index bac0fb389cf1..d5dd471da225 100644
--- a/include/linux/pfkeyv2.h
+++ b/include/linux/pfkeyv2.h
@@ -159,7 +159,7 @@ struct sadb_spirange {
159struct sadb_x_kmprivate { 159struct sadb_x_kmprivate {
160 uint16_t sadb_x_kmprivate_len; 160 uint16_t sadb_x_kmprivate_len;
161 uint16_t sadb_x_kmprivate_exttype; 161 uint16_t sadb_x_kmprivate_exttype;
162 u_int32_t sadb_x_kmprivate_reserved; 162 uint32_t sadb_x_kmprivate_reserved;
163} __attribute__((packed)); 163} __attribute__((packed));
164/* sizeof(struct sadb_x_kmprivate) == 8 */ 164/* sizeof(struct sadb_x_kmprivate) == 8 */
165 165
diff --git a/include/linux/security.h b/include/linux/security.h
index 1bab48f6aeac..4dfb1b84a9b3 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -805,31 +805,37 @@ struct swap_info_struct;
805 * used by the XFRM system. 805 * used by the XFRM system.
806 * @sec_ctx contains the security context information being provided by 806 * @sec_ctx contains the security context information being provided by
807 * the user-level policy update program (e.g., setkey). 807 * the user-level policy update program (e.g., setkey).
808 * Allocate a security structure to the xp->selector.security field. 808 * Allocate a security structure to the xp->security field.
809 * The security field is initialized to NULL when the xfrm_policy is 809 * The security field is initialized to NULL when the xfrm_policy is
810 * allocated. 810 * allocated.
811 * Return 0 if operation was successful (memory to allocate, legal context) 811 * Return 0 if operation was successful (memory to allocate, legal context)
812 * @xfrm_policy_clone_security: 812 * @xfrm_policy_clone_security:
813 * @old contains an existing xfrm_policy in the SPD. 813 * @old contains an existing xfrm_policy in the SPD.
814 * @new contains a new xfrm_policy being cloned from old. 814 * @new contains a new xfrm_policy being cloned from old.
815 * Allocate a security structure to the new->selector.security field 815 * Allocate a security structure to the new->security field
816 * that contains the information from the old->selector.security field. 816 * that contains the information from the old->security field.
817 * Return 0 if operation was successful (memory to allocate). 817 * Return 0 if operation was successful (memory to allocate).
818 * @xfrm_policy_free_security: 818 * @xfrm_policy_free_security:
819 * @xp contains the xfrm_policy 819 * @xp contains the xfrm_policy
820 * Deallocate xp->selector.security. 820 * Deallocate xp->security.
821 * @xfrm_policy_delete_security:
822 * @xp contains the xfrm_policy.
823 * Authorize deletion of xp->security.
821 * @xfrm_state_alloc_security: 824 * @xfrm_state_alloc_security:
822 * @x contains the xfrm_state being added to the Security Association 825 * @x contains the xfrm_state being added to the Security Association
823 * Database by the XFRM system. 826 * Database by the XFRM system.
824 * @sec_ctx contains the security context information being provided by 827 * @sec_ctx contains the security context information being provided by
825 * the user-level SA generation program (e.g., setkey or racoon). 828 * the user-level SA generation program (e.g., setkey or racoon).
826 * Allocate a security structure to the x->sel.security field. The 829 * Allocate a security structure to the x->security field. The
827 * security field is initialized to NULL when the xfrm_state is 830 * security field is initialized to NULL when the xfrm_state is
828 * allocated. 831 * allocated.
829 * Return 0 if operation was successful (memory to allocate, legal context). 832 * Return 0 if operation was successful (memory to allocate, legal context).
830 * @xfrm_state_free_security: 833 * @xfrm_state_free_security:
831 * @x contains the xfrm_state. 834 * @x contains the xfrm_state.
832 * Deallocate x>sel.security. 835 * Deallocate x->security.
836 * @xfrm_state_delete_security:
837 * @x contains the xfrm_state.
838 * Authorize deletion of x->security.
833 * @xfrm_policy_lookup: 839 * @xfrm_policy_lookup:
834 * @xp contains the xfrm_policy for which the access control is being 840 * @xp contains the xfrm_policy for which the access control is being
835 * checked. 841 * checked.
@@ -1298,8 +1304,10 @@ struct security_operations {
1298 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); 1304 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
1299 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new); 1305 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1300 void (*xfrm_policy_free_security) (struct xfrm_policy *xp); 1306 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1307 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1301 int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 1308 int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1302 void (*xfrm_state_free_security) (struct xfrm_state *x); 1309 void (*xfrm_state_free_security) (struct xfrm_state *x);
1310 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1303 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir); 1311 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
1304#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1312#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1305 1313
@@ -2934,11 +2942,21 @@ static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2934 security_ops->xfrm_policy_free_security(xp); 2942 security_ops->xfrm_policy_free_security(xp);
2935} 2943}
2936 2944
2945static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2946{
2947 return security_ops->xfrm_policy_delete_security(xp);
2948}
2949
2937static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) 2950static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
2938{ 2951{
2939 return security_ops->xfrm_state_alloc_security(x, sec_ctx); 2952 return security_ops->xfrm_state_alloc_security(x, sec_ctx);
2940} 2953}
2941 2954
2955static inline int security_xfrm_state_delete(struct xfrm_state *x)
2956{
2957 return security_ops->xfrm_state_delete_security(x);
2958}
2959
2942static inline void security_xfrm_state_free(struct xfrm_state *x) 2960static inline void security_xfrm_state_free(struct xfrm_state *x)
2943{ 2961{
2944 security_ops->xfrm_state_free_security(x); 2962 security_ops->xfrm_state_free_security(x);
@@ -2963,6 +2981,11 @@ static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
2963{ 2981{
2964} 2982}
2965 2983
2984static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
2985{
2986 return 0;
2987}
2988
2966static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) 2989static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
2967{ 2990{
2968 return 0; 2991 return 0;
@@ -2972,6 +2995,11 @@ static inline void security_xfrm_state_free(struct xfrm_state *x)
2972{ 2995{
2973} 2996}
2974 2997
2998static inline int security_xfrm_state_delete(struct xfrm_state *x)
2999{
3000 return 0;
3001}
3002
2975static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) 3003static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
2976{ 3004{
2977 return 0; 3005 return 0;
diff --git a/include/linux/selinux.h b/include/linux/selinux.h
index 4047bcde4484..aad4e390d6a5 100644
--- a/include/linux/selinux.h
+++ b/include/linux/selinux.h
@@ -118,6 +118,27 @@ void selinux_get_ipc_sid(const struct kern_ipc_perm *ipcp, u32 *sid);
118 */ 118 */
119void selinux_get_task_sid(struct task_struct *tsk, u32 *sid); 119void selinux_get_task_sid(struct task_struct *tsk, u32 *sid);
120 120
121/**
122 * selinux_string_to_sid - map a security context string to a security ID
123 * @str: the security context string to be mapped
124 * @sid: ID value returned via this.
125 *
126 * Returns 0 if successful, with the SID stored in sid. A value
127 * of zero for sid indicates no SID could be determined (but no error
128 * occurred).
129 */
130int selinux_string_to_sid(char *str, u32 *sid);
131
132/**
133 * selinux_relabel_packet_permission - check permission to relabel a packet
134 * @sid: ID value to be applied to network packet (via SECMARK, most likely)
135 *
136 * Returns 0 if the current task is allowed to label packets with the
137 * supplied security ID. Note that it is implicit that the packet is always
138 * being relabeled from the default unlabled value, and that the access
139 * control decision is made in the AVC.
140 */
141int selinux_relabel_packet_permission(u32 sid);
121 142
122#else 143#else
123 144
@@ -172,6 +193,17 @@ static inline void selinux_get_task_sid(struct task_struct *tsk, u32 *sid)
172 *sid = 0; 193 *sid = 0;
173} 194}
174 195
196static inline int selinux_string_to_sid(const char *str, u32 *sid)
197{
198 *sid = 0;
199 return 0;
200}
201
202static inline int selinux_relabel_packet_permission(u32 sid)
203{
204 return 0;
205}
206
175#endif /* CONFIG_SECURITY_SELINUX */ 207#endif /* CONFIG_SECURITY_SELINUX */
176 208
177#endif /* _LINUX_SELINUX_H */ 209#endif /* _LINUX_SELINUX_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index f8f234708b98..93e4db221585 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -29,6 +29,7 @@
29#include <linux/net.h> 29#include <linux/net.h>
30#include <linux/textsearch.h> 30#include <linux/textsearch.h>
31#include <net/checksum.h> 31#include <net/checksum.h>
32#include <linux/dmaengine.h>
32 33
33#define HAVE_ALLOC_SKB /* For the drivers to know */ 34#define HAVE_ALLOC_SKB /* For the drivers to know */
34#define HAVE_ALIGNABLE_SKB /* Ditto 8) */ 35#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
@@ -209,6 +210,7 @@ enum {
209 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c 210 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
210 * @tc_index: Traffic control index 211 * @tc_index: Traffic control index
211 * @tc_verd: traffic control verdict 212 * @tc_verd: traffic control verdict
213 * @secmark: security marking
212 */ 214 */
213 215
214struct sk_buff { 216struct sk_buff {
@@ -285,6 +287,12 @@ struct sk_buff {
285 __u16 tc_verd; /* traffic control verdict */ 287 __u16 tc_verd; /* traffic control verdict */
286#endif 288#endif
287#endif 289#endif
290#ifdef CONFIG_NET_DMA
291 dma_cookie_t dma_cookie;
292#endif
293#ifdef CONFIG_NETWORK_SECMARK
294 __u32 secmark;
295#endif
288 296
289 297
290 /* These elements must be at the end, see alloc_skb() for details. */ 298 /* These elements must be at the end, see alloc_skb() for details. */
@@ -967,15 +975,16 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
967#define NET_SKB_PAD 16 975#define NET_SKB_PAD 16
968#endif 976#endif
969 977
970extern int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc); 978extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
971 979
972static inline void __skb_trim(struct sk_buff *skb, unsigned int len) 980static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
973{ 981{
974 if (!skb->data_len) { 982 if (unlikely(skb->data_len)) {
975 skb->len = len; 983 WARN_ON(1);
976 skb->tail = skb->data + len; 984 return;
977 } else 985 }
978 ___pskb_trim(skb, len, 0); 986 skb->len = len;
987 skb->tail = skb->data + len;
979} 988}
980 989
981/** 990/**
@@ -985,6 +994,7 @@ static inline void __skb_trim(struct sk_buff *skb, unsigned int len)
985 * 994 *
986 * Cut the length of a buffer down by removing data from the tail. If 995 * Cut the length of a buffer down by removing data from the tail. If
987 * the buffer is already under the length specified it is not modified. 996 * the buffer is already under the length specified it is not modified.
997 * The skb must be linear.
988 */ 998 */
989static inline void skb_trim(struct sk_buff *skb, unsigned int len) 999static inline void skb_trim(struct sk_buff *skb, unsigned int len)
990{ 1000{
@@ -995,12 +1005,10 @@ static inline void skb_trim(struct sk_buff *skb, unsigned int len)
995 1005
996static inline int __pskb_trim(struct sk_buff *skb, unsigned int len) 1006static inline int __pskb_trim(struct sk_buff *skb, unsigned int len)
997{ 1007{
998 if (!skb->data_len) { 1008 if (skb->data_len)
999 skb->len = len; 1009 return ___pskb_trim(skb, len);
1000 skb->tail = skb->data+len; 1010 __skb_trim(skb, len);
1001 return 0; 1011 return 0;
1002 }
1003 return ___pskb_trim(skb, len, 1);
1004} 1012}
1005 1013
1006static inline int pskb_trim(struct sk_buff *skb, unsigned int len) 1014static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
@@ -1161,18 +1169,34 @@ static inline int skb_can_coalesce(struct sk_buff *skb, int i,
1161 return 0; 1169 return 0;
1162} 1170}
1163 1171
1172static inline int __skb_linearize(struct sk_buff *skb)
1173{
1174 return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM;
1175}
1176
1164/** 1177/**
1165 * skb_linearize - convert paged skb to linear one 1178 * skb_linearize - convert paged skb to linear one
1166 * @skb: buffer to linarize 1179 * @skb: buffer to linarize
1167 * @gfp: allocation mode
1168 * 1180 *
1169 * If there is no free memory -ENOMEM is returned, otherwise zero 1181 * If there is no free memory -ENOMEM is returned, otherwise zero
1170 * is returned and the old skb data released. 1182 * is returned and the old skb data released.
1171 */ 1183 */
1172extern int __skb_linearize(struct sk_buff *skb, gfp_t gfp); 1184static inline int skb_linearize(struct sk_buff *skb)
1173static inline int skb_linearize(struct sk_buff *skb, gfp_t gfp) 1185{
1186 return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0;
1187}
1188
1189/**
1190 * skb_linearize_cow - make sure skb is linear and writable
1191 * @skb: buffer to process
1192 *
1193 * If there is no free memory -ENOMEM is returned, otherwise zero
1194 * is returned and the old skb data released.
1195 */
1196static inline int skb_linearize_cow(struct sk_buff *skb)
1174{ 1197{
1175 return __skb_linearize(skb, gfp); 1198 return skb_is_nonlinear(skb) || skb_cloned(skb) ?
1199 __skb_linearize(skb) : 0;
1176} 1200}
1177 1201
1178/** 1202/**
@@ -1396,5 +1420,23 @@ static inline void nf_reset(struct sk_buff *skb)
1396static inline void nf_reset(struct sk_buff *skb) {} 1420static inline void nf_reset(struct sk_buff *skb) {}
1397#endif /* CONFIG_NETFILTER */ 1421#endif /* CONFIG_NETFILTER */
1398 1422
1423#ifdef CONFIG_NETWORK_SECMARK
1424static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from)
1425{
1426 to->secmark = from->secmark;
1427}
1428
1429static inline void skb_init_secmark(struct sk_buff *skb)
1430{
1431 skb->secmark = 0;
1432}
1433#else
1434static inline void skb_copy_secmark(struct sk_buff *to, const struct sk_buff *from)
1435{ }
1436
1437static inline void skb_init_secmark(struct sk_buff *skb)
1438{ }
1439#endif
1440
1399#endif /* __KERNEL__ */ 1441#endif /* __KERNEL__ */
1400#endif /* _LINUX_SKBUFF_H */ 1442#endif /* _LINUX_SKBUFF_H */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 76eaeff76f82..cee944dbdcd4 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -313,6 +313,7 @@ enum
313 NET_NF_CONNTRACK_FRAG6_TIMEOUT=29, 313 NET_NF_CONNTRACK_FRAG6_TIMEOUT=29,
314 NET_NF_CONNTRACK_FRAG6_LOW_THRESH=30, 314 NET_NF_CONNTRACK_FRAG6_LOW_THRESH=30,
315 NET_NF_CONNTRACK_FRAG6_HIGH_THRESH=31, 315 NET_NF_CONNTRACK_FRAG6_HIGH_THRESH=31,
316 NET_NF_CONNTRACK_CHECKSUM=32,
316}; 317};
317 318
318/* /proc/sys/net/ipv4 */ 319/* /proc/sys/net/ipv4 */
@@ -403,6 +404,8 @@ enum
403 NET_TCP_MTU_PROBING=113, 404 NET_TCP_MTU_PROBING=113,
404 NET_TCP_BASE_MSS=114, 405 NET_TCP_BASE_MSS=114,
405 NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS=115, 406 NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS=115,
407 NET_TCP_DMA_COPYBREAK=116,
408 NET_TCP_SLOW_START_AFTER_IDLE=117,
406}; 409};
407 410
408enum { 411enum {
@@ -491,6 +494,7 @@ enum
491 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD=25, 494 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD=25,
492 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT=26, 495 NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT=26,
493 NET_IPV4_NF_CONNTRACK_COUNT=27, 496 NET_IPV4_NF_CONNTRACK_COUNT=27,
497 NET_IPV4_NF_CONNTRACK_CHECKSUM=28,
494}; 498};
495 499
496/* /proc/sys/net/ipv6 */ 500/* /proc/sys/net/ipv6 */
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 542d39596bd8..c90daa5da6c3 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -18,6 +18,7 @@
18#define _LINUX_TCP_H 18#define _LINUX_TCP_H
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/dmaengine.h>
21#include <asm/byteorder.h> 22#include <asm/byteorder.h>
22 23
23struct tcphdr { 24struct tcphdr {
@@ -233,6 +234,13 @@ struct tcp_sock {
233 struct iovec *iov; 234 struct iovec *iov;
234 int memory; 235 int memory;
235 int len; 236 int len;
237#ifdef CONFIG_NET_DMA
238 /* members for async copy */
239 struct dma_chan *dma_chan;
240 int wakeup;
241 struct dma_pinned_list *pinned_list;
242 dma_cookie_t dma_cookie;
243#endif
236 } ucopy; 244 } ucopy;
237 245
238 __u32 snd_wl1; /* Sequence for window update */ 246 __u32 snd_wl1; /* Sequence for window update */
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index 6b42cc474c01..46a15c7a1a13 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -118,6 +118,10 @@ enum
118 XFRM_SHARE_UNIQUE /* Use once */ 118 XFRM_SHARE_UNIQUE /* Use once */
119}; 119};
120 120
121#define XFRM_MODE_TRANSPORT 0
122#define XFRM_MODE_TUNNEL 1
123#define XFRM_MODE_MAX 2
124
121/* Netlink configuration messages. */ 125/* Netlink configuration messages. */
122enum { 126enum {
123 XFRM_MSG_BASE = 0x10, 127 XFRM_MSG_BASE = 0x10,
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index d5926bfb1fc9..d5147770ad47 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -29,7 +29,7 @@
29#include <linux/kernel.h> /* ARRAY_SIZE */ 29#include <linux/kernel.h> /* ARRAY_SIZE */
30#include <linux/wireless.h> 30#include <linux/wireless.h>
31 31
32#define IEEE80211_VERSION "git-1.1.7" 32#define IEEE80211_VERSION "git-1.1.13"
33 33
34#define IEEE80211_DATA_LEN 2304 34#define IEEE80211_DATA_LEN 2304
35/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 35/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
@@ -104,6 +104,9 @@
104#define IEEE80211_SCTL_FRAG 0x000F 104#define IEEE80211_SCTL_FRAG 0x000F
105#define IEEE80211_SCTL_SEQ 0xFFF0 105#define IEEE80211_SCTL_SEQ 0xFFF0
106 106
107/* QOS control */
108#define IEEE80211_QCTL_TID 0x000F
109
107/* debug macros */ 110/* debug macros */
108 111
109#ifdef CONFIG_IEEE80211_DEBUG 112#ifdef CONFIG_IEEE80211_DEBUG
@@ -1075,6 +1078,7 @@ struct ieee80211_device {
1075 1078
1076 int (*handle_management) (struct net_device * dev, 1079 int (*handle_management) (struct net_device * dev,
1077 struct ieee80211_network * network, u16 type); 1080 struct ieee80211_network * network, u16 type);
1081 int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
1078 1082
1079 /* Typical STA methods */ 1083 /* Typical STA methods */
1080 int (*handle_auth) (struct net_device * dev, 1084 int (*handle_auth) (struct net_device * dev,
@@ -1243,7 +1247,8 @@ extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
1243extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); 1247extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
1244extern void ieee80211_txb_free(struct ieee80211_txb *); 1248extern void ieee80211_txb_free(struct ieee80211_txb *);
1245extern int ieee80211_tx_frame(struct ieee80211_device *ieee, 1249extern int ieee80211_tx_frame(struct ieee80211_device *ieee,
1246 struct ieee80211_hdr *frame, int len); 1250 struct ieee80211_hdr *frame, int hdr_len,
1251 int total_len, int encrypt_mpdu);
1247 1252
1248/* ieee80211_rx.c */ 1253/* ieee80211_rx.c */
1249extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, 1254extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
index 052ed596a4e4..7a483ab4022f 100644
--- a/include/net/ieee80211softmac.h
+++ b/include/net/ieee80211softmac.h
@@ -86,6 +86,9 @@ struct ieee80211softmac_assoc_info {
86 86
87 /* BSSID we're trying to associate to */ 87 /* BSSID we're trying to associate to */
88 char bssid[ETH_ALEN]; 88 char bssid[ETH_ALEN];
89
90 /* Rates supported by the network */
91 struct ieee80211softmac_ratesinfo supported_rates;
89 92
90 /* some flags. 93 /* some flags.
91 * static_essid is valid if the essid is constant, 94 * static_essid is valid if the essid is constant,
@@ -132,23 +135,26 @@ enum {
132struct ieee80211softmac_txrates { 135struct ieee80211softmac_txrates {
133 /* The Bit-Rate to be used for multicast frames. */ 136 /* The Bit-Rate to be used for multicast frames. */
134 u8 mcast_rate; 137 u8 mcast_rate;
135 /* The Bit-Rate to be used for multicast fallback 138
136 * (If the device supports fallback and hardware-retry) 139 /* The Bit-Rate to be used for multicast management frames. */
137 */ 140 u8 mgt_mcast_rate;
138 u8 mcast_fallback; 141
139 /* The Bit-Rate to be used for any other (normal) data packet. */ 142 /* The Bit-Rate to be used for any other (normal) data packet. */
140 u8 default_rate; 143 u8 default_rate;
141 /* The Bit-Rate to be used for default fallback 144 /* The Bit-Rate to be used for default fallback
142 * (If the device supports fallback and hardware-retry) 145 * (If the device supports fallback and hardware-retry)
143 */ 146 */
144 u8 default_fallback; 147 u8 default_fallback;
148
149 /* This is the rate that the user asked for */
150 u8 user_rate;
145}; 151};
146 152
147/* Bits for txrates_change callback. */ 153/* Bits for txrates_change callback. */
148#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */ 154#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */
149#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */ 155#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */
150#define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */ 156#define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */
151#define IEEE80211SOFTMAC_TXRATECHG_MCAST_FBACK (1 << 3) /* mcast_fallback */ 157#define IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST (1 << 3) /* mgt_mcast_rate */
152 158
153struct ieee80211softmac_device { 159struct ieee80211softmac_device {
154 /* 802.11 structure for data stuff */ 160 /* 802.11 structure for data stuff */
@@ -250,6 +256,28 @@ extern void ieee80211softmac_fragment_lost(struct net_device *dev,
250 * Note that the rates need to be sorted. */ 256 * Note that the rates need to be sorted. */
251extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates); 257extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates);
252 258
259/* Helper function which advises you the rate at which a frame should be
260 * transmitted at. */
261static inline u8 ieee80211softmac_suggest_txrate(struct ieee80211softmac_device *mac,
262 int is_multicast,
263 int is_mgt)
264{
265 struct ieee80211softmac_txrates *txrates = &mac->txrates;
266
267 if (!mac->associated)
268 return txrates->mgt_mcast_rate;
269
270 /* We are associated, sending unicast frame */
271 if (!is_multicast)
272 return txrates->default_rate;
273
274 /* We are associated, sending multicast frame */
275 if (is_mgt)
276 return txrates->mgt_mcast_rate;
277 else
278 return txrates->mcast_rate;
279}
280
253/* Start the SoftMAC. Call this after you initialized the device 281/* Start the SoftMAC. Call this after you initialized the device
254 * and it is ready to run. 282 * and it is ready to run.
255 */ 283 */
@@ -282,7 +310,7 @@ extern void ieee80211softmac_stop(struct net_device *dev);
282 * - context set to the context data you want passed 310 * - context set to the context data you want passed
283 * The return value is 0, or an error. 311 * The return value is 0, or an error.
284 */ 312 */
285typedef void (*notify_function_ptr)(struct net_device *dev, void *context); 313typedef void (*notify_function_ptr)(struct net_device *dev, int event_type, void *context);
286 314
287#define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL); 315#define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL);
288#define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC); 316#define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC);
diff --git a/include/net/ieee80211softmac_wx.h b/include/net/ieee80211softmac_wx.h
index 3e0be453ecea..4ee3ad57283f 100644
--- a/include/net/ieee80211softmac_wx.h
+++ b/include/net/ieee80211softmac_wx.h
@@ -91,4 +91,9 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
91 struct iw_request_info *info, 91 struct iw_request_info *info,
92 union iwreq_data *wrqu, 92 union iwreq_data *wrqu,
93 char *extra); 93 char *extra);
94extern int
95ieee80211softmac_wx_set_mlme(struct net_device *dev,
96 struct iw_request_info *info,
97 union iwreq_data *wrqu,
98 char *extra);
94#endif /* _IEEE80211SOFTMAC_WX */ 99#endif /* _IEEE80211SOFTMAC_WX */
diff --git a/include/net/ip.h b/include/net/ip.h
index 3d2e5ca62a5a..ead233c9540d 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -147,7 +147,6 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
147struct ipv4_config 147struct ipv4_config
148{ 148{
149 int log_martians; 149 int log_martians;
150 int autoconfig;
151 int no_pmtu_disc; 150 int no_pmtu_disc;
152}; 151};
153 152
diff --git a/include/net/llc_if.h b/include/net/llc_if.h
index 090eaa0d71f9..c608812a8e89 100644
--- a/include/net/llc_if.h
+++ b/include/net/llc_if.h
@@ -16,6 +16,7 @@
16#include <linux/if.h> 16#include <linux/if.h>
17#include <linux/if_arp.h> 17#include <linux/if_arp.h>
18#include <linux/llc.h> 18#include <linux/llc.h>
19#include <linux/etherdevice.h>
19#include <net/llc.h> 20#include <net/llc.h>
20 21
21#define LLC_DATAUNIT_PRIM 1 22#define LLC_DATAUNIT_PRIM 1
@@ -61,8 +62,6 @@
61#define LLC_STATUS_CONFLICT 7 /* disconnect conn */ 62#define LLC_STATUS_CONFLICT 7 /* disconnect conn */
62#define LLC_STATUS_RESET_DONE 8 /* */ 63#define LLC_STATUS_RESET_DONE 8 /* */
63 64
64extern u8 llc_mac_null_var[IFHWADDRLEN];
65
66/** 65/**
67 * llc_mac_null - determines if a address is a null mac address 66 * llc_mac_null - determines if a address is a null mac address
68 * @mac: Mac address to test if null. 67 * @mac: Mac address to test if null.
@@ -70,16 +69,20 @@ extern u8 llc_mac_null_var[IFHWADDRLEN];
70 * Determines if a given address is a null mac address. Returns 0 if the 69 * Determines if a given address is a null mac address. Returns 0 if the
71 * address is not a null mac, 1 if the address is a null mac. 70 * address is not a null mac, 1 if the address is a null mac.
72 */ 71 */
73static __inline__ int llc_mac_null(u8 *mac) 72static inline int llc_mac_null(const u8 *mac)
74{ 73{
75 return !memcmp(mac, llc_mac_null_var, IFHWADDRLEN); 74 return is_zero_ether_addr(mac);
76} 75}
77 76
78static __inline__ int llc_addrany(struct llc_addr *addr) 77static inline int llc_addrany(const struct llc_addr *addr)
79{ 78{
80 return llc_mac_null(addr->mac) && !addr->lsap; 79 return llc_mac_null(addr->mac) && !addr->lsap;
81} 80}
82 81
82static inline int llc_mac_multicast(const u8 *mac)
83{
84 return is_multicast_ether_addr(mac);
85}
83/** 86/**
84 * llc_mac_match - determines if two mac addresses are the same 87 * llc_mac_match - determines if two mac addresses are the same
85 * @mac1: First mac address to compare. 88 * @mac1: First mac address to compare.
@@ -89,9 +92,9 @@ static __inline__ int llc_addrany(struct llc_addr *addr)
89 * is not a complete match up to len, 1 if a complete match up to len is 92 * is not a complete match up to len, 1 if a complete match up to len is
90 * found. 93 * found.
91 */ 94 */
92static __inline__ int llc_mac_match(u8 *mac1, u8 *mac2) 95static inline int llc_mac_match(const u8 *mac1, const u8 *mac2)
93{ 96{
94 return !memcmp(mac1, mac2, IFHWADDRLEN); 97 return !compare_ether_addr(mac1, mac2);
95} 98}
96 99
97extern int llc_establish_connection(struct sock *sk, u8 *lmac, 100extern int llc_establish_connection(struct sock *sk, u8 *lmac,
diff --git a/include/net/netdma.h b/include/net/netdma.h
new file mode 100644
index 000000000000..19760eb131aa
--- /dev/null
+++ b/include/net/netdma.h
@@ -0,0 +1,44 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called COPYING.
20 */
21#ifndef NETDMA_H
22#define NETDMA_H
23#include <linux/config.h>
24#ifdef CONFIG_NET_DMA
25#include <linux/dmaengine.h>
26#include <linux/skbuff.h>
27
28static inline struct dma_chan *get_softnet_dma(void)
29{
30 struct dma_chan *chan;
31 rcu_read_lock();
32 chan = rcu_dereference(__get_cpu_var(softnet_data.net_dma));
33 if (chan)
34 dma_chan_get(chan);
35 rcu_read_unlock();
36 return chan;
37}
38
39int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
40 const struct sk_buff *skb, int offset, struct iovec *to,
41 size_t len, struct dma_pinned_list *pinned_list);
42
43#endif /* CONFIG_NET_DMA */
44#endif /* NETDMA_H */
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 916013ca4a5c..411117815807 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -114,6 +114,10 @@ struct nf_conn
114 u_int32_t mark; 114 u_int32_t mark;
115#endif 115#endif
116 116
117#ifdef CONFIG_NF_CONNTRACK_SECMARK
118 u_int32_t secmark;
119#endif
120
117 /* Storage reserved for other modules: */ 121 /* Storage reserved for other modules: */
118 union nf_conntrack_proto proto; 122 union nf_conntrack_proto proto;
119 123
@@ -285,6 +289,7 @@ static inline int nf_ct_is_dying(struct nf_conn *ct)
285} 289}
286 290
287extern unsigned int nf_conntrack_htable_size; 291extern unsigned int nf_conntrack_htable_size;
292extern int nf_conntrack_checksum;
288 293
289#define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++) 294#define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++)
290 295
diff --git a/include/net/netfilter/nf_conntrack_compat.h b/include/net/netfilter/nf_conntrack_compat.h
index 3cac19fb3648..f1b1482d7200 100644
--- a/include/net/netfilter/nf_conntrack_compat.h
+++ b/include/net/netfilter/nf_conntrack_compat.h
@@ -20,6 +20,19 @@ static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
20} 20}
21#endif /* CONFIG_IP_NF_CONNTRACK_MARK */ 21#endif /* CONFIG_IP_NF_CONNTRACK_MARK */
22 22
23#ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
24static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
25 u_int32_t *ctinfo)
26{
27 struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo);
28
29 if (ct)
30 return &ct->secmark;
31 else
32 return NULL;
33}
34#endif /* CONFIG_IP_NF_CONNTRACK_SECMARK */
35
23#ifdef CONFIG_IP_NF_CT_ACCT 36#ifdef CONFIG_IP_NF_CT_ACCT
24static inline struct ip_conntrack_counter * 37static inline struct ip_conntrack_counter *
25nf_ct_get_counters(const struct sk_buff *skb) 38nf_ct_get_counters(const struct sk_buff *skb)
@@ -70,6 +83,19 @@ static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb,
70} 83}
71#endif /* CONFIG_NF_CONNTRACK_MARK */ 84#endif /* CONFIG_NF_CONNTRACK_MARK */
72 85
86#ifdef CONFIG_NF_CONNTRACK_SECMARK
87static inline u_int32_t *nf_ct_get_secmark(const struct sk_buff *skb,
88 u_int32_t *ctinfo)
89{
90 struct nf_conn *ct = nf_ct_get(skb, ctinfo);
91
92 if (ct)
93 return &ct->secmark;
94 else
95 return NULL;
96}
97#endif /* CONFIG_NF_CONNTRACK_MARK */
98
73#ifdef CONFIG_NF_CT_ACCT 99#ifdef CONFIG_NF_CT_ACCT
74static inline struct ip_conntrack_counter * 100static inline struct ip_conntrack_counter *
75nf_ct_get_counters(const struct sk_buff *skb) 101nf_ct_get_counters(const struct sk_buff *skb)
diff --git a/include/net/raw.h b/include/net/raw.h
index e67b28a0248c..d83571fe4c69 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -36,7 +36,7 @@ extern rwlock_t raw_v4_lock;
36 36
37 37
38extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num, 38extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
39 unsigned long raddr, unsigned long laddr, 39 __be32 raddr, __be32 laddr,
40 int dif); 40 int dif);
41 41
42extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash); 42extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash);
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index aa6033ca7cd8..b2b40f951ae6 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -255,7 +255,7 @@ extern int sctp_debug_flag;
255#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) 255#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
256#define SCTP_ENABLE_DEBUG 256#define SCTP_ENABLE_DEBUG
257#define SCTP_DISABLE_DEBUG 257#define SCTP_DISABLE_DEBUG
258#define SCTP_ASSERT(expr, str, func) 258#define SCTP_ASSERT(expr, str, func) BUG_ON(!(expr))
259 259
260#endif /* SCTP_DEBUG */ 260#endif /* SCTP_DEBUG */
261 261
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 7f4fea173fb1..5f69158c1006 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -555,7 +555,8 @@ struct sctp_af {
555 int (*to_addr_param) (const union sctp_addr *, 555 int (*to_addr_param) (const union sctp_addr *,
556 union sctp_addr_param *); 556 union sctp_addr_param *);
557 int (*addr_valid) (union sctp_addr *, 557 int (*addr_valid) (union sctp_addr *,
558 struct sctp_sock *); 558 struct sctp_sock *,
559 const struct sk_buff *);
559 sctp_scope_t (*scope) (union sctp_addr *); 560 sctp_scope_t (*scope) (union sctp_addr *);
560 void (*inaddr_any) (union sctp_addr *, unsigned short); 561 void (*inaddr_any) (union sctp_addr *, unsigned short);
561 int (*is_any) (const union sctp_addr *); 562 int (*is_any) (const union sctp_addr *);
diff --git a/include/net/sock.h b/include/net/sock.h
index c9fad6fb629b..96565ff0de6a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -132,6 +132,7 @@ struct sock_common {
132 * @sk_receive_queue: incoming packets 132 * @sk_receive_queue: incoming packets
133 * @sk_wmem_alloc: transmit queue bytes committed 133 * @sk_wmem_alloc: transmit queue bytes committed
134 * @sk_write_queue: Packet sending queue 134 * @sk_write_queue: Packet sending queue
135 * @sk_async_wait_queue: DMA copied packets
135 * @sk_omem_alloc: "o" is "option" or "other" 136 * @sk_omem_alloc: "o" is "option" or "other"
136 * @sk_wmem_queued: persistent queue size 137 * @sk_wmem_queued: persistent queue size
137 * @sk_forward_alloc: space allocated forward 138 * @sk_forward_alloc: space allocated forward
@@ -205,6 +206,7 @@ struct sock {
205 atomic_t sk_omem_alloc; 206 atomic_t sk_omem_alloc;
206 struct sk_buff_head sk_receive_queue; 207 struct sk_buff_head sk_receive_queue;
207 struct sk_buff_head sk_write_queue; 208 struct sk_buff_head sk_write_queue;
209 struct sk_buff_head sk_async_wait_queue;
208 int sk_wmem_queued; 210 int sk_wmem_queued;
209 int sk_forward_alloc; 211 int sk_forward_alloc;
210 gfp_t sk_allocation; 212 gfp_t sk_allocation;
@@ -871,10 +873,7 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb, int needlock)
871 if (filter) { 873 if (filter) {
872 unsigned int pkt_len = sk_run_filter(skb, filter->insns, 874 unsigned int pkt_len = sk_run_filter(skb, filter->insns,
873 filter->len); 875 filter->len);
874 if (!pkt_len) 876 err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
875 err = -EPERM;
876 else
877 skb_trim(skb, pkt_len);
878 } 877 }
879 878
880 if (needlock) 879 if (needlock)
@@ -1271,11 +1270,22 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
1271 * This routine must be called with interrupts disabled or with the socket 1270 * This routine must be called with interrupts disabled or with the socket
1272 * locked so that the sk_buff queue operation is ok. 1271 * locked so that the sk_buff queue operation is ok.
1273*/ 1272*/
1274static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb) 1273#ifdef CONFIG_NET_DMA
1274static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)
1275{
1276 __skb_unlink(skb, &sk->sk_receive_queue);
1277 if (!copied_early)
1278 __kfree_skb(skb);
1279 else
1280 __skb_queue_tail(&sk->sk_async_wait_queue, skb);
1281}
1282#else
1283static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)
1275{ 1284{
1276 __skb_unlink(skb, &sk->sk_receive_queue); 1285 __skb_unlink(skb, &sk->sk_receive_queue);
1277 __kfree_skb(skb); 1286 __kfree_skb(skb);
1278} 1287}
1288#endif
1279 1289
1280extern void sock_enable_timestamp(struct sock *sk); 1290extern void sock_enable_timestamp(struct sock *sk);
1281extern int sock_get_timestamp(struct sock *, struct timeval __user *); 1291extern int sock_get_timestamp(struct sock *, struct timeval __user *);
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3c989db8a7aa..bfc71f954bbe 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -28,6 +28,7 @@
28#include <linux/cache.h> 28#include <linux/cache.h>
29#include <linux/percpu.h> 29#include <linux/percpu.h>
30#include <linux/skbuff.h> 30#include <linux/skbuff.h>
31#include <linux/dmaengine.h>
31 32
32#include <net/inet_connection_sock.h> 33#include <net/inet_connection_sock.h>
33#include <net/inet_timewait_sock.h> 34#include <net/inet_timewait_sock.h>
@@ -218,6 +219,7 @@ extern int sysctl_tcp_adv_win_scale;
218extern int sysctl_tcp_tw_reuse; 219extern int sysctl_tcp_tw_reuse;
219extern int sysctl_tcp_frto; 220extern int sysctl_tcp_frto;
220extern int sysctl_tcp_low_latency; 221extern int sysctl_tcp_low_latency;
222extern int sysctl_tcp_dma_copybreak;
221extern int sysctl_tcp_nometrics_save; 223extern int sysctl_tcp_nometrics_save;
222extern int sysctl_tcp_moderate_rcvbuf; 224extern int sysctl_tcp_moderate_rcvbuf;
223extern int sysctl_tcp_tso_win_divisor; 225extern int sysctl_tcp_tso_win_divisor;
@@ -225,6 +227,7 @@ extern int sysctl_tcp_abc;
225extern int sysctl_tcp_mtu_probing; 227extern int sysctl_tcp_mtu_probing;
226extern int sysctl_tcp_base_mss; 228extern int sysctl_tcp_base_mss;
227extern int sysctl_tcp_workaround_signed_windows; 229extern int sysctl_tcp_workaround_signed_windows;
230extern int sysctl_tcp_slow_start_after_idle;
228 231
229extern atomic_t tcp_memory_allocated; 232extern atomic_t tcp_memory_allocated;
230extern atomic_t tcp_sockets_allocated; 233extern atomic_t tcp_sockets_allocated;
@@ -293,6 +296,8 @@ extern int tcp_rcv_established(struct sock *sk,
293 296
294extern void tcp_rcv_space_adjust(struct sock *sk); 297extern void tcp_rcv_space_adjust(struct sock *sk);
295 298
299extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
300
296extern int tcp_twsk_unique(struct sock *sk, 301extern int tcp_twsk_unique(struct sock *sk,
297 struct sock *sktw, void *twp); 302 struct sock *sktw, void *twp);
298 303
@@ -628,7 +633,7 @@ struct tcp_congestion_ops {
628 /* return slow start threshold (required) */ 633 /* return slow start threshold (required) */
629 u32 (*ssthresh)(struct sock *sk); 634 u32 (*ssthresh)(struct sock *sk);
630 /* lower bound for congestion window (optional) */ 635 /* lower bound for congestion window (optional) */
631 u32 (*min_cwnd)(struct sock *sk); 636 u32 (*min_cwnd)(const struct sock *sk);
632 /* do new cwnd calculation (required) */ 637 /* do new cwnd calculation (required) */
633 void (*cong_avoid)(struct sock *sk, u32 ack, 638 void (*cong_avoid)(struct sock *sk, u32 ack,
634 u32 rtt, u32 in_flight, int good_ack); 639 u32 rtt, u32 in_flight, int good_ack);
@@ -663,7 +668,7 @@ extern struct tcp_congestion_ops tcp_init_congestion_ops;
663extern u32 tcp_reno_ssthresh(struct sock *sk); 668extern u32 tcp_reno_ssthresh(struct sock *sk);
664extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack, 669extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack,
665 u32 rtt, u32 in_flight, int flag); 670 u32 rtt, u32 in_flight, int flag);
666extern u32 tcp_reno_min_cwnd(struct sock *sk); 671extern u32 tcp_reno_min_cwnd(const struct sock *sk);
667extern struct tcp_congestion_ops tcp_reno; 672extern struct tcp_congestion_ops tcp_reno;
668 673
669static inline void tcp_set_ca_state(struct sock *sk, const u8 ca_state) 674static inline void tcp_set_ca_state(struct sock *sk, const u8 ca_state)
@@ -817,6 +822,12 @@ static inline void tcp_prequeue_init(struct tcp_sock *tp)
817 tp->ucopy.len = 0; 822 tp->ucopy.len = 0;
818 tp->ucopy.memory = 0; 823 tp->ucopy.memory = 0;
819 skb_queue_head_init(&tp->ucopy.prequeue); 824 skb_queue_head_init(&tp->ucopy.prequeue);
825#ifdef CONFIG_NET_DMA
826 tp->ucopy.dma_chan = NULL;
827 tp->ucopy.wakeup = 0;
828 tp->ucopy.pinned_list = NULL;
829 tp->ucopy.dma_cookie = 0;
830#endif
820} 831}
821 832
822/* Packet is added to VJ-style prequeue for processing in process 833/* Packet is added to VJ-style prequeue for processing in process
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index afa508d92c93..9c5ee9f20b65 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -20,6 +20,8 @@
20#include <net/ip6_fib.h> 20#include <net/ip6_fib.h>
21 21
22#define XFRM_ALIGN8(len) (((len) + 7) & ~7) 22#define XFRM_ALIGN8(len) (((len) + 7) & ~7)
23#define MODULE_ALIAS_XFRM_MODE(family, encap) \
24 MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap))
23 25
24extern struct sock *xfrm_nl; 26extern struct sock *xfrm_nl;
25extern u32 sysctl_xfrm_aevent_etime; 27extern u32 sysctl_xfrm_aevent_etime;
@@ -164,6 +166,7 @@ struct xfrm_state
164 /* Reference to data common to all the instances of this 166 /* Reference to data common to all the instances of this
165 * transformer. */ 167 * transformer. */
166 struct xfrm_type *type; 168 struct xfrm_type *type;
169 struct xfrm_mode *mode;
167 170
168 /* Security context */ 171 /* Security context */
169 struct xfrm_sec_ctx *security; 172 struct xfrm_sec_ctx *security;
@@ -204,8 +207,8 @@ struct xfrm_type;
204struct xfrm_dst; 207struct xfrm_dst;
205struct xfrm_policy_afinfo { 208struct xfrm_policy_afinfo {
206 unsigned short family; 209 unsigned short family;
207 rwlock_t lock; 210 struct xfrm_type *type_map[IPPROTO_MAX];
208 struct xfrm_type_map *type_map; 211 struct xfrm_mode *mode_map[XFRM_MODE_MAX];
209 struct dst_ops *dst_ops; 212 struct dst_ops *dst_ops;
210 void (*garbage_collect)(void); 213 void (*garbage_collect)(void);
211 int (*dst_lookup)(struct xfrm_dst **dst, struct flowi *fl); 214 int (*dst_lookup)(struct xfrm_dst **dst, struct flowi *fl);
@@ -232,7 +235,6 @@ extern int __xfrm_state_delete(struct xfrm_state *x);
232 235
233struct xfrm_state_afinfo { 236struct xfrm_state_afinfo {
234 unsigned short family; 237 unsigned short family;
235 rwlock_t lock;
236 struct list_head *state_bydst; 238 struct list_head *state_bydst;
237 struct list_head *state_byspi; 239 struct list_head *state_byspi;
238 int (*init_flags)(struct xfrm_state *x); 240 int (*init_flags)(struct xfrm_state *x);
@@ -264,16 +266,24 @@ struct xfrm_type
264 u32 (*get_max_size)(struct xfrm_state *, int size); 266 u32 (*get_max_size)(struct xfrm_state *, int size);
265}; 267};
266 268
267struct xfrm_type_map {
268 rwlock_t lock;
269 struct xfrm_type *map[256];
270};
271
272extern int xfrm_register_type(struct xfrm_type *type, unsigned short family); 269extern int xfrm_register_type(struct xfrm_type *type, unsigned short family);
273extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family); 270extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family);
274extern struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family); 271extern struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family);
275extern void xfrm_put_type(struct xfrm_type *type); 272extern void xfrm_put_type(struct xfrm_type *type);
276 273
274struct xfrm_mode {
275 int (*input)(struct xfrm_state *x, struct sk_buff *skb);
276 int (*output)(struct sk_buff *skb);
277
278 struct module *owner;
279 unsigned int encap;
280};
281
282extern int xfrm_register_mode(struct xfrm_mode *mode, int family);
283extern int xfrm_unregister_mode(struct xfrm_mode *mode, int family);
284extern struct xfrm_mode *xfrm_get_mode(unsigned int encap, int family);
285extern void xfrm_put_mode(struct xfrm_mode *mode);
286
277struct xfrm_tmpl 287struct xfrm_tmpl
278{ 288{
279/* id in template is interpreted as: 289/* id in template is interpreted as:
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
new file mode 100644
index 000000000000..fcb5ba87dcc5
--- /dev/null
+++ b/include/rdma/ib_addr.h
@@ -0,0 +1,114 @@
1/*
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 *
5 * This Software is licensed under one of the following licenses:
6 *
7 * 1) under the terms of the "Common Public License 1.0" a copy of which is
8 * available from the Open Source Initiative, see
9 * http://www.opensource.org/licenses/cpl.php.
10 *
11 * 2) under the terms of the "The BSD License" a copy of which is
12 * available from the Open Source Initiative, see
13 * http://www.opensource.org/licenses/bsd-license.php.
14 *
15 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
16 * copy of which is available from the Open Source Initiative, see
17 * http://www.opensource.org/licenses/gpl-license.php.
18 *
19 * Licensee has the right to choose one of the above licenses.
20 *
21 * Redistributions of source code must retain the above copyright
22 * notice and one of the license notices.
23 *
24 * Redistributions in binary form must reproduce both the above copyright
25 * notice, one of the license notices in the documentation
26 * and/or other materials provided with the distribution.
27 *
28 */
29
30#if !defined(IB_ADDR_H)
31#define IB_ADDR_H
32
33#include <linux/in.h>
34#include <linux/in6.h>
35#include <linux/netdevice.h>
36#include <linux/socket.h>
37#include <rdma/ib_verbs.h>
38
39struct rdma_dev_addr {
40 unsigned char src_dev_addr[MAX_ADDR_LEN];
41 unsigned char dst_dev_addr[MAX_ADDR_LEN];
42 unsigned char broadcast[MAX_ADDR_LEN];
43 enum ib_node_type dev_type;
44};
45
46/**
47 * rdma_translate_ip - Translate a local IP address to an RDMA hardware
48 * address.
49 */
50int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr);
51
52/**
53 * rdma_resolve_ip - Resolve source and destination IP addresses to
54 * RDMA hardware addresses.
55 * @src_addr: An optional source address to use in the resolution. If a
56 * source address is not provided, a usable address will be returned via
57 * the callback.
58 * @dst_addr: The destination address to resolve.
59 * @addr: A reference to a data location that will receive the resolved
60 * addresses. The data location must remain valid until the callback has
61 * been invoked.
62 * @timeout_ms: Amount of time to wait for the address resolution to complete.
63 * @callback: Call invoked once address resolution has completed, timed out,
64 * or been canceled. A status of 0 indicates success.
65 * @context: User-specified context associated with the call.
66 */
67int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
68 struct rdma_dev_addr *addr, int timeout_ms,
69 void (*callback)(int status, struct sockaddr *src_addr,
70 struct rdma_dev_addr *addr, void *context),
71 void *context);
72
73void rdma_addr_cancel(struct rdma_dev_addr *addr);
74
75static inline int ip_addr_size(struct sockaddr *addr)
76{
77 return addr->sa_family == AF_INET6 ?
78 sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
79}
80
81static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
82{
83 return ((u16)dev_addr->broadcast[8] << 8) | (u16)dev_addr->broadcast[9];
84}
85
86static inline void ib_addr_set_pkey(struct rdma_dev_addr *dev_addr, u16 pkey)
87{
88 dev_addr->broadcast[8] = pkey >> 8;
89 dev_addr->broadcast[9] = (unsigned char) pkey;
90}
91
92static inline union ib_gid *ib_addr_get_sgid(struct rdma_dev_addr *dev_addr)
93{
94 return (union ib_gid *) (dev_addr->src_dev_addr + 4);
95}
96
97static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr,
98 union ib_gid *gid)
99{
100 memcpy(dev_addr->src_dev_addr + 4, gid, sizeof *gid);
101}
102
103static inline union ib_gid *ib_addr_get_dgid(struct rdma_dev_addr *dev_addr)
104{
105 return (union ib_gid *) (dev_addr->dst_dev_addr + 4);
106}
107
108static inline void ib_addr_set_dgid(struct rdma_dev_addr *dev_addr,
109 union ib_gid *gid)
110{
111 memcpy(dev_addr->dst_dev_addr + 4, gid, sizeof *gid);
112}
113
114#endif /* IB_ADDR_H */
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h
index 5bf9834f7dca..f179d233ffc3 100644
--- a/include/rdma/ib_cache.h
+++ b/include/rdma/ib_cache.h
@@ -102,4 +102,17 @@ int ib_find_cached_pkey(struct ib_device *device,
102 u16 pkey, 102 u16 pkey,
103 u16 *index); 103 u16 *index);
104 104
105/**
106 * ib_get_cached_lmc - Returns a cached lmc table entry
107 * @device: The device to query.
108 * @port_num: The port number of the device to query.
109 * @lmc: The lmc value for the specified port for that device.
110 *
111 * ib_get_cached_lmc() fetches the specified lmc table entry stored in
112 * the local software cache.
113 */
114int ib_get_cached_lmc(struct ib_device *device,
115 u8 port_num,
116 u8 *lmc);
117
105#endif /* _IB_CACHE_H */ 118#endif /* _IB_CACHE_H */
diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h
index 0a9fcd59eb43..c9b4738be9d6 100644
--- a/include/rdma/ib_cm.h
+++ b/include/rdma/ib_cm.h
@@ -32,7 +32,7 @@
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 * 34 *
35 * $Id: ib_cm.h 2730 2005-06-28 16:43:03Z sean.hefty $ 35 * $Id: ib_cm.h 4311 2005-12-05 18:42:01Z sean.hefty $
36 */ 36 */
37#if !defined(IB_CM_H) 37#if !defined(IB_CM_H)
38#define IB_CM_H 38#define IB_CM_H
@@ -102,7 +102,8 @@ enum ib_cm_data_size {
102 IB_CM_APR_INFO_LENGTH = 72, 102 IB_CM_APR_INFO_LENGTH = 72,
103 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216, 103 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
104 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136, 104 IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
105 IB_CM_SIDR_REP_INFO_LENGTH = 72 105 IB_CM_SIDR_REP_INFO_LENGTH = 72,
106 IB_CM_COMPARE_SIZE = 64
106}; 107};
107 108
108struct ib_cm_id; 109struct ib_cm_id;
@@ -238,7 +239,6 @@ struct ib_cm_sidr_rep_event_param {
238 u32 qpn; 239 u32 qpn;
239 void *info; 240 void *info;
240 u8 info_len; 241 u8 info_len;
241
242}; 242};
243 243
244struct ib_cm_event { 244struct ib_cm_event {
@@ -317,6 +317,15 @@ void ib_destroy_cm_id(struct ib_cm_id *cm_id);
317 317
318#define IB_SERVICE_ID_AGN_MASK __constant_cpu_to_be64(0xFF00000000000000ULL) 318#define IB_SERVICE_ID_AGN_MASK __constant_cpu_to_be64(0xFF00000000000000ULL)
319#define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL) 319#define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL)
320#define IB_CMA_SERVICE_ID __constant_cpu_to_be64(0x0000000001000000ULL)
321#define IB_CMA_SERVICE_ID_MASK __constant_cpu_to_be64(0xFFFFFFFFFF000000ULL)
322#define IB_SDP_SERVICE_ID __constant_cpu_to_be64(0x0000000000010000ULL)
323#define IB_SDP_SERVICE_ID_MASK __constant_cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
324
325struct ib_cm_compare_data {
326 u8 data[IB_CM_COMPARE_SIZE];
327 u8 mask[IB_CM_COMPARE_SIZE];
328};
320 329
321/** 330/**
322 * ib_cm_listen - Initiates listening on the specified service ID for 331 * ib_cm_listen - Initiates listening on the specified service ID for
@@ -330,10 +339,12 @@ void ib_destroy_cm_id(struct ib_cm_id *cm_id);
330 * range of service IDs. If set to 0, the service ID is matched 339 * range of service IDs. If set to 0, the service ID is matched
331 * exactly. This parameter is ignored if %service_id is set to 340 * exactly. This parameter is ignored if %service_id is set to
332 * IB_CM_ASSIGN_SERVICE_ID. 341 * IB_CM_ASSIGN_SERVICE_ID.
342 * @compare_data: This parameter is optional. It specifies data that must
343 * appear in the private data of a connection request for the specified
344 * listen request.
333 */ 345 */
334int ib_cm_listen(struct ib_cm_id *cm_id, 346int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
335 __be64 service_id, 347 struct ib_cm_compare_data *compare_data);
336 __be64 service_mask);
337 348
338struct ib_cm_req_param { 349struct ib_cm_req_param {
339 struct ib_sa_path_rec *primary_path; 350 struct ib_sa_path_rec *primary_path;
@@ -535,7 +546,6 @@ struct ib_cm_sidr_req_param {
535 const void *private_data; 546 const void *private_data;
536 u8 private_data_len; 547 u8 private_data_len;
537 u8 max_cm_retries; 548 u8 max_cm_retries;
538 u16 pkey;
539}; 549};
540 550
541/** 551/**
@@ -559,7 +569,7 @@ struct ib_cm_sidr_rep_param {
559}; 569};
560 570
561/** 571/**
562 * ib_send_cm_sidr_rep - Sends a service ID resolution request to the 572 * ib_send_cm_sidr_rep - Sends a service ID resolution reply to the
563 * remote node. 573 * remote node.
564 * @cm_id: Communication identifier associated with the received service ID 574 * @cm_id: Communication identifier associated with the received service ID
565 * resolution request. 575 * resolution request.
diff --git a/include/rdma/ib_marshall.h b/include/rdma/ib_marshall.h
new file mode 100644
index 000000000000..66bf4d7d0dfb
--- /dev/null
+++ b/include/rdma/ib_marshall.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (c) 2005 Intel Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#if !defined(IB_USER_MARSHALL_H)
34#define IB_USER_MARSHALL_H
35
36#include <rdma/ib_verbs.h>
37#include <rdma/ib_sa.h>
38#include <rdma/ib_user_verbs.h>
39#include <rdma/ib_user_sa.h>
40
41void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
42 struct ib_qp_attr *src);
43
44void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
45 struct ib_sa_path_rec *src);
46
47void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
48 struct ib_user_path_rec *src);
49
50#endif /* IB_USER_MARSHALL_H */
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index ad63c215efe5..c99e4420fd7e 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -370,5 +370,12 @@ ib_sa_mcmember_rec_delete(struct ib_device *device, u8 port_num,
370 context, query); 370 context, query);
371} 371}
372 372
373/**
374 * ib_init_ah_from_path - Initialize address handle attributes based on an SA
375 * path record.
376 */
377int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
378 struct ib_sa_path_rec *rec,
379 struct ib_ah_attr *ah_attr);
373 380
374#endif /* IB_SA_H */ 381#endif /* IB_SA_H */
diff --git a/include/rdma/ib_smi.h b/include/rdma/ib_smi.h
index 87f60737f695..f29af135ba83 100644
--- a/include/rdma/ib_smi.h
+++ b/include/rdma/ib_smi.h
@@ -85,6 +85,42 @@ struct ib_smp {
85#define IB_SMP_ATTR_LED_INFO __constant_htons(0x0031) 85#define IB_SMP_ATTR_LED_INFO __constant_htons(0x0031)
86#define IB_SMP_ATTR_VENDOR_MASK __constant_htons(0xFF00) 86#define IB_SMP_ATTR_VENDOR_MASK __constant_htons(0xFF00)
87 87
88struct ib_port_info {
89 __be64 mkey;
90 __be64 gid_prefix;
91 __be16 lid;
92 __be16 sm_lid;
93 __be32 cap_mask;
94 __be16 diag_code;
95 __be16 mkey_lease_period;
96 u8 local_port_num;
97 u8 link_width_enabled;
98 u8 link_width_supported;
99 u8 link_width_active;
100 u8 linkspeed_portstate; /* 4 bits, 4 bits */
101 u8 portphysstate_linkdown; /* 4 bits, 4 bits */
102 u8 mkeyprot_resv_lmc; /* 2 bits, 3, 3 */
103 u8 linkspeedactive_enabled; /* 4 bits, 4 bits */
104 u8 neighbormtu_mastersmsl; /* 4 bits, 4 bits */
105 u8 vlcap_inittype; /* 4 bits, 4 bits */
106 u8 vl_high_limit;
107 u8 vl_arb_high_cap;
108 u8 vl_arb_low_cap;
109 u8 inittypereply_mtucap; /* 4 bits, 4 bits */
110 u8 vlstallcnt_hoqlife; /* 3 bits, 5 bits */
111 u8 operationalvl_pei_peo_fpi_fpo; /* 4 bits, 1, 1, 1, 1 */
112 __be16 mkey_violations;
113 __be16 pkey_violations;
114 __be16 qkey_violations;
115 u8 guid_cap;
116 u8 clientrereg_resv_subnetto; /* 1 bit, 2 bits, 5 */
117 u8 resv_resptimevalue; /* 3 bits, 5 bits */
118 u8 localphyerrors_overrunerrors; /* 4 bits, 4 bits */
119 __be16 max_credit_hint;
120 u8 resv;
121 u8 link_roundtrip_latency[3];
122};
123
88static inline u8 124static inline u8
89ib_get_smp_direction(struct ib_smp *smp) 125ib_get_smp_direction(struct ib_smp *smp)
90{ 126{
diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h
index 19be116047f6..066c20b7cdfb 100644
--- a/include/rdma/ib_user_cm.h
+++ b/include/rdma/ib_user_cm.h
@@ -30,13 +30,13 @@
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 * 32 *
33 * $Id: ib_user_cm.h 2576 2005-06-09 17:00:30Z libor $ 33 * $Id: ib_user_cm.h 4019 2005-11-11 00:33:09Z sean.hefty $
34 */ 34 */
35 35
36#ifndef IB_USER_CM_H 36#ifndef IB_USER_CM_H
37#define IB_USER_CM_H 37#define IB_USER_CM_H
38 38
39#include <linux/types.h> 39#include <rdma/ib_user_sa.h>
40 40
41#define IB_USER_CM_ABI_VERSION 4 41#define IB_USER_CM_ABI_VERSION 4
42 42
@@ -110,58 +110,6 @@ struct ib_ucm_init_qp_attr {
110 __u32 qp_state; 110 __u32 qp_state;
111}; 111};
112 112
113struct ib_ucm_ah_attr {
114 __u8 grh_dgid[16];
115 __u32 grh_flow_label;
116 __u16 dlid;
117 __u16 reserved;
118 __u8 grh_sgid_index;
119 __u8 grh_hop_limit;
120 __u8 grh_traffic_class;
121 __u8 sl;
122 __u8 src_path_bits;
123 __u8 static_rate;
124 __u8 is_global;
125 __u8 port_num;
126};
127
128struct ib_ucm_init_qp_attr_resp {
129 __u32 qp_attr_mask;
130 __u32 qp_state;
131 __u32 cur_qp_state;
132 __u32 path_mtu;
133 __u32 path_mig_state;
134 __u32 qkey;
135 __u32 rq_psn;
136 __u32 sq_psn;
137 __u32 dest_qp_num;
138 __u32 qp_access_flags;
139
140 struct ib_ucm_ah_attr ah_attr;
141 struct ib_ucm_ah_attr alt_ah_attr;
142
143 /* ib_qp_cap */
144 __u32 max_send_wr;
145 __u32 max_recv_wr;
146 __u32 max_send_sge;
147 __u32 max_recv_sge;
148 __u32 max_inline_data;
149
150 __u16 pkey_index;
151 __u16 alt_pkey_index;
152 __u8 en_sqd_async_notify;
153 __u8 sq_draining;
154 __u8 max_rd_atomic;
155 __u8 max_dest_rd_atomic;
156 __u8 min_rnr_timer;
157 __u8 port_num;
158 __u8 timeout;
159 __u8 retry_cnt;
160 __u8 rnr_retry;
161 __u8 alt_port_num;
162 __u8 alt_timeout;
163};
164
165struct ib_ucm_listen { 113struct ib_ucm_listen {
166 __be64 service_id; 114 __be64 service_id;
167 __be64 service_mask; 115 __be64 service_mask;
@@ -180,28 +128,6 @@ struct ib_ucm_private_data {
180 __u8 reserved[3]; 128 __u8 reserved[3];
181}; 129};
182 130
183struct ib_ucm_path_rec {
184 __u8 dgid[16];
185 __u8 sgid[16];
186 __be16 dlid;
187 __be16 slid;
188 __u32 raw_traffic;
189 __be32 flow_label;
190 __u32 reversible;
191 __u32 mtu;
192 __be16 pkey;
193 __u8 hop_limit;
194 __u8 traffic_class;
195 __u8 numb_path;
196 __u8 sl;
197 __u8 mtu_selector;
198 __u8 rate_selector;
199 __u8 rate;
200 __u8 packet_life_time_selector;
201 __u8 packet_life_time;
202 __u8 preference;
203};
204
205struct ib_ucm_req { 131struct ib_ucm_req {
206 __u32 id; 132 __u32 id;
207 __u32 qpn; 133 __u32 qpn;
@@ -274,7 +200,7 @@ struct ib_ucm_sidr_req {
274 __be64 sid; 200 __be64 sid;
275 __u64 data; 201 __u64 data;
276 __u64 path; 202 __u64 path;
277 __u16 pkey; 203 __u16 reserved_pkey;
278 __u8 len; 204 __u8 len;
279 __u8 max_cm_retries; 205 __u8 max_cm_retries;
280 __u8 reserved[4]; 206 __u8 reserved[4];
@@ -304,8 +230,8 @@ struct ib_ucm_event_get {
304}; 230};
305 231
306struct ib_ucm_req_event_resp { 232struct ib_ucm_req_event_resp {
307 struct ib_ucm_path_rec primary_path; 233 struct ib_user_path_rec primary_path;
308 struct ib_ucm_path_rec alternate_path; 234 struct ib_user_path_rec alternate_path;
309 __be64 remote_ca_guid; 235 __be64 remote_ca_guid;
310 __u32 remote_qkey; 236 __u32 remote_qkey;
311 __u32 remote_qpn; 237 __u32 remote_qpn;
@@ -349,7 +275,7 @@ struct ib_ucm_mra_event_resp {
349}; 275};
350 276
351struct ib_ucm_lap_event_resp { 277struct ib_ucm_lap_event_resp {
352 struct ib_ucm_path_rec path; 278 struct ib_user_path_rec path;
353}; 279};
354 280
355struct ib_ucm_apr_event_resp { 281struct ib_ucm_apr_event_resp {
diff --git a/include/rdma/ib_user_sa.h b/include/rdma/ib_user_sa.h
new file mode 100644
index 000000000000..659120157e14
--- /dev/null
+++ b/include/rdma/ib_user_sa.h
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 2005 Intel Corporation. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#ifndef IB_USER_SA_H
34#define IB_USER_SA_H
35
36#include <linux/types.h>
37
38struct ib_user_path_rec {
39 __u8 dgid[16];
40 __u8 sgid[16];
41 __be16 dlid;
42 __be16 slid;
43 __u32 raw_traffic;
44 __be32 flow_label;
45 __u32 reversible;
46 __u32 mtu;
47 __be16 pkey;
48 __u8 hop_limit;
49 __u8 traffic_class;
50 __u8 numb_path;
51 __u8 sl;
52 __u8 mtu_selector;
53 __u8 rate_selector;
54 __u8 rate;
55 __u8 packet_life_time_selector;
56 __u8 packet_life_time;
57 __u8 preference;
58};
59
60#endif /* IB_USER_SA_H */
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h
index 338ed4333063..7b5372010f4b 100644
--- a/include/rdma/ib_user_verbs.h
+++ b/include/rdma/ib_user_verbs.h
@@ -32,7 +32,7 @@
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 * 34 *
35 * $Id: ib_user_verbs.h 2708 2005-06-24 17:27:21Z roland $ 35 * $Id: ib_user_verbs.h 4019 2005-11-11 00:33:09Z sean.hefty $
36 */ 36 */
37 37
38#ifndef IB_USER_VERBS_H 38#ifndef IB_USER_VERBS_H
@@ -323,6 +323,64 @@ struct ib_uverbs_destroy_cq_resp {
323 __u32 async_events_reported; 323 __u32 async_events_reported;
324}; 324};
325 325
326struct ib_uverbs_global_route {
327 __u8 dgid[16];
328 __u32 flow_label;
329 __u8 sgid_index;
330 __u8 hop_limit;
331 __u8 traffic_class;
332 __u8 reserved;
333};
334
335struct ib_uverbs_ah_attr {
336 struct ib_uverbs_global_route grh;
337 __u16 dlid;
338 __u8 sl;
339 __u8 src_path_bits;
340 __u8 static_rate;
341 __u8 is_global;
342 __u8 port_num;
343 __u8 reserved;
344};
345
346struct ib_uverbs_qp_attr {
347 __u32 qp_attr_mask;
348 __u32 qp_state;
349 __u32 cur_qp_state;
350 __u32 path_mtu;
351 __u32 path_mig_state;
352 __u32 qkey;
353 __u32 rq_psn;
354 __u32 sq_psn;
355 __u32 dest_qp_num;
356 __u32 qp_access_flags;
357
358 struct ib_uverbs_ah_attr ah_attr;
359 struct ib_uverbs_ah_attr alt_ah_attr;
360
361 /* ib_qp_cap */
362 __u32 max_send_wr;
363 __u32 max_recv_wr;
364 __u32 max_send_sge;
365 __u32 max_recv_sge;
366 __u32 max_inline_data;
367
368 __u16 pkey_index;
369 __u16 alt_pkey_index;
370 __u8 en_sqd_async_notify;
371 __u8 sq_draining;
372 __u8 max_rd_atomic;
373 __u8 max_dest_rd_atomic;
374 __u8 min_rnr_timer;
375 __u8 port_num;
376 __u8 timeout;
377 __u8 retry_cnt;
378 __u8 rnr_retry;
379 __u8 alt_port_num;
380 __u8 alt_timeout;
381 __u8 reserved[5];
382};
383
326struct ib_uverbs_create_qp { 384struct ib_uverbs_create_qp {
327 __u64 response; 385 __u64 response;
328 __u64 user_handle; 386 __u64 user_handle;
@@ -541,26 +599,6 @@ struct ib_uverbs_post_srq_recv_resp {
541 __u32 bad_wr; 599 __u32 bad_wr;
542}; 600};
543 601
544struct ib_uverbs_global_route {
545 __u8 dgid[16];
546 __u32 flow_label;
547 __u8 sgid_index;
548 __u8 hop_limit;
549 __u8 traffic_class;
550 __u8 reserved;
551};
552
553struct ib_uverbs_ah_attr {
554 struct ib_uverbs_global_route grh;
555 __u16 dlid;
556 __u8 sl;
557 __u8 src_path_bits;
558 __u8 static_rate;
559 __u8 is_global;
560 __u8 port_num;
561 __u8 reserved;
562};
563
564struct ib_uverbs_create_ah { 602struct ib_uverbs_create_ah {
565 __u64 response; 603 __u64 response;
566 __u64 user_handle; 604 __u64 user_handle;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6bbf1b364400..ee1f3a355666 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -260,7 +260,8 @@ enum ib_event_type {
260 IB_EVENT_SM_CHANGE, 260 IB_EVENT_SM_CHANGE,
261 IB_EVENT_SRQ_ERR, 261 IB_EVENT_SRQ_ERR,
262 IB_EVENT_SRQ_LIMIT_REACHED, 262 IB_EVENT_SRQ_LIMIT_REACHED,
263 IB_EVENT_QP_LAST_WQE_REACHED 263 IB_EVENT_QP_LAST_WQE_REACHED,
264 IB_EVENT_CLIENT_REREGISTER
264}; 265};
265 266
266struct ib_event { 267struct ib_event {
@@ -696,8 +697,12 @@ struct ib_ucontext {
696struct ib_uobject { 697struct ib_uobject {
697 u64 user_handle; /* handle given to us by userspace */ 698 u64 user_handle; /* handle given to us by userspace */
698 struct ib_ucontext *context; /* associated user context */ 699 struct ib_ucontext *context; /* associated user context */
700 void *object; /* containing object */
699 struct list_head list; /* link to context's list */ 701 struct list_head list; /* link to context's list */
700 u32 id; /* index into kernel idr */ 702 u32 id; /* index into kernel idr */
703 struct kref ref;
704 struct rw_semaphore mutex; /* protects .live */
705 int live;
701}; 706};
702 707
703struct ib_umem { 708struct ib_umem {
@@ -827,6 +832,7 @@ struct ib_cache {
827 struct ib_event_handler event_handler; 832 struct ib_event_handler event_handler;
828 struct ib_pkey_cache **pkey_cache; 833 struct ib_pkey_cache **pkey_cache;
829 struct ib_gid_cache **gid_cache; 834 struct ib_gid_cache **gid_cache;
835 u8 *lmc_cache;
830}; 836};
831 837
832struct ib_device { 838struct ib_device {
@@ -1086,6 +1092,20 @@ int ib_dealloc_pd(struct ib_pd *pd);
1086struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); 1092struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
1087 1093
1088/** 1094/**
1095 * ib_init_ah_from_wc - Initializes address handle attributes from a
1096 * work completion.
1097 * @device: Device on which the received message arrived.
1098 * @port_num: Port on which the received message arrived.
1099 * @wc: Work completion associated with the received message.
1100 * @grh: References the received global route header. This parameter is
1101 * ignored unless the work completion indicates that the GRH is valid.
1102 * @ah_attr: Returned attributes that can be used when creating an address
1103 * handle for replying to the message.
1104 */
1105int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
1106 struct ib_grh *grh, struct ib_ah_attr *ah_attr);
1107
1108/**
1089 * ib_create_ah_from_wc - Creates an address handle associated with the 1109 * ib_create_ah_from_wc - Creates an address handle associated with the
1090 * sender of the specified work completion. 1110 * sender of the specified work completion.
1091 * @pd: The protection domain associated with the address handle. 1111 * @pd: The protection domain associated with the address handle.
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
new file mode 100644
index 000000000000..402c63d7226b
--- /dev/null
+++ b/include/rdma/rdma_cm.h
@@ -0,0 +1,256 @@
1/*
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 *
5 * This Software is licensed under one of the following licenses:
6 *
7 * 1) under the terms of the "Common Public License 1.0" a copy of which is
8 * available from the Open Source Initiative, see
9 * http://www.opensource.org/licenses/cpl.php.
10 *
11 * 2) under the terms of the "The BSD License" a copy of which is
12 * available from the Open Source Initiative, see
13 * http://www.opensource.org/licenses/bsd-license.php.
14 *
15 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
16 * copy of which is available from the Open Source Initiative, see
17 * http://www.opensource.org/licenses/gpl-license.php.
18 *
19 * Licensee has the right to choose one of the above licenses.
20 *
21 * Redistributions of source code must retain the above copyright
22 * notice and one of the license notices.
23 *
24 * Redistributions in binary form must reproduce both the above copyright
25 * notice, one of the license notices in the documentation
26 * and/or other materials provided with the distribution.
27 *
28 */
29
30#if !defined(RDMA_CM_H)
31#define RDMA_CM_H
32
33#include <linux/socket.h>
34#include <linux/in6.h>
35#include <rdma/ib_addr.h>
36#include <rdma/ib_sa.h>
37
38/*
39 * Upon receiving a device removal event, users must destroy the associated
40 * RDMA identifier and release all resources allocated with the device.
41 */
42enum rdma_cm_event_type {
43 RDMA_CM_EVENT_ADDR_RESOLVED,
44 RDMA_CM_EVENT_ADDR_ERROR,
45 RDMA_CM_EVENT_ROUTE_RESOLVED,
46 RDMA_CM_EVENT_ROUTE_ERROR,
47 RDMA_CM_EVENT_CONNECT_REQUEST,
48 RDMA_CM_EVENT_CONNECT_RESPONSE,
49 RDMA_CM_EVENT_CONNECT_ERROR,
50 RDMA_CM_EVENT_UNREACHABLE,
51 RDMA_CM_EVENT_REJECTED,
52 RDMA_CM_EVENT_ESTABLISHED,
53 RDMA_CM_EVENT_DISCONNECTED,
54 RDMA_CM_EVENT_DEVICE_REMOVAL,
55};
56
57enum rdma_port_space {
58 RDMA_PS_SDP = 0x0001,
59 RDMA_PS_TCP = 0x0106,
60 RDMA_PS_UDP = 0x0111,
61 RDMA_PS_SCTP = 0x0183
62};
63
64struct rdma_addr {
65 struct sockaddr src_addr;
66 u8 src_pad[sizeof(struct sockaddr_in6) -
67 sizeof(struct sockaddr)];
68 struct sockaddr dst_addr;
69 u8 dst_pad[sizeof(struct sockaddr_in6) -
70 sizeof(struct sockaddr)];
71 struct rdma_dev_addr dev_addr;
72};
73
74struct rdma_route {
75 struct rdma_addr addr;
76 struct ib_sa_path_rec *path_rec;
77 int num_paths;
78};
79
80struct rdma_cm_event {
81 enum rdma_cm_event_type event;
82 int status;
83 void *private_data;
84 u8 private_data_len;
85};
86
87struct rdma_cm_id;
88
89/**
90 * rdma_cm_event_handler - Callback used to report user events.
91 *
92 * Notes: Users may not call rdma_destroy_id from this callback to destroy
93 * the passed in id, or a corresponding listen id. Returning a
94 * non-zero value from the callback will destroy the passed in id.
95 */
96typedef int (*rdma_cm_event_handler)(struct rdma_cm_id *id,
97 struct rdma_cm_event *event);
98
99struct rdma_cm_id {
100 struct ib_device *device;
101 void *context;
102 struct ib_qp *qp;
103 rdma_cm_event_handler event_handler;
104 struct rdma_route route;
105 enum rdma_port_space ps;
106 u8 port_num;
107};
108
109/**
110 * rdma_create_id - Create an RDMA identifier.
111 *
112 * @event_handler: User callback invoked to report events associated with the
113 * returned rdma_id.
114 * @context: User specified context associated with the id.
115 * @ps: RDMA port space.
116 */
117struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
118 void *context, enum rdma_port_space ps);
119
120void rdma_destroy_id(struct rdma_cm_id *id);
121
122/**
123 * rdma_bind_addr - Bind an RDMA identifier to a source address and
124 * associated RDMA device, if needed.
125 *
126 * @id: RDMA identifier.
127 * @addr: Local address information. Wildcard values are permitted.
128 *
129 * This associates a source address with the RDMA identifier before calling
130 * rdma_listen. If a specific local address is given, the RDMA identifier will
131 * be bound to a local RDMA device.
132 */
133int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
134
135/**
136 * rdma_resolve_addr - Resolve destination and optional source addresses
137 * from IP addresses to an RDMA address. If successful, the specified
138 * rdma_cm_id will be bound to a local device.
139 *
140 * @id: RDMA identifier.
141 * @src_addr: Source address information. This parameter may be NULL.
142 * @dst_addr: Destination address information.
143 * @timeout_ms: Time to wait for resolution to complete.
144 */
145int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
146 struct sockaddr *dst_addr, int timeout_ms);
147
148/**
149 * rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier
150 * into route information needed to establish a connection.
151 *
152 * This is called on the client side of a connection.
153 * Users must have first called rdma_resolve_addr to resolve a dst_addr
154 * into an RDMA address before calling this routine.
155 */
156int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);
157
158/**
159 * rdma_create_qp - Allocate a QP and associate it with the specified RDMA
160 * identifier.
161 *
162 * QPs allocated to an rdma_cm_id will automatically be transitioned by the CMA
163 * through their states.
164 */
165int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
166 struct ib_qp_init_attr *qp_init_attr);
167
168/**
169 * rdma_destroy_qp - Deallocate the QP associated with the specified RDMA
170 * identifier.
171 *
172 * Users must destroy any QP associated with an RDMA identifier before
173 * destroying the RDMA ID.
174 */
175void rdma_destroy_qp(struct rdma_cm_id *id);
176
177/**
178 * rdma_init_qp_attr - Initializes the QP attributes for use in transitioning
179 * to a specified QP state.
180 * @id: Communication identifier associated with the QP attributes to
181 * initialize.
182 * @qp_attr: On input, specifies the desired QP state. On output, the
183 * mandatory and desired optional attributes will be set in order to
184 * modify the QP to the specified state.
185 * @qp_attr_mask: The QP attribute mask that may be used to transition the
186 * QP to the specified state.
187 *
188 * Users must set the @qp_attr->qp_state to the desired QP state. This call
189 * will set all required attributes for the given transition, along with
190 * known optional attributes. Users may override the attributes returned from
191 * this call before calling ib_modify_qp.
192 *
193 * Users that wish to have their QP automatically transitioned through its
194 * states can associate a QP with the rdma_cm_id by calling rdma_create_qp().
195 */
196int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
197 int *qp_attr_mask);
198
199struct rdma_conn_param {
200 const void *private_data;
201 u8 private_data_len;
202 u8 responder_resources;
203 u8 initiator_depth;
204 u8 flow_control;
205 u8 retry_count; /* ignored when accepting */
206 u8 rnr_retry_count;
207 /* Fields below ignored if a QP is created on the rdma_cm_id. */
208 u8 srq;
209 u32 qp_num;
210 enum ib_qp_type qp_type;
211};
212
213/**
214 * rdma_connect - Initiate an active connection request.
215 *
216 * Users must have resolved a route for the rdma_cm_id to connect with
217 * by having called rdma_resolve_route before calling this routine.
218 */
219int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
220
221/**
222 * rdma_listen - This function is called by the passive side to
223 * listen for incoming connection requests.
224 *
225 * Users must have bound the rdma_cm_id to a local address by calling
226 * rdma_bind_addr before calling this routine.
227 */
228int rdma_listen(struct rdma_cm_id *id, int backlog);
229
230/**
231 * rdma_accept - Called to accept a connection request or response.
232 * @id: Connection identifier associated with the request.
233 * @conn_param: Information needed to establish the connection. This must be
234 * provided if accepting a connection request. If accepting a connection
235 * response, this parameter must be NULL.
236 *
237 * Typically, this routine is only called by the listener to accept a connection
238 * request. It must also be called on the active side of a connection if the
239 * user is performing their own QP transitions.
240 */
241int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
242
243/**
244 * rdma_reject - Called to reject a connection request or response.
245 */
246int rdma_reject(struct rdma_cm_id *id, const void *private_data,
247 u8 private_data_len);
248
249/**
250 * rdma_disconnect - This function disconnects the associated QP and
251 * transitions it into the error state.
252 */
253int rdma_disconnect(struct rdma_cm_id *id);
254
255#endif /* RDMA_CM_H */
256
diff --git a/include/rdma/rdma_cm_ib.h b/include/rdma/rdma_cm_ib.h
new file mode 100644
index 000000000000..e8c3af1804d4
--- /dev/null
+++ b/include/rdma/rdma_cm_ib.h
@@ -0,0 +1,47 @@
1/*
2 * Copyright (c) 2006 Intel Corporation. All rights reserved.
3 *
4 * This Software is licensed under one of the following licenses:
5 *
6 * 1) under the terms of the "Common Public License 1.0" a copy of which is
7 * available from the Open Source Initiative, see
8 * http://www.opensource.org/licenses/cpl.php.
9 *
10 * 2) under the terms of the "The BSD License" a copy of which is
11 * available from the Open Source Initiative, see
12 * http://www.opensource.org/licenses/bsd-license.php.
13 *
14 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
15 * copy of which is available from the Open Source Initiative, see
16 * http://www.opensource.org/licenses/gpl-license.php.
17 *
18 * Licensee has the right to choose one of the above licenses.
19 *
20 * Redistributions of source code must retain the above copyright
21 * notice and one of the license notices.
22 *
23 * Redistributions in binary form must reproduce both the above copyright
24 * notice, one of the license notices in the documentation
25 * and/or other materials provided with the distribution.
26 *
27 */
28
29#if !defined(RDMA_CM_IB_H)
30#define RDMA_CM_IB_H
31
32#include <rdma/rdma_cm.h>
33
34/**
35 * rdma_set_ib_paths - Manually sets the path records used to establish a
36 * connection.
37 * @id: Connection identifier associated with the request.
38 * @path_rec: Reference to the path record
39 *
40 * This call permits a user to specify routing information for rdma_cm_id's
41 * bound to Infiniband devices. It is called on the client side of a
42 * connection and replaces the call to rdma_resolve_route.
43 */
44int rdma_set_ib_paths(struct rdma_cm_id *id,
45 struct ib_sa_path_rec *path_rec, int num_paths);
46
47#endif /* RDMA_CM_IB_H */
diff --git a/include/scsi/srp.h b/include/scsi/srp.h
index 637f77eccf0c..ad178fa78f66 100644
--- a/include/scsi/srp.h
+++ b/include/scsi/srp.h
@@ -87,6 +87,11 @@ enum srp_login_rej_reason {
87 SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006 87 SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
88}; 88};
89 89
90enum {
91 SRP_REV10_IB_IO_CLASS = 0xff00,
92 SRP_REV16A_IB_IO_CLASS = 0x0100
93};
94
90struct srp_direct_buf { 95struct srp_direct_buf {
91 __be64 va; 96 __be64 va;
92 __be32 key; 97 __be32 key;
diff --git a/kernel/exit.c b/kernel/exit.c
index e95b93282210..e06d0c10a24e 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -881,14 +881,6 @@ fastcall NORET_TYPE void do_exit(long code)
881 881
882 tsk->flags |= PF_EXITING; 882 tsk->flags |= PF_EXITING;
883 883
884 /*
885 * Make sure we don't try to process any timer firings
886 * while we are already exiting.
887 */
888 tsk->it_virt_expires = cputime_zero;
889 tsk->it_prof_expires = cputime_zero;
890 tsk->it_sched_expires = 0;
891
892 if (unlikely(in_atomic())) 884 if (unlikely(in_atomic()))
893 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n", 885 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
894 current->comm, current->pid, 886 current->comm, current->pid,
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index 520f6c59948d..d38d9ec3276c 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -555,9 +555,6 @@ static void arm_timer(struct k_itimer *timer, union cpu_time_count now)
555 struct cpu_timer_list *next; 555 struct cpu_timer_list *next;
556 unsigned long i; 556 unsigned long i;
557 557
558 if (CPUCLOCK_PERTHREAD(timer->it_clock) && (p->flags & PF_EXITING))
559 return;
560
561 head = (CPUCLOCK_PERTHREAD(timer->it_clock) ? 558 head = (CPUCLOCK_PERTHREAD(timer->it_clock) ?
562 p->cpu_timers : p->signal->cpu_timers); 559 p->cpu_timers : p->signal->cpu_timers);
563 head += CPUCLOCK_WHICH(timer->it_clock); 560 head += CPUCLOCK_WHICH(timer->it_clock);
@@ -1173,6 +1170,9 @@ static void check_process_timers(struct task_struct *tsk,
1173 } 1170 }
1174 t = tsk; 1171 t = tsk;
1175 do { 1172 do {
1173 if (unlikely(t->flags & PF_EXITING))
1174 continue;
1175
1176 ticks = cputime_add(cputime_add(t->utime, t->stime), 1176 ticks = cputime_add(cputime_add(t->utime, t->stime),
1177 prof_left); 1177 prof_left);
1178 if (!cputime_eq(prof_expires, cputime_zero) && 1178 if (!cputime_eq(prof_expires, cputime_zero) &&
@@ -1193,11 +1193,7 @@ static void check_process_timers(struct task_struct *tsk,
1193 t->it_sched_expires > sched)) { 1193 t->it_sched_expires > sched)) {
1194 t->it_sched_expires = sched; 1194 t->it_sched_expires = sched;
1195 } 1195 }
1196 1196 } while ((t = next_thread(t)) != tsk);
1197 do {
1198 t = next_thread(t);
1199 } while (unlikely(t->flags & PF_EXITING));
1200 } while (t != tsk);
1201 } 1197 }
1202} 1198}
1203 1199
@@ -1289,30 +1285,30 @@ void run_posix_cpu_timers(struct task_struct *tsk)
1289 1285
1290#undef UNEXPIRED 1286#undef UNEXPIRED
1291 1287
1292 BUG_ON(tsk->exit_state);
1293
1294 /* 1288 /*
1295 * Double-check with locks held. 1289 * Double-check with locks held.
1296 */ 1290 */
1297 read_lock(&tasklist_lock); 1291 read_lock(&tasklist_lock);
1298 spin_lock(&tsk->sighand->siglock); 1292 if (likely(tsk->signal != NULL)) {
1293 spin_lock(&tsk->sighand->siglock);
1299 1294
1300 /* 1295 /*
1301 * Here we take off tsk->cpu_timers[N] and tsk->signal->cpu_timers[N] 1296 * Here we take off tsk->cpu_timers[N] and tsk->signal->cpu_timers[N]
1302 * all the timers that are firing, and put them on the firing list. 1297 * all the timers that are firing, and put them on the firing list.
1303 */ 1298 */
1304 check_thread_timers(tsk, &firing); 1299 check_thread_timers(tsk, &firing);
1305 check_process_timers(tsk, &firing); 1300 check_process_timers(tsk, &firing);
1306 1301
1307 /* 1302 /*
1308 * We must release these locks before taking any timer's lock. 1303 * We must release these locks before taking any timer's lock.
1309 * There is a potential race with timer deletion here, as the 1304 * There is a potential race with timer deletion here, as the
1310 * siglock now protects our private firing list. We have set 1305 * siglock now protects our private firing list. We have set
1311 * the firing flag in each timer, so that a deletion attempt 1306 * the firing flag in each timer, so that a deletion attempt
1312 * that gets the timer lock before we do will give it up and 1307 * that gets the timer lock before we do will give it up and
1313 * spin until we've taken care of that timer below. 1308 * spin until we've taken care of that timer below.
1314 */ 1309 */
1315 spin_unlock(&tsk->sighand->siglock); 1310 spin_unlock(&tsk->sighand->siglock);
1311 }
1316 read_unlock(&tasklist_lock); 1312 read_unlock(&tasklist_lock);
1317 1313
1318 /* 1314 /*
diff --git a/kernel/power/main.c b/kernel/power/main.c
index a6d9ef46009e..0a907f0dc56b 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -86,6 +86,7 @@ static int suspend_prepare(suspend_state_t state)
86 goto Thaw; 86 goto Thaw;
87 } 87 }
88 88
89 suspend_console();
89 if ((error = device_suspend(PMSG_SUSPEND))) { 90 if ((error = device_suspend(PMSG_SUSPEND))) {
90 printk(KERN_ERR "Some devices failed to suspend\n"); 91 printk(KERN_ERR "Some devices failed to suspend\n");
91 goto Finish; 92 goto Finish;
@@ -133,6 +134,7 @@ int suspend_enter(suspend_state_t state)
133static void suspend_finish(suspend_state_t state) 134static void suspend_finish(suspend_state_t state)
134{ 135{
135 device_resume(); 136 device_resume();
137 resume_console();
136 thaw_processes(); 138 thaw_processes();
137 enable_nonboot_cpus(); 139 enable_nonboot_cpus();
138 if (pm_ops && pm_ops->finish) 140 if (pm_ops && pm_ops->finish)
diff --git a/kernel/printk.c b/kernel/printk.c
index c056f3324432..19a955619294 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -67,6 +67,7 @@ EXPORT_SYMBOL(oops_in_progress);
67 * driver system. 67 * driver system.
68 */ 68 */
69static DECLARE_MUTEX(console_sem); 69static DECLARE_MUTEX(console_sem);
70static DECLARE_MUTEX(secondary_console_sem);
70struct console *console_drivers; 71struct console *console_drivers;
71/* 72/*
72 * This is used for debugging the mess that is the VT code by 73 * This is used for debugging the mess that is the VT code by
@@ -76,7 +77,7 @@ struct console *console_drivers;
76 * path in the console code where we end up in places I want 77 * path in the console code where we end up in places I want
77 * locked without the console sempahore held 78 * locked without the console sempahore held
78 */ 79 */
79static int console_locked; 80static int console_locked, console_suspended;
80 81
81/* 82/*
82 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars 83 * logbuf_lock protects log_buf, log_start, log_end, con_start and logged_chars
@@ -698,6 +699,23 @@ int __init add_preferred_console(char *name, int idx, char *options)
698} 699}
699 700
700/** 701/**
702 * suspend_console - suspend the console subsystem
703 *
704 * This disables printk() while we go into suspend states
705 */
706void suspend_console(void)
707{
708 acquire_console_sem();
709 console_suspended = 1;
710}
711
712void resume_console(void)
713{
714 console_suspended = 0;
715 release_console_sem();
716}
717
718/**
701 * acquire_console_sem - lock the console system for exclusive use. 719 * acquire_console_sem - lock the console system for exclusive use.
702 * 720 *
703 * Acquires a semaphore which guarantees that the caller has 721 * Acquires a semaphore which guarantees that the caller has
@@ -708,6 +726,10 @@ int __init add_preferred_console(char *name, int idx, char *options)
708void acquire_console_sem(void) 726void acquire_console_sem(void)
709{ 727{
710 BUG_ON(in_interrupt()); 728 BUG_ON(in_interrupt());
729 if (console_suspended) {
730 down(&secondary_console_sem);
731 return;
732 }
711 down(&console_sem); 733 down(&console_sem);
712 console_locked = 1; 734 console_locked = 1;
713 console_may_schedule = 1; 735 console_may_schedule = 1;
@@ -750,6 +772,10 @@ void release_console_sem(void)
750 unsigned long _con_start, _log_end; 772 unsigned long _con_start, _log_end;
751 unsigned long wake_klogd = 0; 773 unsigned long wake_klogd = 0;
752 774
775 if (console_suspended) {
776 up(&secondary_console_sem);
777 return;
778 }
753 for ( ; ; ) { 779 for ( ; ; ) {
754 spin_lock_irqsave(&logbuf_lock, flags); 780 spin_lock_irqsave(&logbuf_lock, flags);
755 wake_klogd |= log_start - log_end; 781 wake_klogd |= log_start - log_end;
diff --git a/mm/shmem.c b/mm/shmem.c
index 8184342440f0..797eef3805ce 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1780,6 +1780,7 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
1780 if (!simple_empty(dentry)) 1780 if (!simple_empty(dentry))
1781 return -ENOTEMPTY; 1781 return -ENOTEMPTY;
1782 1782
1783 dentry->d_inode->i_nlink--;
1783 dir->i_nlink--; 1784 dir->i_nlink--;
1784 return shmem_unlink(dir, dentry); 1785 return shmem_unlink(dir, dentry);
1785} 1786}
@@ -2102,6 +2103,7 @@ static int shmem_fill_super(struct super_block *sb,
2102 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 2103 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
2103 sb->s_magic = TMPFS_MAGIC; 2104 sb->s_magic = TMPFS_MAGIC;
2104 sb->s_op = &shmem_ops; 2105 sb->s_op = &shmem_ops;
2106 sb->s_time_gran = 1;
2105 2107
2106 inode = shmem_get_inode(sb, S_IFDIR | mode, 0); 2108 inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
2107 if (!inode) 2109 if (!inode)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 4649a63a8cb6..440a733fe2e9 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1061,7 +1061,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, unsigned long nr_pages,
1061loop_again: 1061loop_again:
1062 total_scanned = 0; 1062 total_scanned = 0;
1063 nr_reclaimed = 0; 1063 nr_reclaimed = 0;
1064 sc.may_writepage = !laptop_mode, 1064 sc.may_writepage = !laptop_mode;
1065 sc.nr_mapped = read_page_state(nr_mapped); 1065 sc.nr_mapped = read_page_state(nr_mapped);
1066 1066
1067 inc_page_state(pageoutrun); 1067 inc_page_state(pageoutrun);
diff --git a/net/Kconfig b/net/Kconfig
index 4193cdcd3ae7..c6cec5aa5486 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -66,6 +66,13 @@ source "net/ipv6/Kconfig"
66 66
67endif # if INET 67endif # if INET
68 68
69config NETWORK_SECMARK
70 bool "Security Marking"
71 help
72 This enables security marking of network packets, similar
73 to nfmark, but designated for security purposes.
74 If you are unsure how to answer this question, answer N.
75
69menuconfig NETFILTER 76menuconfig NETFILTER
70 bool "Network packet filtering (replaces ipchains)" 77 bool "Network packet filtering (replaces ipchains)"
71 ---help--- 78 ---help---
@@ -215,6 +222,21 @@ config NET_PKTGEN
215 To compile this code as a module, choose M here: the 222 To compile this code as a module, choose M here: the
216 module will be called pktgen. 223 module will be called pktgen.
217 224
225config NET_TCPPROBE
226 tristate "TCP connection probing"
227 depends on INET && EXPERIMENTAL && PROC_FS && KPROBES
228 ---help---
229 This module allows for capturing the changes to TCP connection
230 state in response to incoming packets. It is used for debugging
231 TCP congestion avoidance modules. If you don't understand
232 what was just said, you don't need it: say N.
233
234 Documentation on how to use the packet generator can be found
235 at http://linux-net.osdl.org/index.php/TcpProbe
236
237 To compile this code as a module, choose M here: the
238 module will be called tcp_probe.
239
218endmenu 240endmenu
219 241
220endmenu 242endmenu
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 72d852982664..f92f9c94d2c7 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -98,7 +98,7 @@ static void unlink_clip_vcc(struct clip_vcc *clip_vcc)
98 printk(KERN_CRIT "!clip_vcc->entry (clip_vcc %p)\n", clip_vcc); 98 printk(KERN_CRIT "!clip_vcc->entry (clip_vcc %p)\n", clip_vcc);
99 return; 99 return;
100 } 100 }
101 spin_lock_bh(&entry->neigh->dev->xmit_lock); /* block clip_start_xmit() */ 101 netif_tx_lock_bh(entry->neigh->dev); /* block clip_start_xmit() */
102 entry->neigh->used = jiffies; 102 entry->neigh->used = jiffies;
103 for (walk = &entry->vccs; *walk; walk = &(*walk)->next) 103 for (walk = &entry->vccs; *walk; walk = &(*walk)->next)
104 if (*walk == clip_vcc) { 104 if (*walk == clip_vcc) {
@@ -122,7 +122,7 @@ static void unlink_clip_vcc(struct clip_vcc *clip_vcc)
122 printk(KERN_CRIT "ATMARP: unlink_clip_vcc failed (entry %p, vcc " 122 printk(KERN_CRIT "ATMARP: unlink_clip_vcc failed (entry %p, vcc "
123 "0x%p)\n", entry, clip_vcc); 123 "0x%p)\n", entry, clip_vcc);
124 out: 124 out:
125 spin_unlock_bh(&entry->neigh->dev->xmit_lock); 125 netif_tx_unlock_bh(entry->neigh->dev);
126} 126}
127 127
128/* The neighbour entry n->lock is held. */ 128/* The neighbour entry n->lock is held. */
diff --git a/net/bridge/Makefile b/net/bridge/Makefile
index 59556e40e143..f444c12cde5a 100644
--- a/net/bridge/Makefile
+++ b/net/bridge/Makefile
@@ -6,7 +6,7 @@ obj-$(CONFIG_BRIDGE) += bridge.o
6 6
7bridge-y := br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \ 7bridge-y := br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \
8 br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \ 8 br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o \
9 br_stp_if.o br_stp_timer.o 9 br_stp_if.o br_stp_timer.o br_netlink.o
10 10
11bridge-$(CONFIG_SYSFS) += br_sysfs_if.o br_sysfs_br.o 11bridge-$(CONFIG_SYSFS) += br_sysfs_if.o br_sysfs_br.o
12 12
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 12da21afb9ca..654401ceb2db 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -30,36 +30,46 @@ static struct llc_sap *br_stp_sap;
30 30
31static int __init br_init(void) 31static int __init br_init(void)
32{ 32{
33 int err;
34
33 br_stp_sap = llc_sap_open(LLC_SAP_BSPAN, br_stp_rcv); 35 br_stp_sap = llc_sap_open(LLC_SAP_BSPAN, br_stp_rcv);
34 if (!br_stp_sap) { 36 if (!br_stp_sap) {
35 printk(KERN_ERR "bridge: can't register sap for STP\n"); 37 printk(KERN_ERR "bridge: can't register sap for STP\n");
36 return -EBUSY; 38 return -EADDRINUSE;
37 } 39 }
38 40
39 br_fdb_init(); 41 br_fdb_init();
40 42
41#ifdef CONFIG_BRIDGE_NETFILTER 43 err = br_netfilter_init();
42 if (br_netfilter_init()) 44 if (err)
43 return 1; 45 goto err_out1;
44#endif 46
47 err = register_netdevice_notifier(&br_device_notifier);
48 if (err)
49 goto err_out2;
50
51 br_netlink_init();
45 brioctl_set(br_ioctl_deviceless_stub); 52 brioctl_set(br_ioctl_deviceless_stub);
46 br_handle_frame_hook = br_handle_frame; 53 br_handle_frame_hook = br_handle_frame;
47 54
48 br_fdb_get_hook = br_fdb_get; 55 br_fdb_get_hook = br_fdb_get;
49 br_fdb_put_hook = br_fdb_put; 56 br_fdb_put_hook = br_fdb_put;
50 57
51 register_netdevice_notifier(&br_device_notifier);
52
53 return 0; 58 return 0;
59
60err_out2:
61 br_netfilter_fini();
62err_out1:
63 llc_sap_put(br_stp_sap);
64 return err;
54} 65}
55 66
56static void __exit br_deinit(void) 67static void __exit br_deinit(void)
57{ 68{
58 rcu_assign_pointer(br_stp_sap->rcv_func, NULL); 69 rcu_assign_pointer(br_stp_sap->rcv_func, NULL);
59 70
60#ifdef CONFIG_BRIDGE_NETFILTER 71 br_netlink_fini();
61 br_netfilter_fini(); 72 br_netfilter_fini();
62#endif
63 unregister_netdevice_notifier(&br_device_notifier); 73 unregister_netdevice_notifier(&br_device_notifier);
64 brioctl_set(NULL); 74 brioctl_set(NULL);
65 75
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 0c88a2ac32c1..2afdc7c0736c 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -145,9 +145,9 @@ static int br_set_tx_csum(struct net_device *dev, u32 data)
145 struct net_bridge *br = netdev_priv(dev); 145 struct net_bridge *br = netdev_priv(dev);
146 146
147 if (data) 147 if (data)
148 br->feature_mask |= NETIF_F_IP_CSUM; 148 br->feature_mask |= NETIF_F_NO_CSUM;
149 else 149 else
150 br->feature_mask &= ~NETIF_F_IP_CSUM; 150 br->feature_mask &= ~NETIF_F_ALL_CSUM;
151 151
152 br_features_recompute(br); 152 br_features_recompute(br);
153 return 0; 153 return 0;
@@ -185,5 +185,5 @@ void br_dev_setup(struct net_device *dev)
185 dev->priv_flags = IFF_EBRIDGE; 185 dev->priv_flags = IFF_EBRIDGE;
186 186
187 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST 187 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST
188 | NETIF_F_HIGHDMA | NETIF_F_TSO | NETIF_F_IP_CSUM; 188 | NETIF_F_HIGHDMA | NETIF_F_TSO | NETIF_F_NO_CSUM;
189} 189}
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 56f3aa47e758..0dca027ceb80 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -20,14 +20,11 @@
20#include <linux/netfilter_bridge.h> 20#include <linux/netfilter_bridge.h>
21#include "br_private.h" 21#include "br_private.h"
22 22
23/* Don't forward packets to originating port or forwarding diasabled */
23static inline int should_deliver(const struct net_bridge_port *p, 24static inline int should_deliver(const struct net_bridge_port *p,
24 const struct sk_buff *skb) 25 const struct sk_buff *skb)
25{ 26{
26 if (skb->dev == p->dev || 27 return (skb->dev != p->dev && p->state == BR_STATE_FORWARDING);
27 p->state != BR_STATE_FORWARDING)
28 return 0;
29
30 return 1;
31} 28}
32 29
33static inline unsigned packet_length(const struct sk_buff *skb) 30static inline unsigned packet_length(const struct sk_buff *skb)
@@ -55,10 +52,9 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
55 52
56int br_forward_finish(struct sk_buff *skb) 53int br_forward_finish(struct sk_buff *skb)
57{ 54{
58 NF_HOOK(PF_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev, 55 return NF_HOOK(PF_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
59 br_dev_queue_push_xmit); 56 br_dev_queue_push_xmit);
60 57
61 return 0;
62} 58}
63 59
64static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) 60static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index f5d47bf4f967..fdec773f5b52 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -372,12 +372,17 @@ void br_features_recompute(struct net_bridge *br)
372 struct net_bridge_port *p; 372 struct net_bridge_port *p;
373 unsigned long features, checksum; 373 unsigned long features, checksum;
374 374
375 features = br->feature_mask &~ NETIF_F_IP_CSUM; 375 checksum = br->feature_mask & NETIF_F_ALL_CSUM ? NETIF_F_NO_CSUM : 0;
376 checksum = br->feature_mask & NETIF_F_IP_CSUM; 376 features = br->feature_mask & ~NETIF_F_ALL_CSUM;
377 377
378 list_for_each_entry(p, &br->port_list, list) { 378 list_for_each_entry(p, &br->port_list, list) {
379 if (!(p->dev->features 379 if (checksum & NETIF_F_NO_CSUM &&
380 & (NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM))) 380 !(p->dev->features & NETIF_F_NO_CSUM))
381 checksum ^= NETIF_F_NO_CSUM | NETIF_F_HW_CSUM;
382 if (checksum & NETIF_F_HW_CSUM &&
383 !(p->dev->features & NETIF_F_HW_CSUM))
384 checksum ^= NETIF_F_HW_CSUM | NETIF_F_IP_CSUM;
385 if (!(p->dev->features & NETIF_F_IP_CSUM))
381 checksum = 0; 386 checksum = 0;
382 features &= p->dev->features; 387 features &= p->dev->features;
383 } 388 }
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 3da9264449f7..3e41f9d6d51c 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -407,12 +407,8 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook,
407 if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) { 407 if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {
408 if (pkt_len + sizeof(struct ipv6hdr) > skb->len) 408 if (pkt_len + sizeof(struct ipv6hdr) > skb->len)
409 goto inhdr_error; 409 goto inhdr_error;
410 if (pkt_len + sizeof(struct ipv6hdr) < skb->len) { 410 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
411 if (__pskb_trim(skb, pkt_len + sizeof(struct ipv6hdr))) 411 goto inhdr_error;
412 goto inhdr_error;
413 if (skb->ip_summed == CHECKSUM_HW)
414 skb->ip_summed = CHECKSUM_NONE;
415 }
416 } 412 }
417 if (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb)) 413 if (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb))
418 goto inhdr_error; 414 goto inhdr_error;
@@ -495,11 +491,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
495 if (skb->len < len || len < 4 * iph->ihl) 491 if (skb->len < len || len < 4 * iph->ihl)
496 goto inhdr_error; 492 goto inhdr_error;
497 493
498 if (skb->len > len) { 494 pskb_trim_rcsum(skb, len);
499 __pskb_trim(skb, len);
500 if (skb->ip_summed == CHECKSUM_HW)
501 skb->ip_summed = CHECKSUM_NONE;
502 }
503 495
504 nf_bridge_put(skb->nf_bridge); 496 nf_bridge_put(skb->nf_bridge);
505 if (!nf_bridge_alloc(skb)) 497 if (!nf_bridge_alloc(skb))
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
new file mode 100644
index 000000000000..881d7d1a732a
--- /dev/null
+++ b/net/bridge/br_netlink.c
@@ -0,0 +1,199 @@
1/*
2 * Bridge netlink control interface
3 *
4 * Authors:
5 * Stephen Hemminger <shemminger@osdl.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/kernel.h>
14#include <linux/rtnetlink.h>
15#include "br_private.h"
16
17/*
18 * Create one netlink message for one interface
19 * Contains port and master info as well as carrier and bridge state.
20 */
21static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *port,
22 u32 pid, u32 seq, int event, unsigned int flags)
23{
24 const struct net_bridge *br = port->br;
25 const struct net_device *dev = port->dev;
26 struct ifinfomsg *r;
27 struct nlmsghdr *nlh;
28 unsigned char *b = skb->tail;
29 u32 mtu = dev->mtu;
30 u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
31 u8 portstate = port->state;
32
33 pr_debug("br_fill_info event %d port %s master %s\n",
34 event, dev->name, br->dev->name);
35
36 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags);
37 r = NLMSG_DATA(nlh);
38 r->ifi_family = AF_BRIDGE;
39 r->__ifi_pad = 0;
40 r->ifi_type = dev->type;
41 r->ifi_index = dev->ifindex;
42 r->ifi_flags = dev_get_flags(dev);
43 r->ifi_change = 0;
44
45 RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name);
46
47 RTA_PUT(skb, IFLA_MASTER, sizeof(int), &br->dev->ifindex);
48
49 if (dev->addr_len)
50 RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
51
52 RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu);
53 if (dev->ifindex != dev->iflink)
54 RTA_PUT(skb, IFLA_LINK, sizeof(int), &dev->iflink);
55
56
57 RTA_PUT(skb, IFLA_OPERSTATE, sizeof(operstate), &operstate);
58
59 if (event == RTM_NEWLINK)
60 RTA_PUT(skb, IFLA_PROTINFO, sizeof(portstate), &portstate);
61
62 nlh->nlmsg_len = skb->tail - b;
63
64 return skb->len;
65
66nlmsg_failure:
67rtattr_failure:
68
69 skb_trim(skb, b - skb->data);
70 return -EINVAL;
71}
72
73/*
74 * Notify listeners of a change in port information
75 */
76void br_ifinfo_notify(int event, struct net_bridge_port *port)
77{
78 struct sk_buff *skb;
79 int err = -ENOMEM;
80
81 pr_debug("bridge notify event=%d\n", event);
82 skb = alloc_skb(NLMSG_SPACE(sizeof(struct ifinfomsg) + 128),
83 GFP_ATOMIC);
84 if (!skb)
85 goto err_out;
86
87 err = br_fill_ifinfo(skb, port, current->pid, 0, event, 0);
88 if (err)
89 goto err_kfree;
90
91 NETLINK_CB(skb).dst_group = RTNLGRP_LINK;
92 netlink_broadcast(rtnl, skb, 0, RTNLGRP_LINK, GFP_ATOMIC);
93 return;
94
95err_kfree:
96 kfree_skb(skb);
97err_out:
98 netlink_set_err(rtnl, 0, RTNLGRP_LINK, err);
99}
100
101/*
102 * Dump information about all ports, in response to GETLINK
103 */
104static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
105{
106 struct net_device *dev;
107 int idx;
108 int s_idx = cb->args[0];
109 int err = 0;
110
111 read_lock(&dev_base_lock);
112 for (dev = dev_base, idx = 0; dev; dev = dev->next) {
113 struct net_bridge_port *p = dev->br_port;
114
115 /* not a bridge port */
116 if (!p)
117 continue;
118
119 if (idx < s_idx)
120 continue;
121
122 err = br_fill_ifinfo(skb, p, NETLINK_CB(cb->skb).pid,
123 cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI);
124 if (err <= 0)
125 break;
126 ++idx;
127 }
128 read_unlock(&dev_base_lock);
129
130 cb->args[0] = idx;
131
132 return skb->len;
133}
134
135/*
136 * Change state of port (ie from forwarding to blocking etc)
137 * Used by spanning tree in user space.
138 */
139static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
140{
141 struct rtattr **rta = arg;
142 struct ifinfomsg *ifm = NLMSG_DATA(nlh);
143 struct net_device *dev;
144 struct net_bridge_port *p;
145 u8 new_state;
146
147 if (ifm->ifi_family != AF_BRIDGE)
148 return -EPFNOSUPPORT;
149
150 /* Must pass valid state as PROTINFO */
151 if (rta[IFLA_PROTINFO-1]) {
152 u8 *pstate = RTA_DATA(rta[IFLA_PROTINFO-1]);
153 new_state = *pstate;
154 } else
155 return -EINVAL;
156
157 if (new_state > BR_STATE_BLOCKING)
158 return -EINVAL;
159
160 /* Find bridge port */
161 dev = __dev_get_by_index(ifm->ifi_index);
162 if (!dev)
163 return -ENODEV;
164
165 p = dev->br_port;
166 if (!p)
167 return -EINVAL;
168
169 /* if kernel STP is running, don't allow changes */
170 if (p->br->stp_enabled)
171 return -EBUSY;
172
173 if (!netif_running(dev))
174 return -ENETDOWN;
175
176 if (!netif_carrier_ok(dev) && new_state != BR_STATE_DISABLED)
177 return -ENETDOWN;
178
179 p->state = new_state;
180 br_log_state(p);
181 return 0;
182}
183
184
185static struct rtnetlink_link bridge_rtnetlink_table[RTM_NR_MSGTYPES] = {
186 [RTM_GETLINK - RTM_BASE] = { .dumpit = br_dump_ifinfo, },
187 [RTM_SETLINK - RTM_BASE] = { .doit = br_rtm_setlink, },
188};
189
190void __init br_netlink_init(void)
191{
192 rtnetlink_links[PF_BRIDGE] = bridge_rtnetlink_table;
193}
194
195void __exit br_netlink_fini(void)
196{
197 rtnetlink_links[PF_BRIDGE] = NULL;
198}
199
diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c
index a43a9c1d50d7..20278494e4da 100644
--- a/net/bridge/br_notify.c
+++ b/net/bridge/br_notify.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/rtnetlink.h>
17 18
18#include "br_private.h" 19#include "br_private.h"
19 20
@@ -49,6 +50,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
49 50
50 case NETDEV_CHANGEADDR: 51 case NETDEV_CHANGEADDR:
51 br_fdb_changeaddr(p, dev->dev_addr); 52 br_fdb_changeaddr(p, dev->dev_addr);
53 br_ifinfo_notify(RTM_NEWLINK, p);
52 br_stp_recalculate_bridge_id(br); 54 br_stp_recalculate_bridge_id(br);
53 break; 55 break;
54 56
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 86ecea7ed372..c491fb2f280e 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -29,7 +29,7 @@
29 29
30#define BR_PORT_DEBOUNCE (HZ/10) 30#define BR_PORT_DEBOUNCE (HZ/10)
31 31
32#define BR_VERSION "2.1" 32#define BR_VERSION "2.2"
33 33
34typedef struct bridge_id bridge_id; 34typedef struct bridge_id bridge_id;
35typedef struct mac_addr mac_addr; 35typedef struct mac_addr mac_addr;
@@ -192,8 +192,13 @@ extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
192extern int br_ioctl_deviceless_stub(unsigned int cmd, void __user *arg); 192extern int br_ioctl_deviceless_stub(unsigned int cmd, void __user *arg);
193 193
194/* br_netfilter.c */ 194/* br_netfilter.c */
195#ifdef CONFIG_BRIDGE_NETFILTER
195extern int br_netfilter_init(void); 196extern int br_netfilter_init(void);
196extern void br_netfilter_fini(void); 197extern void br_netfilter_fini(void);
198#else
199#define br_netfilter_init() (0)
200#define br_netfilter_fini() do { } while(0)
201#endif
197 202
198/* br_stp.c */ 203/* br_stp.c */
199extern void br_log_state(const struct net_bridge_port *p); 204extern void br_log_state(const struct net_bridge_port *p);
@@ -232,6 +237,11 @@ extern struct net_bridge_fdb_entry *(*br_fdb_get_hook)(struct net_bridge *br,
232extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent); 237extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent);
233 238
234 239
240/* br_netlink.c */
241extern void br_netlink_init(void);
242extern void br_netlink_fini(void);
243extern void br_ifinfo_notify(int event, struct net_bridge_port *port);
244
235#ifdef CONFIG_SYSFS 245#ifdef CONFIG_SYSFS
236/* br_sysfs_if.c */ 246/* br_sysfs_if.c */
237extern struct sysfs_ops brport_sysfs_ops; 247extern struct sysfs_ops brport_sysfs_ops;
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index 23dea1422c9a..14cd025079af 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/smp_lock.h> 17#include <linux/smp_lock.h>
18#include <linux/etherdevice.h> 18#include <linux/etherdevice.h>
19#include <linux/rtnetlink.h>
19 20
20#include "br_private.h" 21#include "br_private.h"
21#include "br_private_stp.h" 22#include "br_private_stp.h"
@@ -86,6 +87,7 @@ void br_stp_disable_bridge(struct net_bridge *br)
86void br_stp_enable_port(struct net_bridge_port *p) 87void br_stp_enable_port(struct net_bridge_port *p)
87{ 88{
88 br_init_port(p); 89 br_init_port(p);
90 br_ifinfo_notify(RTM_NEWLINK, p);
89 br_port_state_selection(p->br); 91 br_port_state_selection(p->br);
90} 92}
91 93
@@ -99,6 +101,8 @@ void br_stp_disable_port(struct net_bridge_port *p)
99 printk(KERN_INFO "%s: port %i(%s) entering %s state\n", 101 printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
100 br->dev->name, p->port_no, p->dev->name, "disabled"); 102 br->dev->name, p->port_no, p->dev->name, "disabled");
101 103
104 br_ifinfo_notify(RTM_DELLINK, p);
105
102 wasroot = br_is_root_bridge(br); 106 wasroot = br_is_root_bridge(br);
103 br_become_designated_port(p); 107 br_become_designated_port(p);
104 p->state = BR_STATE_DISABLED; 108 p->state = BR_STATE_DISABLED;
diff --git a/net/core/Makefile b/net/core/Makefile
index 79fe12cced27..e9bd2467d5a9 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_NET_DIVERT) += dv.o
16obj-$(CONFIG_NET_PKTGEN) += pktgen.o 16obj-$(CONFIG_NET_PKTGEN) += pktgen.o
17obj-$(CONFIG_WIRELESS_EXT) += wireless.o 17obj-$(CONFIG_WIRELESS_EXT) += wireless.o
18obj-$(CONFIG_NETPOLL) += netpoll.o 18obj-$(CONFIG_NETPOLL) += netpoll.o
19obj-$(CONFIG_NET_DMA) += user_dma.o
diff --git a/net/core/dev.c b/net/core/dev.c
index 4fba549caf29..ab39fe17cb58 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -115,6 +115,7 @@
115#include <net/iw_handler.h> 115#include <net/iw_handler.h>
116#include <asm/current.h> 116#include <asm/current.h>
117#include <linux/audit.h> 117#include <linux/audit.h>
118#include <linux/dmaengine.h>
118 119
119/* 120/*
120 * The list of packet types we will receive (as opposed to discard) 121 * The list of packet types we will receive (as opposed to discard)
@@ -148,6 +149,12 @@ static DEFINE_SPINLOCK(ptype_lock);
148static struct list_head ptype_base[16]; /* 16 way hashed list */ 149static struct list_head ptype_base[16]; /* 16 way hashed list */
149static struct list_head ptype_all; /* Taps */ 150static struct list_head ptype_all; /* Taps */
150 151
152#ifdef CONFIG_NET_DMA
153static struct dma_client *net_dma_client;
154static unsigned int net_dma_count;
155static spinlock_t net_dma_event_lock;
156#endif
157
151/* 158/*
152 * The @dev_base list is protected by @dev_base_lock and the rtnl 159 * The @dev_base list is protected by @dev_base_lock and the rtnl
153 * semaphore. 160 * semaphore.
@@ -1215,75 +1222,15 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
1215#define illegal_highdma(dev, skb) (0) 1222#define illegal_highdma(dev, skb) (0)
1216#endif 1223#endif
1217 1224
1218/* Keep head the same: replace data */
1219int __skb_linearize(struct sk_buff *skb, gfp_t gfp_mask)
1220{
1221 unsigned int size;
1222 u8 *data;
1223 long offset;
1224 struct skb_shared_info *ninfo;
1225 int headerlen = skb->data - skb->head;
1226 int expand = (skb->tail + skb->data_len) - skb->end;
1227
1228 if (skb_shared(skb))
1229 BUG();
1230
1231 if (expand <= 0)
1232 expand = 0;
1233
1234 size = skb->end - skb->head + expand;
1235 size = SKB_DATA_ALIGN(size);
1236 data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
1237 if (!data)
1238 return -ENOMEM;
1239
1240 /* Copy entire thing */
1241 if (skb_copy_bits(skb, -headerlen, data, headerlen + skb->len))
1242 BUG();
1243
1244 /* Set up shinfo */
1245 ninfo = (struct skb_shared_info*)(data + size);
1246 atomic_set(&ninfo->dataref, 1);
1247 ninfo->tso_size = skb_shinfo(skb)->tso_size;
1248 ninfo->tso_segs = skb_shinfo(skb)->tso_segs;
1249 ninfo->nr_frags = 0;
1250 ninfo->frag_list = NULL;
1251
1252 /* Offset between the two in bytes */
1253 offset = data - skb->head;
1254
1255 /* Free old data. */
1256 skb_release_data(skb);
1257
1258 skb->head = data;
1259 skb->end = data + size;
1260
1261 /* Set up new pointers */
1262 skb->h.raw += offset;
1263 skb->nh.raw += offset;
1264 skb->mac.raw += offset;
1265 skb->tail += offset;
1266 skb->data += offset;
1267
1268 /* We are no longer a clone, even if we were. */
1269 skb->cloned = 0;
1270
1271 skb->tail += skb->data_len;
1272 skb->data_len = 0;
1273 return 0;
1274}
1275
1276#define HARD_TX_LOCK(dev, cpu) { \ 1225#define HARD_TX_LOCK(dev, cpu) { \
1277 if ((dev->features & NETIF_F_LLTX) == 0) { \ 1226 if ((dev->features & NETIF_F_LLTX) == 0) { \
1278 spin_lock(&dev->xmit_lock); \ 1227 netif_tx_lock(dev); \
1279 dev->xmit_lock_owner = cpu; \
1280 } \ 1228 } \
1281} 1229}
1282 1230
1283#define HARD_TX_UNLOCK(dev) { \ 1231#define HARD_TX_UNLOCK(dev) { \
1284 if ((dev->features & NETIF_F_LLTX) == 0) { \ 1232 if ((dev->features & NETIF_F_LLTX) == 0) { \
1285 dev->xmit_lock_owner = -1; \ 1233 netif_tx_unlock(dev); \
1286 spin_unlock(&dev->xmit_lock); \
1287 } \ 1234 } \
1288} 1235}
1289 1236
@@ -1321,7 +1268,7 @@ int dev_queue_xmit(struct sk_buff *skb)
1321 1268
1322 if (skb_shinfo(skb)->frag_list && 1269 if (skb_shinfo(skb)->frag_list &&
1323 !(dev->features & NETIF_F_FRAGLIST) && 1270 !(dev->features & NETIF_F_FRAGLIST) &&
1324 __skb_linearize(skb, GFP_ATOMIC)) 1271 __skb_linearize(skb))
1325 goto out_kfree_skb; 1272 goto out_kfree_skb;
1326 1273
1327 /* Fragmented skb is linearized if device does not support SG, 1274 /* Fragmented skb is linearized if device does not support SG,
@@ -1330,14 +1277,14 @@ int dev_queue_xmit(struct sk_buff *skb)
1330 */ 1277 */
1331 if (skb_shinfo(skb)->nr_frags && 1278 if (skb_shinfo(skb)->nr_frags &&
1332 (!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) && 1279 (!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) &&
1333 __skb_linearize(skb, GFP_ATOMIC)) 1280 __skb_linearize(skb))
1334 goto out_kfree_skb; 1281 goto out_kfree_skb;
1335 1282
1336 /* If packet is not checksummed and device does not support 1283 /* If packet is not checksummed and device does not support
1337 * checksumming for this protocol, complete checksumming here. 1284 * checksumming for this protocol, complete checksumming here.
1338 */ 1285 */
1339 if (skb->ip_summed == CHECKSUM_HW && 1286 if (skb->ip_summed == CHECKSUM_HW &&
1340 (!(dev->features & (NETIF_F_HW_CSUM | NETIF_F_NO_CSUM)) && 1287 (!(dev->features & NETIF_F_GEN_CSUM) &&
1341 (!(dev->features & NETIF_F_IP_CSUM) || 1288 (!(dev->features & NETIF_F_IP_CSUM) ||
1342 skb->protocol != htons(ETH_P_IP)))) 1289 skb->protocol != htons(ETH_P_IP))))
1343 if (skb_checksum_help(skb, 0)) 1290 if (skb_checksum_help(skb, 0))
@@ -1382,8 +1329,8 @@ int dev_queue_xmit(struct sk_buff *skb)
1382 /* The device has no queue. Common case for software devices: 1329 /* The device has no queue. Common case for software devices:
1383 loopback, all the sorts of tunnels... 1330 loopback, all the sorts of tunnels...
1384 1331
1385 Really, it is unlikely that xmit_lock protection is necessary here. 1332 Really, it is unlikely that netif_tx_lock protection is necessary
1386 (f.e. loopback and IP tunnels are clean ignoring statistics 1333 here. (f.e. loopback and IP tunnels are clean ignoring statistics
1387 counters.) 1334 counters.)
1388 However, it is possible, that they rely on protection 1335 However, it is possible, that they rely on protection
1389 made by us here. 1336 made by us here.
@@ -1846,6 +1793,19 @@ static void net_rx_action(struct softirq_action *h)
1846 } 1793 }
1847 } 1794 }
1848out: 1795out:
1796#ifdef CONFIG_NET_DMA
1797 /*
1798 * There may not be any more sk_buffs coming right now, so push
1799 * any pending DMA copies to hardware
1800 */
1801 if (net_dma_client) {
1802 struct dma_chan *chan;
1803 rcu_read_lock();
1804 list_for_each_entry_rcu(chan, &net_dma_client->channels, client_node)
1805 dma_async_memcpy_issue_pending(chan);
1806 rcu_read_unlock();
1807 }
1808#endif
1849 local_irq_enable(); 1809 local_irq_enable();
1850 return; 1810 return;
1851 1811
@@ -2785,7 +2745,7 @@ int register_netdevice(struct net_device *dev)
2785 BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); 2745 BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
2786 2746
2787 spin_lock_init(&dev->queue_lock); 2747 spin_lock_init(&dev->queue_lock);
2788 spin_lock_init(&dev->xmit_lock); 2748 spin_lock_init(&dev->_xmit_lock);
2789 dev->xmit_lock_owner = -1; 2749 dev->xmit_lock_owner = -1;
2790#ifdef CONFIG_NET_CLS_ACT 2750#ifdef CONFIG_NET_CLS_ACT
2791 spin_lock_init(&dev->ingress_lock); 2751 spin_lock_init(&dev->ingress_lock);
@@ -2829,9 +2789,7 @@ int register_netdevice(struct net_device *dev)
2829 2789
2830 /* Fix illegal SG+CSUM combinations. */ 2790 /* Fix illegal SG+CSUM combinations. */
2831 if ((dev->features & NETIF_F_SG) && 2791 if ((dev->features & NETIF_F_SG) &&
2832 !(dev->features & (NETIF_F_IP_CSUM | 2792 !(dev->features & NETIF_F_ALL_CSUM)) {
2833 NETIF_F_NO_CSUM |
2834 NETIF_F_HW_CSUM))) {
2835 printk("%s: Dropping NETIF_F_SG since no checksum feature.\n", 2793 printk("%s: Dropping NETIF_F_SG since no checksum feature.\n",
2836 dev->name); 2794 dev->name);
2837 dev->features &= ~NETIF_F_SG; 2795 dev->features &= ~NETIF_F_SG;
@@ -3300,6 +3258,88 @@ static int dev_cpu_callback(struct notifier_block *nfb,
3300} 3258}
3301#endif /* CONFIG_HOTPLUG_CPU */ 3259#endif /* CONFIG_HOTPLUG_CPU */
3302 3260
3261#ifdef CONFIG_NET_DMA
3262/**
3263 * net_dma_rebalance -
3264 * This is called when the number of channels allocated to the net_dma_client
3265 * changes. The net_dma_client tries to have one DMA channel per CPU.
3266 */
3267static void net_dma_rebalance(void)
3268{
3269 unsigned int cpu, i, n;
3270 struct dma_chan *chan;
3271
3272 lock_cpu_hotplug();
3273
3274 if (net_dma_count == 0) {
3275 for_each_online_cpu(cpu)
3276 rcu_assign_pointer(per_cpu(softnet_data.net_dma, cpu), NULL);
3277 unlock_cpu_hotplug();
3278 return;
3279 }
3280
3281 i = 0;
3282 cpu = first_cpu(cpu_online_map);
3283
3284 rcu_read_lock();
3285 list_for_each_entry(chan, &net_dma_client->channels, client_node) {
3286 n = ((num_online_cpus() / net_dma_count)
3287 + (i < (num_online_cpus() % net_dma_count) ? 1 : 0));
3288
3289 while(n) {
3290 per_cpu(softnet_data.net_dma, cpu) = chan;
3291 cpu = next_cpu(cpu, cpu_online_map);
3292 n--;
3293 }
3294 i++;
3295 }
3296 rcu_read_unlock();
3297
3298 unlock_cpu_hotplug();
3299}
3300
3301/**
3302 * netdev_dma_event - event callback for the net_dma_client
3303 * @client: should always be net_dma_client
3304 * @chan:
3305 * @event:
3306 */
3307static void netdev_dma_event(struct dma_client *client, struct dma_chan *chan,
3308 enum dma_event event)
3309{
3310 spin_lock(&net_dma_event_lock);
3311 switch (event) {
3312 case DMA_RESOURCE_ADDED:
3313 net_dma_count++;
3314 net_dma_rebalance();
3315 break;
3316 case DMA_RESOURCE_REMOVED:
3317 net_dma_count--;
3318 net_dma_rebalance();
3319 break;
3320 default:
3321 break;
3322 }
3323 spin_unlock(&net_dma_event_lock);
3324}
3325
3326/**
3327 * netdev_dma_regiser - register the networking subsystem as a DMA client
3328 */
3329static int __init netdev_dma_register(void)
3330{
3331 spin_lock_init(&net_dma_event_lock);
3332 net_dma_client = dma_async_client_register(netdev_dma_event);
3333 if (net_dma_client == NULL)
3334 return -ENOMEM;
3335
3336 dma_async_client_chan_request(net_dma_client, num_online_cpus());
3337 return 0;
3338}
3339
3340#else
3341static int __init netdev_dma_register(void) { return -ENODEV; }
3342#endif /* CONFIG_NET_DMA */
3303 3343
3304/* 3344/*
3305 * Initialize the DEV module. At boot time this walks the device list and 3345 * Initialize the DEV module. At boot time this walks the device list and
@@ -3353,6 +3393,8 @@ static int __init net_dev_init(void)
3353 atomic_set(&queue->backlog_dev.refcnt, 1); 3393 atomic_set(&queue->backlog_dev.refcnt, 1);
3354 } 3394 }
3355 3395
3396 netdev_dma_register();
3397
3356 dev_boot_phase = 0; 3398 dev_boot_phase = 0;
3357 3399
3358 open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL); 3400 open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);
@@ -3371,7 +3413,6 @@ subsys_initcall(net_dev_init);
3371EXPORT_SYMBOL(__dev_get_by_index); 3413EXPORT_SYMBOL(__dev_get_by_index);
3372EXPORT_SYMBOL(__dev_get_by_name); 3414EXPORT_SYMBOL(__dev_get_by_name);
3373EXPORT_SYMBOL(__dev_remove_pack); 3415EXPORT_SYMBOL(__dev_remove_pack);
3374EXPORT_SYMBOL(__skb_linearize);
3375EXPORT_SYMBOL(dev_valid_name); 3416EXPORT_SYMBOL(dev_valid_name);
3376EXPORT_SYMBOL(dev_add_pack); 3417EXPORT_SYMBOL(dev_add_pack);
3377EXPORT_SYMBOL(dev_alloc_name); 3418EXPORT_SYMBOL(dev_alloc_name);
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index 05d60850840e..c57d887da2ef 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -62,7 +62,7 @@
62 * Device mc lists are changed by bh at least if IPv6 is enabled, 62 * Device mc lists are changed by bh at least if IPv6 is enabled,
63 * so that it must be bh protected. 63 * so that it must be bh protected.
64 * 64 *
65 * We block accesses to device mc filters with dev->xmit_lock. 65 * We block accesses to device mc filters with netif_tx_lock.
66 */ 66 */
67 67
68/* 68/*
@@ -93,9 +93,9 @@ static void __dev_mc_upload(struct net_device *dev)
93 93
94void dev_mc_upload(struct net_device *dev) 94void dev_mc_upload(struct net_device *dev)
95{ 95{
96 spin_lock_bh(&dev->xmit_lock); 96 netif_tx_lock_bh(dev);
97 __dev_mc_upload(dev); 97 __dev_mc_upload(dev);
98 spin_unlock_bh(&dev->xmit_lock); 98 netif_tx_unlock_bh(dev);
99} 99}
100 100
101/* 101/*
@@ -107,7 +107,7 @@ int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
107 int err = 0; 107 int err = 0;
108 struct dev_mc_list *dmi, **dmip; 108 struct dev_mc_list *dmi, **dmip;
109 109
110 spin_lock_bh(&dev->xmit_lock); 110 netif_tx_lock_bh(dev);
111 111
112 for (dmip = &dev->mc_list; (dmi = *dmip) != NULL; dmip = &dmi->next) { 112 for (dmip = &dev->mc_list; (dmi = *dmip) != NULL; dmip = &dmi->next) {
113 /* 113 /*
@@ -139,13 +139,13 @@ int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
139 */ 139 */
140 __dev_mc_upload(dev); 140 __dev_mc_upload(dev);
141 141
142 spin_unlock_bh(&dev->xmit_lock); 142 netif_tx_unlock_bh(dev);
143 return 0; 143 return 0;
144 } 144 }
145 } 145 }
146 err = -ENOENT; 146 err = -ENOENT;
147done: 147done:
148 spin_unlock_bh(&dev->xmit_lock); 148 netif_tx_unlock_bh(dev);
149 return err; 149 return err;
150} 150}
151 151
@@ -160,7 +160,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
160 160
161 dmi1 = kmalloc(sizeof(*dmi), GFP_ATOMIC); 161 dmi1 = kmalloc(sizeof(*dmi), GFP_ATOMIC);
162 162
163 spin_lock_bh(&dev->xmit_lock); 163 netif_tx_lock_bh(dev);
164 for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) { 164 for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) {
165 if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 && 165 if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 &&
166 dmi->dmi_addrlen == alen) { 166 dmi->dmi_addrlen == alen) {
@@ -176,7 +176,7 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
176 } 176 }
177 177
178 if ((dmi = dmi1) == NULL) { 178 if ((dmi = dmi1) == NULL) {
179 spin_unlock_bh(&dev->xmit_lock); 179 netif_tx_unlock_bh(dev);
180 return -ENOMEM; 180 return -ENOMEM;
181 } 181 }
182 memcpy(dmi->dmi_addr, addr, alen); 182 memcpy(dmi->dmi_addr, addr, alen);
@@ -189,11 +189,11 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
189 189
190 __dev_mc_upload(dev); 190 __dev_mc_upload(dev);
191 191
192 spin_unlock_bh(&dev->xmit_lock); 192 netif_tx_unlock_bh(dev);
193 return 0; 193 return 0;
194 194
195done: 195done:
196 spin_unlock_bh(&dev->xmit_lock); 196 netif_tx_unlock_bh(dev);
197 kfree(dmi1); 197 kfree(dmi1);
198 return err; 198 return err;
199} 199}
@@ -204,7 +204,7 @@ done:
204 204
205void dev_mc_discard(struct net_device *dev) 205void dev_mc_discard(struct net_device *dev)
206{ 206{
207 spin_lock_bh(&dev->xmit_lock); 207 netif_tx_lock_bh(dev);
208 208
209 while (dev->mc_list != NULL) { 209 while (dev->mc_list != NULL) {
210 struct dev_mc_list *tmp = dev->mc_list; 210 struct dev_mc_list *tmp = dev->mc_list;
@@ -215,7 +215,7 @@ void dev_mc_discard(struct net_device *dev)
215 } 215 }
216 dev->mc_count = 0; 216 dev->mc_count = 0;
217 217
218 spin_unlock_bh(&dev->xmit_lock); 218 netif_tx_unlock_bh(dev);
219} 219}
220 220
221#ifdef CONFIG_PROC_FS 221#ifdef CONFIG_PROC_FS
@@ -250,7 +250,7 @@ static int dev_mc_seq_show(struct seq_file *seq, void *v)
250 struct dev_mc_list *m; 250 struct dev_mc_list *m;
251 struct net_device *dev = v; 251 struct net_device *dev = v;
252 252
253 spin_lock_bh(&dev->xmit_lock); 253 netif_tx_lock_bh(dev);
254 for (m = dev->mc_list; m; m = m->next) { 254 for (m = dev->mc_list; m; m = m->next) {
255 int i; 255 int i;
256 256
@@ -262,7 +262,7 @@ static int dev_mc_seq_show(struct seq_file *seq, void *v)
262 262
263 seq_putc(seq, '\n'); 263 seq_putc(seq, '\n');
264 } 264 }
265 spin_unlock_bh(&dev->xmit_lock); 265 netif_tx_unlock_bh(dev);
266 return 0; 266 return 0;
267} 267}
268 268
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index e6f76106a99b..33ce7ed6afc6 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -30,7 +30,7 @@ u32 ethtool_op_get_link(struct net_device *dev)
30 30
31u32 ethtool_op_get_tx_csum(struct net_device *dev) 31u32 ethtool_op_get_tx_csum(struct net_device *dev)
32{ 32{
33 return (dev->features & (NETIF_F_IP_CSUM | NETIF_F_HW_CSUM)) != 0; 33 return (dev->features & NETIF_F_ALL_CSUM) != 0;
34} 34}
35 35
36int ethtool_op_set_tx_csum(struct net_device *dev, u32 data) 36int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
@@ -551,9 +551,7 @@ static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
551 return -EFAULT; 551 return -EFAULT;
552 552
553 if (edata.data && 553 if (edata.data &&
554 !(dev->features & (NETIF_F_IP_CSUM | 554 !(dev->features & NETIF_F_ALL_CSUM))
555 NETIF_F_NO_CSUM |
556 NETIF_F_HW_CSUM)))
557 return -EINVAL; 555 return -EINVAL;
558 556
559 return __ethtool_set_sg(dev, edata.data); 557 return __ethtool_set_sg(dev, edata.data);
@@ -591,7 +589,7 @@ static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
591 589
592static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr) 590static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr)
593{ 591{
594 struct ethtool_value edata = { ETHTOOL_GTSO }; 592 struct ethtool_value edata = { ETHTOOL_GUFO };
595 593
596 if (!dev->ethtool_ops->get_ufo) 594 if (!dev->ethtool_ops->get_ufo)
597 return -EOPNOTSUPP; 595 return -EOPNOTSUPP;
@@ -600,6 +598,7 @@ static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr)
600 return -EFAULT; 598 return -EFAULT;
601 return 0; 599 return 0;
602} 600}
601
603static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr) 602static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
604{ 603{
605 struct ethtool_value edata; 604 struct ethtool_value edata;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index e8e05cebd95a..9cb781830380 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -273,24 +273,21 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
273 273
274 do { 274 do {
275 npinfo->tries--; 275 npinfo->tries--;
276 spin_lock(&np->dev->xmit_lock); 276 netif_tx_lock(np->dev);
277 np->dev->xmit_lock_owner = smp_processor_id();
278 277
279 /* 278 /*
280 * network drivers do not expect to be called if the queue is 279 * network drivers do not expect to be called if the queue is
281 * stopped. 280 * stopped.
282 */ 281 */
283 if (netif_queue_stopped(np->dev)) { 282 if (netif_queue_stopped(np->dev)) {
284 np->dev->xmit_lock_owner = -1; 283 netif_tx_unlock(np->dev);
285 spin_unlock(&np->dev->xmit_lock);
286 netpoll_poll(np); 284 netpoll_poll(np);
287 udelay(50); 285 udelay(50);
288 continue; 286 continue;
289 } 287 }
290 288
291 status = np->dev->hard_start_xmit(skb, np->dev); 289 status = np->dev->hard_start_xmit(skb, np->dev);
292 np->dev->xmit_lock_owner = -1; 290 netif_tx_unlock(np->dev);
293 spin_unlock(&np->dev->xmit_lock);
294 291
295 /* success */ 292 /* success */
296 if(!status) { 293 if(!status) {
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index c23e9c06ee23..67ed14ddabd2 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2897,7 +2897,7 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
2897 } 2897 }
2898 } 2898 }
2899 2899
2900 spin_lock_bh(&odev->xmit_lock); 2900 netif_tx_lock_bh(odev);
2901 if (!netif_queue_stopped(odev)) { 2901 if (!netif_queue_stopped(odev)) {
2902 2902
2903 atomic_inc(&(pkt_dev->skb->users)); 2903 atomic_inc(&(pkt_dev->skb->users));
@@ -2942,7 +2942,7 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
2942 pkt_dev->next_tx_ns = 0; 2942 pkt_dev->next_tx_ns = 0;
2943 } 2943 }
2944 2944
2945 spin_unlock_bh(&odev->xmit_lock); 2945 netif_tx_unlock_bh(odev);
2946 2946
2947 /* If pkt_dev->count is zero, then run forever */ 2947 /* If pkt_dev->count is zero, then run forever */
2948 if ((pkt_dev->count != 0) && (pkt_dev->sofar >= pkt_dev->count)) { 2948 if ((pkt_dev->count != 0) && (pkt_dev->sofar >= pkt_dev->count)) {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index fb3770f9c094..bb7210f4005e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -464,7 +464,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
464 n->tc_verd = CLR_TC_MUNGED(n->tc_verd); 464 n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
465 C(input_dev); 465 C(input_dev);
466#endif 466#endif
467 467 skb_copy_secmark(n, skb);
468#endif 468#endif
469 C(truesize); 469 C(truesize);
470 atomic_set(&n->users, 1); 470 atomic_set(&n->users, 1);
@@ -526,6 +526,7 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
526#endif 526#endif
527 new->tc_index = old->tc_index; 527 new->tc_index = old->tc_index;
528#endif 528#endif
529 skb_copy_secmark(new, old);
529 atomic_set(&new->users, 1); 530 atomic_set(&new->users, 1);
530 skb_shinfo(new)->tso_size = skb_shinfo(old)->tso_size; 531 skb_shinfo(new)->tso_size = skb_shinfo(old)->tso_size;
531 skb_shinfo(new)->tso_segs = skb_shinfo(old)->tso_segs; 532 skb_shinfo(new)->tso_segs = skb_shinfo(old)->tso_segs;
@@ -800,12 +801,10 @@ struct sk_buff *skb_pad(struct sk_buff *skb, int pad)
800 return nskb; 801 return nskb;
801} 802}
802 803
803/* Trims skb to length len. It can change skb pointers, if "realloc" is 1. 804/* Trims skb to length len. It can change skb pointers.
804 * If realloc==0 and trimming is impossible without change of data,
805 * it is BUG().
806 */ 805 */
807 806
808int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc) 807int ___pskb_trim(struct sk_buff *skb, unsigned int len)
809{ 808{
810 int offset = skb_headlen(skb); 809 int offset = skb_headlen(skb);
811 int nfrags = skb_shinfo(skb)->nr_frags; 810 int nfrags = skb_shinfo(skb)->nr_frags;
@@ -815,7 +814,6 @@ int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc)
815 int end = offset + skb_shinfo(skb)->frags[i].size; 814 int end = offset + skb_shinfo(skb)->frags[i].size;
816 if (end > len) { 815 if (end > len) {
817 if (skb_cloned(skb)) { 816 if (skb_cloned(skb)) {
818 BUG_ON(!realloc);
819 if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 817 if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
820 return -ENOMEM; 818 return -ENOMEM;
821 } 819 }
diff --git a/net/core/sock.c b/net/core/sock.c
index ed2afdb9ea2d..5d820c376653 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -832,6 +832,9 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
832 atomic_set(&newsk->sk_omem_alloc, 0); 832 atomic_set(&newsk->sk_omem_alloc, 0);
833 skb_queue_head_init(&newsk->sk_receive_queue); 833 skb_queue_head_init(&newsk->sk_receive_queue);
834 skb_queue_head_init(&newsk->sk_write_queue); 834 skb_queue_head_init(&newsk->sk_write_queue);
835#ifdef CONFIG_NET_DMA
836 skb_queue_head_init(&newsk->sk_async_wait_queue);
837#endif
835 838
836 rwlock_init(&newsk->sk_dst_lock); 839 rwlock_init(&newsk->sk_dst_lock);
837 rwlock_init(&newsk->sk_callback_lock); 840 rwlock_init(&newsk->sk_callback_lock);
@@ -1383,6 +1386,9 @@ void sock_init_data(struct socket *sock, struct sock *sk)
1383 skb_queue_head_init(&sk->sk_receive_queue); 1386 skb_queue_head_init(&sk->sk_receive_queue);
1384 skb_queue_head_init(&sk->sk_write_queue); 1387 skb_queue_head_init(&sk->sk_write_queue);
1385 skb_queue_head_init(&sk->sk_error_queue); 1388 skb_queue_head_init(&sk->sk_error_queue);
1389#ifdef CONFIG_NET_DMA
1390 skb_queue_head_init(&sk->sk_async_wait_queue);
1391#endif
1386 1392
1387 sk->sk_send_head = NULL; 1393 sk->sk_send_head = NULL;
1388 1394
diff --git a/net/core/user_dma.c b/net/core/user_dma.c
new file mode 100644
index 000000000000..b7c98dbcdb81
--- /dev/null
+++ b/net/core/user_dma.c
@@ -0,0 +1,131 @@
1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved.
3 * Portions based on net/core/datagram.c and copyrighted by their authors.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59
17 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * The full GNU General Public License is included in this distribution in the
20 * file called COPYING.
21 */
22
23/*
24 * This code allows the net stack to make use of a DMA engine for
25 * skb to iovec copies.
26 */
27
28#include <linux/dmaengine.h>
29#include <linux/socket.h>
30#include <linux/rtnetlink.h> /* for BUG_TRAP */
31#include <net/tcp.h>
32
33#define NET_DMA_DEFAULT_COPYBREAK 4096
34
35int sysctl_tcp_dma_copybreak = NET_DMA_DEFAULT_COPYBREAK;
36
37/**
38 * dma_skb_copy_datagram_iovec - Copy a datagram to an iovec.
39 * @skb - buffer to copy
40 * @offset - offset in the buffer to start copying from
41 * @iovec - io vector to copy to
42 * @len - amount of data to copy from buffer to iovec
43 * @pinned_list - locked iovec buffer data
44 *
45 * Note: the iovec is modified during the copy.
46 */
47int dma_skb_copy_datagram_iovec(struct dma_chan *chan,
48 struct sk_buff *skb, int offset, struct iovec *to,
49 size_t len, struct dma_pinned_list *pinned_list)
50{
51 int start = skb_headlen(skb);
52 int i, copy = start - offset;
53 dma_cookie_t cookie = 0;
54
55 /* Copy header. */
56 if (copy > 0) {
57 if (copy > len)
58 copy = len;
59 cookie = dma_memcpy_to_iovec(chan, to, pinned_list,
60 skb->data + offset, copy);
61 if (cookie < 0)
62 goto fault;
63 len -= copy;
64 if (len == 0)
65 goto end;
66 offset += copy;
67 }
68
69 /* Copy paged appendix. Hmm... why does this look so complicated? */
70 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
71 int end;
72
73 BUG_TRAP(start <= offset + len);
74
75 end = start + skb_shinfo(skb)->frags[i].size;
76 copy = end - offset;
77 if ((copy = end - offset) > 0) {
78 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
79 struct page *page = frag->page;
80
81 if (copy > len)
82 copy = len;
83
84 cookie = dma_memcpy_pg_to_iovec(chan, to, pinned_list, page,
85 frag->page_offset + offset - start, copy);
86 if (cookie < 0)
87 goto fault;
88 len -= copy;
89 if (len == 0)
90 goto end;
91 offset += copy;
92 }
93 start = end;
94 }
95
96 if (skb_shinfo(skb)->frag_list) {
97 struct sk_buff *list = skb_shinfo(skb)->frag_list;
98
99 for (; list; list = list->next) {
100 int end;
101
102 BUG_TRAP(start <= offset + len);
103
104 end = start + list->len;
105 copy = end - offset;
106 if (copy > 0) {
107 if (copy > len)
108 copy = len;
109 cookie = dma_skb_copy_datagram_iovec(chan, list,
110 offset - start, to, copy,
111 pinned_list);
112 if (cookie < 0)
113 goto fault;
114 len -= copy;
115 if (len == 0)
116 goto end;
117 offset += copy;
118 }
119 start = end;
120 }
121 }
122
123end:
124 if (!len) {
125 skb->dma_cookie = cookie;
126 return cookie;
127 }
128
129fault:
130 return -EFAULT;
131}
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index b5981e5f6b00..8c211c58893b 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -452,6 +452,7 @@ found:
452 (unsigned long long) 452 (unsigned long long)
453 avr->dccpavr_ack_ackno); 453 avr->dccpavr_ack_ackno);
454 dccp_ackvec_throw_record(av, avr); 454 dccp_ackvec_throw_record(av, avr);
455 break;
455 } 456 }
456 /* 457 /*
457 * If it wasn't received, continue scanning... we might 458 * If it wasn't received, continue scanning... we might
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 2e0ee8355c41..5317fd3e6691 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -719,7 +719,7 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
719 } 719 }
720 dccp_pr_debug("packet_type=%s\n", 720 dccp_pr_debug("packet_type=%s\n",
721 dccp_packet_name(dh->dccph_type)); 721 dccp_packet_name(dh->dccph_type));
722 sk_eat_skb(sk, skb); 722 sk_eat_skb(sk, skb, 0);
723verify_sock_status: 723verify_sock_status:
724 if (sock_flag(sk, SOCK_DONE)) { 724 if (sock_flag(sk, SOCK_DONE)) {
725 len = 0; 725 len = 0;
@@ -773,7 +773,7 @@ verify_sock_status:
773 } 773 }
774 found_fin_ok: 774 found_fin_ok:
775 if (!(flags & MSG_PEEK)) 775 if (!(flags & MSG_PEEK))
776 sk_eat_skb(sk, skb); 776 sk_eat_skb(sk, skb, 0);
777 break; 777 break;
778 } while (1); 778 } while (1);
779out: 779out:
diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
index 547523b41c81..a2ba9db1c376 100644
--- a/net/decnet/dn_nsp_in.c
+++ b/net/decnet/dn_nsp_in.c
@@ -801,8 +801,7 @@ got_it:
801 * We linearize everything except data segments here. 801 * We linearize everything except data segments here.
802 */ 802 */
803 if (cb->nsp_flags & ~0x60) { 803 if (cb->nsp_flags & ~0x60) {
804 if (unlikely(skb_is_nonlinear(skb)) && 804 if (unlikely(skb_linearize(skb)))
805 skb_linearize(skb, GFP_ATOMIC) != 0)
806 goto free_out; 805 goto free_out;
807 } 806 }
808 807
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index e172cf98d7fc..5abf7057af00 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -629,8 +629,7 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
629 padlen); 629 padlen);
630 630
631 if (flags & DN_RT_PKT_CNTL) { 631 if (flags & DN_RT_PKT_CNTL) {
632 if (unlikely(skb_is_nonlinear(skb)) && 632 if (unlikely(skb_linearize(skb)))
633 skb_linearize(skb, GFP_ATOMIC) != 0)
634 goto dump_it; 633 goto dump_it;
635 634
636 switch(flags & DN_RT_CNTL_MSK) { 635 switch(flags & DN_RT_CNTL_MSK) {
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 93def94c1b32..3fa5df2e1f0b 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -501,8 +501,11 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr,
501static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr) 501static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
502{ 502{
503 struct ieee80211_hdr_4addr *hdr11; 503 struct ieee80211_hdr_4addr *hdr11;
504 u16 stype;
504 505
505 hdr11 = (struct ieee80211_hdr_4addr *)skb->data; 506 hdr11 = (struct ieee80211_hdr_4addr *)skb->data;
507 stype = WLAN_FC_GET_STYPE(le16_to_cpu(hdr11->frame_ctl));
508
506 switch (le16_to_cpu(hdr11->frame_ctl) & 509 switch (le16_to_cpu(hdr11->frame_ctl) &
507 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 510 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
508 case IEEE80211_FCTL_TODS: 511 case IEEE80211_FCTL_TODS:
@@ -523,7 +526,13 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
523 break; 526 break;
524 } 527 }
525 528
526 hdr[12] = 0; /* priority */ 529 if (stype & IEEE80211_STYPE_QOS_DATA) {
530 const struct ieee80211_hdr_3addrqos *qoshdr =
531 (struct ieee80211_hdr_3addrqos *)skb->data;
532 hdr[12] = le16_to_cpu(qoshdr->qos_ctl) & IEEE80211_QCTL_TID;
533 } else
534 hdr[12] = 0; /* priority */
535
527 hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */ 536 hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
528} 537}
529 538
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 604b7b0097bc..2bf567fd5a17 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -369,7 +369,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
369 369
370 /* Put this code here so that we avoid duplicating it in all 370 /* Put this code here so that we avoid duplicating it in all
371 * Rx paths. - Jean II */ 371 * Rx paths. - Jean II */
372#ifdef CONFIG_WIRELESS_EXT
373#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */ 372#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
374 /* If spy monitoring on */ 373 /* If spy monitoring on */
375 if (ieee->spy_data.spy_number > 0) { 374 if (ieee->spy_data.spy_number > 0) {
@@ -398,7 +397,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
398 wireless_spy_update(ieee->dev, hdr->addr2, &wstats); 397 wireless_spy_update(ieee->dev, hdr->addr2, &wstats);
399 } 398 }
400#endif /* IW_WIRELESS_SPY */ 399#endif /* IW_WIRELESS_SPY */
401#endif /* CONFIG_WIRELESS_EXT */
402 400
403#ifdef NOT_YET 401#ifdef NOT_YET
404 hostap_update_rx_stats(local->ap, hdr, rx_stats); 402 hostap_update_rx_stats(local->ap, hdr, rx_stats);
@@ -1692,8 +1690,8 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1692 WLAN_FC_GET_STYPE(le16_to_cpu 1690 WLAN_FC_GET_STYPE(le16_to_cpu
1693 (header->frame_ctl))); 1691 (header->frame_ctl)));
1694 1692
1695 IEEE80211_WARNING("%s: IEEE80211_REASSOC_REQ received\n", 1693 IEEE80211_DEBUG_MGMT("%s: IEEE80211_REASSOC_REQ received\n",
1696 ieee->dev->name); 1694 ieee->dev->name);
1697 if (ieee->handle_reassoc_request != NULL) 1695 if (ieee->handle_reassoc_request != NULL)
1698 ieee->handle_reassoc_request(ieee->dev, 1696 ieee->handle_reassoc_request(ieee->dev,
1699 (struct ieee80211_reassoc_request *) 1697 (struct ieee80211_reassoc_request *)
@@ -1705,8 +1703,8 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1705 WLAN_FC_GET_STYPE(le16_to_cpu 1703 WLAN_FC_GET_STYPE(le16_to_cpu
1706 (header->frame_ctl))); 1704 (header->frame_ctl)));
1707 1705
1708 IEEE80211_WARNING("%s: IEEE80211_ASSOC_REQ received\n", 1706 IEEE80211_DEBUG_MGMT("%s: IEEE80211_ASSOC_REQ received\n",
1709 ieee->dev->name); 1707 ieee->dev->name);
1710 if (ieee->handle_assoc_request != NULL) 1708 if (ieee->handle_assoc_request != NULL)
1711 ieee->handle_assoc_request(ieee->dev); 1709 ieee->handle_assoc_request(ieee->dev);
1712 break; 1710 break;
@@ -1722,10 +1720,10 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1722 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n", 1720 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n",
1723 WLAN_FC_GET_STYPE(le16_to_cpu 1721 WLAN_FC_GET_STYPE(le16_to_cpu
1724 (header->frame_ctl))); 1722 (header->frame_ctl)));
1725 IEEE80211_WARNING("%s: Unknown management packet: %d\n", 1723 IEEE80211_DEBUG_MGMT("%s: Unknown management packet: %d\n",
1726 ieee->dev->name, 1724 ieee->dev->name,
1727 WLAN_FC_GET_STYPE(le16_to_cpu 1725 WLAN_FC_GET_STYPE(le16_to_cpu
1728 (header->frame_ctl))); 1726 (header->frame_ctl)));
1729 break; 1727 break;
1730 } 1728 }
1731} 1729}
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
index 8b4332f53394..6a5de1b84459 100644
--- a/net/ieee80211/ieee80211_tx.c
+++ b/net/ieee80211/ieee80211_tx.c
@@ -220,13 +220,43 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
220 return txb; 220 return txb;
221} 221}
222 222
223static int ieee80211_classify(struct sk_buff *skb)
224{
225 struct ethhdr *eth;
226 struct iphdr *ip;
227
228 eth = (struct ethhdr *)skb->data;
229 if (eth->h_proto != __constant_htons(ETH_P_IP))
230 return 0;
231
232 ip = skb->nh.iph;
233 switch (ip->tos & 0xfc) {
234 case 0x20:
235 return 2;
236 case 0x40:
237 return 1;
238 case 0x60:
239 return 3;
240 case 0x80:
241 return 4;
242 case 0xa0:
243 return 5;
244 case 0xc0:
245 return 6;
246 case 0xe0:
247 return 7;
248 default:
249 return 0;
250 }
251}
252
223/* Incoming skb is converted to a txb which consists of 253/* Incoming skb is converted to a txb which consists of
224 * a block of 802.11 fragment packets (stored as skbs) */ 254 * a block of 802.11 fragment packets (stored as skbs) */
225int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) 255int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
226{ 256{
227 struct ieee80211_device *ieee = netdev_priv(dev); 257 struct ieee80211_device *ieee = netdev_priv(dev);
228 struct ieee80211_txb *txb = NULL; 258 struct ieee80211_txb *txb = NULL;
229 struct ieee80211_hdr_3addr *frag_hdr; 259 struct ieee80211_hdr_3addrqos *frag_hdr;
230 int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size, 260 int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size,
231 rts_required; 261 rts_required;
232 unsigned long flags; 262 unsigned long flags;
@@ -234,9 +264,10 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
234 int ether_type, encrypt, host_encrypt, host_encrypt_msdu, host_build_iv; 264 int ether_type, encrypt, host_encrypt, host_encrypt_msdu, host_build_iv;
235 int bytes, fc, hdr_len; 265 int bytes, fc, hdr_len;
236 struct sk_buff *skb_frag; 266 struct sk_buff *skb_frag;
237 struct ieee80211_hdr_3addr header = { /* Ensure zero initialized */ 267 struct ieee80211_hdr_3addrqos header = {/* Ensure zero initialized */
238 .duration_id = 0, 268 .duration_id = 0,
239 .seq_ctl = 0 269 .seq_ctl = 0,
270 .qos_ctl = 0
240 }; 271 };
241 u8 dest[ETH_ALEN], src[ETH_ALEN]; 272 u8 dest[ETH_ALEN], src[ETH_ALEN];
242 struct ieee80211_crypt_data *crypt; 273 struct ieee80211_crypt_data *crypt;
@@ -282,12 +313,6 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
282 memcpy(dest, skb->data, ETH_ALEN); 313 memcpy(dest, skb->data, ETH_ALEN);
283 memcpy(src, skb->data + ETH_ALEN, ETH_ALEN); 314 memcpy(src, skb->data + ETH_ALEN, ETH_ALEN);
284 315
285 /* Advance the SKB to the start of the payload */
286 skb_pull(skb, sizeof(struct ethhdr));
287
288 /* Determine total amount of storage required for TXB packets */
289 bytes = skb->len + SNAP_SIZE + sizeof(u16);
290
291 if (host_encrypt || host_build_iv) 316 if (host_encrypt || host_build_iv)
292 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | 317 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
293 IEEE80211_FCTL_PROTECTED; 318 IEEE80211_FCTL_PROTECTED;
@@ -306,9 +331,23 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
306 memcpy(header.addr2, src, ETH_ALEN); 331 memcpy(header.addr2, src, ETH_ALEN);
307 memcpy(header.addr3, ieee->bssid, ETH_ALEN); 332 memcpy(header.addr3, ieee->bssid, ETH_ALEN);
308 } 333 }
309 header.frame_ctl = cpu_to_le16(fc);
310 hdr_len = IEEE80211_3ADDR_LEN; 334 hdr_len = IEEE80211_3ADDR_LEN;
311 335
336 if (ieee->is_qos_active && ieee->is_qos_active(dev, skb)) {
337 fc |= IEEE80211_STYPE_QOS_DATA;
338 hdr_len += 2;
339
340 skb->priority = ieee80211_classify(skb);
341 header.qos_ctl |= skb->priority & IEEE80211_QCTL_TID;
342 }
343 header.frame_ctl = cpu_to_le16(fc);
344
345 /* Advance the SKB to the start of the payload */
346 skb_pull(skb, sizeof(struct ethhdr));
347
348 /* Determine total amount of storage required for TXB packets */
349 bytes = skb->len + SNAP_SIZE + sizeof(u16);
350
312 /* Encrypt msdu first on the whole data packet. */ 351 /* Encrypt msdu first on the whole data packet. */
313 if ((host_encrypt || host_encrypt_msdu) && 352 if ((host_encrypt || host_encrypt_msdu) &&
314 crypt && crypt->ops && crypt->ops->encrypt_msdu) { 353 crypt && crypt->ops && crypt->ops->encrypt_msdu) {
@@ -402,7 +441,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
402 if (rts_required) { 441 if (rts_required) {
403 skb_frag = txb->fragments[0]; 442 skb_frag = txb->fragments[0];
404 frag_hdr = 443 frag_hdr =
405 (struct ieee80211_hdr_3addr *)skb_put(skb_frag, hdr_len); 444 (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
406 445
407 /* 446 /*
408 * Set header frame_ctl to the RTS. 447 * Set header frame_ctl to the RTS.
@@ -433,7 +472,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
433 crypt->ops->extra_mpdu_prefix_len); 472 crypt->ops->extra_mpdu_prefix_len);
434 473
435 frag_hdr = 474 frag_hdr =
436 (struct ieee80211_hdr_3addr *)skb_put(skb_frag, hdr_len); 475 (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
437 memcpy(frag_hdr, &header, hdr_len); 476 memcpy(frag_hdr, &header, hdr_len);
438 477
439 /* If this is not the last fragment, then add the MOREFRAGS 478 /* If this is not the last fragment, then add the MOREFRAGS
@@ -516,7 +555,8 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
516/* Incoming 802.11 strucure is converted to a TXB 555/* Incoming 802.11 strucure is converted to a TXB
517 * a block of 802.11 fragment packets (stored as skbs) */ 556 * a block of 802.11 fragment packets (stored as skbs) */
518int ieee80211_tx_frame(struct ieee80211_device *ieee, 557int ieee80211_tx_frame(struct ieee80211_device *ieee,
519 struct ieee80211_hdr *frame, int len) 558 struct ieee80211_hdr *frame, int hdr_len, int total_len,
559 int encrypt_mpdu)
520{ 560{
521 struct ieee80211_txb *txb = NULL; 561 struct ieee80211_txb *txb = NULL;
522 unsigned long flags; 562 unsigned long flags;
@@ -526,6 +566,9 @@ int ieee80211_tx_frame(struct ieee80211_device *ieee,
526 566
527 spin_lock_irqsave(&ieee->lock, flags); 567 spin_lock_irqsave(&ieee->lock, flags);
528 568
569 if (encrypt_mpdu && !ieee->sec.encrypt)
570 encrypt_mpdu = 0;
571
529 /* If there is no driver handler to take the TXB, dont' bother 572 /* If there is no driver handler to take the TXB, dont' bother
530 * creating it... */ 573 * creating it... */
531 if (!ieee->hard_start_xmit) { 574 if (!ieee->hard_start_xmit) {
@@ -533,32 +576,41 @@ int ieee80211_tx_frame(struct ieee80211_device *ieee,
533 goto success; 576 goto success;
534 } 577 }
535 578
536 if (unlikely(len < 24)) { 579 if (unlikely(total_len < 24)) {
537 printk(KERN_WARNING "%s: skb too small (%d).\n", 580 printk(KERN_WARNING "%s: skb too small (%d).\n",
538 ieee->dev->name, len); 581 ieee->dev->name, total_len);
539 goto success; 582 goto success;
540 } 583 }
541 584
585 if (encrypt_mpdu)
586 frame->frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
587
542 /* When we allocate the TXB we allocate enough space for the reserve 588 /* When we allocate the TXB we allocate enough space for the reserve
543 * and full fragment bytes (bytes_per_frag doesn't include prefix, 589 * and full fragment bytes (bytes_per_frag doesn't include prefix,
544 * postfix, header, FCS, etc.) */ 590 * postfix, header, FCS, etc.) */
545 txb = ieee80211_alloc_txb(1, len, ieee->tx_headroom, GFP_ATOMIC); 591 txb = ieee80211_alloc_txb(1, total_len, ieee->tx_headroom, GFP_ATOMIC);
546 if (unlikely(!txb)) { 592 if (unlikely(!txb)) {
547 printk(KERN_WARNING "%s: Could not allocate TXB\n", 593 printk(KERN_WARNING "%s: Could not allocate TXB\n",
548 ieee->dev->name); 594 ieee->dev->name);
549 goto failed; 595 goto failed;
550 } 596 }
551 txb->encrypted = 0; 597 txb->encrypted = 0;
552 txb->payload_size = len; 598 txb->payload_size = total_len;
553 599
554 skb_frag = txb->fragments[0]; 600 skb_frag = txb->fragments[0];
555 601
556 memcpy(skb_put(skb_frag, len), frame, len); 602 memcpy(skb_put(skb_frag, total_len), frame, total_len);
557 603
558 if (ieee->config & 604 if (ieee->config &
559 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 605 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
560 skb_put(skb_frag, 4); 606 skb_put(skb_frag, 4);
561 607
608 /* To avoid overcomplicating things, we do the corner-case frame
609 * encryption in software. The only real situation where encryption is
610 * needed here is during software-based shared key authentication. */
611 if (encrypt_mpdu)
612 ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
613
562 success: 614 success:
563 spin_unlock_irqrestore(&ieee->lock, flags); 615 spin_unlock_irqrestore(&ieee->lock, flags);
564 616
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index b885fd189403..a78c4f845f66 100644
--- a/net/ieee80211/ieee80211_wx.c
+++ b/net/ieee80211/ieee80211_wx.c
@@ -50,7 +50,8 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
50 char *p; 50 char *p;
51 struct iw_event iwe; 51 struct iw_event iwe;
52 int i, j; 52 int i, j;
53 u8 max_rate, rate; 53 char *current_val; /* For rates */
54 u8 rate;
54 55
55 /* First entry *MUST* be the AP MAC address */ 56 /* First entry *MUST* be the AP MAC address */
56 iwe.cmd = SIOCGIWAP; 57 iwe.cmd = SIOCGIWAP;
@@ -107,9 +108,13 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
107 start = iwe_stream_add_point(start, stop, &iwe, network->ssid); 108 start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
108 109
109 /* Add basic and extended rates */ 110 /* Add basic and extended rates */
110 max_rate = 0; 111 /* Rate : stuffing multiple values in a single event require a bit
111 p = custom; 112 * more of magic - Jean II */
112 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); 113 current_val = start + IW_EV_LCP_LEN;
114 iwe.cmd = SIOCGIWRATE;
115 /* Those two flags are ignored... */
116 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
117
113 for (i = 0, j = 0; i < network->rates_len;) { 118 for (i = 0, j = 0; i < network->rates_len;) {
114 if (j < network->rates_ex_len && 119 if (j < network->rates_ex_len &&
115 ((network->rates_ex[j] & 0x7F) < 120 ((network->rates_ex[j] & 0x7F) <
@@ -117,28 +122,21 @@ static char *ieee80211_translate_scan(struct ieee80211_device *ieee,
117 rate = network->rates_ex[j++] & 0x7F; 122 rate = network->rates_ex[j++] & 0x7F;
118 else 123 else
119 rate = network->rates[i++] & 0x7F; 124 rate = network->rates[i++] & 0x7F;
120 if (rate > max_rate) 125 /* Bit rate given in 500 kb/s units (+ 0x80) */
121 max_rate = rate; 126 iwe.u.bitrate.value = ((rate & 0x7f) * 500000);
122 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), 127 /* Add new value to event */
123 "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); 128 current_val = iwe_stream_add_value(start, current_val, stop, &iwe, IW_EV_PARAM_LEN);
124 } 129 }
125 for (; j < network->rates_ex_len; j++) { 130 for (; j < network->rates_ex_len; j++) {
126 rate = network->rates_ex[j] & 0x7F; 131 rate = network->rates_ex[j] & 0x7F;
127 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), 132 /* Bit rate given in 500 kb/s units (+ 0x80) */
128 "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); 133 iwe.u.bitrate.value = ((rate & 0x7f) * 500000);
129 if (rate > max_rate) 134 /* Add new value to event */
130 max_rate = rate; 135 current_val = iwe_stream_add_value(start, current_val, stop, &iwe, IW_EV_PARAM_LEN);
131 } 136 }
132 137 /* Check if we added any rate */
133 iwe.cmd = SIOCGIWRATE; 138 if((current_val - start) > IW_EV_LCP_LEN)
134 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; 139 start = current_val;
135 iwe.u.bitrate.value = max_rate * 500000;
136 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_PARAM_LEN);
137
138 iwe.cmd = IWEVCUSTOM;
139 iwe.u.data.length = p - custom;
140 if (iwe.u.data.length)
141 start = iwe_stream_add_point(start, stop, &iwe, custom);
142 140
143 /* Add quality statistics */ 141 /* Add quality statistics */
144 iwe.cmd = IWEVQUAL; 142 iwe.cmd = IWEVQUAL;
@@ -505,7 +503,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
505 len = sec->key_sizes[key]; 503 len = sec->key_sizes[key];
506 memcpy(keybuf, sec->keys[key], len); 504 memcpy(keybuf, sec->keys[key], len);
507 505
508 erq->length = (len >= 0 ? len : 0); 506 erq->length = len;
509 erq->flags |= IW_ENCODE_ENABLED; 507 erq->flags |= IW_ENCODE_ENABLED;
510 508
511 if (ieee->open_wep) 509 if (ieee->open_wep)
diff --git a/net/ieee80211/softmac/Kconfig b/net/ieee80211/softmac/Kconfig
index f2a27cc6ecb1..2811651cb134 100644
--- a/net/ieee80211/softmac/Kconfig
+++ b/net/ieee80211/softmac/Kconfig
@@ -2,6 +2,7 @@ config IEEE80211_SOFTMAC
2 tristate "Software MAC add-on to the IEEE 802.11 networking stack" 2 tristate "Software MAC add-on to the IEEE 802.11 networking stack"
3 depends on IEEE80211 && EXPERIMENTAL 3 depends on IEEE80211 && EXPERIMENTAL
4 select WIRELESS_EXT 4 select WIRELESS_EXT
5 select IEEE80211_CRYPT_WEP
5 ---help--- 6 ---help---
6 This option enables the hardware independent software MAC addon 7 This option enables the hardware independent software MAC addon
7 for the IEEE 802.11 networking stack. 8 for the IEEE 802.11 networking stack.
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index 57ea9f6f465c..5e9a90651d04 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -82,51 +82,52 @@ ieee80211softmac_assoc_timeout(void *d)
82 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, NULL); 82 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, NULL);
83} 83}
84 84
85/* Sends out a disassociation request to the desired AP */ 85void
86static void 86ieee80211softmac_disassoc(struct ieee80211softmac_device *mac)
87ieee80211softmac_disassoc(struct ieee80211softmac_device *mac, u16 reason)
88{ 87{
89 unsigned long flags; 88 unsigned long flags;
89
90 spin_lock_irqsave(&mac->lock, flags);
91 if (mac->associnfo.associating)
92 cancel_delayed_work(&mac->associnfo.timeout);
93
94 netif_carrier_off(mac->dev);
95
96 mac->associated = 0;
97 mac->associnfo.bssvalid = 0;
98 mac->associnfo.associating = 0;
99 ieee80211softmac_init_txrates(mac);
100 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_DISASSOCIATED, NULL);
101 spin_unlock_irqrestore(&mac->lock, flags);
102}
103
104/* Sends out a disassociation request to the desired AP */
105void
106ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason)
107{
90 struct ieee80211softmac_network *found; 108 struct ieee80211softmac_network *found;
91 109
92 if (mac->associnfo.bssvalid && mac->associated) { 110 if (mac->associnfo.bssvalid && mac->associated) {
93 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); 111 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
94 if (found) 112 if (found)
95 ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason); 113 ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason);
96 } else if (mac->associnfo.associating) {
97 cancel_delayed_work(&mac->associnfo.timeout);
98 } 114 }
99 115
100 /* Change our state */ 116 ieee80211softmac_disassoc(mac);
101 spin_lock_irqsave(&mac->lock, flags);
102 /* Do NOT clear bssvalid as that will break ieee80211softmac_assoc_work! */
103 mac->associated = 0;
104 mac->associnfo.associating = 0;
105 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_DISASSOCIATED, NULL);
106 spin_unlock_irqrestore(&mac->lock, flags);
107} 117}
108 118
109static inline int 119static inline int
110we_support_all_basic_rates(struct ieee80211softmac_device *mac, u8 *from, u8 from_len) 120we_support_all_basic_rates(struct ieee80211softmac_device *mac, u8 *from, u8 from_len)
111{ 121{
112 int idx, search, found; 122 int idx;
113 u8 rate, search_rate; 123 u8 rate;
114 124
115 for (idx = 0; idx < (from_len); idx++) { 125 for (idx = 0; idx < (from_len); idx++) {
116 rate = (from)[idx]; 126 rate = (from)[idx];
117 if (!(rate & IEEE80211_BASIC_RATE_MASK)) 127 if (!(rate & IEEE80211_BASIC_RATE_MASK))
118 continue; 128 continue;
119 found = 0;
120 rate &= ~IEEE80211_BASIC_RATE_MASK; 129 rate &= ~IEEE80211_BASIC_RATE_MASK;
121 for (search = 0; search < mac->ratesinfo.count; search++) { 130 if (!ieee80211softmac_ratesinfo_rate_supported(&mac->ratesinfo, rate))
122 search_rate = mac->ratesinfo.rates[search];
123 search_rate &= ~IEEE80211_BASIC_RATE_MASK;
124 if (rate == search_rate) {
125 found = 1;
126 break;
127 }
128 }
129 if (!found)
130 return 0; 131 return 0;
131 } 132 }
132 return 1; 133 return 1;
@@ -163,12 +164,28 @@ network_matches_request(struct ieee80211softmac_device *mac, struct ieee80211_ne
163} 164}
164 165
165static void 166static void
166ieee80211softmac_assoc_notify(struct net_device *dev, void *context) 167ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
167{ 168{
168 struct ieee80211softmac_device *mac = ieee80211_priv(dev); 169 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
169 ieee80211softmac_assoc_work((void*)mac); 170 ieee80211softmac_assoc_work((void*)mac);
170} 171}
171 172
173static void
174ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void *context)
175{
176 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
177
178 switch (event_type) {
179 case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
180 ieee80211softmac_assoc_work((void*)mac);
181 break;
182 case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
183 case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
184 ieee80211softmac_disassoc(mac);
185 break;
186 }
187}
188
172/* This function is called to handle userspace requests (asynchronously) */ 189/* This function is called to handle userspace requests (asynchronously) */
173void 190void
174ieee80211softmac_assoc_work(void *d) 191ieee80211softmac_assoc_work(void *d)
@@ -176,14 +193,18 @@ ieee80211softmac_assoc_work(void *d)
176 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 193 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d;
177 struct ieee80211softmac_network *found = NULL; 194 struct ieee80211softmac_network *found = NULL;
178 struct ieee80211_network *net = NULL, *best = NULL; 195 struct ieee80211_network *net = NULL, *best = NULL;
196 int bssvalid;
179 unsigned long flags; 197 unsigned long flags;
180 198
199 /* ieee80211_disassoc might clear this */
200 bssvalid = mac->associnfo.bssvalid;
201
181 /* meh */ 202 /* meh */
182 if (mac->associated) 203 if (mac->associated)
183 ieee80211softmac_disassoc(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT); 204 ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT);
184 205
185 /* try to find the requested network in our list, if we found one already */ 206 /* try to find the requested network in our list, if we found one already */
186 if (mac->associnfo.bssvalid || mac->associnfo.bssfixed) 207 if (bssvalid || mac->associnfo.bssfixed)
187 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid); 208 found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
188 209
189 /* Search the ieee80211 networks for this network if we didn't find it by bssid, 210 /* Search the ieee80211 networks for this network if we didn't find it by bssid,
@@ -244,7 +265,7 @@ ieee80211softmac_assoc_work(void *d)
244 * Maybe we can hope to have more memory after scanning finishes ;) 265 * Maybe we can hope to have more memory after scanning finishes ;)
245 */ 266 */
246 dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n"); 267 dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n");
247 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify, NULL); 268 ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
248 if (ieee80211softmac_start_scan(mac)) 269 if (ieee80211softmac_start_scan(mac))
249 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n"); 270 dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
250 return; 271 return;
@@ -279,7 +300,7 @@ ieee80211softmac_assoc_work(void *d)
279 * otherwise adding the notification would be racy. */ 300 * otherwise adding the notification would be racy. */
280 if (!ieee80211softmac_auth_req(mac, found)) { 301 if (!ieee80211softmac_auth_req(mac, found)) {
281 dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n"); 302 dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n");
282 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL); 303 ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
283 } else { 304 } else {
284 printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n"); 305 printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n");
285 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found); 306 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
@@ -297,6 +318,9 @@ ieee80211softmac_associated(struct ieee80211softmac_device *mac,
297 struct ieee80211softmac_network *net) 318 struct ieee80211softmac_network *net)
298{ 319{
299 mac->associnfo.associating = 0; 320 mac->associnfo.associating = 0;
321 mac->associnfo.supported_rates = net->supported_rates;
322 ieee80211softmac_recalc_txrates(mac);
323
300 mac->associated = 1; 324 mac->associated = 1;
301 if (mac->set_bssid_filter) 325 if (mac->set_bssid_filter)
302 mac->set_bssid_filter(mac->dev, net->bssid); 326 mac->set_bssid_filter(mac->dev, net->bssid);
@@ -380,7 +404,6 @@ ieee80211softmac_handle_disassoc(struct net_device * dev,
380 struct ieee80211_disassoc *disassoc) 404 struct ieee80211_disassoc *disassoc)
381{ 405{
382 struct ieee80211softmac_device *mac = ieee80211_priv(dev); 406 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
383 unsigned long flags;
384 407
385 if (unlikely(!mac->running)) 408 if (unlikely(!mac->running))
386 return -ENODEV; 409 return -ENODEV;
@@ -392,14 +415,11 @@ ieee80211softmac_handle_disassoc(struct net_device * dev,
392 return 0; 415 return 0;
393 416
394 dprintk(KERN_INFO PFX "got disassoc frame\n"); 417 dprintk(KERN_INFO PFX "got disassoc frame\n");
395 netif_carrier_off(dev); 418 ieee80211softmac_disassoc(mac);
396 spin_lock_irqsave(&mac->lock, flags); 419
397 mac->associnfo.bssvalid = 0; 420 /* try to reassociate */
398 mac->associated = 0;
399 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_DISASSOCIATED, NULL);
400 schedule_work(&mac->associnfo.work); 421 schedule_work(&mac->associnfo.work);
401 spin_unlock_irqrestore(&mac->lock, flags); 422
402
403 return 0; 423 return 0;
404} 424}
405 425
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
index 06e332624665..90b8484e509b 100644
--- a/net/ieee80211/softmac/ieee80211softmac_auth.c
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -107,6 +107,7 @@ ieee80211softmac_auth_queue(void *data)
107 printkl(KERN_WARNING PFX "Authentication timed out with "MAC_FMT"\n", MAC_ARG(net->bssid)); 107 printkl(KERN_WARNING PFX "Authentication timed out with "MAC_FMT"\n", MAC_ARG(net->bssid));
108 /* Remove this item from the queue */ 108 /* Remove this item from the queue */
109 spin_lock_irqsave(&mac->lock, flags); 109 spin_lock_irqsave(&mac->lock, flags);
110 net->authenticating = 0;
110 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT, net); 111 ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT, net);
111 cancel_delayed_work(&auth->work); /* just to make sure... */ 112 cancel_delayed_work(&auth->work); /* just to make sure... */
112 list_del(&auth->list); 113 list_del(&auth->list);
@@ -212,13 +213,13 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
212 aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; 213 aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE;
213 spin_unlock_irqrestore(&mac->lock, flags); 214 spin_unlock_irqrestore(&mac->lock, flags);
214 215
215 /* Switch to correct channel for this network */ 216 /* Send our response */
216 mac->set_channel(mac->dev, net->channel);
217
218 /* Send our response (How to encrypt?) */
219 ieee80211softmac_send_mgt_frame(mac, aq->net, IEEE80211_STYPE_AUTH, aq->state); 217 ieee80211softmac_send_mgt_frame(mac, aq->net, IEEE80211_STYPE_AUTH, aq->state);
220 break; 218 return 0;
221 case IEEE80211SOFTMAC_AUTH_SHARED_PASS: 219 case IEEE80211SOFTMAC_AUTH_SHARED_PASS:
220 kfree(net->challenge);
221 net->challenge = NULL;
222 net->challenge_len = 0;
222 /* Check the status code of the response */ 223 /* Check the status code of the response */
223 switch(auth->status) { 224 switch(auth->status) {
224 case WLAN_STATUS_SUCCESS: 225 case WLAN_STATUS_SUCCESS:
@@ -229,6 +230,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
229 spin_unlock_irqrestore(&mac->lock, flags); 230 spin_unlock_irqrestore(&mac->lock, flags);
230 printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n", 231 printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n",
231 MAC_ARG(net->bssid)); 232 MAC_ARG(net->bssid));
233 ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_AUTHENTICATED, net);
232 break; 234 break;
233 default: 235 default:
234 printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n", 236 printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n",
@@ -279,6 +281,9 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
279 struct list_head *list_ptr; 281 struct list_head *list_ptr;
280 unsigned long flags; 282 unsigned long flags;
281 283
284 /* deauthentication implies disassociation */
285 ieee80211softmac_disassoc(mac);
286
282 /* Lock and reset status flags */ 287 /* Lock and reset status flags */
283 spin_lock_irqsave(&mac->lock, flags); 288 spin_lock_irqsave(&mac->lock, flags);
284 net->authenticating = 0; 289 net->authenticating = 0;
diff --git a/net/ieee80211/softmac/ieee80211softmac_event.c b/net/ieee80211/softmac/ieee80211softmac_event.c
index 8cc8f3f0f8e7..f34fa2ef666b 100644
--- a/net/ieee80211/softmac/ieee80211softmac_event.c
+++ b/net/ieee80211/softmac/ieee80211softmac_event.c
@@ -38,7 +38,8 @@
38 * The event context is private and can only be used from 38 * The event context is private and can only be used from
39 * within this module. Its meaning varies with the event 39 * within this module. Its meaning varies with the event
40 * type: 40 * type:
41 * SCAN_FINISHED: no special meaning 41 * SCAN_FINISHED,
42 * DISASSOCIATED: NULL
42 * ASSOCIATED, 43 * ASSOCIATED,
43 * ASSOCIATE_FAILED, 44 * ASSOCIATE_FAILED,
44 * ASSOCIATE_TIMEOUT, 45 * ASSOCIATE_TIMEOUT,
@@ -59,15 +60,15 @@
59 */ 60 */
60 61
61static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = { 62static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = {
62 "scan finished", 63 NULL, /* scan finished */
63 "associated", 64 NULL, /* associated */
64 "associating failed", 65 "associating failed",
65 "associating timed out", 66 "associating timed out",
66 "authenticated", 67 "authenticated",
67 "authenticating failed", 68 "authenticating failed",
68 "authenticating timed out", 69 "authenticating timed out",
69 "associating failed because no suitable network was found", 70 "associating failed because no suitable network was found",
70 "disassociated", 71 NULL, /* disassociated */
71}; 72};
72 73
73 74
@@ -77,7 +78,7 @@ ieee80211softmac_notify_callback(void *d)
77 struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d; 78 struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d;
78 kfree(d); 79 kfree(d);
79 80
80 event.fun(event.mac->dev, event.context); 81 event.fun(event.mac->dev, event.event_type, event.context);
81} 82}
82 83
83int 84int
@@ -136,30 +137,24 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
136 int we_event; 137 int we_event;
137 char *msg = NULL; 138 char *msg = NULL;
138 139
140 memset(&wrqu, '\0', sizeof (union iwreq_data));
141
139 switch(event) { 142 switch(event) {
140 case IEEE80211SOFTMAC_EVENT_ASSOCIATED: 143 case IEEE80211SOFTMAC_EVENT_ASSOCIATED:
141 network = (struct ieee80211softmac_network *)event_ctx; 144 network = (struct ieee80211softmac_network *)event_ctx;
142 wrqu.data.length = 0;
143 wrqu.data.flags = 0;
144 memcpy(wrqu.ap_addr.sa_data, &network->bssid[0], ETH_ALEN); 145 memcpy(wrqu.ap_addr.sa_data, &network->bssid[0], ETH_ALEN);
145 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 146 /* fall through */
146 we_event = SIOCGIWAP;
147 break;
148 case IEEE80211SOFTMAC_EVENT_DISASSOCIATED: 147 case IEEE80211SOFTMAC_EVENT_DISASSOCIATED:
149 wrqu.data.length = 0;
150 wrqu.data.flags = 0;
151 memset(&wrqu, '\0', sizeof (union iwreq_data));
152 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 148 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
153 we_event = SIOCGIWAP; 149 we_event = SIOCGIWAP;
154 break; 150 break;
155 case IEEE80211SOFTMAC_EVENT_SCAN_FINISHED: 151 case IEEE80211SOFTMAC_EVENT_SCAN_FINISHED:
156 wrqu.data.length = 0;
157 wrqu.data.flags = 0;
158 memset(&wrqu, '\0', sizeof (union iwreq_data));
159 we_event = SIOCGIWSCAN; 152 we_event = SIOCGIWSCAN;
160 break; 153 break;
161 default: 154 default:
162 msg = event_descriptions[event]; 155 msg = event_descriptions[event];
156 if (!msg)
157 msg = "SOFTMAC EVENT BUG";
163 wrqu.data.length = strlen(msg); 158 wrqu.data.length = strlen(msg);
164 we_event = IWEVCUSTOM; 159 we_event = IWEVCUSTOM;
165 break; 160 break;
@@ -172,6 +167,9 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
172 if ((eventptr->event_type == event || eventptr->event_type == -1) 167 if ((eventptr->event_type == event || eventptr->event_type == -1)
173 && (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) { 168 && (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) {
174 list_del(&eventptr->list); 169 list_del(&eventptr->list);
170 /* User may have subscribed to ANY event, so
171 * we tell them which event triggered it. */
172 eventptr->event_type = event;
175 schedule_work(&eventptr->work); 173 schedule_work(&eventptr->work);
176 } 174 }
177 } 175 }
diff --git a/net/ieee80211/softmac/ieee80211softmac_io.c b/net/ieee80211/softmac/ieee80211softmac_io.c
index cc6cd56c85b1..09541611e48c 100644
--- a/net/ieee80211/softmac/ieee80211softmac_io.c
+++ b/net/ieee80211/softmac/ieee80211softmac_io.c
@@ -149,6 +149,56 @@ ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac,
149 * shouldn't the sequence number be in ieee80211? */ 149 * shouldn't the sequence number be in ieee80211? */
150} 150}
151 151
152static u16
153ieee80211softmac_capabilities(struct ieee80211softmac_device *mac,
154 struct ieee80211softmac_network *net)
155{
156 u16 capability = 0;
157
158 /* ESS and IBSS bits are set according to the current mode */
159 switch (mac->ieee->iw_mode) {
160 case IW_MODE_INFRA:
161 capability = cpu_to_le16(WLAN_CAPABILITY_ESS);
162 break;
163 case IW_MODE_ADHOC:
164 capability = cpu_to_le16(WLAN_CAPABILITY_IBSS);
165 break;
166 case IW_MODE_AUTO:
167 capability = net->capabilities &
168 (WLAN_CAPABILITY_ESS|WLAN_CAPABILITY_IBSS);
169 break;
170 default:
171 /* bleh. we don't ever go to these modes */
172 printk(KERN_ERR PFX "invalid iw_mode!\n");
173 break;
174 }
175
176 /* CF Pollable / CF Poll Request */
177 /* Needs to be implemented, for now, the 0's == not supported */
178
179 /* Privacy Bit */
180 capability |= mac->ieee->sec.level ?
181 cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
182
183 /* Short Preamble */
184 /* Always supported: we probably won't ever be powering devices which
185 * dont support this... */
186 capability |= WLAN_CAPABILITY_SHORT_PREAMBLE;
187
188 /* PBCC */
189 /* Not widely used */
190
191 /* Channel Agility */
192 /* Not widely used */
193
194 /* Short Slot */
195 /* Will be implemented later */
196
197 /* DSSS-OFDM */
198 /* Not widely used */
199
200 return capability;
201}
152 202
153/***************************************************************************** 203/*****************************************************************************
154 * Create Management packets 204 * Create Management packets
@@ -179,27 +229,6 @@ ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt,
179 return 0; 229 return 0;
180 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_ASSOC_REQ, net->bssid, net->bssid); 230 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_ASSOC_REQ, net->bssid, net->bssid);
181 231
182 /* Fill in capability Info */
183 switch (mac->ieee->iw_mode) {
184 case IW_MODE_INFRA:
185 (*pkt)->capability = cpu_to_le16(WLAN_CAPABILITY_ESS);
186 break;
187 case IW_MODE_ADHOC:
188 (*pkt)->capability = cpu_to_le16(WLAN_CAPABILITY_IBSS);
189 break;
190 case IW_MODE_AUTO:
191 (*pkt)->capability = net->capabilities & (WLAN_CAPABILITY_ESS|WLAN_CAPABILITY_IBSS);
192 break;
193 default:
194 /* bleh. we don't ever go to these modes */
195 printk(KERN_ERR PFX "invalid iw_mode!\n");
196 break;
197 }
198 /* Need to add this
199 (*pkt)->capability |= mac->ieee->short_slot ?
200 cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;
201 */
202 (*pkt)->capability |= mac->ieee->sec.level ? cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
203 /* Fill in Listen Interval (?) */ 232 /* Fill in Listen Interval (?) */
204 (*pkt)->listen_interval = cpu_to_le16(10); 233 (*pkt)->listen_interval = cpu_to_le16(10);
205 234
@@ -239,17 +268,9 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
239 return 0; 268 return 0;
240 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_REASSOC_REQ, net->bssid, net->bssid); 269 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_REASSOC_REQ, net->bssid, net->bssid);
241 270
242 /* Fill in capability Info */ 271 /* Fill in the capabilities */
243 (*pkt)->capability = mac->ieee->iw_mode == IW_MODE_MASTER ? 272 (*pkt)->capability = ieee80211softmac_capabilities(mac, net);
244 cpu_to_le16(WLAN_CAPABILITY_ESS) : 273
245 cpu_to_le16(WLAN_CAPABILITY_IBSS);
246 /*
247 (*pkt)->capability |= mac->ieee->short_slot ?
248 cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;
249 */
250 (*pkt)->capability |= mac->ieee->sec.level ?
251 cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
252
253 /* Fill in Listen Interval (?) */ 274 /* Fill in Listen Interval (?) */
254 (*pkt)->listen_interval = cpu_to_le16(10); 275 (*pkt)->listen_interval = cpu_to_le16(10);
255 /* Fill in the current AP MAC */ 276 /* Fill in the current AP MAC */
@@ -268,26 +289,27 @@ ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
268static u32 289static u32
269ieee80211softmac_auth(struct ieee80211_auth **pkt, 290ieee80211softmac_auth(struct ieee80211_auth **pkt,
270 struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, 291 struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
271 u16 transaction, u16 status) 292 u16 transaction, u16 status, int *encrypt_mpdu)
272{ 293{
273 u8 *data; 294 u8 *data;
295 int auth_mode = mac->ieee->sec.auth_mode;
296 int is_shared_response = (auth_mode == WLAN_AUTH_SHARED_KEY
297 && transaction == IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE);
298
274 /* Allocate Packet */ 299 /* Allocate Packet */
275 (*pkt) = (struct ieee80211_auth *)ieee80211softmac_alloc_mgt( 300 (*pkt) = (struct ieee80211_auth *)ieee80211softmac_alloc_mgt(
276 2 + /* Auth Algorithm */ 301 2 + /* Auth Algorithm */
277 2 + /* Auth Transaction Seq */ 302 2 + /* Auth Transaction Seq */
278 2 + /* Status Code */ 303 2 + /* Status Code */
279 /* Challenge Text IE */ 304 /* Challenge Text IE */
280 mac->ieee->open_wep ? 0 : 305 is_shared_response ? 0 : 1 + 1 + net->challenge_len
281 1 + 1 + WLAN_AUTH_CHALLENGE_LEN 306 );
282 );
283 if (unlikely((*pkt) == NULL)) 307 if (unlikely((*pkt) == NULL))
284 return 0; 308 return 0;
285 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid); 309 ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid);
286 310
287 /* Algorithm */ 311 /* Algorithm */
288 (*pkt)->algorithm = mac->ieee->open_wep ? 312 (*pkt)->algorithm = cpu_to_le16(auth_mode);
289 cpu_to_le16(WLAN_AUTH_OPEN) :
290 cpu_to_le16(WLAN_AUTH_SHARED_KEY);
291 /* Transaction */ 313 /* Transaction */
292 (*pkt)->transaction = cpu_to_le16(transaction); 314 (*pkt)->transaction = cpu_to_le16(transaction);
293 /* Status */ 315 /* Status */
@@ -295,18 +317,20 @@ ieee80211softmac_auth(struct ieee80211_auth **pkt,
295 317
296 data = (u8 *)(*pkt)->info_element; 318 data = (u8 *)(*pkt)->info_element;
297 /* Challenge Text */ 319 /* Challenge Text */
298 if(!mac->ieee->open_wep){ 320 if (is_shared_response) {
299 *data = MFIE_TYPE_CHALLENGE; 321 *data = MFIE_TYPE_CHALLENGE;
300 data++; 322 data++;
301 323
302 /* Copy the challenge in */ 324 /* Copy the challenge in */
303 // *data = challenge length 325 *data = net->challenge_len;
304 // data += sizeof(u16); 326 data++;
305 // memcpy(data, challenge, challenge length); 327 memcpy(data, net->challenge, net->challenge_len);
306 // data += challenge length; 328 data += net->challenge_len;
307 329
308 /* Add the full size to the packet length */ 330 /* Make sure this frame gets encrypted with the shared key */
309 } 331 *encrypt_mpdu = 1;
332 } else
333 *encrypt_mpdu = 0;
310 334
311 /* Return the packet size */ 335 /* Return the packet size */
312 return (data - (u8 *)(*pkt)); 336 return (data - (u8 *)(*pkt));
@@ -396,6 +420,7 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
396{ 420{
397 void *pkt = NULL; 421 void *pkt = NULL;
398 u32 pkt_size = 0; 422 u32 pkt_size = 0;
423 int encrypt_mpdu = 0;
399 424
400 switch(type) { 425 switch(type) {
401 case IEEE80211_STYPE_ASSOC_REQ: 426 case IEEE80211_STYPE_ASSOC_REQ:
@@ -405,7 +430,7 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
405 pkt_size = ieee80211softmac_reassoc_req((struct ieee80211_reassoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg); 430 pkt_size = ieee80211softmac_reassoc_req((struct ieee80211_reassoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);
406 break; 431 break;
407 case IEEE80211_STYPE_AUTH: 432 case IEEE80211_STYPE_AUTH:
408 pkt_size = ieee80211softmac_auth((struct ieee80211_auth **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, (u16)(arg & 0xFFFF), (u16) (arg >> 16)); 433 pkt_size = ieee80211softmac_auth((struct ieee80211_auth **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, (u16)(arg & 0xFFFF), (u16) (arg >> 16), &encrypt_mpdu);
409 break; 434 break;
410 case IEEE80211_STYPE_DISASSOC: 435 case IEEE80211_STYPE_DISASSOC:
411 case IEEE80211_STYPE_DEAUTH: 436 case IEEE80211_STYPE_DEAUTH:
@@ -434,52 +459,8 @@ ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
434 * or get rid of it alltogether? 459 * or get rid of it alltogether?
435 * Does this work for you now? 460 * Does this work for you now?
436 */ 461 */
437 ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *)pkt, pkt_size); 462 ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *)pkt,
438 463 IEEE80211_3ADDR_LEN, pkt_size, encrypt_mpdu);
439 kfree(pkt);
440 return 0;
441}
442
443
444/* Create an rts/cts frame */
445static u32
446ieee80211softmac_rts_cts(struct ieee80211_hdr_2addr **pkt,
447 struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
448 u32 type)
449{
450 /* Allocate Packet */
451 (*pkt) = kmalloc(IEEE80211_2ADDR_LEN, GFP_ATOMIC);
452 memset(*pkt, 0, IEEE80211_2ADDR_LEN);
453 if((*pkt) == NULL)
454 return 0;
455 ieee80211softmac_hdr_2addr(mac, (*pkt), type, net->bssid);
456 return IEEE80211_2ADDR_LEN;
457}
458
459
460/* Sends a control packet */
461static int
462ieee80211softmac_send_ctl_frame(struct ieee80211softmac_device *mac,
463 struct ieee80211softmac_network *net, u32 type, u32 arg)
464{
465 void *pkt = NULL;
466 u32 pkt_size = 0;
467
468 switch(type) {
469 case IEEE80211_STYPE_RTS:
470 case IEEE80211_STYPE_CTS:
471 pkt_size = ieee80211softmac_rts_cts((struct ieee80211_hdr_2addr **)(&pkt), mac, net, type);
472 break;
473 default:
474 printkl(KERN_DEBUG PFX "Unsupported Control Frame type: %i\n", type);
475 return -EINVAL;
476 }
477
478 if(pkt_size == 0)
479 return -ENOMEM;
480
481 /* Send the packet to the ieee80211 layer for tx */
482 ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *) pkt, pkt_size);
483 464
484 kfree(pkt); 465 kfree(pkt);
485 return 0; 466 return 0;
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
index 6252be2c0db9..4b2e57d12418 100644
--- a/net/ieee80211/softmac/ieee80211softmac_module.c
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -26,6 +26,7 @@
26 26
27#include "ieee80211softmac_priv.h" 27#include "ieee80211softmac_priv.h"
28#include <linux/sort.h> 28#include <linux/sort.h>
29#include <linux/etherdevice.h>
29 30
30struct net_device *alloc_ieee80211softmac(int sizeof_priv) 31struct net_device *alloc_ieee80211softmac(int sizeof_priv)
31{ 32{
@@ -61,14 +62,6 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
61 softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation; 62 softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation;
62 softmac->stop_scan = ieee80211softmac_stop_scan_implementation; 63 softmac->stop_scan = ieee80211softmac_stop_scan_implementation;
63 64
64 //TODO: The mcast rate has to be assigned dynamically somewhere (in scanning, association. Not sure...)
65 // It has to be set to the highest rate all stations in the current network can handle.
66 softmac->txrates.mcast_rate = IEEE80211_CCK_RATE_1MB;
67 softmac->txrates.mcast_fallback = IEEE80211_CCK_RATE_1MB;
68 /* This is reassigned in ieee80211softmac_start to sane values. */
69 softmac->txrates.default_rate = IEEE80211_CCK_RATE_1MB;
70 softmac->txrates.default_fallback = IEEE80211_CCK_RATE_1MB;
71
72 /* to start with, we can't send anything ... */ 65 /* to start with, we can't send anything ... */
73 netif_carrier_off(dev); 66 netif_carrier_off(dev);
74 67
@@ -170,15 +163,82 @@ static void ieee80211softmac_start_check_rates(struct ieee80211softmac_device *m
170 } 163 }
171} 164}
172 165
173void ieee80211softmac_start(struct net_device *dev) 166int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo *ri, u8 rate)
167{
168 int search;
169 u8 search_rate;
170
171 for (search = 0; search < ri->count; search++) {
172 search_rate = ri->rates[search];
173 search_rate &= ~IEEE80211_BASIC_RATE_MASK;
174 if (rate == search_rate)
175 return 1;
176 }
177
178 return 0;
179}
180
181/* Finds the highest rate which is:
182 * 1. Present in ri (optionally a basic rate)
183 * 2. Supported by the device
184 * 3. Less than or equal to the user-defined rate
185 */
186static u8 highest_supported_rate(struct ieee80211softmac_device *mac,
187 struct ieee80211softmac_ratesinfo *ri, int basic_only)
188{
189 u8 user_rate = mac->txrates.user_rate;
190 int i;
191
192 if (ri->count == 0) {
193 dprintk(KERN_ERR PFX "empty ratesinfo?\n");
194 return IEEE80211_CCK_RATE_1MB;
195 }
196
197 for (i = ri->count - 1; i >= 0; i--) {
198 u8 rate = ri->rates[i];
199 if (basic_only && !(rate & IEEE80211_BASIC_RATE_MASK))
200 continue;
201 rate &= ~IEEE80211_BASIC_RATE_MASK;
202 if (rate > user_rate)
203 continue;
204 if (ieee80211softmac_ratesinfo_rate_supported(&mac->ratesinfo, rate))
205 return rate;
206 }
207
208 /* If we haven't found a suitable rate by now, just trust the user */
209 return user_rate;
210}
211
212void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac)
213{
214 struct ieee80211softmac_txrates *txrates = &mac->txrates;
215 struct ieee80211softmac_txrates oldrates;
216 u32 change = 0;
217
218 if (mac->txrates_change)
219 oldrates = mac->txrates;
220
221 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
222 txrates->default_rate = highest_supported_rate(mac, &mac->associnfo.supported_rates, 0);
223
224 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
225 txrates->default_fallback = lower_rate(mac, txrates->default_rate);
226
227 change |= IEEE80211SOFTMAC_TXRATECHG_MCAST;
228 txrates->mcast_rate = highest_supported_rate(mac, &mac->associnfo.supported_rates, 1);
229
230 if (mac->txrates_change)
231 mac->txrates_change(mac->dev, change, &oldrates);
232
233}
234
235void ieee80211softmac_init_txrates(struct ieee80211softmac_device *mac)
174{ 236{
175 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
176 struct ieee80211_device *ieee = mac->ieee; 237 struct ieee80211_device *ieee = mac->ieee;
177 u32 change = 0; 238 u32 change = 0;
239 struct ieee80211softmac_txrates *txrates = &mac->txrates;
178 struct ieee80211softmac_txrates oldrates; 240 struct ieee80211softmac_txrates oldrates;
179 241
180 ieee80211softmac_start_check_rates(mac);
181
182 /* TODO: We need some kind of state machine to lower the default rates 242 /* TODO: We need some kind of state machine to lower the default rates
183 * if we loose too many packets. 243 * if we loose too many packets.
184 */ 244 */
@@ -193,22 +253,37 @@ void ieee80211softmac_start(struct net_device *dev)
193 more reliable. Note similar logic in 253 more reliable. Note similar logic in
194 ieee80211softmac_wx_set_rate() */ 254 ieee80211softmac_wx_set_rate() */
195 if (ieee->modulation & IEEE80211_CCK_MODULATION) { 255 if (ieee->modulation & IEEE80211_CCK_MODULATION) {
196 mac->txrates.default_rate = IEEE80211_CCK_RATE_11MB; 256 txrates->user_rate = IEEE80211_CCK_RATE_11MB;
197 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
198 mac->txrates.default_fallback = IEEE80211_CCK_RATE_5MB;
199 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
200 } else if (ieee->modulation & IEEE80211_OFDM_MODULATION) { 257 } else if (ieee->modulation & IEEE80211_OFDM_MODULATION) {
201 mac->txrates.default_rate = IEEE80211_OFDM_RATE_54MB; 258 txrates->user_rate = IEEE80211_OFDM_RATE_54MB;
202 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
203 mac->txrates.default_fallback = IEEE80211_OFDM_RATE_24MB;
204 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
205 } else 259 } else
206 assert(0); 260 assert(0);
261
262 txrates->default_rate = IEEE80211_CCK_RATE_1MB;
263 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
264
265 txrates->default_fallback = IEEE80211_CCK_RATE_1MB;
266 change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
267
268 txrates->mcast_rate = IEEE80211_CCK_RATE_1MB;
269 change |= IEEE80211SOFTMAC_TXRATECHG_MCAST;
270
271 txrates->mgt_mcast_rate = IEEE80211_CCK_RATE_1MB;
272 change |= IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST;
273
207 if (mac->txrates_change) 274 if (mac->txrates_change)
208 mac->txrates_change(dev, change, &oldrates); 275 mac->txrates_change(mac->dev, change, &oldrates);
209 276
210 mac->running = 1; 277 mac->running = 1;
211} 278}
279
280void ieee80211softmac_start(struct net_device *dev)
281{
282 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
283
284 ieee80211softmac_start_check_rates(mac);
285 ieee80211softmac_init_txrates(mac);
286}
212EXPORT_SYMBOL_GPL(ieee80211softmac_start); 287EXPORT_SYMBOL_GPL(ieee80211softmac_start);
213 288
214void ieee80211softmac_stop(struct net_device *dev) 289void ieee80211softmac_stop(struct net_device *dev)
diff --git a/net/ieee80211/softmac/ieee80211softmac_priv.h b/net/ieee80211/softmac/ieee80211softmac_priv.h
index 65d9816c8ecc..fa1f8e3acfc0 100644
--- a/net/ieee80211/softmac/ieee80211softmac_priv.h
+++ b/net/ieee80211/softmac/ieee80211softmac_priv.h
@@ -116,7 +116,10 @@ ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
116 struct ieee80211softmac_essid *essid); 116 struct ieee80211softmac_essid *essid);
117 117
118/* Rates related */ 118/* Rates related */
119int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo *ri, u8 rate);
119u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta); 120u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
121void ieee80211softmac_init_txrates(struct ieee80211softmac_device *mac);
122void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac);
120static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) { 123static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
121 return ieee80211softmac_lower_rate_delta(mac, rate, 1); 124 return ieee80211softmac_lower_rate_delta(mac, rate, 1);
122} 125}
@@ -150,6 +153,8 @@ int ieee80211softmac_handle_disassoc(struct net_device * dev,
150int ieee80211softmac_handle_reassoc_req(struct net_device * dev, 153int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
151 struct ieee80211_reassoc_request * reassoc); 154 struct ieee80211_reassoc_request * reassoc);
152void ieee80211softmac_assoc_timeout(void *d); 155void ieee80211softmac_assoc_timeout(void *d);
156void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason);
157void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
153 158
154/* some helper functions */ 159/* some helper functions */
155static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm) 160static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 27edb2b5581a..22aa6199185b 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -211,8 +211,8 @@ ieee80211softmac_wx_set_rate(struct net_device *net_dev,
211 if (is_ofdm && !(ieee->modulation & IEEE80211_OFDM_MODULATION)) 211 if (is_ofdm && !(ieee->modulation & IEEE80211_OFDM_MODULATION))
212 goto out_unlock; 212 goto out_unlock;
213 213
214 mac->txrates.default_rate = rate; 214 mac->txrates.user_rate = rate;
215 mac->txrates.default_fallback = lower_rate(mac, rate); 215 ieee80211softmac_recalc_txrates(mac);
216 err = 0; 216 err = 0;
217 217
218out_unlock: 218out_unlock:
@@ -431,3 +431,35 @@ ieee80211softmac_wx_get_genie(struct net_device *dev,
431} 431}
432EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie); 432EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie);
433 433
434int
435ieee80211softmac_wx_set_mlme(struct net_device *dev,
436 struct iw_request_info *info,
437 union iwreq_data *wrqu,
438 char *extra)
439{
440 struct ieee80211softmac_device *mac = ieee80211_priv(dev);
441 struct iw_mlme *mlme = (struct iw_mlme *)extra;
442 u16 reason = cpu_to_le16(mlme->reason_code);
443 struct ieee80211softmac_network *net;
444
445 if (memcmp(mac->associnfo.bssid, mlme->addr.sa_data, ETH_ALEN)) {
446 printk(KERN_DEBUG PFX "wx_set_mlme: requested operation on net we don't use\n");
447 return -EINVAL;
448 }
449
450 switch (mlme->cmd) {
451 case IW_MLME_DEAUTH:
452 net = ieee80211softmac_get_network_by_bssid_locked(mac, mlme->addr.sa_data);
453 if (!net) {
454 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n");
455 return -EINVAL;
456 }
457 return ieee80211softmac_deauth_req(mac, net, reason);
458 case IW_MLME_DISASSOC:
459 ieee80211softmac_send_disassoc_req(mac, reason);
460 return 0;
461 default:
462 return -EOPNOTSUPP;
463 }
464}
465EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_mlme);
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index e40f75322377..da33393be45f 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -414,6 +414,24 @@ config INET_TUNNEL
414 tristate 414 tristate
415 default n 415 default n
416 416
417config INET_XFRM_MODE_TRANSPORT
418 tristate "IP: IPsec transport mode"
419 default y
420 select XFRM
421 ---help---
422 Support for IPsec transport mode.
423
424 If unsure, say Y.
425
426config INET_XFRM_MODE_TUNNEL
427 tristate "IP: IPsec tunnel mode"
428 default y
429 select XFRM
430 ---help---
431 Support for IPsec tunnel mode.
432
433 If unsure, say Y.
434
417config INET_DIAG 435config INET_DIAG
418 tristate "INET: socket monitoring interface" 436 tristate "INET: socket monitoring interface"
419 default y 437 default y
@@ -532,6 +550,38 @@ config TCP_CONG_SCALABLE
532 properties, though is known to have fairness issues. 550 properties, though is known to have fairness issues.
533 See http://www-lce.eng.cam.ac.uk/~ctk21/scalable/ 551 See http://www-lce.eng.cam.ac.uk/~ctk21/scalable/
534 552
553config TCP_CONG_LP
554 tristate "TCP Low Priority"
555 depends on EXPERIMENTAL
556 default n
557 ---help---
558 TCP Low Priority (TCP-LP), a distributed algorithm whose goal is
559 to utiliza only the excess network bandwidth as compared to the
560 ``fair share`` of bandwidth as targeted by TCP.
561 See http://www-ece.rice.edu/networks/TCP-LP/
562
563config TCP_CONG_VENO
564 tristate "TCP Veno"
565 depends on EXPERIMENTAL
566 default n
567 ---help---
568 TCP Veno is a sender-side only enhancement of TCP to obtain better
569 throughput over wireless networks. TCP Veno makes use of state
570 distinguishing to circumvent the difficult judgment of the packet loss
571 type. TCP Veno cuts down less congestion window in response to random
572 loss packets.
573 See http://www.ntu.edu.sg/home5/ZHOU0022/papers/CPFu03a.pdf
574
575config TCP_CONG_COMPOUND
576 tristate "TCP Compound"
577 depends on EXPERIMENTAL
578 default n
579 ---help---
580 TCP Compound is a sender-side only change to TCP that uses
581 a mixed Reno/Vegas approach to calculate the cwnd.
582 For further details look here:
583 ftp://ftp.research.microsoft.com/pub/tr/TR-2005-86.pdf
584
535endmenu 585endmenu
536 586
537config TCP_CONG_BIC 587config TCP_CONG_BIC
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 9ef50a0b9d2c..38b8039bdd55 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -24,6 +24,8 @@ obj-$(CONFIG_INET_ESP) += esp4.o
24obj-$(CONFIG_INET_IPCOMP) += ipcomp.o 24obj-$(CONFIG_INET_IPCOMP) += ipcomp.o
25obj-$(CONFIG_INET_XFRM_TUNNEL) += xfrm4_tunnel.o 25obj-$(CONFIG_INET_XFRM_TUNNEL) += xfrm4_tunnel.o
26obj-$(CONFIG_INET_TUNNEL) += tunnel4.o 26obj-$(CONFIG_INET_TUNNEL) += tunnel4.o
27obj-$(CONFIG_INET_XFRM_MODE_TRANSPORT) += xfrm4_mode_transport.o
28obj-$(CONFIG_INET_XFRM_MODE_TUNNEL) += xfrm4_mode_tunnel.o
27obj-$(CONFIG_IP_PNP) += ipconfig.o 29obj-$(CONFIG_IP_PNP) += ipconfig.o
28obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += multipath_rr.o 30obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += multipath_rr.o
29obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o 31obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o
@@ -34,6 +36,7 @@ obj-$(CONFIG_IP_VS) += ipvs/
34obj-$(CONFIG_INET_DIAG) += inet_diag.o 36obj-$(CONFIG_INET_DIAG) += inet_diag.o
35obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o 37obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o
36obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o 38obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o
39obj-$(CONFIG_NET_TCPPROBE) += tcp_probe.o
37obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o 40obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o
38obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o 41obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o
39obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o 42obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o
@@ -41,7 +44,10 @@ obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o
41obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o 44obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o
42obj-$(CONFIG_TCP_CONG_HTCP) += tcp_htcp.o 45obj-$(CONFIG_TCP_CONG_HTCP) += tcp_htcp.o
43obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o 46obj-$(CONFIG_TCP_CONG_VEGAS) += tcp_vegas.o
47obj-$(CONFIG_TCP_CONG_VENO) += tcp_veno.o
44obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o 48obj-$(CONFIG_TCP_CONG_SCALABLE) += tcp_scalable.o
49obj-$(CONFIG_TCP_CONG_LP) += tcp_lp.o
50obj-$(CONFIG_TCP_CONG_COMPOUND) += tcp_compound.o
45 51
46obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \ 52obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
47 xfrm4_output.o 53 xfrm4_output.o
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index e2e4771fa4c6..c7782230080d 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -119,6 +119,7 @@ error:
119static int ah_input(struct xfrm_state *x, struct sk_buff *skb) 119static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
120{ 120{
121 int ah_hlen; 121 int ah_hlen;
122 int ihl;
122 struct iphdr *iph; 123 struct iphdr *iph;
123 struct ip_auth_hdr *ah; 124 struct ip_auth_hdr *ah;
124 struct ah_data *ahp; 125 struct ah_data *ahp;
@@ -149,13 +150,14 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
149 ah = (struct ip_auth_hdr*)skb->data; 150 ah = (struct ip_auth_hdr*)skb->data;
150 iph = skb->nh.iph; 151 iph = skb->nh.iph;
151 152
152 memcpy(work_buf, iph, iph->ihl*4); 153 ihl = skb->data - skb->nh.raw;
154 memcpy(work_buf, iph, ihl);
153 155
154 iph->ttl = 0; 156 iph->ttl = 0;
155 iph->tos = 0; 157 iph->tos = 0;
156 iph->frag_off = 0; 158 iph->frag_off = 0;
157 iph->check = 0; 159 iph->check = 0;
158 if (iph->ihl != 5) { 160 if (ihl > sizeof(*iph)) {
159 u32 dummy; 161 u32 dummy;
160 if (ip_clear_mutable_options(iph, &dummy)) 162 if (ip_clear_mutable_options(iph, &dummy))
161 goto out; 163 goto out;
@@ -164,7 +166,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
164 u8 auth_data[MAX_AH_AUTH_LEN]; 166 u8 auth_data[MAX_AH_AUTH_LEN];
165 167
166 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len); 168 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
167 skb_push(skb, skb->data - skb->nh.raw); 169 skb_push(skb, ihl);
168 ahp->icv(ahp, skb, ah->auth_data); 170 ahp->icv(ahp, skb, ah->auth_data);
169 if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) { 171 if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) {
170 x->stats.integrity_failed++; 172 x->stats.integrity_failed++;
@@ -172,11 +174,8 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
172 } 174 }
173 } 175 }
174 ((struct iphdr*)work_buf)->protocol = ah->nexthdr; 176 ((struct iphdr*)work_buf)->protocol = ah->nexthdr;
175 skb->nh.raw = skb_pull(skb, ah_hlen); 177 skb->h.raw = memcpy(skb->nh.raw += ah_hlen, work_buf, ihl);
176 memcpy(skb->nh.raw, work_buf, iph->ihl*4); 178 __skb_pull(skb, ah_hlen + ihl);
177 skb->nh.iph->tot_len = htons(skb->len);
178 skb_pull(skb, skb->nh.iph->ihl*4);
179 skb->h.raw = skb->data;
180 179
181 return 0; 180 return 0;
182 181
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 9d1881c07a32..9bbdd4494551 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -143,10 +143,9 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
143 int alen = esp->auth.icv_trunc_len; 143 int alen = esp->auth.icv_trunc_len;
144 int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen; 144 int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen;
145 int nfrags; 145 int nfrags;
146 int encap_len = 0; 146 int ihl;
147 u8 nexthdr[2]; 147 u8 nexthdr[2];
148 struct scatterlist *sg; 148 struct scatterlist *sg;
149 u8 workbuf[60];
150 int padlen; 149 int padlen;
151 150
152 if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr))) 151 if (!pskb_may_pull(skb, sizeof(struct ip_esp_hdr)))
@@ -177,7 +176,6 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
177 skb->ip_summed = CHECKSUM_NONE; 176 skb->ip_summed = CHECKSUM_NONE;
178 177
179 esph = (struct ip_esp_hdr*)skb->data; 178 esph = (struct ip_esp_hdr*)skb->data;
180 iph = skb->nh.iph;
181 179
182 /* Get ivec. This can be wrong, check against another impls. */ 180 /* Get ivec. This can be wrong, check against another impls. */
183 if (esp->conf.ivlen) 181 if (esp->conf.ivlen)
@@ -204,12 +202,12 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
204 202
205 /* ... check padding bits here. Silly. :-) */ 203 /* ... check padding bits here. Silly. :-) */
206 204
205 iph = skb->nh.iph;
206 ihl = iph->ihl * 4;
207
207 if (x->encap) { 208 if (x->encap) {
208 struct xfrm_encap_tmpl *encap = x->encap; 209 struct xfrm_encap_tmpl *encap = x->encap;
209 struct udphdr *uh; 210 struct udphdr *uh = (void *)(skb->nh.raw + ihl);
210
211 uh = (struct udphdr *)(iph + 1);
212 encap_len = (void*)esph - (void*)uh;
213 211
214 /* 212 /*
215 * 1) if the NAT-T peer's IP or port changed then 213 * 1) if the NAT-T peer's IP or port changed then
@@ -246,11 +244,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
246 244
247 iph->protocol = nexthdr[1]; 245 iph->protocol = nexthdr[1];
248 pskb_trim(skb, skb->len - alen - padlen - 2); 246 pskb_trim(skb, skb->len - alen - padlen - 2);
249 memcpy(workbuf, skb->nh.raw, iph->ihl*4); 247 skb->h.raw = __skb_pull(skb, sizeof(*esph) + esp->conf.ivlen) - ihl;
250 skb->h.raw = skb_pull(skb, sizeof(struct ip_esp_hdr) + esp->conf.ivlen);
251 skb->nh.raw += encap_len + sizeof(struct ip_esp_hdr) + esp->conf.ivlen;
252 memcpy(skb->nh.raw, workbuf, iph->ihl*4);
253 skb->nh.iph->tot_len = htons(skb->len);
254 248
255 return 0; 249 return 0;
256 250
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index cdde96390960..31387abf53a2 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -666,3 +666,4 @@ void __init ip_fib_init(void)
666} 666}
667 667
668EXPORT_SYMBOL(inet_addr_type); 668EXPORT_SYMBOL(inet_addr_type);
669EXPORT_SYMBOL(ip_dev_find);
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 2a0455911ee0..017900172f7d 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -730,7 +730,6 @@ out_err:
730static void icmp_redirect(struct sk_buff *skb) 730static void icmp_redirect(struct sk_buff *skb)
731{ 731{
732 struct iphdr *iph; 732 struct iphdr *iph;
733 unsigned long ip;
734 733
735 if (skb->len < sizeof(struct iphdr)) 734 if (skb->len < sizeof(struct iphdr))
736 goto out_err; 735 goto out_err;
@@ -742,7 +741,6 @@ static void icmp_redirect(struct sk_buff *skb)
742 goto out; 741 goto out;
743 742
744 iph = (struct iphdr *)skb->data; 743 iph = (struct iphdr *)skb->data;
745 ip = iph->daddr;
746 744
747 switch (skb->h.icmph->code & 7) { 745 switch (skb->h.icmph->code & 7) {
748 case ICMP_REDIR_NET: 746 case ICMP_REDIR_NET:
@@ -752,7 +750,8 @@ static void icmp_redirect(struct sk_buff *skb)
752 */ 750 */
753 case ICMP_REDIR_HOST: 751 case ICMP_REDIR_HOST:
754 case ICMP_REDIR_HOSTTOS: 752 case ICMP_REDIR_HOSTTOS:
755 ip_rt_redirect(skb->nh.iph->saddr, ip, skb->h.icmph->un.gateway, 753 ip_rt_redirect(skb->nh.iph->saddr, iph->daddr,
754 skb->h.icmph->un.gateway,
756 iph->saddr, skb->dev); 755 iph->saddr, skb->dev);
757 break; 756 break;
758 } 757 }
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index d512239a1473..ab680c851aa2 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2361,7 +2361,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v)
2361 } 2361 }
2362 2362
2363 seq_printf(seq, 2363 seq_printf(seq,
2364 "\t\t\t\t%08lX %5d %d:%08lX\t\t%d\n", 2364 "\t\t\t\t%08X %5d %d:%08lX\t\t%d\n",
2365 im->multiaddr, im->users, 2365 im->multiaddr, im->users,
2366 im->tm_running, im->tm_running ? 2366 im->tm_running, im->tm_running ?
2367 jiffies_to_clock_t(im->timer.expires-jiffies) : 0, 2367 jiffies_to_clock_t(im->timer.expires-jiffies) : 0,
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index 0923add122b4..9f0bb529ab70 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -116,6 +116,7 @@ sr_failed:
116 116
117too_many_hops: 117too_many_hops:
118 /* Tell the sender its packet died... */ 118 /* Tell the sender its packet died... */
119 IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS);
119 icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0); 120 icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
120drop: 121drop:
121 kfree_skb(skb); 122 kfree_skb(skb);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index cff9c3a72daf..8538aac3d148 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -410,6 +410,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
410 nf_bridge_get(to->nf_bridge); 410 nf_bridge_get(to->nf_bridge);
411#endif 411#endif
412#endif 412#endif
413 skb_copy_secmark(to, from);
413} 414}
414 415
415/* 416/*
@@ -839,7 +840,7 @@ int ip_append_data(struct sock *sk,
839 */ 840 */
840 if (transhdrlen && 841 if (transhdrlen &&
841 length + fragheaderlen <= mtu && 842 length + fragheaderlen <= mtu &&
842 rt->u.dst.dev->features&(NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM) && 843 rt->u.dst.dev->features & NETIF_F_ALL_CSUM &&
843 !exthdrlen) 844 !exthdrlen)
844 csummode = CHECKSUM_HW; 845 csummode = CHECKSUM_HW;
845 846
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 95278b22b669..3ed8b57a1002 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -45,7 +45,6 @@ static LIST_HEAD(ipcomp_tfms_list);
45static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb) 45static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
46{ 46{
47 int err, plen, dlen; 47 int err, plen, dlen;
48 struct iphdr *iph;
49 struct ipcomp_data *ipcd = x->data; 48 struct ipcomp_data *ipcd = x->data;
50 u8 *start, *scratch; 49 u8 *start, *scratch;
51 struct crypto_tfm *tfm; 50 struct crypto_tfm *tfm;
@@ -74,8 +73,6 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
74 73
75 skb_put(skb, dlen - plen); 74 skb_put(skb, dlen - plen);
76 memcpy(skb->data, scratch, dlen); 75 memcpy(skb->data, scratch, dlen);
77 iph = skb->nh.iph;
78 iph->tot_len = htons(dlen + iph->ihl * 4);
79out: 76out:
80 put_cpu(); 77 put_cpu();
81 return err; 78 return err;
@@ -83,34 +80,21 @@ out:
83 80
84static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb) 81static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
85{ 82{
86 u8 nexthdr; 83 int err = -ENOMEM;
87 int err = 0;
88 struct iphdr *iph; 84 struct iphdr *iph;
89 union { 85 struct ip_comp_hdr *ipch;
90 struct iphdr iph;
91 char buf[60];
92 } tmp_iph;
93
94 86
95 if ((skb_is_nonlinear(skb) || skb_cloned(skb)) && 87 if (skb_linearize_cow(skb))
96 skb_linearize(skb, GFP_ATOMIC) != 0) {
97 err = -ENOMEM;
98 goto out; 88 goto out;
99 }
100 89
101 skb->ip_summed = CHECKSUM_NONE; 90 skb->ip_summed = CHECKSUM_NONE;
102 91
103 /* Remove ipcomp header and decompress original payload */ 92 /* Remove ipcomp header and decompress original payload */
104 iph = skb->nh.iph; 93 iph = skb->nh.iph;
105 memcpy(&tmp_iph, iph, iph->ihl * 4); 94 ipch = (void *)skb->data;
106 nexthdr = *(u8 *)skb->data; 95 iph->protocol = ipch->nexthdr;
107 skb_pull(skb, sizeof(struct ip_comp_hdr)); 96 skb->h.raw = skb->nh.raw + sizeof(*ipch);
108 skb->nh.raw += sizeof(struct ip_comp_hdr); 97 __skb_pull(skb, sizeof(*ipch));
109 memcpy(skb->nh.raw, &tmp_iph, tmp_iph.iph.ihl * 4);
110 iph = skb->nh.iph;
111 iph->tot_len = htons(ntohs(iph->tot_len) - sizeof(struct ip_comp_hdr));
112 iph->protocol = nexthdr;
113 skb->h.raw = skb->data;
114 err = ipcomp_decompress(x, skb); 98 err = ipcomp_decompress(x, skb);
115 99
116out: 100out:
@@ -171,10 +155,8 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
171 goto out_ok; 155 goto out_ok;
172 } 156 }
173 157
174 if ((skb_is_nonlinear(skb) || skb_cloned(skb)) && 158 if (skb_linearize_cow(skb))
175 skb_linearize(skb, GFP_ATOMIC) != 0) {
176 goto out_ok; 159 goto out_ok;
177 }
178 160
179 err = ipcomp_compress(x, skb); 161 err = ipcomp_compress(x, skb);
180 iph = skb->nh.iph; 162 iph = skb->nh.iph;
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index d4072533da21..e1d7f5fbc526 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -55,6 +55,18 @@ config IP_NF_CONNTRACK_MARK
55 of packets, but this mark value is kept in the conntrack session 55 of packets, but this mark value is kept in the conntrack session
56 instead of the individual packets. 56 instead of the individual packets.
57 57
58config IP_NF_CONNTRACK_SECMARK
59 bool 'Connection tracking security mark support'
60 depends on IP_NF_CONNTRACK && NETWORK_SECMARK
61 help
62 This option enables security markings to be applied to
63 connections. Typically they are copied to connections from
64 packets using the CONNSECMARK target and copied back from
65 connections to packets with the same target, with the packets
66 being originally labeled via SECMARK.
67
68 If unsure, say 'N'.
69
58config IP_NF_CONNTRACK_EVENTS 70config IP_NF_CONNTRACK_EVENTS
59 bool "Connection tracking events (EXPERIMENTAL)" 71 bool "Connection tracking events (EXPERIMENTAL)"
60 depends on EXPERIMENTAL && IP_NF_CONNTRACK 72 depends on EXPERIMENTAL && IP_NF_CONNTRACK
@@ -142,6 +154,8 @@ config IP_NF_TFTP
142config IP_NF_AMANDA 154config IP_NF_AMANDA
143 tristate "Amanda backup protocol support" 155 tristate "Amanda backup protocol support"
144 depends on IP_NF_CONNTRACK 156 depends on IP_NF_CONNTRACK
157 select TEXTSEARCH
158 select TEXTSEARCH_KMP
145 help 159 help
146 If you are running the Amanda backup package <http://www.amanda.org/> 160 If you are running the Amanda backup package <http://www.amanda.org/>
147 on this machine or machines that will be MASQUERADED through this 161 on this machine or machines that will be MASQUERADED through this
@@ -181,14 +195,26 @@ config IP_NF_H323
181 With this module you can support H.323 on a connection tracking/NAT 195 With this module you can support H.323 on a connection tracking/NAT
182 firewall. 196 firewall.
183 197
184 This module supports RAS, Fast-start, H.245 tunnelling, RTP/RTCP 198 This module supports RAS, Fast Start, H.245 Tunnelling, Call
185 and T.120 based data and applications including audio, video, FAX, 199 Forwarding, RTP/RTCP and T.120 based audio, video, fax, chat,
186 chat, whiteboard, file transfer, etc. For more information, please 200 whiteboard, file transfer, etc. For more information, please
187 see http://nath323.sourceforge.net/. 201 visit http://nath323.sourceforge.net/.
188 202
189 If you want to compile it as a module, say 'M' here and read 203 If you want to compile it as a module, say 'M' here and read
190 Documentation/modules.txt. If unsure, say 'N'. 204 Documentation/modules.txt. If unsure, say 'N'.
191 205
206config IP_NF_SIP
207 tristate "SIP protocol support (EXPERIMENTAL)"
208 depends on IP_NF_CONNTRACK && EXPERIMENTAL
209 help
210 SIP is an application-layer control protocol that can establish,
211 modify, and terminate multimedia sessions (conferences) such as
212 Internet telephony calls. With the ip_conntrack_sip and
213 the ip_nat_sip modules you can support the protocol on a connection
214 tracking/NATing firewall.
215
216 To compile it as a module, choose M here. If unsure, say Y.
217
192config IP_NF_QUEUE 218config IP_NF_QUEUE
193 tristate "IP Userspace queueing via NETLINK (OBSOLETE)" 219 tristate "IP Userspace queueing via NETLINK (OBSOLETE)"
194 help 220 help
@@ -501,6 +527,12 @@ config IP_NF_NAT_H323
501 default IP_NF_NAT if IP_NF_H323=y 527 default IP_NF_NAT if IP_NF_H323=y
502 default m if IP_NF_H323=m 528 default m if IP_NF_H323=m
503 529
530config IP_NF_NAT_SIP
531 tristate
532 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
533 default IP_NF_NAT if IP_NF_SIP=y
534 default m if IP_NF_SIP=m
535
504# mangle + specific targets 536# mangle + specific targets
505config IP_NF_MANGLE 537config IP_NF_MANGLE
506 tristate "Packet mangling" 538 tristate "Packet mangling"
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
index 461cb1eb5de7..3ded4a3af59c 100644
--- a/net/ipv4/netfilter/Makefile
+++ b/net/ipv4/netfilter/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_IP_NF_AMANDA) += ip_conntrack_amanda.o
31obj-$(CONFIG_IP_NF_TFTP) += ip_conntrack_tftp.o 31obj-$(CONFIG_IP_NF_TFTP) += ip_conntrack_tftp.o
32obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o 32obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o
33obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_irc.o 33obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_irc.o
34obj-$(CONFIG_IP_NF_SIP) += ip_conntrack_sip.o
34obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o 35obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o
35 36
36# NAT helpers 37# NAT helpers
@@ -40,6 +41,7 @@ obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o
40obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_tftp.o 41obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_tftp.o
41obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o 42obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o
42obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o 43obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o
44obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o
43 45
44# generic IP tables 46# generic IP tables
45obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o 47obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
index a604b1ccfdaa..0a7bd7f04061 100644
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c
@@ -17,33 +17,29 @@
17 * this value. 17 * this value.
18 * 18 *
19 */ 19 */
20
21#include <linux/in.h>
22#include <linux/kernel.h> 20#include <linux/kernel.h>
23#include <linux/module.h> 21#include <linux/module.h>
24#include <linux/netfilter.h>
25#include <linux/ip.h>
26#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23#include <linux/textsearch.h>
24#include <linux/skbuff.h>
25#include <linux/in.h>
26#include <linux/ip.h>
27#include <linux/udp.h> 27#include <linux/udp.h>
28#include <net/checksum.h>
29#include <net/udp.h>
30 28
29#include <linux/netfilter.h>
31#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 30#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
32#include <linux/netfilter_ipv4/ip_conntrack_amanda.h> 31#include <linux/netfilter_ipv4/ip_conntrack_amanda.h>
33 32
34static unsigned int master_timeout = 300; 33static unsigned int master_timeout = 300;
34static char *ts_algo = "kmp";
35 35
36MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>"); 36MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
37MODULE_DESCRIPTION("Amanda connection tracking module"); 37MODULE_DESCRIPTION("Amanda connection tracking module");
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
39module_param(master_timeout, uint, 0600); 39module_param(master_timeout, uint, 0600);
40MODULE_PARM_DESC(master_timeout, "timeout for the master connection"); 40MODULE_PARM_DESC(master_timeout, "timeout for the master connection");
41 41module_param(ts_algo, charp, 0400);
42static const char *conns[] = { "DATA ", "MESG ", "INDEX " }; 42MODULE_PARM_DESC(ts_algo, "textsearch algorithm to use (default kmp)");
43
44/* This is slow, but it's simple. --RR */
45static char *amanda_buffer;
46static DEFINE_SPINLOCK(amanda_buffer_lock);
47 43
48unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb, 44unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb,
49 enum ip_conntrack_info ctinfo, 45 enum ip_conntrack_info ctinfo,
@@ -52,12 +48,48 @@ unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb,
52 struct ip_conntrack_expect *exp); 48 struct ip_conntrack_expect *exp);
53EXPORT_SYMBOL_GPL(ip_nat_amanda_hook); 49EXPORT_SYMBOL_GPL(ip_nat_amanda_hook);
54 50
51enum amanda_strings {
52 SEARCH_CONNECT,
53 SEARCH_NEWLINE,
54 SEARCH_DATA,
55 SEARCH_MESG,
56 SEARCH_INDEX,
57};
58
59static struct {
60 char *string;
61 size_t len;
62 struct ts_config *ts;
63} search[] = {
64 [SEARCH_CONNECT] = {
65 .string = "CONNECT ",
66 .len = 8,
67 },
68 [SEARCH_NEWLINE] = {
69 .string = "\n",
70 .len = 1,
71 },
72 [SEARCH_DATA] = {
73 .string = "DATA ",
74 .len = 5,
75 },
76 [SEARCH_MESG] = {
77 .string = "MESG ",
78 .len = 5,
79 },
80 [SEARCH_INDEX] = {
81 .string = "INDEX ",
82 .len = 6,
83 },
84};
85
55static int help(struct sk_buff **pskb, 86static int help(struct sk_buff **pskb,
56 struct ip_conntrack *ct, enum ip_conntrack_info ctinfo) 87 struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
57{ 88{
89 struct ts_state ts;
58 struct ip_conntrack_expect *exp; 90 struct ip_conntrack_expect *exp;
59 char *data, *data_limit, *tmp; 91 unsigned int dataoff, start, stop, off, i;
60 unsigned int dataoff, i; 92 char pbuf[sizeof("65535")], *tmp;
61 u_int16_t port, len; 93 u_int16_t port, len;
62 int ret = NF_ACCEPT; 94 int ret = NF_ACCEPT;
63 95
@@ -77,29 +109,34 @@ static int help(struct sk_buff **pskb,
77 return NF_ACCEPT; 109 return NF_ACCEPT;
78 } 110 }
79 111
80 spin_lock_bh(&amanda_buffer_lock); 112 memset(&ts, 0, sizeof(ts));
81 skb_copy_bits(*pskb, dataoff, amanda_buffer, (*pskb)->len - dataoff); 113 start = skb_find_text(*pskb, dataoff, (*pskb)->len,
82 data = amanda_buffer; 114 search[SEARCH_CONNECT].ts, &ts);
83 data_limit = amanda_buffer + (*pskb)->len - dataoff; 115 if (start == UINT_MAX)
84 *data_limit = '\0';
85
86 /* Search for the CONNECT string */
87 data = strstr(data, "CONNECT ");
88 if (!data)
89 goto out; 116 goto out;
90 data += strlen("CONNECT "); 117 start += dataoff + search[SEARCH_CONNECT].len;
91 118
92 /* Only search first line. */ 119 memset(&ts, 0, sizeof(ts));
93 if ((tmp = strchr(data, '\n'))) 120 stop = skb_find_text(*pskb, start, (*pskb)->len,
94 *tmp = '\0'; 121 search[SEARCH_NEWLINE].ts, &ts);
122 if (stop == UINT_MAX)
123 goto out;
124 stop += start;
95 125
96 for (i = 0; i < ARRAY_SIZE(conns); i++) { 126 for (i = SEARCH_DATA; i <= SEARCH_INDEX; i++) {
97 char *match = strstr(data, conns[i]); 127 memset(&ts, 0, sizeof(ts));
98 if (!match) 128 off = skb_find_text(*pskb, start, stop, search[i].ts, &ts);
129 if (off == UINT_MAX)
99 continue; 130 continue;
100 tmp = data = match + strlen(conns[i]); 131 off += start + search[i].len;
101 port = simple_strtoul(data, &data, 10); 132
102 len = data - tmp; 133 len = min_t(unsigned int, sizeof(pbuf) - 1, stop - off);
134 if (skb_copy_bits(*pskb, off, pbuf, len))
135 break;
136 pbuf[len] = '\0';
137
138 port = simple_strtoul(pbuf, &tmp, 10);
139 len = tmp - pbuf;
103 if (port == 0 || len > 5) 140 if (port == 0 || len > 5)
104 break; 141 break;
105 142
@@ -125,8 +162,7 @@ static int help(struct sk_buff **pskb,
125 exp->mask.dst.u.tcp.port = 0xFFFF; 162 exp->mask.dst.u.tcp.port = 0xFFFF;
126 163
127 if (ip_nat_amanda_hook) 164 if (ip_nat_amanda_hook)
128 ret = ip_nat_amanda_hook(pskb, ctinfo, 165 ret = ip_nat_amanda_hook(pskb, ctinfo, off - dataoff,
129 tmp - amanda_buffer,
130 len, exp); 166 len, exp);
131 else if (ip_conntrack_expect_related(exp) != 0) 167 else if (ip_conntrack_expect_related(exp) != 0)
132 ret = NF_DROP; 168 ret = NF_DROP;
@@ -134,12 +170,11 @@ static int help(struct sk_buff **pskb,
134 } 170 }
135 171
136out: 172out:
137 spin_unlock_bh(&amanda_buffer_lock);
138 return ret; 173 return ret;
139} 174}
140 175
141static struct ip_conntrack_helper amanda_helper = { 176static struct ip_conntrack_helper amanda_helper = {
142 .max_expected = ARRAY_SIZE(conns), 177 .max_expected = 3,
143 .timeout = 180, 178 .timeout = 180,
144 .me = THIS_MODULE, 179 .me = THIS_MODULE,
145 .help = help, 180 .help = help,
@@ -155,26 +190,36 @@ static struct ip_conntrack_helper amanda_helper = {
155 190
156static void __exit ip_conntrack_amanda_fini(void) 191static void __exit ip_conntrack_amanda_fini(void)
157{ 192{
193 int i;
194
158 ip_conntrack_helper_unregister(&amanda_helper); 195 ip_conntrack_helper_unregister(&amanda_helper);
159 kfree(amanda_buffer); 196 for (i = 0; i < ARRAY_SIZE(search); i++)
197 textsearch_destroy(search[i].ts);
160} 198}
161 199
162static int __init ip_conntrack_amanda_init(void) 200static int __init ip_conntrack_amanda_init(void)
163{ 201{
164 int ret; 202 int ret, i;
165 203
166 amanda_buffer = kmalloc(65536, GFP_KERNEL); 204 ret = -ENOMEM;
167 if (!amanda_buffer) 205 for (i = 0; i < ARRAY_SIZE(search); i++) {
168 return -ENOMEM; 206 search[i].ts = textsearch_prepare(ts_algo, search[i].string,
169 207 search[i].len,
170 ret = ip_conntrack_helper_register(&amanda_helper); 208 GFP_KERNEL, TS_AUTOLOAD);
171 if (ret < 0) { 209 if (search[i].ts == NULL)
172 kfree(amanda_buffer); 210 goto err;
173 return ret;
174 } 211 }
212 ret = ip_conntrack_helper_register(&amanda_helper);
213 if (ret < 0)
214 goto err;
175 return 0; 215 return 0;
176 216
177 217err:
218 for (; i >= 0; i--) {
219 if (search[i].ts)
220 textsearch_destroy(search[i].ts);
221 }
222 return ret;
178} 223}
179 224
180module_init(ip_conntrack_amanda_init); 225module_init(ip_conntrack_amanda_init);
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index a297da7bbef5..7e4cf9a4d15f 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -724,6 +724,9 @@ init_conntrack(struct ip_conntrack_tuple *tuple,
724 /* this is ugly, but there is no other place where to put it */ 724 /* this is ugly, but there is no other place where to put it */
725 conntrack->nat.masq_index = exp->master->nat.masq_index; 725 conntrack->nat.masq_index = exp->master->nat.masq_index;
726#endif 726#endif
727#ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
728 conntrack->secmark = exp->master->secmark;
729#endif
727 nf_conntrack_get(&conntrack->master->ct_general); 730 nf_conntrack_get(&conntrack->master->ct_general);
728 CONNTRACK_STAT_INC(expect_new); 731 CONNTRACK_STAT_INC(expect_new);
729 } else { 732 } else {
@@ -1130,6 +1133,12 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct,
1130 1133
1131 write_lock_bh(&ip_conntrack_lock); 1134 write_lock_bh(&ip_conntrack_lock);
1132 1135
1136 /* Only update if this is not a fixed timeout */
1137 if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status)) {
1138 write_unlock_bh(&ip_conntrack_lock);
1139 return;
1140 }
1141
1133 /* If not in hash table, timer will not be active yet */ 1142 /* If not in hash table, timer will not be active yet */
1134 if (!is_confirmed(ct)) { 1143 if (!is_confirmed(ct)) {
1135 ct->timeout.expires = extra_jiffies; 1144 ct->timeout.expires = extra_jiffies;
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index 3e542bf28a9d..4dcf526c3944 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -56,37 +56,48 @@ static int try_eprt(const char *, size_t, u_int32_t [], char);
56static int try_epsv_response(const char *, size_t, u_int32_t [], char); 56static int try_epsv_response(const char *, size_t, u_int32_t [], char);
57 57
58static const struct ftp_search { 58static const struct ftp_search {
59 enum ip_conntrack_dir dir;
60 const char *pattern; 59 const char *pattern;
61 size_t plen; 60 size_t plen;
62 char skip; 61 char skip;
63 char term; 62 char term;
64 enum ip_ct_ftp_type ftptype; 63 enum ip_ct_ftp_type ftptype;
65 int (*getnum)(const char *, size_t, u_int32_t[], char); 64 int (*getnum)(const char *, size_t, u_int32_t[], char);
66} search[] = { 65} search[IP_CT_DIR_MAX][2] = {
67 { 66 [IP_CT_DIR_ORIGINAL] = {
68 IP_CT_DIR_ORIGINAL, 67 {
69 "PORT", sizeof("PORT") - 1, ' ', '\r', 68 .pattern = "PORT",
70 IP_CT_FTP_PORT, 69 .plen = sizeof("PORT") - 1,
71 try_rfc959, 70 .skip = ' ',
71 .term = '\r',
72 .ftptype = IP_CT_FTP_PORT,
73 .getnum = try_rfc959,
74 },
75 {
76 .pattern = "EPRT",
77 .plen = sizeof("EPRT") - 1,
78 .skip = ' ',
79 .term = '\r',
80 .ftptype = IP_CT_FTP_EPRT,
81 .getnum = try_eprt,
82 },
72 }, 83 },
73 { 84 [IP_CT_DIR_REPLY] = {
74 IP_CT_DIR_REPLY, 85 {
75 "227 ", sizeof("227 ") - 1, '(', ')', 86 .pattern = "227 ",
76 IP_CT_FTP_PASV, 87 .plen = sizeof("227 ") - 1,
77 try_rfc959, 88 .skip = '(',
78 }, 89 .term = ')',
79 { 90 .ftptype = IP_CT_FTP_PASV,
80 IP_CT_DIR_ORIGINAL, 91 .getnum = try_rfc959,
81 "EPRT", sizeof("EPRT") - 1, ' ', '\r', 92 },
82 IP_CT_FTP_EPRT, 93 {
83 try_eprt, 94 .pattern = "229 ",
84 }, 95 .plen = sizeof("229 ") - 1,
85 { 96 .skip = '(',
86 IP_CT_DIR_REPLY, 97 .term = ')',
87 "229 ", sizeof("229 ") - 1, '(', ')', 98 .ftptype = IP_CT_FTP_EPSV,
88 IP_CT_FTP_EPSV, 99 .getnum = try_epsv_response,
89 try_epsv_response, 100 },
90 }, 101 },
91}; 102};
92 103
@@ -346,17 +357,15 @@ static int help(struct sk_buff **pskb,
346 array[2] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 8) & 0xFF; 357 array[2] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 8) & 0xFF;
347 array[3] = ntohl(ct->tuplehash[dir].tuple.src.ip) & 0xFF; 358 array[3] = ntohl(ct->tuplehash[dir].tuple.src.ip) & 0xFF;
348 359
349 for (i = 0; i < ARRAY_SIZE(search); i++) { 360 for (i = 0; i < ARRAY_SIZE(search[dir]); i++) {
350 if (search[i].dir != dir) continue;
351
352 found = find_pattern(fb_ptr, (*pskb)->len - dataoff, 361 found = find_pattern(fb_ptr, (*pskb)->len - dataoff,
353 search[i].pattern, 362 search[dir][i].pattern,
354 search[i].plen, 363 search[dir][i].plen,
355 search[i].skip, 364 search[dir][i].skip,
356 search[i].term, 365 search[dir][i].term,
357 &matchoff, &matchlen, 366 &matchoff, &matchlen,
358 array, 367 array,
359 search[i].getnum); 368 search[dir][i].getnum);
360 if (found) break; 369 if (found) break;
361 } 370 }
362 if (found == -1) { 371 if (found == -1) {
@@ -366,7 +375,7 @@ static int help(struct sk_buff **pskb,
366 this case. */ 375 this case. */
367 if (net_ratelimit()) 376 if (net_ratelimit())
368 printk("conntrack_ftp: partial %s %u+%u\n", 377 printk("conntrack_ftp: partial %s %u+%u\n",
369 search[i].pattern, 378 search[dir][i].pattern,
370 ntohl(th->seq), datalen); 379 ntohl(th->seq), datalen);
371 ret = NF_DROP; 380 ret = NF_DROP;
372 goto out; 381 goto out;
@@ -426,7 +435,7 @@ static int help(struct sk_buff **pskb,
426 /* Now, NAT might want to mangle the packet, and register the 435 /* Now, NAT might want to mangle the packet, and register the
427 * (possibly changed) expectation itself. */ 436 * (possibly changed) expectation itself. */
428 if (ip_nat_ftp_hook) 437 if (ip_nat_ftp_hook)
429 ret = ip_nat_ftp_hook(pskb, ctinfo, search[i].ftptype, 438 ret = ip_nat_ftp_hook(pskb, ctinfo, search[dir][i].ftptype,
430 matchoff, matchlen, exp, &seq); 439 matchoff, matchlen, exp, &seq);
431 else { 440 else {
432 /* Can't expect this? Best to drop packet now. */ 441 /* Can't expect this? Best to drop packet now. */
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 518f581d39ec..0665674218c6 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -22,6 +22,8 @@
22#include <linux/netfilter_ipv4/ip_conntrack_tuple.h> 22#include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
23#include <linux/netfilter_ipv4/ip_conntrack_h323.h> 23#include <linux/netfilter_ipv4/ip_conntrack_h323.h>
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/ctype.h>
26#include <linux/inet.h>
25 27
26#if 0 28#if 0
27#define DEBUGP printk 29#define DEBUGP printk
@@ -38,6 +40,12 @@ static int gkrouted_only = 1;
38module_param(gkrouted_only, int, 0600); 40module_param(gkrouted_only, int, 0600);
39MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper"); 41MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper");
40 42
43static int callforward_filter = 1;
44module_param(callforward_filter, bool, 0600);
45MODULE_PARM_DESC(callforward_filter, "only create call forwarding expectations "
46 "if both endpoints are on different sides "
47 "(determined by routing information)");
48
41/* Hooks for NAT */ 49/* Hooks for NAT */
42int (*set_h245_addr_hook) (struct sk_buff ** pskb, 50int (*set_h245_addr_hook) (struct sk_buff ** pskb,
43 unsigned char **data, int dataoff, 51 unsigned char **data, int dataoff,
@@ -77,6 +85,12 @@ int (*nat_h245_hook) (struct sk_buff ** pskb,
77 unsigned char **data, int dataoff, 85 unsigned char **data, int dataoff,
78 TransportAddress * addr, u_int16_t port, 86 TransportAddress * addr, u_int16_t port,
79 struct ip_conntrack_expect * exp); 87 struct ip_conntrack_expect * exp);
88int (*nat_callforwarding_hook) (struct sk_buff ** pskb,
89 struct ip_conntrack * ct,
90 enum ip_conntrack_info ctinfo,
91 unsigned char **data, int dataoff,
92 TransportAddress * addr, u_int16_t port,
93 struct ip_conntrack_expect * exp);
80int (*nat_q931_hook) (struct sk_buff ** pskb, 94int (*nat_q931_hook) (struct sk_buff ** pskb,
81 struct ip_conntrack * ct, 95 struct ip_conntrack * ct,
82 enum ip_conntrack_info ctinfo, 96 enum ip_conntrack_info ctinfo,
@@ -683,6 +697,92 @@ static int expect_h245(struct sk_buff **pskb, struct ip_conntrack *ct,
683 return ret; 697 return ret;
684} 698}
685 699
700/* Forwarding declaration */
701void ip_conntrack_q931_expect(struct ip_conntrack *new,
702 struct ip_conntrack_expect *this);
703
704/****************************************************************************/
705static int expect_callforwarding(struct sk_buff **pskb,
706 struct ip_conntrack *ct,
707 enum ip_conntrack_info ctinfo,
708 unsigned char **data, int dataoff,
709 TransportAddress * addr)
710{
711 int dir = CTINFO2DIR(ctinfo);
712 int ret = 0;
713 u_int32_t ip;
714 u_int16_t port;
715 struct ip_conntrack_expect *exp = NULL;
716
717 /* Read alternativeAddress */
718 if (!get_h225_addr(*data, addr, &ip, &port) || port == 0)
719 return 0;
720
721 /* If the calling party is on the same side of the forward-to party,
722 * we don't need to track the second call */
723 if (callforward_filter) {
724 struct rtable *rt1, *rt2;
725 struct flowi fl1 = {
726 .fl4_dst = ip,
727 };
728 struct flowi fl2 = {
729 .fl4_dst = ct->tuplehash[!dir].tuple.src.ip,
730 };
731
732 if (ip_route_output_key(&rt1, &fl1) == 0) {
733 if (ip_route_output_key(&rt2, &fl2) == 0) {
734 if (rt1->rt_gateway == rt2->rt_gateway &&
735 rt1->u.dst.dev == rt2->u.dst.dev)
736 ret = 1;
737 dst_release(&rt2->u.dst);
738 }
739 dst_release(&rt1->u.dst);
740 }
741 if (ret) {
742 DEBUGP("ip_ct_q931: Call Forwarding not tracked\n");
743 return 0;
744 }
745 }
746
747 /* Create expect for the second call leg */
748 if ((exp = ip_conntrack_expect_alloc(ct)) == NULL)
749 return -1;
750 exp->tuple.src.ip = ct->tuplehash[!dir].tuple.src.ip;
751 exp->tuple.src.u.tcp.port = 0;
752 exp->tuple.dst.ip = ip;
753 exp->tuple.dst.u.tcp.port = htons(port);
754 exp->tuple.dst.protonum = IPPROTO_TCP;
755 exp->mask.src.ip = 0xFFFFFFFF;
756 exp->mask.src.u.tcp.port = 0;
757 exp->mask.dst.ip = 0xFFFFFFFF;
758 exp->mask.dst.u.tcp.port = 0xFFFF;
759 exp->mask.dst.protonum = 0xFF;
760 exp->flags = 0;
761
762 if (ct->tuplehash[dir].tuple.src.ip !=
763 ct->tuplehash[!dir].tuple.dst.ip && nat_callforwarding_hook) {
764 /* Need NAT */
765 ret = nat_callforwarding_hook(pskb, ct, ctinfo, data, dataoff,
766 addr, port, exp);
767 } else { /* Conntrack only */
768 exp->expectfn = ip_conntrack_q931_expect;
769
770 if (ip_conntrack_expect_related(exp) == 0) {
771 DEBUGP("ip_ct_q931: expect Call Forwarding "
772 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
773 NIPQUAD(exp->tuple.src.ip),
774 ntohs(exp->tuple.src.u.tcp.port),
775 NIPQUAD(exp->tuple.dst.ip),
776 ntohs(exp->tuple.dst.u.tcp.port));
777 } else
778 ret = -1;
779 }
780
781 ip_conntrack_expect_put(exp);
782
783 return ret;
784}
785
686/****************************************************************************/ 786/****************************************************************************/
687static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct, 787static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct,
688 enum ip_conntrack_info ctinfo, 788 enum ip_conntrack_info ctinfo,
@@ -878,6 +978,15 @@ static int process_facility(struct sk_buff **pskb, struct ip_conntrack *ct,
878 978
879 DEBUGP("ip_ct_q931: Facility\n"); 979 DEBUGP("ip_ct_q931: Facility\n");
880 980
981 if (facility->reason.choice == eFacilityReason_callForwarded) {
982 if (facility->options & eFacility_UUIE_alternativeAddress)
983 return expect_callforwarding(pskb, ct, ctinfo, data,
984 dataoff,
985 &facility->
986 alternativeAddress);
987 return 0;
988 }
989
881 if (facility->options & eFacility_UUIE_h245Address) { 990 if (facility->options & eFacility_UUIE_h245Address) {
882 ret = expect_h245(pskb, ct, ctinfo, data, dataoff, 991 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
883 &facility->h245Address); 992 &facility->h245Address);
@@ -1677,7 +1786,6 @@ static int __init init(void)
1677 fini(); 1786 fini();
1678 return ret; 1787 return ret;
1679 } 1788 }
1680
1681 DEBUGP("ip_ct_h323: init success\n"); 1789 DEBUGP("ip_ct_h323: init success\n");
1682 return 0; 1790 return 0;
1683} 1791}
@@ -1696,6 +1804,7 @@ EXPORT_SYMBOL_GPL(set_ras_addr_hook);
1696EXPORT_SYMBOL_GPL(nat_rtp_rtcp_hook); 1804EXPORT_SYMBOL_GPL(nat_rtp_rtcp_hook);
1697EXPORT_SYMBOL_GPL(nat_t120_hook); 1805EXPORT_SYMBOL_GPL(nat_t120_hook);
1698EXPORT_SYMBOL_GPL(nat_h245_hook); 1806EXPORT_SYMBOL_GPL(nat_h245_hook);
1807EXPORT_SYMBOL_GPL(nat_callforwarding_hook);
1699EXPORT_SYMBOL_GPL(nat_q931_hook); 1808EXPORT_SYMBOL_GPL(nat_q931_hook);
1700 1809
1701MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>"); 1810MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_types.c b/net/ipv4/netfilter/ip_conntrack_helper_h323_types.c
index 022c47b9f6c9..4b359618bedd 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_types.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323_types.c
@@ -1,4 +1,4 @@
1/* Generated by Jing Min Zhao's ASN.1 parser, Mar 15 2006 1/* Generated by Jing Min Zhao's ASN.1 parser, Apr 20 2006
2 * 2 *
3 * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net> 3 * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net>
4 * 4 *
@@ -1069,8 +1069,8 @@ static field_t _Facility_UUIE_fastStart[] = { /* SEQUENCE OF */
1069 1069
1070static field_t _Facility_UUIE[] = { /* SEQUENCE */ 1070static field_t _Facility_UUIE[] = { /* SEQUENCE */
1071 {FNAME("protocolIdentifier") OID, BYTE, 0, 0, SKIP, 0, NULL}, 1071 {FNAME("protocolIdentifier") OID, BYTE, 0, 0, SKIP, 0, NULL},
1072 {FNAME("alternativeAddress") CHOICE, 3, 7, 7, SKIP | EXT | OPT, 0, 1072 {FNAME("alternativeAddress") CHOICE, 3, 7, 7, DECODE | EXT | OPT,
1073 _TransportAddress}, 1073 offsetof(Facility_UUIE, alternativeAddress), _TransportAddress},
1074 {FNAME("alternativeAliasAddress") SEQOF, SEMI, 0, 0, SKIP | OPT, 0, 1074 {FNAME("alternativeAliasAddress") SEQOF, SEMI, 0, 0, SKIP | OPT, 0,
1075 _Facility_UUIE_alternativeAliasAddress}, 1075 _Facility_UUIE_alternativeAliasAddress},
1076 {FNAME("conferenceID") OCTSTR, FIXD, 16, 0, SKIP | OPT, 0, NULL}, 1076 {FNAME("conferenceID") OCTSTR, FIXD, 16, 0, SKIP | OPT, 0, NULL},
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 01bd7cab9367..33891bb1fde4 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -399,38 +399,54 @@ nfattr_failure:
399static int ctnetlink_done(struct netlink_callback *cb) 399static int ctnetlink_done(struct netlink_callback *cb)
400{ 400{
401 DEBUGP("entered %s\n", __FUNCTION__); 401 DEBUGP("entered %s\n", __FUNCTION__);
402 if (cb->args[1])
403 ip_conntrack_put((struct ip_conntrack *)cb->args[1]);
402 return 0; 404 return 0;
403} 405}
404 406
405static int 407static int
406ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) 408ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
407{ 409{
408 struct ip_conntrack *ct = NULL; 410 struct ip_conntrack *ct, *last;
409 struct ip_conntrack_tuple_hash *h; 411 struct ip_conntrack_tuple_hash *h;
410 struct list_head *i; 412 struct list_head *i;
411 u_int32_t *id = (u_int32_t *) &cb->args[1];
412 413
413 DEBUGP("entered %s, last bucket=%lu id=%u\n", __FUNCTION__, 414 DEBUGP("entered %s, last bucket=%lu id=%u\n", __FUNCTION__,
414 cb->args[0], *id); 415 cb->args[0], *id);
415 416
416 read_lock_bh(&ip_conntrack_lock); 417 read_lock_bh(&ip_conntrack_lock);
417 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++, *id = 0) { 418 for (; cb->args[0] < ip_conntrack_htable_size; cb->args[0]++) {
419restart:
420 last = (struct ip_conntrack *)cb->args[1];
418 list_for_each_prev(i, &ip_conntrack_hash[cb->args[0]]) { 421 list_for_each_prev(i, &ip_conntrack_hash[cb->args[0]]) {
419 h = (struct ip_conntrack_tuple_hash *) i; 422 h = (struct ip_conntrack_tuple_hash *) i;
420 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) 423 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL)
421 continue; 424 continue;
422 ct = tuplehash_to_ctrack(h); 425 ct = tuplehash_to_ctrack(h);
423 if (ct->id <= *id) 426 if (last != NULL) {
424 continue; 427 if (ct == last) {
428 ip_conntrack_put(last);
429 cb->args[1] = 0;
430 last = NULL;
431 } else
432 continue;
433 }
425 if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, 434 if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
426 cb->nlh->nlmsg_seq, 435 cb->nlh->nlmsg_seq,
427 IPCTNL_MSG_CT_NEW, 436 IPCTNL_MSG_CT_NEW,
428 1, ct) < 0) 437 1, ct) < 0) {
438 nf_conntrack_get(&ct->ct_general);
439 cb->args[1] = (unsigned long)ct;
429 goto out; 440 goto out;
430 *id = ct->id; 441 }
442 }
443 if (last != NULL) {
444 ip_conntrack_put(last);
445 cb->args[1] = 0;
446 goto restart;
431 } 447 }
432 } 448 }
433out: 449out:
434 read_unlock_bh(&ip_conntrack_lock); 450 read_unlock_bh(&ip_conntrack_lock);
435 451
436 DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id); 452 DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id);
@@ -629,7 +645,7 @@ static const size_t cta_min_nat[CTA_NAT_MAX] = {
629}; 645};
630 646
631static inline int 647static inline int
632ctnetlink_parse_nat(struct nfattr *cda[], 648ctnetlink_parse_nat(struct nfattr *nat,
633 const struct ip_conntrack *ct, struct ip_nat_range *range) 649 const struct ip_conntrack *ct, struct ip_nat_range *range)
634{ 650{
635 struct nfattr *tb[CTA_NAT_MAX]; 651 struct nfattr *tb[CTA_NAT_MAX];
@@ -639,7 +655,7 @@ ctnetlink_parse_nat(struct nfattr *cda[],
639 655
640 memset(range, 0, sizeof(*range)); 656 memset(range, 0, sizeof(*range));
641 657
642 nfattr_parse_nested(tb, CTA_NAT_MAX, cda[CTA_NAT-1]); 658 nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
643 659
644 if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat)) 660 if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat))
645 return -EINVAL; 661 return -EINVAL;
@@ -854,39 +870,30 @@ ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[])
854 /* ASSURED bit can only be set */ 870 /* ASSURED bit can only be set */
855 return -EINVAL; 871 return -EINVAL;
856 872
857 if (cda[CTA_NAT-1]) { 873 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
858#ifndef CONFIG_IP_NF_NAT_NEEDED 874#ifndef CONFIG_IP_NF_NAT_NEEDED
859 return -EINVAL; 875 return -EINVAL;
860#else 876#else
861 unsigned int hooknum;
862 struct ip_nat_range range; 877 struct ip_nat_range range;
863 878
864 if (ctnetlink_parse_nat(cda, ct, &range) < 0) 879 if (cda[CTA_NAT_DST-1]) {
865 return -EINVAL; 880 if (ctnetlink_parse_nat(cda[CTA_NAT_DST-1], ct,
866 881 &range) < 0)
867 DEBUGP("NAT: %u.%u.%u.%u-%u.%u.%u.%u:%u-%u\n", 882 return -EINVAL;
868 NIPQUAD(range.min_ip), NIPQUAD(range.max_ip), 883 if (ip_nat_initialized(ct,
869 htons(range.min.all), htons(range.max.all)); 884 HOOK2MANIP(NF_IP_PRE_ROUTING)))
870 885 return -EEXIST;
871 /* This is tricky but it works. ip_nat_setup_info needs the 886 ip_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
872 * hook number as parameter, so let's do the correct 887 }
873 * conversion and run away */ 888 if (cda[CTA_NAT_SRC-1]) {
874 if (status & IPS_SRC_NAT_DONE) 889 if (ctnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct,
875 hooknum = NF_IP_POST_ROUTING; /* IP_NAT_MANIP_SRC */ 890 &range) < 0)
876 else if (status & IPS_DST_NAT_DONE) 891 return -EINVAL;
877 hooknum = NF_IP_PRE_ROUTING; /* IP_NAT_MANIP_DST */ 892 if (ip_nat_initialized(ct,
878 else 893 HOOK2MANIP(NF_IP_POST_ROUTING)))
879 return -EINVAL; /* Missing NAT flags */ 894 return -EEXIST;
880 895 ip_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
881 DEBUGP("NAT status: %lu\n", 896 }
882 status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK));
883
884 if (ip_nat_initialized(ct, HOOK2MANIP(hooknum)))
885 return -EEXIST;
886 ip_nat_setup_info(ct, &range, hooknum);
887
888 DEBUGP("NAT status after setup_info: %lu\n",
889 ct->status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK));
890#endif 897#endif
891 } 898 }
892 899
@@ -1106,7 +1113,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1106 /* implicit 'else' */ 1113 /* implicit 'else' */
1107 1114
1108 /* we only allow nat config for new conntracks */ 1115 /* we only allow nat config for new conntracks */
1109 if (cda[CTA_NAT-1]) { 1116 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
1110 err = -EINVAL; 1117 err = -EINVAL;
1111 goto out_unlock; 1118 goto out_unlock;
1112 } 1119 }
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_gre.c b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
index 56794797d55b..21ee124c0463 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_gre.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
@@ -77,10 +77,10 @@ static inline int gre_key_cmpfn(const struct ip_ct_gre_keymap *km,
77} 77}
78 78
79/* look up the source key for a given tuple */ 79/* look up the source key for a given tuple */
80static u_int32_t gre_keymap_lookup(struct ip_conntrack_tuple *t) 80static __be16 gre_keymap_lookup(struct ip_conntrack_tuple *t)
81{ 81{
82 struct ip_ct_gre_keymap *km; 82 struct ip_ct_gre_keymap *km;
83 u_int32_t key = 0; 83 __be16 key = 0;
84 84
85 read_lock_bh(&ip_ct_gre_lock); 85 read_lock_bh(&ip_ct_gre_lock);
86 km = LIST_FIND(&gre_keymap_list, gre_key_cmpfn, 86 km = LIST_FIND(&gre_keymap_list, gre_key_cmpfn,
@@ -190,7 +190,7 @@ static int gre_pkt_to_tuple(const struct sk_buff *skb,
190 struct ip_conntrack_tuple *tuple) 190 struct ip_conntrack_tuple *tuple)
191{ 191{
192 struct gre_hdr_pptp _pgrehdr, *pgrehdr; 192 struct gre_hdr_pptp _pgrehdr, *pgrehdr;
193 u_int32_t srckey; 193 __be16 srckey;
194 struct gre_hdr _grehdr, *grehdr; 194 struct gre_hdr _grehdr, *grehdr;
195 195
196 /* first only delinearize old RFC1701 GRE header */ 196 /* first only delinearize old RFC1701 GRE header */
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
index d8b14a9010a6..23f1c504586d 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -224,7 +224,7 @@ icmp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
224 } 224 }
225 225
226 /* See ip_conntrack_proto_tcp.c */ 226 /* See ip_conntrack_proto_tcp.c */
227 if (hooknum == NF_IP_PRE_ROUTING && 227 if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
228 nf_ip_checksum(skb, hooknum, skb->nh.iph->ihl * 4, 0)) { 228 nf_ip_checksum(skb, hooknum, skb->nh.iph->ihl * 4, 0)) {
229 if (LOG_INVALID(IPPROTO_ICMP)) 229 if (LOG_INVALID(IPPROTO_ICMP))
230 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 230 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index 062b252b58ad..c5c2ce5cdeb8 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -870,7 +870,7 @@ static int tcp_error(struct sk_buff *skb,
870 * and moreover root might send raw packets. 870 * and moreover root might send raw packets.
871 */ 871 */
872 /* FIXME: Source route IP option packets --RR */ 872 /* FIXME: Source route IP option packets --RR */
873 if (hooknum == NF_IP_PRE_ROUTING && 873 if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
874 nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_TCP)) { 874 nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_TCP)) {
875 if (LOG_INVALID(IPPROTO_TCP)) 875 if (LOG_INVALID(IPPROTO_TCP))
876 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 876 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_udp.c b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
index 70899868783b..9b2c16b4d2ff 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c
@@ -120,7 +120,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
120 * because the semantic of CHECKSUM_HW is different there 120 * because the semantic of CHECKSUM_HW is different there
121 * and moreover root might send raw packets. 121 * and moreover root might send raw packets.
122 * FIXME: Source route IP option packets --RR */ 122 * FIXME: Source route IP option packets --RR */
123 if (hooknum == NF_IP_PRE_ROUTING && 123 if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
124 nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_UDP)) { 124 nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_UDP)) {
125 if (LOG_INVALID(IPPROTO_UDP)) 125 if (LOG_INVALID(IPPROTO_UDP))
126 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 126 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
diff --git a/net/ipv4/netfilter/ip_conntrack_sip.c b/net/ipv4/netfilter/ip_conntrack_sip.c
new file mode 100644
index 000000000000..fc87ce0da40d
--- /dev/null
+++ b/net/ipv4/netfilter/ip_conntrack_sip.c
@@ -0,0 +1,471 @@
1/* SIP extension for IP connection tracking.
2 *
3 * (C) 2005 by Christian Hentschel <chentschel@arnet.com.ar>
4 * based on RR's ip_conntrack_ftp.c and other modules.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/config.h>
12#include <linux/module.h>
13#include <linux/ctype.h>
14#include <linux/skbuff.h>
15#include <linux/in.h>
16#include <linux/ip.h>
17#include <linux/udp.h>
18
19#include <linux/netfilter.h>
20#include <linux/netfilter_ipv4.h>
21#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
22#include <linux/netfilter_ipv4/ip_conntrack_sip.h>
23
24#if 0
25#define DEBUGP printk
26#else
27#define DEBUGP(format, args...)
28#endif
29
30MODULE_LICENSE("GPL");
31MODULE_AUTHOR("Christian Hentschel <chentschel@arnet.com.ar>");
32MODULE_DESCRIPTION("SIP connection tracking helper");
33
34#define MAX_PORTS 8
35static unsigned short ports[MAX_PORTS];
36static int ports_c;
37module_param_array(ports, ushort, &ports_c, 0400);
38MODULE_PARM_DESC(ports, "port numbers of sip servers");
39
40static unsigned int sip_timeout = SIP_TIMEOUT;
41module_param(sip_timeout, uint, 0600);
42MODULE_PARM_DESC(sip_timeout, "timeout for the master SIP session");
43
44unsigned int (*ip_nat_sip_hook)(struct sk_buff **pskb,
45 enum ip_conntrack_info ctinfo,
46 struct ip_conntrack *ct,
47 const char **dptr);
48EXPORT_SYMBOL_GPL(ip_nat_sip_hook);
49
50unsigned int (*ip_nat_sdp_hook)(struct sk_buff **pskb,
51 enum ip_conntrack_info ctinfo,
52 struct ip_conntrack_expect *exp,
53 const char *dptr);
54EXPORT_SYMBOL_GPL(ip_nat_sdp_hook);
55
56int ct_sip_get_info(const char *dptr, size_t dlen,
57 unsigned int *matchoff,
58 unsigned int *matchlen,
59 struct sip_header_nfo *hnfo);
60EXPORT_SYMBOL_GPL(ct_sip_get_info);
61
62
63static int digits_len(const char *dptr, const char *limit, int *shift);
64static int epaddr_len(const char *dptr, const char *limit, int *shift);
65static int skp_digits_len(const char *dptr, const char *limit, int *shift);
66static int skp_epaddr_len(const char *dptr, const char *limit, int *shift);
67
68struct sip_header_nfo ct_sip_hdrs[] = {
69 { /* Via header */
70 .lname = "Via:",
71 .lnlen = sizeof("Via:") - 1,
72 .sname = "\r\nv:",
73 .snlen = sizeof("\r\nv:") - 1, /* rfc3261 "\r\n" */
74 .ln_str = "UDP ",
75 .ln_strlen = sizeof("UDP ") - 1,
76 .match_len = epaddr_len,
77 },
78 { /* Contact header */
79 .lname = "Contact:",
80 .lnlen = sizeof("Contact:") - 1,
81 .sname = "\r\nm:",
82 .snlen = sizeof("\r\nm:") - 1,
83 .ln_str = "sip:",
84 .ln_strlen = sizeof("sip:") - 1,
85 .match_len = skp_epaddr_len
86 },
87 { /* Content length header */
88 .lname = "Content-Length:",
89 .lnlen = sizeof("Content-Length:") - 1,
90 .sname = "\r\nl:",
91 .snlen = sizeof("\r\nl:") - 1,
92 .ln_str = ":",
93 .ln_strlen = sizeof(":") - 1,
94 .match_len = skp_digits_len
95 },
96 { /* SDP media info */
97 .lname = "\nm=",
98 .lnlen = sizeof("\nm=") - 1,
99 .sname = "\rm=",
100 .snlen = sizeof("\rm=") - 1,
101 .ln_str = "audio ",
102 .ln_strlen = sizeof("audio ") - 1,
103 .match_len = digits_len
104 },
105 { /* SDP owner address*/
106 .lname = "\no=",
107 .lnlen = sizeof("\no=") - 1,
108 .sname = "\ro=",
109 .snlen = sizeof("\ro=") - 1,
110 .ln_str = "IN IP4 ",
111 .ln_strlen = sizeof("IN IP4 ") - 1,
112 .match_len = epaddr_len
113 },
114 { /* SDP connection info */
115 .lname = "\nc=",
116 .lnlen = sizeof("\nc=") - 1,
117 .sname = "\rc=",
118 .snlen = sizeof("\rc=") - 1,
119 .ln_str = "IN IP4 ",
120 .ln_strlen = sizeof("IN IP4 ") - 1,
121 .match_len = epaddr_len
122 },
123 { /* Requests headers */
124 .lname = "sip:",
125 .lnlen = sizeof("sip:") - 1,
126 .sname = "sip:",
127 .snlen = sizeof("sip:") - 1, /* yes, i know.. ;) */
128 .ln_str = "@",
129 .ln_strlen = sizeof("@") - 1,
130 .match_len = epaddr_len
131 },
132 { /* SDP version header */
133 .lname = "\nv=",
134 .lnlen = sizeof("\nv=") - 1,
135 .sname = "\rv=",
136 .snlen = sizeof("\rv=") - 1,
137 .ln_str = "=",
138 .ln_strlen = sizeof("=") - 1,
139 .match_len = digits_len
140 }
141};
142EXPORT_SYMBOL_GPL(ct_sip_hdrs);
143
144/* get line lenght until first CR or LF seen. */
145int ct_sip_lnlen(const char *line, const char *limit)
146{
147 const char *k = line;
148
149 while ((line <= limit) && (*line == '\r' || *line == '\n'))
150 line++;
151
152 while (line <= limit) {
153 if (*line == '\r' || *line == '\n')
154 break;
155 line++;
156 }
157 return line - k;
158}
159EXPORT_SYMBOL_GPL(ct_sip_lnlen);
160
161/* Linear string search, case sensitive. */
162const char *ct_sip_search(const char *needle, const char *haystack,
163 size_t needle_len, size_t haystack_len)
164{
165 const char *limit = haystack + (haystack_len - needle_len);
166
167 while (haystack <= limit) {
168 if (memcmp(haystack, needle, needle_len) == 0)
169 return haystack;
170 haystack++;
171 }
172 return NULL;
173}
174EXPORT_SYMBOL_GPL(ct_sip_search);
175
176static int digits_len(const char *dptr, const char *limit, int *shift)
177{
178 int len = 0;
179 while (dptr <= limit && isdigit(*dptr)) {
180 dptr++;
181 len++;
182 }
183 return len;
184}
185
186/* get digits lenght, skiping blank spaces. */
187static int skp_digits_len(const char *dptr, const char *limit, int *shift)
188{
189 for (; dptr <= limit && *dptr == ' '; dptr++)
190 (*shift)++;
191
192 return digits_len(dptr, limit, shift);
193}
194
195/* Simple ipaddr parser.. */
196static int parse_ipaddr(const char *cp, const char **endp,
197 u_int32_t *ipaddr, const char *limit)
198{
199 unsigned long int val;
200 int i, digit = 0;
201
202 for (i = 0, *ipaddr = 0; cp <= limit && i < 4; i++) {
203 digit = 0;
204 if (!isdigit(*cp))
205 break;
206
207 val = simple_strtoul(cp, (char **)&cp, 10);
208 if (val > 0xFF)
209 return -1;
210
211 ((u_int8_t *)ipaddr)[i] = val;
212 digit = 1;
213
214 if (*cp != '.')
215 break;
216 cp++;
217 }
218 if (!digit)
219 return -1;
220
221 if (endp)
222 *endp = cp;
223
224 return 0;
225}
226
227/* skip ip address. returns it lenght. */
228static int epaddr_len(const char *dptr, const char *limit, int *shift)
229{
230 const char *aux = dptr;
231 u_int32_t ip;
232
233 if (parse_ipaddr(dptr, &dptr, &ip, limit) < 0) {
234 DEBUGP("ip: %s parse failed.!\n", dptr);
235 return 0;
236 }
237
238 /* Port number */
239 if (*dptr == ':') {
240 dptr++;
241 dptr += digits_len(dptr, limit, shift);
242 }
243 return dptr - aux;
244}
245
246/* get address length, skiping user info. */
247static int skp_epaddr_len(const char *dptr, const char *limit, int *shift)
248{
249 int s = *shift;
250
251 for (; dptr <= limit && *dptr != '@'; dptr++)
252 (*shift)++;
253
254 if (*dptr == '@') {
255 dptr++;
256 (*shift)++;
257 } else
258 *shift = s;
259
260 return epaddr_len(dptr, limit, shift);
261}
262
263/* Returns 0 if not found, -1 error parsing. */
264int ct_sip_get_info(const char *dptr, size_t dlen,
265 unsigned int *matchoff,
266 unsigned int *matchlen,
267 struct sip_header_nfo *hnfo)
268{
269 const char *limit, *aux, *k = dptr;
270 int shift = 0;
271
272 limit = dptr + (dlen - hnfo->lnlen);
273
274 while (dptr <= limit) {
275 if ((strncmp(dptr, hnfo->lname, hnfo->lnlen) != 0) &&
276 (strncmp(dptr, hnfo->sname, hnfo->snlen) != 0)) {
277 dptr++;
278 continue;
279 }
280 aux = ct_sip_search(hnfo->ln_str, dptr, hnfo->ln_strlen,
281 ct_sip_lnlen(dptr, limit));
282 if (!aux) {
283 DEBUGP("'%s' not found in '%s'.\n", hnfo->ln_str,
284 hnfo->lname);
285 return -1;
286 }
287 aux += hnfo->ln_strlen;
288
289 *matchlen = hnfo->match_len(aux, limit, &shift);
290 if (!*matchlen)
291 return -1;
292
293 *matchoff = (aux - k) + shift;
294
295 DEBUGP("%s match succeeded! - len: %u\n", hnfo->lname,
296 *matchlen);
297 return 1;
298 }
299 DEBUGP("%s header not found.\n", hnfo->lname);
300 return 0;
301}
302
303static int set_expected_rtp(struct sk_buff **pskb,
304 struct ip_conntrack *ct,
305 enum ip_conntrack_info ctinfo,
306 u_int32_t ipaddr, u_int16_t port,
307 const char *dptr)
308{
309 struct ip_conntrack_expect *exp;
310 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
311 int ret;
312
313 exp = ip_conntrack_expect_alloc(ct);
314 if (exp == NULL)
315 return NF_DROP;
316
317 exp->tuple.src.ip = ct->tuplehash[!dir].tuple.src.ip;
318 exp->tuple.src.u.udp.port = 0;
319 exp->tuple.dst.ip = ipaddr;
320 exp->tuple.dst.u.udp.port = htons(port);
321 exp->tuple.dst.protonum = IPPROTO_UDP;
322
323 exp->mask.src.ip = 0xFFFFFFFF;
324 exp->mask.src.u.udp.port = 0;
325 exp->mask.dst.ip = 0xFFFFFFFF;
326 exp->mask.dst.u.udp.port = 0xFFFF;
327 exp->mask.dst.protonum = 0xFF;
328
329 exp->expectfn = NULL;
330 exp->flags = 0;
331
332 if (ip_nat_sdp_hook)
333 ret = ip_nat_sdp_hook(pskb, ctinfo, exp, dptr);
334 else {
335 if (ip_conntrack_expect_related(exp) != 0)
336 ret = NF_DROP;
337 else
338 ret = NF_ACCEPT;
339 }
340 ip_conntrack_expect_put(exp);
341
342 return ret;
343}
344
345static int sip_help(struct sk_buff **pskb,
346 struct ip_conntrack *ct,
347 enum ip_conntrack_info ctinfo)
348{
349 unsigned int dataoff, datalen;
350 const char *dptr;
351 int ret = NF_ACCEPT;
352 int matchoff, matchlen;
353 u_int32_t ipaddr;
354 u_int16_t port;
355
356 /* No Data ? */
357 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
358 if (dataoff >= (*pskb)->len) {
359 DEBUGP("skb->len = %u\n", (*pskb)->len);
360 return NF_ACCEPT;
361 }
362
363 ip_ct_refresh(ct, *pskb, sip_timeout * HZ);
364
365 if (!skb_is_nonlinear(*pskb))
366 dptr = (*pskb)->data + dataoff;
367 else {
368 DEBUGP("Copy of skbuff not supported yet.\n");
369 goto out;
370 }
371
372 if (ip_nat_sip_hook) {
373 if (!ip_nat_sip_hook(pskb, ctinfo, ct, &dptr)) {
374 ret = NF_DROP;
375 goto out;
376 }
377 }
378
379 /* After this point NAT, could have mangled skb, so
380 we need to recalculate payload lenght. */
381 datalen = (*pskb)->len - dataoff;
382
383 if (datalen < (sizeof("SIP/2.0 200") - 1))
384 goto out;
385
386 /* RTP info only in some SDP pkts */
387 if (memcmp(dptr, "INVITE", sizeof("INVITE") - 1) != 0 &&
388 memcmp(dptr, "SIP/2.0 200", sizeof("SIP/2.0 200") - 1) != 0) {
389 goto out;
390 }
391 /* Get ip and port address from SDP packet. */
392 if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen,
393 &ct_sip_hdrs[POS_CONNECTION]) > 0) {
394
395 /* We'll drop only if there are parse problems. */
396 if (parse_ipaddr(dptr + matchoff, NULL, &ipaddr,
397 dptr + datalen) < 0) {
398 ret = NF_DROP;
399 goto out;
400 }
401 if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen,
402 &ct_sip_hdrs[POS_MEDIA]) > 0) {
403
404 port = simple_strtoul(dptr + matchoff, NULL, 10);
405 if (port < 1024) {
406 ret = NF_DROP;
407 goto out;
408 }
409 ret = set_expected_rtp(pskb, ct, ctinfo,
410 ipaddr, port, dptr);
411 }
412 }
413out:
414 return ret;
415}
416
417static struct ip_conntrack_helper sip[MAX_PORTS];
418static char sip_names[MAX_PORTS][10];
419
420static void fini(void)
421{
422 int i;
423 for (i = 0; i < ports_c; i++) {
424 DEBUGP("unregistering helper for port %d\n", ports[i]);
425 ip_conntrack_helper_unregister(&sip[i]);
426 }
427}
428
429static int __init init(void)
430{
431 int i, ret;
432 char *tmpname;
433
434 if (ports_c == 0)
435 ports[ports_c++] = SIP_PORT;
436
437 for (i = 0; i < ports_c; i++) {
438 /* Create helper structure */
439 memset(&sip[i], 0, sizeof(struct ip_conntrack_helper));
440
441 sip[i].tuple.dst.protonum = IPPROTO_UDP;
442 sip[i].tuple.src.u.udp.port = htons(ports[i]);
443 sip[i].mask.src.u.udp.port = 0xFFFF;
444 sip[i].mask.dst.protonum = 0xFF;
445 sip[i].max_expected = 1;
446 sip[i].timeout = 3 * 60; /* 3 minutes */
447 sip[i].me = THIS_MODULE;
448 sip[i].help = sip_help;
449
450 tmpname = &sip_names[i][0];
451 if (ports[i] == SIP_PORT)
452 sprintf(tmpname, "sip");
453 else
454 sprintf(tmpname, "sip-%d", i);
455 sip[i].name = tmpname;
456
457 DEBUGP("port #%d: %d\n", i, ports[i]);
458
459 ret = ip_conntrack_helper_register(&sip[i]);
460 if (ret) {
461 printk("ERROR registering helper for port %d\n",
462 ports[i]);
463 fini();
464 return ret;
465 }
466 }
467 return 0;
468}
469
470module_init(init);
471module_exit(fini);
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 929d61f7be91..88445aac3f28 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -189,6 +189,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
189 return -ENOSPC; 189 return -ENOSPC;
190#endif 190#endif
191 191
192#ifdef CONFIG_IP_NF_CONNTRACK_SECMARK
193 if (seq_printf(s, "secmark=%u ", conntrack->secmark))
194 return -ENOSPC;
195#endif
196
192 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use))) 197 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
193 return -ENOSPC; 198 return -ENOSPC;
194 199
@@ -417,7 +422,7 @@ static unsigned int ip_conntrack_help(unsigned int hooknum,
417 422
418 /* This is where we call the helper: as the packet goes out. */ 423 /* This is where we call the helper: as the packet goes out. */
419 ct = ip_conntrack_get(*pskb, &ctinfo); 424 ct = ip_conntrack_get(*pskb, &ctinfo);
420 if (ct && ct->helper) { 425 if (ct && ct->helper && ctinfo != IP_CT_RELATED + IP_CT_IS_REPLY) {
421 unsigned int ret; 426 unsigned int ret;
422 ret = ct->helper->help(pskb, ct, ctinfo); 427 ret = ct->helper->help(pskb, ct, ctinfo);
423 if (ret != NF_ACCEPT) 428 if (ret != NF_ACCEPT)
@@ -564,6 +569,8 @@ extern unsigned int ip_ct_generic_timeout;
564static int log_invalid_proto_min = 0; 569static int log_invalid_proto_min = 0;
565static int log_invalid_proto_max = 255; 570static int log_invalid_proto_max = 255;
566 571
572int ip_conntrack_checksum = 1;
573
567static struct ctl_table_header *ip_ct_sysctl_header; 574static struct ctl_table_header *ip_ct_sysctl_header;
568 575
569static ctl_table ip_ct_sysctl_table[] = { 576static ctl_table ip_ct_sysctl_table[] = {
@@ -592,6 +599,14 @@ static ctl_table ip_ct_sysctl_table[] = {
592 .proc_handler = &proc_dointvec, 599 .proc_handler = &proc_dointvec,
593 }, 600 },
594 { 601 {
602 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM,
603 .procname = "ip_conntrack_checksum",
604 .data = &ip_conntrack_checksum,
605 .maxlen = sizeof(int),
606 .mode = 0644,
607 .proc_handler = &proc_dointvec,
608 },
609 {
595 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT, 610 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
596 .procname = "ip_conntrack_tcp_timeout_syn_sent", 611 .procname = "ip_conntrack_tcp_timeout_syn_sent",
597 .data = &ip_ct_tcp_timeout_syn_sent, 612 .data = &ip_ct_tcp_timeout_syn_sent,
@@ -946,6 +961,7 @@ EXPORT_SYMBOL_GPL(__ip_conntrack_helper_find_byname);
946EXPORT_SYMBOL_GPL(ip_conntrack_proto_find_get); 961EXPORT_SYMBOL_GPL(ip_conntrack_proto_find_get);
947EXPORT_SYMBOL_GPL(ip_conntrack_proto_put); 962EXPORT_SYMBOL_GPL(ip_conntrack_proto_put);
948EXPORT_SYMBOL_GPL(__ip_conntrack_proto_find); 963EXPORT_SYMBOL_GPL(__ip_conntrack_proto_find);
964EXPORT_SYMBOL_GPL(ip_conntrack_checksum);
949#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ 965#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
950 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) 966 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
951EXPORT_SYMBOL_GPL(ip_ct_port_tuple_to_nfattr); 967EXPORT_SYMBOL_GPL(ip_ct_port_tuple_to_nfattr);
diff --git a/net/ipv4/netfilter/ip_nat_helper_h323.c b/net/ipv4/netfilter/ip_nat_helper_h323.c
index d45663d137a7..419b878fb467 100644
--- a/net/ipv4/netfilter/ip_nat_helper_h323.c
+++ b/net/ipv4/netfilter/ip_nat_helper_h323.c
@@ -487,6 +487,80 @@ static int nat_q931(struct sk_buff **pskb, struct ip_conntrack *ct,
487} 487}
488 488
489/****************************************************************************/ 489/****************************************************************************/
490static void ip_nat_callforwarding_expect(struct ip_conntrack *new,
491 struct ip_conntrack_expect *this)
492{
493 struct ip_nat_range range;
494
495 /* This must be a fresh one. */
496 BUG_ON(new->status & IPS_NAT_DONE_MASK);
497
498 /* Change src to where master sends to */
499 range.flags = IP_NAT_RANGE_MAP_IPS;
500 range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.ip;
501
502 /* hook doesn't matter, but it has to do source manip */
503 ip_nat_setup_info(new, &range, NF_IP_POST_ROUTING);
504
505 /* For DST manip, map port here to where it's expected. */
506 range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
507 range.min = range.max = this->saved_proto;
508 range.min_ip = range.max_ip = this->saved_ip;
509
510 /* hook doesn't matter, but it has to do destination manip */
511 ip_nat_setup_info(new, &range, NF_IP_PRE_ROUTING);
512
513 ip_conntrack_q931_expect(new, this);
514}
515
516/****************************************************************************/
517static int nat_callforwarding(struct sk_buff **pskb, struct ip_conntrack *ct,
518 enum ip_conntrack_info ctinfo,
519 unsigned char **data, int dataoff,
520 TransportAddress * addr, u_int16_t port,
521 struct ip_conntrack_expect *exp)
522{
523 int dir = CTINFO2DIR(ctinfo);
524 u_int16_t nated_port;
525
526 /* Set expectations for NAT */
527 exp->saved_ip = exp->tuple.dst.ip;
528 exp->tuple.dst.ip = ct->tuplehash[!dir].tuple.dst.ip;
529 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
530 exp->expectfn = ip_nat_callforwarding_expect;
531 exp->dir = !dir;
532
533 /* Try to get same port: if not, try to change it. */
534 for (nated_port = port; nated_port != 0; nated_port++) {
535 exp->tuple.dst.u.tcp.port = htons(nated_port);
536 if (ip_conntrack_expect_related(exp) == 0)
537 break;
538 }
539
540 if (nated_port == 0) { /* No port available */
541 if (net_ratelimit())
542 printk("ip_nat_q931: out of TCP ports\n");
543 return 0;
544 }
545
546 /* Modify signal */
547 if (!set_h225_addr(pskb, data, dataoff, addr,
548 ct->tuplehash[!dir].tuple.dst.ip,
549 nated_port) == 0) {
550 ip_conntrack_unexpect_related(exp);
551 return -1;
552 }
553
554 /* Success */
555 DEBUGP("ip_nat_q931: expect Call Forwarding "
556 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
557 NIPQUAD(exp->tuple.src.ip), ntohs(exp->tuple.src.u.tcp.port),
558 NIPQUAD(exp->tuple.dst.ip), ntohs(exp->tuple.dst.u.tcp.port));
559
560 return 0;
561}
562
563/****************************************************************************/
490static int __init init(void) 564static int __init init(void)
491{ 565{
492 BUG_ON(set_h245_addr_hook != NULL); 566 BUG_ON(set_h245_addr_hook != NULL);
@@ -496,6 +570,7 @@ static int __init init(void)
496 BUG_ON(nat_rtp_rtcp_hook != NULL); 570 BUG_ON(nat_rtp_rtcp_hook != NULL);
497 BUG_ON(nat_t120_hook != NULL); 571 BUG_ON(nat_t120_hook != NULL);
498 BUG_ON(nat_h245_hook != NULL); 572 BUG_ON(nat_h245_hook != NULL);
573 BUG_ON(nat_callforwarding_hook != NULL);
499 BUG_ON(nat_q931_hook != NULL); 574 BUG_ON(nat_q931_hook != NULL);
500 575
501 set_h245_addr_hook = set_h245_addr; 576 set_h245_addr_hook = set_h245_addr;
@@ -505,6 +580,7 @@ static int __init init(void)
505 nat_rtp_rtcp_hook = nat_rtp_rtcp; 580 nat_rtp_rtcp_hook = nat_rtp_rtcp;
506 nat_t120_hook = nat_t120; 581 nat_t120_hook = nat_t120;
507 nat_h245_hook = nat_h245; 582 nat_h245_hook = nat_h245;
583 nat_callforwarding_hook = nat_callforwarding;
508 nat_q931_hook = nat_q931; 584 nat_q931_hook = nat_q931;
509 585
510 DEBUGP("ip_nat_h323: init success\n"); 586 DEBUGP("ip_nat_h323: init success\n");
@@ -521,6 +597,7 @@ static void __exit fini(void)
521 nat_rtp_rtcp_hook = NULL; 597 nat_rtp_rtcp_hook = NULL;
522 nat_t120_hook = NULL; 598 nat_t120_hook = NULL;
523 nat_h245_hook = NULL; 599 nat_h245_hook = NULL;
600 nat_callforwarding_hook = NULL;
524 nat_q931_hook = NULL; 601 nat_q931_hook = NULL;
525 synchronize_net(); 602 synchronize_net();
526} 603}
diff --git a/net/ipv4/netfilter/ip_nat_sip.c b/net/ipv4/netfilter/ip_nat_sip.c
new file mode 100644
index 000000000000..6ffba63adca2
--- /dev/null
+++ b/net/ipv4/netfilter/ip_nat_sip.c
@@ -0,0 +1,249 @@
1/* SIP extension for UDP NAT alteration.
2 *
3 * (C) 2005 by Christian Hentschel <chentschel@arnet.com.ar>
4 * based on RR's ip_nat_ftp.c and other modules.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/module.h>
12#include <linux/skbuff.h>
13#include <linux/ip.h>
14#include <linux/udp.h>
15
16#include <linux/netfilter_ipv4.h>
17#include <linux/netfilter_ipv4/ip_nat.h>
18#include <linux/netfilter_ipv4/ip_nat_helper.h>
19#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
20#include <linux/netfilter_ipv4/ip_conntrack_sip.h>
21
22MODULE_LICENSE("GPL");
23MODULE_AUTHOR("Christian Hentschel <chentschel@arnet.com.ar>");
24MODULE_DESCRIPTION("SIP NAT helper");
25
26#if 0
27#define DEBUGP printk
28#else
29#define DEBUGP(format, args...)
30#endif
31
32extern struct sip_header_nfo ct_sip_hdrs[];
33
34static unsigned int mangle_sip_packet(struct sk_buff **pskb,
35 enum ip_conntrack_info ctinfo,
36 struct ip_conntrack *ct,
37 const char **dptr, size_t dlen,
38 char *buffer, int bufflen,
39 struct sip_header_nfo *hnfo)
40{
41 unsigned int matchlen, matchoff;
42
43 if (ct_sip_get_info(*dptr, dlen, &matchoff, &matchlen, hnfo) <= 0)
44 return 0;
45
46 if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
47 matchoff, matchlen, buffer, bufflen))
48 return 0;
49
50 /* We need to reload this. Thanks Patrick. */
51 *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
52 return 1;
53}
54
55static unsigned int ip_nat_sip(struct sk_buff **pskb,
56 enum ip_conntrack_info ctinfo,
57 struct ip_conntrack *ct,
58 const char **dptr)
59{
60 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
61 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
62 unsigned int bufflen, dataoff;
63 u_int32_t ip;
64 u_int16_t port;
65
66 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
67
68 ip = ct->tuplehash[!dir].tuple.dst.ip;
69 port = ct->tuplehash[!dir].tuple.dst.u.udp.port;
70 bufflen = sprintf(buffer, "%u.%u.%u.%u:%u", NIPQUAD(ip), ntohs(port));
71
72 /* short packet ? */
73 if (((*pskb)->len - dataoff) < (sizeof("SIP/2.0") - 1))
74 return 0;
75
76 /* Basic rules: requests and responses. */
77 if (memcmp(*dptr, "SIP/2.0", sizeof("SIP/2.0") - 1) == 0) {
78 const char *aux;
79
80 if ((ctinfo) < IP_CT_IS_REPLY) {
81 mangle_sip_packet(pskb, ctinfo, ct, dptr,
82 (*pskb)->len - dataoff,
83 buffer, bufflen,
84 &ct_sip_hdrs[POS_CONTACT]);
85 return 1;
86 }
87
88 if (!mangle_sip_packet(pskb, ctinfo, ct, dptr,
89 (*pskb)->len - dataoff,
90 buffer, bufflen, &ct_sip_hdrs[POS_VIA]))
91 return 0;
92
93 /* This search should ignore case, but later.. */
94 aux = ct_sip_search("CSeq:", *dptr, sizeof("CSeq:") - 1,
95 (*pskb)->len - dataoff);
96 if (!aux)
97 return 0;
98
99 if (!ct_sip_search("REGISTER", aux, sizeof("REGISTER"),
100 ct_sip_lnlen(aux, *dptr + (*pskb)->len - dataoff)))
101 return 1;
102
103 return mangle_sip_packet(pskb, ctinfo, ct, dptr,
104 (*pskb)->len - dataoff,
105 buffer, bufflen,
106 &ct_sip_hdrs[POS_CONTACT]);
107 }
108 if ((ctinfo) < IP_CT_IS_REPLY) {
109 if (!mangle_sip_packet(pskb, ctinfo, ct, dptr,
110 (*pskb)->len - dataoff,
111 buffer, bufflen, &ct_sip_hdrs[POS_VIA]))
112 return 0;
113
114 /* Mangle Contact if exists only. - watch udp_nat_mangle()! */
115 mangle_sip_packet(pskb, ctinfo, ct, dptr, (*pskb)->len - dataoff,
116 buffer, bufflen, &ct_sip_hdrs[POS_CONTACT]);
117 return 1;
118 }
119 /* This mangle requests headers. */
120 return mangle_sip_packet(pskb, ctinfo, ct, dptr,
121 ct_sip_lnlen(*dptr,
122 *dptr + (*pskb)->len - dataoff),
123 buffer, bufflen, &ct_sip_hdrs[POS_REQ_HEADER]);
124}
125
126static int mangle_content_len(struct sk_buff **pskb,
127 enum ip_conntrack_info ctinfo,
128 struct ip_conntrack *ct,
129 const char *dptr)
130{
131 unsigned int dataoff, matchoff, matchlen;
132 char buffer[sizeof("65536")];
133 int bufflen;
134
135 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
136
137 /* Get actual SDP lenght */
138 if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
139 &matchlen, &ct_sip_hdrs[POS_SDP_HEADER]) > 0) {
140
141 /* since ct_sip_get_info() give us a pointer passing 'v='
142 we need to add 2 bytes in this count. */
143 int c_len = (*pskb)->len - dataoff - matchoff + 2;
144
145 /* Now, update SDP lenght */
146 if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
147 &matchlen, &ct_sip_hdrs[POS_CONTENT]) > 0) {
148
149 bufflen = sprintf(buffer, "%u", c_len);
150
151 return ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
152 matchoff, matchlen,
153 buffer, bufflen);
154 }
155 }
156 return 0;
157}
158
159static unsigned int mangle_sdp(struct sk_buff **pskb,
160 enum ip_conntrack_info ctinfo,
161 struct ip_conntrack *ct,
162 u_int32_t newip, u_int16_t port,
163 const char *dptr)
164{
165 char buffer[sizeof("nnn.nnn.nnn.nnn")];
166 unsigned int dataoff, bufflen;
167
168 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
169
170 /* Mangle owner and contact info. */
171 bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
172 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
173 buffer, bufflen, &ct_sip_hdrs[POS_OWNER]))
174 return 0;
175
176 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
177 buffer, bufflen, &ct_sip_hdrs[POS_CONNECTION]))
178 return 0;
179
180 /* Mangle media port. */
181 bufflen = sprintf(buffer, "%u", port);
182 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
183 buffer, bufflen, &ct_sip_hdrs[POS_MEDIA]))
184 return 0;
185
186 return mangle_content_len(pskb, ctinfo, ct, dptr);
187}
188
189/* So, this packet has hit the connection tracking matching code.
190 Mangle it, and change the expectation to match the new version. */
191static unsigned int ip_nat_sdp(struct sk_buff **pskb,
192 enum ip_conntrack_info ctinfo,
193 struct ip_conntrack_expect *exp,
194 const char *dptr)
195{
196 struct ip_conntrack *ct = exp->master;
197 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
198 u_int32_t newip;
199 u_int16_t port;
200
201 DEBUGP("ip_nat_sdp():\n");
202
203 /* Connection will come from reply */
204 newip = ct->tuplehash[!dir].tuple.dst.ip;
205
206 exp->tuple.dst.ip = newip;
207 exp->saved_proto.udp.port = exp->tuple.dst.u.udp.port;
208 exp->dir = !dir;
209
210 /* When you see the packet, we need to NAT it the same as the
211 this one. */
212 exp->expectfn = ip_nat_follow_master;
213
214 /* Try to get same port: if not, try to change it. */
215 for (port = ntohs(exp->saved_proto.udp.port); port != 0; port++) {
216 exp->tuple.dst.u.udp.port = htons(port);
217 if (ip_conntrack_expect_related(exp) == 0)
218 break;
219 }
220
221 if (port == 0)
222 return NF_DROP;
223
224 if (!mangle_sdp(pskb, ctinfo, ct, newip, port, dptr)) {
225 ip_conntrack_unexpect_related(exp);
226 return NF_DROP;
227 }
228 return NF_ACCEPT;
229}
230
231static void __exit fini(void)
232{
233 ip_nat_sip_hook = NULL;
234 ip_nat_sdp_hook = NULL;
235 /* Make sure noone calls it, meanwhile. */
236 synchronize_net();
237}
238
239static int __init init(void)
240{
241 BUG_ON(ip_nat_sip_hook);
242 BUG_ON(ip_nat_sdp_hook);
243 ip_nat_sip_hook = ip_nat_sip;
244 ip_nat_sdp_hook = ip_nat_sdp;
245 return 0;
246}
247
248module_init(init);
249module_exit(fini);
diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
index c33244263b90..d20d557f915a 100644
--- a/net/ipv4/netfilter/ip_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c
@@ -1348,4 +1348,4 @@ static void __exit ip_nat_snmp_basic_fini(void)
1348module_init(ip_nat_snmp_basic_init); 1348module_init(ip_nat_snmp_basic_init);
1349module_exit(ip_nat_snmp_basic_fini); 1349module_exit(ip_nat_snmp_basic_fini);
1350 1350
1351module_param(debug, bool, 0600); 1351module_param(debug, int, 0600);
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index aad9d28c8d71..dbc83c5d7aa6 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -241,25 +241,17 @@ clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
241 struct iphdr *iph = skb->nh.iph; 241 struct iphdr *iph = skb->nh.iph;
242 unsigned long hashval; 242 unsigned long hashval;
243 u_int16_t sport, dport; 243 u_int16_t sport, dport;
244 struct tcphdr *th; 244 u_int16_t *ports;
245 struct udphdr *uh;
246 struct icmphdr *ih;
247 245
248 switch (iph->protocol) { 246 switch (iph->protocol) {
249 case IPPROTO_TCP: 247 case IPPROTO_TCP:
250 th = (void *)iph+iph->ihl*4;
251 sport = ntohs(th->source);
252 dport = ntohs(th->dest);
253 break;
254 case IPPROTO_UDP: 248 case IPPROTO_UDP:
255 uh = (void *)iph+iph->ihl*4; 249 case IPPROTO_SCTP:
256 sport = ntohs(uh->source); 250 case IPPROTO_DCCP:
257 dport = ntohs(uh->dest);
258 break;
259 case IPPROTO_ICMP: 251 case IPPROTO_ICMP:
260 ih = (void *)iph+iph->ihl*4; 252 ports = (void *)iph+iph->ihl*4;
261 sport = ntohs(ih->un.echo.id); 253 sport = ports[0];
262 dport = (ih->type<<8)|ih->code; 254 dport = ports[1];
263 break; 255 break;
264 default: 256 default:
265 if (net_ratelimit()) { 257 if (net_ratelimit()) {
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index 0bba3c2bb786..431a3ce6f7b7 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -147,6 +147,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
147 /* This packet will not be the same as the other: clear nf fields */ 147 /* This packet will not be the same as the other: clear nf fields */
148 nf_reset(nskb); 148 nf_reset(nskb);
149 nskb->nfmark = 0; 149 nskb->nfmark = 0;
150 skb_init_secmark(nskb);
150 151
151 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl); 152 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
152 153
diff --git a/net/ipv4/netfilter/ipt_hashlimit.c b/net/ipv4/netfilter/ipt_hashlimit.c
index 7c6836c4646e..92980ab8ce48 100644
--- a/net/ipv4/netfilter/ipt_hashlimit.c
+++ b/net/ipv4/netfilter/ipt_hashlimit.c
@@ -28,9 +28,6 @@
28#include <linux/jhash.h> 28#include <linux/jhash.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <linux/tcp.h>
32#include <linux/udp.h>
33#include <linux/sctp.h>
34#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
35#include <linux/seq_file.h> 32#include <linux/seq_file.h>
36#include <linux/list.h> 33#include <linux/list.h>
@@ -83,6 +80,7 @@ struct ipt_hashlimit_htable {
83 /* used internally */ 80 /* used internally */
84 spinlock_t lock; /* lock for list_head */ 81 spinlock_t lock; /* lock for list_head */
85 u_int32_t rnd; /* random seed for hash */ 82 u_int32_t rnd; /* random seed for hash */
83 int rnd_initialized;
86 struct timer_list timer; /* timer for gc */ 84 struct timer_list timer; /* timer for gc */
87 atomic_t count; /* number entries in table */ 85 atomic_t count; /* number entries in table */
88 86
@@ -137,8 +135,10 @@ __dsthash_alloc_init(struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst)
137 135
138 /* initialize hash with random val at the time we allocate 136 /* initialize hash with random val at the time we allocate
139 * the first hashtable entry */ 137 * the first hashtable entry */
140 if (!ht->rnd) 138 if (!ht->rnd_initialized) {
141 get_random_bytes(&ht->rnd, 4); 139 get_random_bytes(&ht->rnd, 4);
140 ht->rnd_initialized = 1;
141 }
142 142
143 if (ht->cfg.max && 143 if (ht->cfg.max &&
144 atomic_read(&ht->count) >= ht->cfg.max) { 144 atomic_read(&ht->count) >= ht->cfg.max) {
@@ -217,7 +217,7 @@ static int htable_create(struct ipt_hashlimit_info *minfo)
217 217
218 atomic_set(&hinfo->count, 0); 218 atomic_set(&hinfo->count, 0);
219 atomic_set(&hinfo->use, 1); 219 atomic_set(&hinfo->use, 1);
220 hinfo->rnd = 0; 220 hinfo->rnd_initialized = 0;
221 spin_lock_init(&hinfo->lock); 221 spin_lock_init(&hinfo->lock);
222 hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir); 222 hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir);
223 if (!hinfo->pde) { 223 if (!hinfo->pde) {
@@ -381,49 +381,6 @@ static inline void rateinfo_recalc(struct dsthash_ent *dh, unsigned long now)
381 dh->rateinfo.credit = dh->rateinfo.credit_cap; 381 dh->rateinfo.credit = dh->rateinfo.credit_cap;
382} 382}
383 383
384static inline int get_ports(const struct sk_buff *skb, int offset,
385 u16 ports[2])
386{
387 union {
388 struct tcphdr th;
389 struct udphdr uh;
390 sctp_sctphdr_t sctph;
391 } hdr_u, *ptr_u;
392
393 /* Must not be a fragment. */
394 if (offset)
395 return 1;
396
397 /* Must be big enough to read ports (both UDP and TCP have
398 them at the start). */
399 ptr_u = skb_header_pointer(skb, skb->nh.iph->ihl*4, 8, &hdr_u);
400 if (!ptr_u)
401 return 1;
402
403 switch (skb->nh.iph->protocol) {
404 case IPPROTO_TCP:
405 ports[0] = ptr_u->th.source;
406 ports[1] = ptr_u->th.dest;
407 break;
408 case IPPROTO_UDP:
409 ports[0] = ptr_u->uh.source;
410 ports[1] = ptr_u->uh.dest;
411 break;
412 case IPPROTO_SCTP:
413 ports[0] = ptr_u->sctph.source;
414 ports[1] = ptr_u->sctph.dest;
415 break;
416 default:
417 /* all other protocols don't supprot per-port hash
418 * buckets */
419 ports[0] = ports[1] = 0;
420 break;
421 }
422
423 return 0;
424}
425
426
427static int 384static int
428hashlimit_match(const struct sk_buff *skb, 385hashlimit_match(const struct sk_buff *skb,
429 const struct net_device *in, 386 const struct net_device *in,
@@ -449,8 +406,22 @@ hashlimit_match(const struct sk_buff *skb,
449 dst.src_ip = skb->nh.iph->saddr; 406 dst.src_ip = skb->nh.iph->saddr;
450 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT 407 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT
451 ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) { 408 ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) {
452 u_int16_t ports[2]; 409 u_int16_t _ports[2], *ports;
453 if (get_ports(skb, offset, ports)) { 410
411 switch (skb->nh.iph->protocol) {
412 case IPPROTO_TCP:
413 case IPPROTO_UDP:
414 case IPPROTO_SCTP:
415 case IPPROTO_DCCP:
416 ports = skb_header_pointer(skb, skb->nh.iph->ihl*4,
417 sizeof(_ports), &_ports);
418 break;
419 default:
420 _ports[0] = _ports[1] = 0;
421 ports = _ports;
422 break;
423 }
424 if (!ports) {
454 /* We've been asked to examine this packet, and we 425 /* We've been asked to examine this packet, and we
455 can't. Hence, no choice but to drop. */ 426 can't. Hence, no choice but to drop. */
456 *hotdrop = 1; 427 *hotdrop = 1;
@@ -561,7 +532,7 @@ static void
561hashlimit_destroy(const struct xt_match *match, void *matchinfo, 532hashlimit_destroy(const struct xt_match *match, void *matchinfo,
562 unsigned int matchsize) 533 unsigned int matchsize)
563{ 534{
564 struct ipt_hashlimit_info *r = (struct ipt_hashlimit_info *) matchinfo; 535 struct ipt_hashlimit_info *r = matchinfo;
565 536
566 htable_put(r->hinfo); 537 htable_put(r->hinfo);
567} 538}
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c
index b847ee409efb..61a2139f9cfd 100644
--- a/net/ipv4/netfilter/ipt_recent.c
+++ b/net/ipv4/netfilter/ipt_recent.c
@@ -1,1007 +1,499 @@
1/* Kernel module to check if the source address has been seen recently. */ 1/*
2/* Copyright 2002-2003, Stephen Frost, 2.5.x port by laforge@netfilter.org */ 2 * Copyright (c) 2006 Patrick McHardy <kaber@trash.net>
3/* Author: Stephen Frost <sfrost@snowman.net> */ 3 *
4/* Project Page: http://snowman.net/projects/ipt_recent/ */ 4 * This program is free software; you can redistribute it and/or modify
5/* This software is distributed under the terms of the GPL, Version 2 */ 5 * it under the terms of the GNU General Public License version 2 as
6/* This copyright does not cover user programs that use kernel services 6 * published by the Free Software Foundation.
7 * by normal system calls. */ 7 *
8 8 * This is a replacement of the old ipt_recent module, which carried the
9#include <linux/module.h> 9 * following copyright notice:
10#include <linux/skbuff.h> 10 *
11 * Author: Stephen Frost <sfrost@snowman.net>
12 * Copyright 2002-2003, Stephen Frost, 2.5.x port by laforge@netfilter.org
13 */
14#include <linux/init.h>
15#include <linux/moduleparam.h>
11#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
12#include <linux/spinlock.h> 17#include <linux/seq_file.h>
13#include <linux/interrupt.h> 18#include <linux/string.h>
14#include <asm/uaccess.h>
15#include <linux/ctype.h> 19#include <linux/ctype.h>
16#include <linux/ip.h> 20#include <linux/list.h>
17#include <linux/vmalloc.h> 21#include <linux/random.h>
18#include <linux/moduleparam.h> 22#include <linux/jhash.h>
23#include <linux/bitops.h>
24#include <linux/skbuff.h>
25#include <linux/inet.h>
19 26
20#include <linux/netfilter_ipv4/ip_tables.h> 27#include <linux/netfilter_ipv4/ip_tables.h>
21#include <linux/netfilter_ipv4/ipt_recent.h> 28#include <linux/netfilter_ipv4/ipt_recent.h>
22 29
23#undef DEBUG 30MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
24#define HASH_LOG 9 31MODULE_DESCRIPTION("IP tables recently seen matching module");
32MODULE_LICENSE("GPL");
25 33
26/* Defaults, these can be overridden on the module command-line. */
27static unsigned int ip_list_tot = 100; 34static unsigned int ip_list_tot = 100;
28static unsigned int ip_pkt_list_tot = 20; 35static unsigned int ip_pkt_list_tot = 20;
29static unsigned int ip_list_hash_size = 0; 36static unsigned int ip_list_hash_size = 0;
30static unsigned int ip_list_perms = 0644; 37static unsigned int ip_list_perms = 0644;
31#ifdef DEBUG
32static int debug = 1;
33#endif
34
35static char version[] =
36KERN_INFO RECENT_NAME " " RECENT_VER ": Stephen Frost <sfrost@snowman.net>. http://snowman.net/projects/ipt_recent/\n";
37
38MODULE_AUTHOR("Stephen Frost <sfrost@snowman.net>");
39MODULE_DESCRIPTION("IP tables recently seen matching module " RECENT_VER);
40MODULE_LICENSE("GPL");
41module_param(ip_list_tot, uint, 0400); 38module_param(ip_list_tot, uint, 0400);
42module_param(ip_pkt_list_tot, uint, 0400); 39module_param(ip_pkt_list_tot, uint, 0400);
43module_param(ip_list_hash_size, uint, 0400); 40module_param(ip_list_hash_size, uint, 0400);
44module_param(ip_list_perms, uint, 0400); 41module_param(ip_list_perms, uint, 0400);
45#ifdef DEBUG 42MODULE_PARM_DESC(ip_list_tot, "number of IPs to remember per list");
46module_param(debug, bool, 0600); 43MODULE_PARM_DESC(ip_pkt_list_tot, "number of packets per IP to remember (max. 255)");
47MODULE_PARM_DESC(debug,"enable debugging output"); 44MODULE_PARM_DESC(ip_list_hash_size, "size of hash table used to look up IPs");
48#endif 45MODULE_PARM_DESC(ip_list_perms, "permissions on /proc/net/ipt_recent/* files");
49MODULE_PARM_DESC(ip_list_tot,"number of IPs to remember per list"); 46
50MODULE_PARM_DESC(ip_pkt_list_tot,"number of packets per IP to remember"); 47
51MODULE_PARM_DESC(ip_list_hash_size,"size of hash table used to look up IPs"); 48struct recent_entry {
52MODULE_PARM_DESC(ip_list_perms,"permissions on /proc/net/ipt_recent/* files"); 49 struct list_head list;
53 50 struct list_head lru_list;
54/* Structure of our list of recently seen addresses. */ 51 u_int32_t addr;
55struct recent_ip_list { 52 u_int8_t ttl;
56 u_int32_t addr; 53 u_int8_t index;
57 u_int8_t ttl; 54 u_int16_t nstamps;
58 unsigned long last_seen; 55 unsigned long stamps[0];
59 unsigned long *last_pkts;
60 u_int32_t oldest_pkt;
61 u_int32_t hash_entry;
62 u_int32_t time_pos;
63};
64
65struct time_info_list {
66 u_int32_t position;
67 u_int32_t time;
68}; 56};
69 57
70/* Structure of our linked list of tables of recent lists. */ 58struct recent_table {
71struct recent_ip_tables { 59 struct list_head list;
72 char name[IPT_RECENT_NAME_LEN]; 60 char name[IPT_RECENT_NAME_LEN];
73 int count;
74 int time_pos;
75 struct recent_ip_list *table;
76 struct recent_ip_tables *next;
77 spinlock_t list_lock;
78 int *hash_table;
79 struct time_info_list *time_info;
80#ifdef CONFIG_PROC_FS 61#ifdef CONFIG_PROC_FS
81 struct proc_dir_entry *status_proc; 62 struct proc_dir_entry *proc;
82#endif /* CONFIG_PROC_FS */ 63#endif
64 unsigned int refcnt;
65 unsigned int entries;
66 struct list_head lru_list;
67 struct list_head iphash[0];
83}; 68};
84 69
85/* Our current list of addresses we have recently seen. 70static LIST_HEAD(tables);
86 * Only added to on a --set, and only updated on --set || --update
87 */
88static struct recent_ip_tables *r_tables = NULL;
89
90/* We protect r_list with this spinlock so two processors are not modifying
91 * the list at the same time.
92 */
93static DEFINE_SPINLOCK(recent_lock); 71static DEFINE_SPINLOCK(recent_lock);
72static DEFINE_MUTEX(recent_mutex);
94 73
95#ifdef CONFIG_PROC_FS 74#ifdef CONFIG_PROC_FS
96/* Our /proc/net/ipt_recent entry */ 75static struct proc_dir_entry *proc_dir;
97static struct proc_dir_entry *proc_net_ipt_recent = NULL; 76static struct file_operations recent_fops;
98#endif
99
100/* Function declaration for later. */
101static int
102match(const struct sk_buff *skb,
103 const struct net_device *in,
104 const struct net_device *out,
105 const struct xt_match *match,
106 const void *matchinfo,
107 int offset,
108 unsigned int protoff,
109 int *hotdrop);
110
111/* Function to hash a given address into the hash table of table_size size */
112static int hash_func(unsigned int addr, int table_size)
113{
114 int result = 0;
115 unsigned int value = addr;
116 do { result ^= value; } while((value >>= HASH_LOG));
117
118#ifdef DEBUG
119 if(debug) printk(KERN_INFO RECENT_NAME ": %d = hash_func(%u,%d)\n",
120 result & (table_size - 1),
121 addr,
122 table_size);
123#endif 77#endif
124 78
125 return(result & (table_size - 1)); 79static u_int32_t hash_rnd;
126} 80static int hash_rnd_initted;
127 81
128#ifdef CONFIG_PROC_FS 82static unsigned int recent_entry_hash(u_int32_t addr)
129/* This is the function which produces the output for our /proc output
130 * interface which lists each IP address, the last seen time and the
131 * other recent times the address was seen.
132 */
133
134static int ip_recent_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
135{ 83{
136 int len = 0, count, last_len = 0, pkt_count; 84 if (!hash_rnd_initted) {
137 off_t pos = 0; 85 get_random_bytes(&hash_rnd, 4);
138 off_t begin = 0; 86 hash_rnd_initted = 1;
139 struct recent_ip_tables *curr_table;
140
141 curr_table = (struct recent_ip_tables*) data;
142
143 spin_lock_bh(&curr_table->list_lock);
144 for(count = 0; count < ip_list_tot; count++) {
145 if(!curr_table->table[count].addr) continue;
146 last_len = len;
147 len += sprintf(buffer+len,"src=%u.%u.%u.%u ",NIPQUAD(curr_table->table[count].addr));
148 len += sprintf(buffer+len,"ttl: %u ",curr_table->table[count].ttl);
149 len += sprintf(buffer+len,"last_seen: %lu ",curr_table->table[count].last_seen);
150 len += sprintf(buffer+len,"oldest_pkt: %u ",curr_table->table[count].oldest_pkt);
151 len += sprintf(buffer+len,"last_pkts: %lu",curr_table->table[count].last_pkts[0]);
152 for(pkt_count = 1; pkt_count < ip_pkt_list_tot; pkt_count++) {
153 if(!curr_table->table[count].last_pkts[pkt_count]) break;
154 len += sprintf(buffer+len,", %lu",curr_table->table[count].last_pkts[pkt_count]);
155 }
156 len += sprintf(buffer+len,"\n");
157 pos = begin + len;
158 if(pos < offset) { len = 0; begin = pos; }
159 if(pos > offset + length) { len = last_len; break; }
160 } 87 }
161 88 return jhash_1word(addr, hash_rnd) & (ip_list_hash_size - 1);
162 *start = buffer + (offset - begin);
163 len -= (offset - begin);
164 if(len > length) len = length;
165
166 spin_unlock_bh(&curr_table->list_lock);
167 return len;
168} 89}
169 90
170/* ip_recent_ctrl provides an interface for users to modify the table 91static struct recent_entry *
171 * directly. This allows adding entries, removing entries, and 92recent_entry_lookup(const struct recent_table *table, u_int32_t addr, u_int8_t ttl)
172 * flushing the entire table.
173 * This is done by opening up the appropriate table for writing and
174 * sending one of:
175 * xx.xx.xx.xx -- Add entry to table with current time
176 * +xx.xx.xx.xx -- Add entry to table with current time
177 * -xx.xx.xx.xx -- Remove entry from table
178 * clear -- Flush table, remove all entries
179 */
180
181static int ip_recent_ctrl(struct file *file, const char __user *input, unsigned long size, void *data)
182{ 93{
183 static const u_int32_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff }; 94 struct recent_entry *e;
184 u_int32_t val; 95 unsigned int h;
185 int base, used = 0; 96
186 char c, *cp; 97 h = recent_entry_hash(addr);
187 union iaddr { 98 list_for_each_entry(e, &table->iphash[h], list)
188 uint8_t bytes[4]; 99 if (e->addr == addr && (ttl == e->ttl || !ttl || !e->ttl))
189 uint32_t word; 100 return e;
190 } res; 101 return NULL;
191 uint8_t *pp = res.bytes; 102}
192 int digit;
193
194 char buffer[20];
195 int len, check_set = 0, count;
196 u_int32_t addr = 0;
197 struct sk_buff *skb;
198 struct ipt_recent_info *info;
199 struct recent_ip_tables *curr_table;
200
201 curr_table = (struct recent_ip_tables*) data;
202
203 if(size > 20) len = 20; else len = size;
204
205 if(copy_from_user(buffer,input,len)) return -EFAULT;
206
207 if(len < 20) buffer[len] = '\0';
208
209#ifdef DEBUG
210 if(debug) printk(KERN_INFO RECENT_NAME ": ip_recent_ctrl len: %d, input: `%.20s'\n",len,buffer);
211#endif
212 103
213 cp = buffer; 104static void recent_entry_remove(struct recent_table *t, struct recent_entry *e)
214 while(isspace(*cp)) { cp++; used++; if(used >= len-5) return used; } 105{
106 list_del(&e->list);
107 list_del(&e->lru_list);
108 kfree(e);
109 t->entries--;
110}
215 111
216 /* Check if we are asked to flush the entire table */ 112static struct recent_entry *
217 if(!memcmp(cp,"clear",5)) { 113recent_entry_init(struct recent_table *t, u_int32_t addr, u_int8_t ttl)
218 used += 5; 114{
219 spin_lock_bh(&curr_table->list_lock); 115 struct recent_entry *e;
220 curr_table->time_pos = 0;
221 for(count = 0; count < ip_list_hash_size; count++) {
222 curr_table->hash_table[count] = -1;
223 }
224 for(count = 0; count < ip_list_tot; count++) {
225 curr_table->table[count].last_seen = 0;
226 curr_table->table[count].addr = 0;
227 curr_table->table[count].ttl = 0;
228 memset(curr_table->table[count].last_pkts,0,ip_pkt_list_tot*sizeof(unsigned long));
229 curr_table->table[count].oldest_pkt = 0;
230 curr_table->table[count].time_pos = 0;
231 curr_table->time_info[count].position = count;
232 curr_table->time_info[count].time = 0;
233 }
234 spin_unlock_bh(&curr_table->list_lock);
235 return used;
236 }
237 116
238 check_set = IPT_RECENT_SET; 117 if (t->entries >= ip_list_tot) {
239 switch(*cp) { 118 e = list_entry(t->lru_list.next, struct recent_entry, lru_list);
240 case '+': check_set = IPT_RECENT_SET; cp++; used++; break; 119 recent_entry_remove(t, e);
241 case '-': check_set = IPT_RECENT_REMOVE; cp++; used++; break;
242 default: if(!isdigit(*cp)) return (used+1); break;
243 } 120 }
121 e = kmalloc(sizeof(*e) + sizeof(e->stamps[0]) * ip_pkt_list_tot,
122 GFP_ATOMIC);
123 if (e == NULL)
124 return NULL;
125 e->addr = addr;
126 e->ttl = ttl;
127 e->stamps[0] = jiffies;
128 e->nstamps = 1;
129 e->index = 1;
130 list_add_tail(&e->list, &t->iphash[recent_entry_hash(addr)]);
131 list_add_tail(&e->lru_list, &t->lru_list);
132 t->entries++;
133 return e;
134}
244 135
245#ifdef DEBUG 136static void recent_entry_update(struct recent_table *t, struct recent_entry *e)
246 if(debug) printk(KERN_INFO RECENT_NAME ": ip_recent_ctrl cp: `%c', check_set: %d\n",*cp,check_set); 137{
247#endif 138 e->stamps[e->index++] = jiffies;
248 /* Get addr (effectively inet_aton()) */ 139 if (e->index > e->nstamps)
249 /* Shamelessly stolen from libc, a function in the kernel for doing 140 e->nstamps = e->index;
250 * this would, of course, be greatly preferred, but our options appear 141 e->index %= ip_pkt_list_tot;
251 * to be rather limited, so we will just do it ourselves here. 142 list_move_tail(&e->lru_list, &t->lru_list);
252 */ 143}
253 res.word = 0;
254
255 c = *cp;
256 for(;;) {
257 if(!isdigit(c)) return used;
258 val = 0; base = 10; digit = 0;
259 if(c == '0') {
260 c = *++cp;
261 if(c == 'x' || c == 'X') base = 16, c = *++cp;
262 else { base = 8; digit = 1; }
263 }
264 for(;;) {
265 if(isascii(c) && isdigit(c)) {
266 if(base == 8 && (c == '8' || c == '0')) return used;
267 val = (val * base) + (c - '0');
268 c = *++cp;
269 digit = 1;
270 } else if(base == 16 && isascii(c) && isxdigit(c)) {
271 val = (val << 4) | (c + 10 - (islower(c) ? 'a' : 'A'));
272 c = *++cp;
273 digit = 1;
274 } else break;
275 }
276 if(c == '.') {
277 if(pp > res.bytes + 2 || val > 0xff) return used;
278 *pp++ = val;
279 c = *++cp;
280 } else break;
281 }
282 used = cp - buffer;
283 if(c != '\0' && (!isascii(c) || !isspace(c))) return used;
284 if(c == '\n') used++;
285 if(!digit) return used;
286 144
287 if(val > max[pp - res.bytes]) return used; 145static struct recent_table *recent_table_lookup(const char *name)
288 addr = res.word | htonl(val); 146{
147 struct recent_table *t;
289 148
290 if(!addr && check_set == IPT_RECENT_SET) return used; 149 list_for_each_entry(t, &tables, list)
150 if (!strcmp(t->name, name))
151 return t;
152 return NULL;
153}
291 154
292#ifdef DEBUG 155static void recent_table_flush(struct recent_table *t)
293 if(debug) printk(KERN_INFO RECENT_NAME ": ip_recent_ctrl c: %c, addr: %u used: %d\n",c,addr,used); 156{
294#endif 157 struct recent_entry *e, *next;
158 unsigned int i;
295 159
296 /* Set up and just call match */ 160 for (i = 0; i < ip_list_hash_size; i++) {
297 info = kmalloc(sizeof(struct ipt_recent_info),GFP_KERNEL); 161 list_for_each_entry_safe(e, next, &t->iphash[i], list)
298 if(!info) { return -ENOMEM; } 162 recent_entry_remove(t, e);
299 info->seconds = 0;
300 info->hit_count = 0;
301 info->check_set = check_set;
302 info->invert = 0;
303 info->side = IPT_RECENT_SOURCE;
304 strncpy(info->name,curr_table->name,IPT_RECENT_NAME_LEN);
305 info->name[IPT_RECENT_NAME_LEN-1] = '\0';
306
307 skb = kmalloc(sizeof(struct sk_buff),GFP_KERNEL);
308 if (!skb) {
309 used = -ENOMEM;
310 goto out_free_info;
311 }
312 skb->nh.iph = kmalloc(sizeof(struct iphdr),GFP_KERNEL);
313 if (!skb->nh.iph) {
314 used = -ENOMEM;
315 goto out_free_skb;
316 } 163 }
317
318 skb->nh.iph->saddr = addr;
319 skb->nh.iph->daddr = 0;
320 /* Clear ttl since we have no way of knowing it */
321 skb->nh.iph->ttl = 0;
322 match(skb,NULL,NULL,NULL,info,0,0,NULL);
323
324 kfree(skb->nh.iph);
325out_free_skb:
326 kfree(skb);
327out_free_info:
328 kfree(info);
329
330#ifdef DEBUG
331 if(debug) printk(KERN_INFO RECENT_NAME ": Leaving ip_recent_ctrl addr: %u used: %d\n",addr,used);
332#endif
333 return used;
334} 164}
335 165
336#endif /* CONFIG_PROC_FS */
337
338/* 'match' is our primary function, called by the kernel whenever a rule is
339 * hit with our module as an option to it.
340 * What this function does depends on what was specifically asked of it by
341 * the user:
342 * --set -- Add or update last seen time of the source address of the packet
343 * -- matchinfo->check_set == IPT_RECENT_SET
344 * --rcheck -- Just check if the source address is in the list
345 * -- matchinfo->check_set == IPT_RECENT_CHECK
346 * --update -- If the source address is in the list, update last_seen
347 * -- matchinfo->check_set == IPT_RECENT_UPDATE
348 * --remove -- If the source address is in the list, remove it
349 * -- matchinfo->check_set == IPT_RECENT_REMOVE
350 * --seconds -- Option to --rcheck/--update, only match if last_seen within seconds
351 * -- matchinfo->seconds
352 * --hitcount -- Option to --rcheck/--update, only match if seen hitcount times
353 * -- matchinfo->hit_count
354 * --seconds and --hitcount can be combined
355 */
356static int 166static int
357match(const struct sk_buff *skb, 167ipt_recent_match(const struct sk_buff *skb,
358 const struct net_device *in, 168 const struct net_device *in, const struct net_device *out,
359 const struct net_device *out, 169 const struct xt_match *match, const void *matchinfo,
360 const struct xt_match *match, 170 int offset, unsigned int protoff, int *hotdrop)
361 const void *matchinfo,
362 int offset,
363 unsigned int protoff,
364 int *hotdrop)
365{ 171{
366 int pkt_count, hits_found, ans;
367 unsigned long now;
368 const struct ipt_recent_info *info = matchinfo; 172 const struct ipt_recent_info *info = matchinfo;
369 u_int32_t addr = 0, time_temp; 173 struct recent_table *t;
370 u_int8_t ttl = skb->nh.iph->ttl; 174 struct recent_entry *e;
371 int *hash_table; 175 u_int32_t addr;
372 int orig_hash_result, hash_result, temp, location = 0, time_loc, end_collision_chain = -1; 176 u_int8_t ttl;
373 struct time_info_list *time_info; 177 int ret = info->invert;
374 struct recent_ip_tables *curr_table;
375 struct recent_ip_tables *last_table;
376 struct recent_ip_list *r_list;
377
378#ifdef DEBUG
379 if(debug) printk(KERN_INFO RECENT_NAME ": match() called\n");
380#endif
381
382 /* Default is false ^ info->invert */
383 ans = info->invert;
384 178
385#ifdef DEBUG 179 if (info->side == IPT_RECENT_DEST)
386 if(debug) printk(KERN_INFO RECENT_NAME ": match(): name = '%s'\n",info->name); 180 addr = skb->nh.iph->daddr;
387#endif 181 else
182 addr = skb->nh.iph->saddr;
388 183
389 /* if out != NULL then routing has been done and TTL changed. 184 ttl = skb->nh.iph->ttl;
390 * We change it back here internally for match what came in before routing. */ 185 /* use TTL as seen before forwarding */
391 if(out) ttl++; 186 if (out && !skb->sk)
187 ttl++;
392 188
393 /* Find the right table */
394 spin_lock_bh(&recent_lock); 189 spin_lock_bh(&recent_lock);
395 curr_table = r_tables; 190 t = recent_table_lookup(info->name);
396 while( (last_table = curr_table) && strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (curr_table = curr_table->next) ); 191 e = recent_entry_lookup(t, addr,
397 192 info->check_set & IPT_RECENT_TTL ? ttl : 0);
398#ifdef DEBUG 193 if (e == NULL) {
399 if(debug) printk(KERN_INFO RECENT_NAME ": match(): table found('%s')\n",info->name); 194 if (!(info->check_set & IPT_RECENT_SET))
400#endif 195 goto out;
401 196 e = recent_entry_init(t, addr, ttl);
402 spin_unlock_bh(&recent_lock); 197 if (e == NULL)
403 198 *hotdrop = 1;
404 /* Table with this name not found, match impossible */ 199 ret ^= 1;
405 if(!curr_table) { return ans; } 200 goto out;
406
407 /* Make sure no one is changing the list while we work with it */
408 spin_lock_bh(&curr_table->list_lock);
409
410 r_list = curr_table->table;
411 if(info->side == IPT_RECENT_DEST) addr = skb->nh.iph->daddr; else addr = skb->nh.iph->saddr;
412
413 if(!addr) {
414#ifdef DEBUG
415 if(debug) printk(KERN_INFO RECENT_NAME ": match() address (%u) invalid, leaving.\n",addr);
416#endif
417 spin_unlock_bh(&curr_table->list_lock);
418 return ans;
419 }
420
421#ifdef DEBUG
422 if(debug) printk(KERN_INFO RECENT_NAME ": match(): checking table, addr: %u, ttl: %u, orig_ttl: %u\n",addr,ttl,skb->nh.iph->ttl);
423#endif
424
425 /* Get jiffies now in case they changed while we were waiting for a lock */
426 now = jiffies;
427 hash_table = curr_table->hash_table;
428 time_info = curr_table->time_info;
429
430 orig_hash_result = hash_result = hash_func(addr,ip_list_hash_size);
431 /* Hash entry at this result used */
432 /* Check for TTL match if requested. If TTL is zero then a match would never
433 * happen, so match regardless of existing TTL in that case. Zero means the
434 * entry was added via the /proc interface anyway, so we will just use the
435 * first TTL we get for that IP address. */
436 if(info->check_set & IPT_RECENT_TTL) {
437 while(hash_table[hash_result] != -1 && !(r_list[hash_table[hash_result]].addr == addr &&
438 (!r_list[hash_table[hash_result]].ttl || r_list[hash_table[hash_result]].ttl == ttl))) {
439 /* Collision in hash table */
440 hash_result = (hash_result + 1) % ip_list_hash_size;
441 }
442 } else {
443 while(hash_table[hash_result] != -1 && r_list[hash_table[hash_result]].addr != addr) {
444 /* Collision in hash table */
445 hash_result = (hash_result + 1) % ip_list_hash_size;
446 }
447 }
448
449 if(hash_table[hash_result] == -1 && !(info->check_set & IPT_RECENT_SET)) {
450 /* IP not in list and not asked to SET */
451 spin_unlock_bh(&curr_table->list_lock);
452 return ans;
453 }
454
455 /* Check if we need to handle the collision, do not need to on REMOVE */
456 if(orig_hash_result != hash_result && !(info->check_set & IPT_RECENT_REMOVE)) {
457#ifdef DEBUG
458 if(debug) printk(KERN_INFO RECENT_NAME ": match(): Collision in hash table. (or: %d,hr: %d,oa: %u,ha: %u)\n",
459 orig_hash_result,
460 hash_result,
461 r_list[hash_table[orig_hash_result]].addr,
462 addr);
463#endif
464
465 /* We had a collision.
466 * orig_hash_result is where we started, hash_result is where we ended up.
467 * So, swap them because we are likely to see the same guy again sooner */
468#ifdef DEBUG
469 if(debug) {
470 printk(KERN_INFO RECENT_NAME ": match(): Collision; hash_table[orig_hash_result] = %d\n",hash_table[orig_hash_result]);
471 printk(KERN_INFO RECENT_NAME ": match(): Collision; r_list[hash_table[orig_hash_result]].hash_entry = %d\n",
472 r_list[hash_table[orig_hash_result]].hash_entry);
473 }
474#endif
475
476 r_list[hash_table[orig_hash_result]].hash_entry = hash_result;
477
478
479 temp = hash_table[orig_hash_result];
480#ifdef DEBUG
481 if(debug) printk(KERN_INFO RECENT_NAME ": match(): Collision; hash_table[hash_result] = %d\n",hash_table[hash_result]);
482#endif
483 hash_table[orig_hash_result] = hash_table[hash_result];
484 hash_table[hash_result] = temp;
485 temp = hash_result;
486 hash_result = orig_hash_result;
487 orig_hash_result = temp;
488 time_info[r_list[hash_table[orig_hash_result]].time_pos].position = hash_table[orig_hash_result];
489 if(hash_table[hash_result] != -1) {
490 r_list[hash_table[hash_result]].hash_entry = hash_result;
491 time_info[r_list[hash_table[hash_result]].time_pos].position = hash_table[hash_result];
492 }
493
494#ifdef DEBUG
495 if(debug) printk(KERN_INFO RECENT_NAME ": match(): Collision handled.\n");
496#endif
497 } 201 }
498 202
499 if(hash_table[hash_result] == -1) { 203 if (info->check_set & IPT_RECENT_SET)
500#ifdef DEBUG 204 ret ^= 1;
501 if(debug) printk(KERN_INFO RECENT_NAME ": match(): New table entry. (hr: %d,ha: %u)\n", 205 else if (info->check_set & IPT_RECENT_REMOVE) {
502 hash_result, addr); 206 recent_entry_remove(t, e);
503#endif 207 ret ^= 1;
504 208 } else if (info->check_set & (IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) {
505 /* New item found and IPT_RECENT_SET, so we need to add it */ 209 unsigned long t = jiffies - info->seconds * HZ;
506 location = time_info[curr_table->time_pos].position; 210 unsigned int i, hits = 0;
507 hash_table[r_list[location].hash_entry] = -1; 211
508 hash_table[hash_result] = location; 212 for (i = 0; i < e->nstamps; i++) {
509 memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(unsigned long)); 213 if (info->seconds && time_after(t, e->stamps[i]))
510 r_list[location].time_pos = curr_table->time_pos; 214 continue;
511 r_list[location].addr = addr; 215 if (++hits >= info->hit_count) {
512 r_list[location].ttl = ttl; 216 ret ^= 1;
513 r_list[location].last_seen = now; 217 break;
514 r_list[location].oldest_pkt = 1;
515 r_list[location].last_pkts[0] = now;
516 r_list[location].hash_entry = hash_result;
517 time_info[curr_table->time_pos].time = r_list[location].last_seen;
518 curr_table->time_pos = (curr_table->time_pos + 1) % ip_list_tot;
519
520 ans = !info->invert;
521 } else {
522#ifdef DEBUG
523 if(debug) printk(KERN_INFO RECENT_NAME ": match(): Existing table entry. (hr: %d,ha: %u)\n",
524 hash_result,
525 addr);
526#endif
527
528 /* Existing item found */
529 location = hash_table[hash_result];
530 /* We have a match on address, now to make sure it meets all requirements for a
531 * full match. */
532 if(info->check_set & IPT_RECENT_CHECK || info->check_set & IPT_RECENT_UPDATE) {
533 if(!info->seconds && !info->hit_count) ans = !info->invert; else ans = info->invert;
534 if(info->seconds && !info->hit_count) {
535 if(time_before_eq(now,r_list[location].last_seen+info->seconds*HZ)) ans = !info->invert; else ans = info->invert;
536 }
537 if(info->seconds && info->hit_count) {
538 for(pkt_count = 0, hits_found = 0; pkt_count < ip_pkt_list_tot; pkt_count++) {
539 if(r_list[location].last_pkts[pkt_count] == 0) break;
540 if(time_before_eq(now,r_list[location].last_pkts[pkt_count]+info->seconds*HZ)) hits_found++;
541 }
542 if(hits_found >= info->hit_count) ans = !info->invert; else ans = info->invert;
543 }
544 if(info->hit_count && !info->seconds) {
545 for(pkt_count = 0, hits_found = 0; pkt_count < ip_pkt_list_tot; pkt_count++) {
546 if(r_list[location].last_pkts[pkt_count] == 0) break;
547 hits_found++;
548 }
549 if(hits_found >= info->hit_count) ans = !info->invert; else ans = info->invert;
550 } 218 }
551 } 219 }
552#ifdef DEBUG
553 if(debug) {
554 if(ans)
555 printk(KERN_INFO RECENT_NAME ": match(): match addr: %u\n",addr);
556 else
557 printk(KERN_INFO RECENT_NAME ": match(): no match addr: %u\n",addr);
558 }
559#endif
560
561 /* If and only if we have been asked to SET, or to UPDATE (on match) do we add the
562 * current timestamp to the last_seen. */
563 if((info->check_set & IPT_RECENT_SET && (ans = !info->invert)) || (info->check_set & IPT_RECENT_UPDATE && ans)) {
564#ifdef DEBUG
565 if(debug) printk(KERN_INFO RECENT_NAME ": match(): SET or UPDATE; updating time info.\n");
566#endif
567 /* Have to update our time info */
568 time_loc = r_list[location].time_pos;
569 time_info[time_loc].time = now;
570 time_info[time_loc].position = location;
571 while((time_info[(time_loc+1) % ip_list_tot].time < time_info[time_loc].time) && ((time_loc+1) % ip_list_tot) != curr_table->time_pos) {
572 time_temp = time_info[time_loc].time;
573 time_info[time_loc].time = time_info[(time_loc+1)%ip_list_tot].time;
574 time_info[(time_loc+1)%ip_list_tot].time = time_temp;
575 time_temp = time_info[time_loc].position;
576 time_info[time_loc].position = time_info[(time_loc+1)%ip_list_tot].position;
577 time_info[(time_loc+1)%ip_list_tot].position = time_temp;
578 r_list[time_info[time_loc].position].time_pos = time_loc;
579 r_list[time_info[(time_loc+1)%ip_list_tot].position].time_pos = (time_loc+1)%ip_list_tot;
580 time_loc = (time_loc+1) % ip_list_tot;
581 }
582 r_list[location].time_pos = time_loc;
583 r_list[location].ttl = ttl;
584 r_list[location].last_pkts[r_list[location].oldest_pkt] = now;
585 r_list[location].oldest_pkt = ++r_list[location].oldest_pkt % ip_pkt_list_tot;
586 r_list[location].last_seen = now;
587 }
588 /* If we have been asked to remove the entry from the list, just set it to 0 */
589 if(info->check_set & IPT_RECENT_REMOVE) {
590#ifdef DEBUG
591 if(debug) printk(KERN_INFO RECENT_NAME ": match(): REMOVE; clearing entry (or: %d, hr: %d).\n",orig_hash_result,hash_result);
592#endif
593 /* Check if this is part of a collision chain */
594 while(hash_table[(orig_hash_result+1) % ip_list_hash_size] != -1) {
595 orig_hash_result++;
596 if(hash_func(r_list[hash_table[orig_hash_result]].addr,ip_list_hash_size) == hash_result) {
597 /* Found collision chain, how deep does this rabbit hole go? */
598#ifdef DEBUG
599 if(debug) printk(KERN_INFO RECENT_NAME ": match(): REMOVE; found collision chain.\n");
600#endif
601 end_collision_chain = orig_hash_result;
602 }
603 }
604 if(end_collision_chain != -1) {
605#ifdef DEBUG
606 if(debug) printk(KERN_INFO RECENT_NAME ": match(): REMOVE; part of collision chain, moving to end.\n");
607#endif
608 /* Part of a collision chain, swap it with the end of the chain
609 * before removing. */
610 r_list[hash_table[end_collision_chain]].hash_entry = hash_result;
611 temp = hash_table[end_collision_chain];
612 hash_table[end_collision_chain] = hash_table[hash_result];
613 hash_table[hash_result] = temp;
614 time_info[r_list[hash_table[hash_result]].time_pos].position = hash_table[hash_result];
615 hash_result = end_collision_chain;
616 r_list[hash_table[hash_result]].hash_entry = hash_result;
617 time_info[r_list[hash_table[hash_result]].time_pos].position = hash_table[hash_result];
618 }
619 location = hash_table[hash_result];
620 hash_table[r_list[location].hash_entry] = -1;
621 time_loc = r_list[location].time_pos;
622 time_info[time_loc].time = 0;
623 time_info[time_loc].position = location;
624 while((time_info[(time_loc+1) % ip_list_tot].time < time_info[time_loc].time) && ((time_loc+1) % ip_list_tot) != curr_table->time_pos) {
625 time_temp = time_info[time_loc].time;
626 time_info[time_loc].time = time_info[(time_loc+1)%ip_list_tot].time;
627 time_info[(time_loc+1)%ip_list_tot].time = time_temp;
628 time_temp = time_info[time_loc].position;
629 time_info[time_loc].position = time_info[(time_loc+1)%ip_list_tot].position;
630 time_info[(time_loc+1)%ip_list_tot].position = time_temp;
631 r_list[time_info[time_loc].position].time_pos = time_loc;
632 r_list[time_info[(time_loc+1)%ip_list_tot].position].time_pos = (time_loc+1)%ip_list_tot;
633 time_loc = (time_loc+1) % ip_list_tot;
634 }
635 r_list[location].time_pos = time_loc;
636 r_list[location].last_seen = 0;
637 r_list[location].addr = 0;
638 r_list[location].ttl = 0;
639 memset(r_list[location].last_pkts,0,ip_pkt_list_tot*sizeof(unsigned long));
640 r_list[location].oldest_pkt = 0;
641 ans = !info->invert;
642 }
643 spin_unlock_bh(&curr_table->list_lock);
644 return ans;
645 } 220 }
646 221
647 spin_unlock_bh(&curr_table->list_lock); 222 if (info->check_set & IPT_RECENT_SET ||
648#ifdef DEBUG 223 (info->check_set & IPT_RECENT_UPDATE && ret)) {
649 if(debug) printk(KERN_INFO RECENT_NAME ": match() left.\n"); 224 recent_entry_update(t, e);
650#endif 225 e->ttl = ttl;
651 return ans; 226 }
227out:
228 spin_unlock_bh(&recent_lock);
229 return ret;
652} 230}
653 231
654/* This function is to verify that the rule given during the userspace iptables
655 * command is correct.
656 * If the command is valid then we check if the table name referred to by the
657 * rule exists, if not it is created.
658 */
659static int 232static int
660checkentry(const char *tablename, 233ipt_recent_checkentry(const char *tablename, const void *ip,
661 const void *ip, 234 const struct xt_match *match, void *matchinfo,
662 const struct xt_match *match, 235 unsigned int matchsize, unsigned int hook_mask)
663 void *matchinfo,
664 unsigned int matchsize,
665 unsigned int hook_mask)
666{ 236{
667 int flag = 0, c;
668 unsigned long *hold;
669 const struct ipt_recent_info *info = matchinfo; 237 const struct ipt_recent_info *info = matchinfo;
670 struct recent_ip_tables *curr_table, *find_table, *last_table; 238 struct recent_table *t;
671 239 unsigned i;
672#ifdef DEBUG 240 int ret = 0;
673 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() entered.\n");
674#endif
675
676 /* seconds and hit_count only valid for CHECK/UPDATE */
677 if(info->check_set & IPT_RECENT_SET) { flag++; if(info->seconds || info->hit_count) return 0; }
678 if(info->check_set & IPT_RECENT_REMOVE) { flag++; if(info->seconds || info->hit_count) return 0; }
679 if(info->check_set & IPT_RECENT_CHECK) flag++;
680 if(info->check_set & IPT_RECENT_UPDATE) flag++;
681
682 /* One and only one of these should ever be set */
683 if(flag != 1) return 0;
684
685 /* Name must be set to something */
686 if(!info->name || !info->name[0]) return 0;
687 241
688 /* Things look good, create a list for this if it does not exist */ 242 if (hweight8(info->check_set &
689 /* Lock the linked list while we play with it */ 243 (IPT_RECENT_SET | IPT_RECENT_REMOVE |
690 spin_lock_bh(&recent_lock); 244 IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) != 1)
691 245 return 0;
692 /* Look for an entry with this name already created */ 246 if ((info->check_set & (IPT_RECENT_SET | IPT_RECENT_REMOVE)) &&
693 /* Finds the end of the list and the entry before the end if current name does not exist */ 247 (info->seconds || info->hit_count))
694 find_table = r_tables; 248 return 0;
695 while( (last_table = find_table) && strncmp(info->name,find_table->name,IPT_RECENT_NAME_LEN) && (find_table = find_table->next) ); 249 if (info->name[0] == '\0' ||
250 strnlen(info->name, IPT_RECENT_NAME_LEN) == IPT_RECENT_NAME_LEN)
251 return 0;
696 252
697 /* If a table already exists just increment the count on that table and return */ 253 mutex_lock(&recent_mutex);
698 if(find_table) { 254 t = recent_table_lookup(info->name);
699#ifdef DEBUG 255 if (t != NULL) {
700 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: table found (%s), incrementing count.\n",info->name); 256 t->refcnt++;
701#endif 257 ret = 1;
702 find_table->count++; 258 goto out;
703 spin_unlock_bh(&recent_lock);
704 return 1;
705 } 259 }
706 260
707 spin_unlock_bh(&recent_lock); 261 t = kzalloc(sizeof(*t) + sizeof(t->iphash[0]) * ip_list_hash_size,
708 262 GFP_KERNEL);
709 /* Table with this name not found */ 263 if (t == NULL)
710 /* Allocate memory for new linked list item */ 264 goto out;
711 265 t->refcnt = 1;
712#ifdef DEBUG 266 strcpy(t->name, info->name);
713 if(debug) { 267 INIT_LIST_HEAD(&t->lru_list);
714 printk(KERN_INFO RECENT_NAME ": checkentry: no table found (%s)\n",info->name); 268 for (i = 0; i < ip_list_hash_size; i++)
715 printk(KERN_INFO RECENT_NAME ": checkentry: Allocationg %d for link-list entry.\n",sizeof(struct recent_ip_tables)); 269 INIT_LIST_HEAD(&t->iphash[i]);
270#ifdef CONFIG_PROC_FS
271 t->proc = create_proc_entry(t->name, ip_list_perms, proc_dir);
272 if (t->proc == NULL) {
273 kfree(t);
274 goto out;
716 } 275 }
276 t->proc->proc_fops = &recent_fops;
277 t->proc->data = t;
717#endif 278#endif
279 spin_lock_bh(&recent_lock);
280 list_add_tail(&t->list, &tables);
281 spin_unlock_bh(&recent_lock);
282 ret = 1;
283out:
284 mutex_unlock(&recent_mutex);
285 return ret;
286}
718 287
719 curr_table = vmalloc(sizeof(struct recent_ip_tables)); 288static void
720 if(curr_table == NULL) return 0; 289ipt_recent_destroy(const struct xt_match *match, void *matchinfo,
721 290 unsigned int matchsize)
722 spin_lock_init(&curr_table->list_lock); 291{
723 curr_table->next = NULL; 292 const struct ipt_recent_info *info = matchinfo;
724 curr_table->count = 1; 293 struct recent_table *t;
725 curr_table->time_pos = 0;
726 strncpy(curr_table->name,info->name,IPT_RECENT_NAME_LEN);
727 curr_table->name[IPT_RECENT_NAME_LEN-1] = '\0';
728
729 /* Allocate memory for this table and the list of packets in each entry. */
730#ifdef DEBUG
731 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for table (%s).\n",
732 sizeof(struct recent_ip_list)*ip_list_tot,
733 info->name);
734#endif
735
736 curr_table->table = vmalloc(sizeof(struct recent_ip_list)*ip_list_tot);
737 if(curr_table->table == NULL) { vfree(curr_table); return 0; }
738 memset(curr_table->table,0,sizeof(struct recent_ip_list)*ip_list_tot);
739#ifdef DEBUG
740 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for pkt_list.\n",
741 sizeof(unsigned long)*ip_pkt_list_tot*ip_list_tot);
742#endif
743
744 hold = vmalloc(sizeof(unsigned long)*ip_pkt_list_tot*ip_list_tot);
745#ifdef DEBUG
746 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: After pkt_list allocation.\n");
747#endif
748 if(hold == NULL) {
749 printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for pkt_list.\n");
750 vfree(curr_table->table);
751 vfree(curr_table);
752 return 0;
753 }
754 for(c = 0; c < ip_list_tot; c++) {
755 curr_table->table[c].last_pkts = hold + c*ip_pkt_list_tot;
756 }
757 294
758 /* Allocate memory for the hash table */ 295 mutex_lock(&recent_mutex);
759#ifdef DEBUG 296 t = recent_table_lookup(info->name);
760 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for hash_table.\n", 297 if (--t->refcnt == 0) {
761 sizeof(int)*ip_list_hash_size); 298 spin_lock_bh(&recent_lock);
299 list_del(&t->list);
300 spin_unlock_bh(&recent_lock);
301 recent_table_flush(t);
302#ifdef CONFIG_PROC_FS
303 remove_proc_entry(t->name, proc_dir);
762#endif 304#endif
763 305 kfree(t);
764 curr_table->hash_table = vmalloc(sizeof(int)*ip_list_hash_size);
765 if(!curr_table->hash_table) {
766 printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for hash_table.\n");
767 vfree(hold);
768 vfree(curr_table->table);
769 vfree(curr_table);
770 return 0;
771 }
772
773 for(c = 0; c < ip_list_hash_size; c++) {
774 curr_table->hash_table[c] = -1;
775 } 306 }
307 mutex_unlock(&recent_mutex);
308}
776 309
777 /* Allocate memory for the time info */ 310#ifdef CONFIG_PROC_FS
778#ifdef DEBUG 311struct recent_iter_state {
779 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: Allocating %d for time_info.\n", 312 struct recent_table *table;
780 sizeof(struct time_info_list)*ip_list_tot); 313 unsigned int bucket;
781#endif 314};
782 315
783 curr_table->time_info = vmalloc(sizeof(struct time_info_list)*ip_list_tot); 316static void *recent_seq_start(struct seq_file *seq, loff_t *pos)
784 if(!curr_table->time_info) { 317{
785 printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for time_info.\n"); 318 struct recent_iter_state *st = seq->private;
786 vfree(curr_table->hash_table); 319 struct recent_table *t = st->table;
787 vfree(hold); 320 struct recent_entry *e;
788 vfree(curr_table->table); 321 loff_t p = *pos;
789 vfree(curr_table);
790 return 0;
791 }
792 for(c = 0; c < ip_list_tot; c++) {
793 curr_table->time_info[c].position = c;
794 curr_table->time_info[c].time = 0;
795 }
796 322
797 /* Put the new table in place */
798 spin_lock_bh(&recent_lock); 323 spin_lock_bh(&recent_lock);
799 find_table = r_tables;
800 while( (last_table = find_table) && strncmp(info->name,find_table->name,IPT_RECENT_NAME_LEN) && (find_table = find_table->next) );
801
802 /* If a table already exists just increment the count on that table and return */
803 if(find_table) {
804 find_table->count++;
805 spin_unlock_bh(&recent_lock);
806#ifdef DEBUG
807 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry: table found (%s), created by other process.\n",info->name);
808#endif
809 vfree(curr_table->time_info);
810 vfree(curr_table->hash_table);
811 vfree(hold);
812 vfree(curr_table->table);
813 vfree(curr_table);
814 return 1;
815 }
816 if(!last_table) r_tables = curr_table; else last_table->next = curr_table;
817
818 spin_unlock_bh(&recent_lock);
819 324
820#ifdef CONFIG_PROC_FS 325 for (st->bucket = 0; st->bucket < ip_list_hash_size; st->bucket++) {
821 /* Create our proc 'status' entry. */ 326 list_for_each_entry(e, &t->iphash[st->bucket], list) {
822 curr_table->status_proc = create_proc_entry(curr_table->name, ip_list_perms, proc_net_ipt_recent); 327 if (p-- == 0)
823 if (!curr_table->status_proc) { 328 return e;
824 vfree(hold);
825 printk(KERN_INFO RECENT_NAME ": checkentry: unable to allocate for /proc entry.\n");
826 /* Destroy the created table */
827 spin_lock_bh(&recent_lock);
828 last_table = NULL;
829 curr_table = r_tables;
830 if(!curr_table) {
831#ifdef DEBUG
832 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, no tables.\n");
833#endif
834 spin_unlock_bh(&recent_lock);
835 return 0;
836 }
837 while( strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (last_table = curr_table) && (curr_table = curr_table->next) );
838 if(!curr_table) {
839#ifdef DEBUG
840 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() create_proc failed, table already destroyed.\n");
841#endif
842 spin_unlock_bh(&recent_lock);
843 return 0;
844 } 329 }
845 if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next;
846 spin_unlock_bh(&recent_lock);
847 vfree(curr_table->time_info);
848 vfree(curr_table->hash_table);
849 vfree(curr_table->table);
850 vfree(curr_table);
851 return 0;
852 } 330 }
853 331 return NULL;
854 curr_table->status_proc->owner = THIS_MODULE; 332}
855 curr_table->status_proc->data = curr_table;
856 wmb();
857 curr_table->status_proc->read_proc = ip_recent_get_info;
858 curr_table->status_proc->write_proc = ip_recent_ctrl;
859#endif /* CONFIG_PROC_FS */
860
861#ifdef DEBUG
862 if(debug) printk(KERN_INFO RECENT_NAME ": checkentry() left.\n");
863#endif
864 333
865 return 1; 334static void *recent_seq_next(struct seq_file *seq, void *v, loff_t *pos)
335{
336 struct recent_iter_state *st = seq->private;
337 struct recent_table *t = st->table;
338 struct recent_entry *e = v;
339 struct list_head *head = e->list.next;
340
341 while (head == &t->iphash[st->bucket]) {
342 if (++st->bucket >= ip_list_hash_size)
343 return NULL;
344 head = t->iphash[st->bucket].next;
345 }
346 (*pos)++;
347 return list_entry(head, struct recent_entry, list);
866} 348}
867 349
868/* This function is called in the event that a rule matching this module is 350static void recent_seq_stop(struct seq_file *s, void *v)
869 * removed.
870 * When this happens we need to check if there are no other rules matching
871 * the table given. If that is the case then we remove the table and clean
872 * up its memory.
873 */
874static void
875destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
876{ 351{
877 const struct ipt_recent_info *info = matchinfo; 352 spin_unlock_bh(&recent_lock);
878 struct recent_ip_tables *curr_table, *last_table; 353}
879 354
880#ifdef DEBUG 355static int recent_seq_show(struct seq_file *seq, void *v)
881 if(debug) printk(KERN_INFO RECENT_NAME ": destroy() entered.\n"); 356{
882#endif 357 struct recent_entry *e = v;
358 unsigned int i;
359
360 i = (e->index - 1) % ip_pkt_list_tot;
361 seq_printf(seq, "src=%u.%u.%u.%u ttl: %u last_seen: %lu oldest_pkt: %u",
362 NIPQUAD(e->addr), e->ttl, e->stamps[i], e->index);
363 for (i = 0; i < e->nstamps; i++)
364 seq_printf(seq, "%s %lu", i ? "," : "", e->stamps[i]);
365 seq_printf(seq, "\n");
366 return 0;
367}
883 368
884 if(matchsize != IPT_ALIGN(sizeof(struct ipt_recent_info))) return; 369static struct seq_operations recent_seq_ops = {
370 .start = recent_seq_start,
371 .next = recent_seq_next,
372 .stop = recent_seq_stop,
373 .show = recent_seq_show,
374};
885 375
886 /* Lock the linked list while we play with it */ 376static int recent_seq_open(struct inode *inode, struct file *file)
887 spin_lock_bh(&recent_lock); 377{
378 struct proc_dir_entry *pde = PDE(inode);
379 struct seq_file *seq;
380 struct recent_iter_state *st;
381 int ret;
382
383 st = kzalloc(sizeof(*st), GFP_KERNEL);
384 if (st == NULL)
385 return -ENOMEM;
386 ret = seq_open(file, &recent_seq_ops);
387 if (ret)
388 kfree(st);
389 st->table = pde->data;
390 seq = file->private_data;
391 seq->private = st;
392 return ret;
393}
888 394
889 /* Look for an entry with this name already created */ 395static ssize_t recent_proc_write(struct file *file, const char __user *input,
890 /* Finds the end of the list and the entry before the end if current name does not exist */ 396 size_t size, loff_t *loff)
891 last_table = NULL; 397{
892 curr_table = r_tables; 398 struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
893 if(!curr_table) { 399 struct recent_table *t = pde->data;
894#ifdef DEBUG 400 struct recent_entry *e;
895 if(debug) printk(KERN_INFO RECENT_NAME ": destroy() No tables found, leaving.\n"); 401 char buf[sizeof("+255.255.255.255")], *c = buf;
896#endif 402 u_int32_t addr;
403 int add;
404
405 if (size > sizeof(buf))
406 size = sizeof(buf);
407 if (copy_from_user(buf, input, size))
408 return -EFAULT;
409 while (isspace(*c))
410 c++;
411
412 if (size - (c - buf) < 5)
413 return c - buf;
414 if (!strncmp(c, "clear", 5)) {
415 c += 5;
416 spin_lock_bh(&recent_lock);
417 recent_table_flush(t);
897 spin_unlock_bh(&recent_lock); 418 spin_unlock_bh(&recent_lock);
898 return; 419 return c - buf;
899 } 420 }
900 while( strncmp(info->name,curr_table->name,IPT_RECENT_NAME_LEN) && (last_table = curr_table) && (curr_table = curr_table->next) );
901 421
902 /* If a table does not exist then do nothing and return */ 422 switch (*c) {
903 if(!curr_table) { 423 case '-':
904#ifdef DEBUG 424 add = 0;
905 if(debug) printk(KERN_INFO RECENT_NAME ": destroy() table not found, leaving.\n"); 425 c++;
906#endif 426 break;
907 spin_unlock_bh(&recent_lock); 427 case '+':
908 return; 428 c++;
429 default:
430 add = 1;
431 break;
909 } 432 }
433 addr = in_aton(c);
910 434
911 curr_table->count--; 435 spin_lock_bh(&recent_lock);
912 436 e = recent_entry_lookup(t, addr, 0);
913 /* If count is still non-zero then there are still rules referenceing it so we do nothing */ 437 if (e == NULL) {
914 if(curr_table->count) { 438 if (add)
915#ifdef DEBUG 439 recent_entry_init(t, addr, 0);
916 if(debug) printk(KERN_INFO RECENT_NAME ": destroy() table found, non-zero count, leaving.\n"); 440 } else {
917#endif 441 if (add)
918 spin_unlock_bh(&recent_lock); 442 recent_entry_update(t, e);
919 return; 443 else
444 recent_entry_remove(t, e);
920 } 445 }
921
922#ifdef DEBUG
923 if(debug) printk(KERN_INFO RECENT_NAME ": destroy() table found, zero count, removing.\n");
924#endif
925
926 /* Count must be zero so we remove this table from the list */
927 if(last_table) last_table->next = curr_table->next; else r_tables = curr_table->next;
928
929 spin_unlock_bh(&recent_lock); 446 spin_unlock_bh(&recent_lock);
447 return size;
448}
930 449
931 /* lock to make sure any late-runners still using this after we removed it from 450static struct file_operations recent_fops = {
932 * the list finish up then remove everything */ 451 .open = recent_seq_open,
933 spin_lock_bh(&curr_table->list_lock); 452 .read = seq_read,
934 spin_unlock_bh(&curr_table->list_lock); 453 .write = recent_proc_write,
935 454 .release = seq_release_private,
936#ifdef CONFIG_PROC_FS 455 .owner = THIS_MODULE,
937 if(curr_table->status_proc) remove_proc_entry(curr_table->name,proc_net_ipt_recent); 456};
938#endif /* CONFIG_PROC_FS */ 457#endif /* CONFIG_PROC_FS */
939 vfree(curr_table->table[0].last_pkts);
940 vfree(curr_table->table);
941 vfree(curr_table->hash_table);
942 vfree(curr_table->time_info);
943 vfree(curr_table);
944
945#ifdef DEBUG
946 if(debug) printk(KERN_INFO RECENT_NAME ": destroy() left.\n");
947#endif
948 458
949 return;
950}
951
952/* This is the structure we pass to ipt_register to register our
953 * module with iptables.
954 */
955static struct ipt_match recent_match = { 459static struct ipt_match recent_match = {
956 .name = "recent", 460 .name = "recent",
957 .match = match, 461 .match = ipt_recent_match,
958 .matchsize = sizeof(struct ipt_recent_info), 462 .matchsize = sizeof(struct ipt_recent_info),
959 .checkentry = checkentry, 463 .checkentry = ipt_recent_checkentry,
960 .destroy = destroy, 464 .destroy = ipt_recent_destroy,
961 .me = THIS_MODULE 465 .me = THIS_MODULE,
962}; 466};
963 467
964/* Kernel module initialization. */
965static int __init ipt_recent_init(void) 468static int __init ipt_recent_init(void)
966{ 469{
967 int err, count; 470 int err;
968 471
969 printk(version); 472 if (!ip_list_tot || !ip_pkt_list_tot || ip_pkt_list_tot > 255)
970#ifdef CONFIG_PROC_FS 473 return -EINVAL;
971 proc_net_ipt_recent = proc_mkdir("ipt_recent",proc_net); 474 ip_list_hash_size = 1 << fls(ip_list_tot);
972 if(!proc_net_ipt_recent) return -ENOMEM;
973#endif
974
975 if(ip_list_hash_size && ip_list_hash_size <= ip_list_tot) {
976 printk(KERN_WARNING RECENT_NAME ": ip_list_hash_size too small, resetting to default.\n");
977 ip_list_hash_size = 0;
978 }
979
980 if(!ip_list_hash_size) {
981 ip_list_hash_size = ip_list_tot*3;
982 count = 2*2;
983 while(ip_list_hash_size > count) count = count*2;
984 ip_list_hash_size = count;
985 }
986
987#ifdef DEBUG
988 if(debug) printk(KERN_INFO RECENT_NAME ": ip_list_hash_size: %d\n",ip_list_hash_size);
989#endif
990 475
991 err = ipt_register_match(&recent_match); 476 err = ipt_register_match(&recent_match);
477#ifdef CONFIG_PROC_FS
992 if (err) 478 if (err)
993 remove_proc_entry("ipt_recent", proc_net); 479 return err;
480 proc_dir = proc_mkdir("ipt_recent", proc_net);
481 if (proc_dir == NULL) {
482 ipt_unregister_match(&recent_match);
483 err = -ENOMEM;
484 }
485#endif
994 return err; 486 return err;
995} 487}
996 488
997/* Kernel module destruction. */ 489static void __exit ipt_recent_exit(void)
998static void __exit ipt_recent_fini(void)
999{ 490{
491 BUG_ON(!list_empty(&tables));
1000 ipt_unregister_match(&recent_match); 492 ipt_unregister_match(&recent_match);
1001 493#ifdef CONFIG_PROC_FS
1002 remove_proc_entry("ipt_recent",proc_net); 494 remove_proc_entry("ipt_recent", proc_net);
495#endif
1003} 496}
1004 497
1005/* Register our module with the kernel. */
1006module_init(ipt_recent_init); 498module_init(ipt_recent_init);
1007module_exit(ipt_recent_fini); 499module_exit(ipt_recent_exit);
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 77d974443c7b..8cc8e1b36778 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -145,7 +145,7 @@ static unsigned int ipv4_conntrack_help(unsigned int hooknum,
145 145
146 /* This is where we call the helper: as the packet goes out. */ 146 /* This is where we call the helper: as the packet goes out. */
147 ct = nf_ct_get(*pskb, &ctinfo); 147 ct = nf_ct_get(*pskb, &ctinfo);
148 if (!ct) 148 if (!ct || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY)
149 return NF_ACCEPT; 149 return NF_ACCEPT;
150 150
151 help = nfct_help(ct); 151 help = nfct_help(ct);
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index 4b0d361cc6e6..663a73ee3f2f 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -235,7 +235,7 @@ icmp_error(struct sk_buff *skb, unsigned int dataoff,
235 } 235 }
236 236
237 /* See ip_conntrack_proto_tcp.c */ 237 /* See ip_conntrack_proto_tcp.c */
238 if (hooknum == NF_IP_PRE_ROUTING && 238 if (nf_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
239 nf_ip_checksum(skb, hooknum, dataoff, 0)) { 239 nf_ip_checksum(skb, hooknum, dataoff, 0)) {
240 if (LOG_INVALID(IPPROTO_ICMP)) 240 if (LOG_INVALID(IPPROTO_ICMP))
241 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL, 241 nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index fc2562415555..bd221ec3f81e 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -103,7 +103,7 @@ static void raw_v4_unhash(struct sock *sk)
103} 103}
104 104
105struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num, 105struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num,
106 unsigned long raddr, unsigned long laddr, 106 __be32 raddr, __be32 laddr,
107 int dif) 107 int dif)
108{ 108{
109 struct hlist_node *node; 109 struct hlist_node *node;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 6b6c3adfcf00..ce4cd5f35511 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -182,14 +182,6 @@ ctl_table ipv4_table[] = {
182 .strategy = &ipv4_doint_and_flush_strategy, 182 .strategy = &ipv4_doint_and_flush_strategy,
183 }, 183 },
184 { 184 {
185 .ctl_name = NET_IPV4_AUTOCONFIG,
186 .procname = "ip_autoconfig",
187 .data = &ipv4_config.autoconfig,
188 .maxlen = sizeof(int),
189 .mode = 0644,
190 .proc_handler = &proc_dointvec
191 },
192 {
193 .ctl_name = NET_IPV4_NO_PMTU_DISC, 185 .ctl_name = NET_IPV4_NO_PMTU_DISC,
194 .procname = "ip_no_pmtu_disc", 186 .procname = "ip_no_pmtu_disc",
195 .data = &ipv4_config.no_pmtu_disc, 187 .data = &ipv4_config.no_pmtu_disc,
@@ -688,6 +680,24 @@ ctl_table ipv4_table[] = {
688 .mode = 0644, 680 .mode = 0644,
689 .proc_handler = &proc_dointvec 681 .proc_handler = &proc_dointvec
690 }, 682 },
683#ifdef CONFIG_NET_DMA
684 {
685 .ctl_name = NET_TCP_DMA_COPYBREAK,
686 .procname = "tcp_dma_copybreak",
687 .data = &sysctl_tcp_dma_copybreak,
688 .maxlen = sizeof(int),
689 .mode = 0644,
690 .proc_handler = &proc_dointvec
691 },
692#endif
693 {
694 .ctl_name = NET_TCP_SLOW_START_AFTER_IDLE,
695 .procname = "tcp_slow_start_after_idle",
696 .data = &sysctl_tcp_slow_start_after_idle,
697 .maxlen = sizeof(int),
698 .mode = 0644,
699 .proc_handler = &proc_dointvec
700 },
691 { .ctl_name = 0 } 701 { .ctl_name = 0 }
692}; 702};
693 703
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e2b7b8055037..74998f250071 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -263,7 +263,7 @@
263#include <net/tcp.h> 263#include <net/tcp.h>
264#include <net/xfrm.h> 264#include <net/xfrm.h>
265#include <net/ip.h> 265#include <net/ip.h>
266 266#include <net/netdma.h>
267 267
268#include <asm/uaccess.h> 268#include <asm/uaccess.h>
269#include <asm/ioctls.h> 269#include <asm/ioctls.h>
@@ -622,14 +622,10 @@ ssize_t tcp_sendpage(struct socket *sock, struct page *page, int offset,
622 ssize_t res; 622 ssize_t res;
623 struct sock *sk = sock->sk; 623 struct sock *sk = sock->sk;
624 624
625#define TCP_ZC_CSUM_FLAGS (NETIF_F_IP_CSUM | NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
626
627 if (!(sk->sk_route_caps & NETIF_F_SG) || 625 if (!(sk->sk_route_caps & NETIF_F_SG) ||
628 !(sk->sk_route_caps & TCP_ZC_CSUM_FLAGS)) 626 !(sk->sk_route_caps & NETIF_F_ALL_CSUM))
629 return sock_no_sendpage(sock, page, offset, size, flags); 627 return sock_no_sendpage(sock, page, offset, size, flags);
630 628
631#undef TCP_ZC_CSUM_FLAGS
632
633 lock_sock(sk); 629 lock_sock(sk);
634 TCP_CHECK_TIMER(sk); 630 TCP_CHECK_TIMER(sk);
635 res = do_tcp_sendpages(sk, &page, offset, size, flags); 631 res = do_tcp_sendpages(sk, &page, offset, size, flags);
@@ -726,9 +722,7 @@ new_segment:
726 /* 722 /*
727 * Check whether we can use HW checksum. 723 * Check whether we can use HW checksum.
728 */ 724 */
729 if (sk->sk_route_caps & 725 if (sk->sk_route_caps & NETIF_F_ALL_CSUM)
730 (NETIF_F_IP_CSUM | NETIF_F_NO_CSUM |
731 NETIF_F_HW_CSUM))
732 skb->ip_summed = CHECKSUM_HW; 726 skb->ip_summed = CHECKSUM_HW;
733 727
734 skb_entail(sk, tp, skb); 728 skb_entail(sk, tp, skb);
@@ -937,7 +931,7 @@ static int tcp_recv_urg(struct sock *sk, long timeo,
937 * calculation of whether or not we must ACK for the sake of 931 * calculation of whether or not we must ACK for the sake of
938 * a window update. 932 * a window update.
939 */ 933 */
940static void cleanup_rbuf(struct sock *sk, int copied) 934void tcp_cleanup_rbuf(struct sock *sk, int copied)
941{ 935{
942 struct tcp_sock *tp = tcp_sk(sk); 936 struct tcp_sock *tp = tcp_sk(sk);
943 int time_to_ack = 0; 937 int time_to_ack = 0;
@@ -1072,11 +1066,11 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
1072 break; 1066 break;
1073 } 1067 }
1074 if (skb->h.th->fin) { 1068 if (skb->h.th->fin) {
1075 sk_eat_skb(sk, skb); 1069 sk_eat_skb(sk, skb, 0);
1076 ++seq; 1070 ++seq;
1077 break; 1071 break;
1078 } 1072 }
1079 sk_eat_skb(sk, skb); 1073 sk_eat_skb(sk, skb, 0);
1080 if (!desc->count) 1074 if (!desc->count)
1081 break; 1075 break;
1082 } 1076 }
@@ -1086,7 +1080,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
1086 1080
1087 /* Clean up data we have read: This will do ACK frames. */ 1081 /* Clean up data we have read: This will do ACK frames. */
1088 if (copied) 1082 if (copied)
1089 cleanup_rbuf(sk, copied); 1083 tcp_cleanup_rbuf(sk, copied);
1090 return copied; 1084 return copied;
1091} 1085}
1092 1086
@@ -1110,6 +1104,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1110 int target; /* Read at least this many bytes */ 1104 int target; /* Read at least this many bytes */
1111 long timeo; 1105 long timeo;
1112 struct task_struct *user_recv = NULL; 1106 struct task_struct *user_recv = NULL;
1107 int copied_early = 0;
1113 1108
1114 lock_sock(sk); 1109 lock_sock(sk);
1115 1110
@@ -1133,6 +1128,17 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1133 1128
1134 target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); 1129 target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
1135 1130
1131#ifdef CONFIG_NET_DMA
1132 tp->ucopy.dma_chan = NULL;
1133 preempt_disable();
1134 if ((len > sysctl_tcp_dma_copybreak) && !(flags & MSG_PEEK) &&
1135 !sysctl_tcp_low_latency && __get_cpu_var(softnet_data.net_dma)) {
1136 preempt_enable_no_resched();
1137 tp->ucopy.pinned_list = dma_pin_iovec_pages(msg->msg_iov, len);
1138 } else
1139 preempt_enable_no_resched();
1140#endif
1141
1136 do { 1142 do {
1137 struct sk_buff *skb; 1143 struct sk_buff *skb;
1138 u32 offset; 1144 u32 offset;
@@ -1220,7 +1226,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1220 } 1226 }
1221 } 1227 }
1222 1228
1223 cleanup_rbuf(sk, copied); 1229 tcp_cleanup_rbuf(sk, copied);
1224 1230
1225 if (!sysctl_tcp_low_latency && tp->ucopy.task == user_recv) { 1231 if (!sysctl_tcp_low_latency && tp->ucopy.task == user_recv) {
1226 /* Install new reader */ 1232 /* Install new reader */
@@ -1274,6 +1280,10 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1274 } else 1280 } else
1275 sk_wait_data(sk, &timeo); 1281 sk_wait_data(sk, &timeo);
1276 1282
1283#ifdef CONFIG_NET_DMA
1284 tp->ucopy.wakeup = 0;
1285#endif
1286
1277 if (user_recv) { 1287 if (user_recv) {
1278 int chunk; 1288 int chunk;
1279 1289
@@ -1329,13 +1339,39 @@ do_prequeue:
1329 } 1339 }
1330 1340
1331 if (!(flags & MSG_TRUNC)) { 1341 if (!(flags & MSG_TRUNC)) {
1332 err = skb_copy_datagram_iovec(skb, offset, 1342#ifdef CONFIG_NET_DMA
1333 msg->msg_iov, used); 1343 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
1334 if (err) { 1344 tp->ucopy.dma_chan = get_softnet_dma();
1335 /* Exception. Bailout! */ 1345
1336 if (!copied) 1346 if (tp->ucopy.dma_chan) {
1337 copied = -EFAULT; 1347 tp->ucopy.dma_cookie = dma_skb_copy_datagram_iovec(
1338 break; 1348 tp->ucopy.dma_chan, skb, offset,
1349 msg->msg_iov, used,
1350 tp->ucopy.pinned_list);
1351
1352 if (tp->ucopy.dma_cookie < 0) {
1353
1354 printk(KERN_ALERT "dma_cookie < 0\n");
1355
1356 /* Exception. Bailout! */
1357 if (!copied)
1358 copied = -EFAULT;
1359 break;
1360 }
1361 if ((offset + used) == skb->len)
1362 copied_early = 1;
1363
1364 } else
1365#endif
1366 {
1367 err = skb_copy_datagram_iovec(skb, offset,
1368 msg->msg_iov, used);
1369 if (err) {
1370 /* Exception. Bailout! */
1371 if (!copied)
1372 copied = -EFAULT;
1373 break;
1374 }
1339 } 1375 }
1340 } 1376 }
1341 1377
@@ -1355,15 +1391,19 @@ skip_copy:
1355 1391
1356 if (skb->h.th->fin) 1392 if (skb->h.th->fin)
1357 goto found_fin_ok; 1393 goto found_fin_ok;
1358 if (!(flags & MSG_PEEK)) 1394 if (!(flags & MSG_PEEK)) {
1359 sk_eat_skb(sk, skb); 1395 sk_eat_skb(sk, skb, copied_early);
1396 copied_early = 0;
1397 }
1360 continue; 1398 continue;
1361 1399
1362 found_fin_ok: 1400 found_fin_ok:
1363 /* Process the FIN. */ 1401 /* Process the FIN. */
1364 ++*seq; 1402 ++*seq;
1365 if (!(flags & MSG_PEEK)) 1403 if (!(flags & MSG_PEEK)) {
1366 sk_eat_skb(sk, skb); 1404 sk_eat_skb(sk, skb, copied_early);
1405 copied_early = 0;
1406 }
1367 break; 1407 break;
1368 } while (len > 0); 1408 } while (len > 0);
1369 1409
@@ -1386,12 +1426,42 @@ skip_copy:
1386 tp->ucopy.len = 0; 1426 tp->ucopy.len = 0;
1387 } 1427 }
1388 1428
1429#ifdef CONFIG_NET_DMA
1430 if (tp->ucopy.dma_chan) {
1431 struct sk_buff *skb;
1432 dma_cookie_t done, used;
1433
1434 dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
1435
1436 while (dma_async_memcpy_complete(tp->ucopy.dma_chan,
1437 tp->ucopy.dma_cookie, &done,
1438 &used) == DMA_IN_PROGRESS) {
1439 /* do partial cleanup of sk_async_wait_queue */
1440 while ((skb = skb_peek(&sk->sk_async_wait_queue)) &&
1441 (dma_async_is_complete(skb->dma_cookie, done,
1442 used) == DMA_SUCCESS)) {
1443 __skb_dequeue(&sk->sk_async_wait_queue);
1444 kfree_skb(skb);
1445 }
1446 }
1447
1448 /* Safe to free early-copied skbs now */
1449 __skb_queue_purge(&sk->sk_async_wait_queue);
1450 dma_chan_put(tp->ucopy.dma_chan);
1451 tp->ucopy.dma_chan = NULL;
1452 }
1453 if (tp->ucopy.pinned_list) {
1454 dma_unpin_iovec_pages(tp->ucopy.pinned_list);
1455 tp->ucopy.pinned_list = NULL;
1456 }
1457#endif
1458
1389 /* According to UNIX98, msg_name/msg_namelen are ignored 1459 /* According to UNIX98, msg_name/msg_namelen are ignored
1390 * on connected socket. I was just happy when found this 8) --ANK 1460 * on connected socket. I was just happy when found this 8) --ANK
1391 */ 1461 */
1392 1462
1393 /* Clean up data we have read: This will do ACK frames. */ 1463 /* Clean up data we have read: This will do ACK frames. */
1394 cleanup_rbuf(sk, copied); 1464 tcp_cleanup_rbuf(sk, copied);
1395 1465
1396 TCP_CHECK_TIMER(sk); 1466 TCP_CHECK_TIMER(sk);
1397 release_sock(sk); 1467 release_sock(sk);
@@ -1658,6 +1728,9 @@ int tcp_disconnect(struct sock *sk, int flags)
1658 __skb_queue_purge(&sk->sk_receive_queue); 1728 __skb_queue_purge(&sk->sk_receive_queue);
1659 sk_stream_writequeue_purge(sk); 1729 sk_stream_writequeue_purge(sk);
1660 __skb_queue_purge(&tp->out_of_order_queue); 1730 __skb_queue_purge(&tp->out_of_order_queue);
1731#ifdef CONFIG_NET_DMA
1732 __skb_queue_purge(&sk->sk_async_wait_queue);
1733#endif
1661 1734
1662 inet->dport = 0; 1735 inet->dport = 0;
1663 1736
@@ -1858,7 +1931,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
1858 (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) && 1931 (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&
1859 inet_csk_ack_scheduled(sk)) { 1932 inet_csk_ack_scheduled(sk)) {
1860 icsk->icsk_ack.pending |= ICSK_ACK_PUSHED; 1933 icsk->icsk_ack.pending |= ICSK_ACK_PUSHED;
1861 cleanup_rbuf(sk, 1); 1934 tcp_cleanup_rbuf(sk, 1);
1862 if (!(val & 1)) 1935 if (!(val & 1))
1863 icsk->icsk_ack.pingpong = 1; 1936 icsk->icsk_ack.pingpong = 1;
1864 } 1937 }
diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c
index 035f2092d73a..b2d9021ad22b 100644
--- a/net/ipv4/tcp_bic.c
+++ b/net/ipv4/tcp_bic.c
@@ -198,12 +198,6 @@ static u32 bictcp_undo_cwnd(struct sock *sk)
198 return max(tp->snd_cwnd, ca->last_max_cwnd); 198 return max(tp->snd_cwnd, ca->last_max_cwnd);
199} 199}
200 200
201static u32 bictcp_min_cwnd(struct sock *sk)
202{
203 const struct tcp_sock *tp = tcp_sk(sk);
204 return tp->snd_ssthresh;
205}
206
207static void bictcp_state(struct sock *sk, u8 new_state) 201static void bictcp_state(struct sock *sk, u8 new_state)
208{ 202{
209 if (new_state == TCP_CA_Loss) 203 if (new_state == TCP_CA_Loss)
@@ -231,7 +225,6 @@ static struct tcp_congestion_ops bictcp = {
231 .cong_avoid = bictcp_cong_avoid, 225 .cong_avoid = bictcp_cong_avoid,
232 .set_state = bictcp_state, 226 .set_state = bictcp_state,
233 .undo_cwnd = bictcp_undo_cwnd, 227 .undo_cwnd = bictcp_undo_cwnd,
234 .min_cwnd = bictcp_min_cwnd,
235 .pkts_acked = bictcp_acked, 228 .pkts_acked = bictcp_acked,
236 .owner = THIS_MODULE, 229 .owner = THIS_MODULE,
237 .name = "bic", 230 .name = "bic",
diff --git a/net/ipv4/tcp_compound.c b/net/ipv4/tcp_compound.c
new file mode 100644
index 000000000000..bc54f7e9aea9
--- /dev/null
+++ b/net/ipv4/tcp_compound.c
@@ -0,0 +1,448 @@
1/*
2 * TCP Vegas congestion control
3 *
4 * This is based on the congestion detection/avoidance scheme described in
5 * Lawrence S. Brakmo and Larry L. Peterson.
6 * "TCP Vegas: End to end congestion avoidance on a global internet."
7 * IEEE Journal on Selected Areas in Communication, 13(8):1465--1480,
8 * October 1995. Available from:
9 * ftp://ftp.cs.arizona.edu/xkernel/Papers/jsac.ps
10 *
11 * See http://www.cs.arizona.edu/xkernel/ for their implementation.
12 * The main aspects that distinguish this implementation from the
13 * Arizona Vegas implementation are:
14 * o We do not change the loss detection or recovery mechanisms of
15 * Linux in any way. Linux already recovers from losses quite well,
16 * using fine-grained timers, NewReno, and FACK.
17 * o To avoid the performance penalty imposed by increasing cwnd
18 * only every-other RTT during slow start, we increase during
19 * every RTT during slow start, just like Reno.
20 * o Largely to allow continuous cwnd growth during slow start,
21 * we use the rate at which ACKs come back as the "actual"
22 * rate, rather than the rate at which data is sent.
23 * o To speed convergence to the right rate, we set the cwnd
24 * to achieve the right ("actual") rate when we exit slow start.
25 * o To filter out the noise caused by delayed ACKs, we use the
26 * minimum RTT sample observed during the last RTT to calculate
27 * the actual rate.
28 * o When the sender re-starts from idle, it waits until it has
29 * received ACKs for an entire flight of new data before making
30 * a cwnd adjustment decision. The original Vegas implementation
31 * assumed senders never went idle.
32 *
33 *
34 * TCP Compound based on TCP Vegas
35 *
36 * further details can be found here:
37 * ftp://ftp.research.microsoft.com/pub/tr/TR-2005-86.pdf
38 */
39
40#include <linux/config.h>
41#include <linux/mm.h>
42#include <linux/module.h>
43#include <linux/skbuff.h>
44#include <linux/inet_diag.h>
45
46#include <net/tcp.h>
47
48/* Default values of the Vegas variables, in fixed-point representation
49 * with V_PARAM_SHIFT bits to the right of the binary point.
50 */
51#define V_PARAM_SHIFT 1
52
53#define TCP_COMPOUND_ALPHA 3U
54#define TCP_COMPOUND_BETA 1U
55#define TCP_COMPOUND_GAMMA 30
56#define TCP_COMPOUND_ZETA 1
57
58/* TCP compound variables */
59struct compound {
60 u32 beg_snd_nxt; /* right edge during last RTT */
61 u32 beg_snd_una; /* left edge during last RTT */
62 u32 beg_snd_cwnd; /* saves the size of the cwnd */
63 u8 doing_vegas_now; /* if true, do vegas for this RTT */
64 u16 cntRTT; /* # of RTTs measured within last RTT */
65 u32 minRTT; /* min of RTTs measured within last RTT (in usec) */
66 u32 baseRTT; /* the min of all Vegas RTT measurements seen (in usec) */
67
68 u32 cwnd;
69 u32 dwnd;
70};
71
72/* There are several situations when we must "re-start" Vegas:
73 *
74 * o when a connection is established
75 * o after an RTO
76 * o after fast recovery
77 * o when we send a packet and there is no outstanding
78 * unacknowledged data (restarting an idle connection)
79 *
80 * In these circumstances we cannot do a Vegas calculation at the
81 * end of the first RTT, because any calculation we do is using
82 * stale info -- both the saved cwnd and congestion feedback are
83 * stale.
84 *
85 * Instead we must wait until the completion of an RTT during
86 * which we actually receive ACKs.
87 */
88static inline void vegas_enable(struct sock *sk)
89{
90 const struct tcp_sock *tp = tcp_sk(sk);
91 struct compound *vegas = inet_csk_ca(sk);
92
93 /* Begin taking Vegas samples next time we send something. */
94 vegas->doing_vegas_now = 1;
95
96 /* Set the beginning of the next send window. */
97 vegas->beg_snd_nxt = tp->snd_nxt;
98
99 vegas->cntRTT = 0;
100 vegas->minRTT = 0x7fffffff;
101}
102
103/* Stop taking Vegas samples for now. */
104static inline void vegas_disable(struct sock *sk)
105{
106 struct compound *vegas = inet_csk_ca(sk);
107
108 vegas->doing_vegas_now = 0;
109}
110
111static void tcp_compound_init(struct sock *sk)
112{
113 struct compound *vegas = inet_csk_ca(sk);
114 const struct tcp_sock *tp = tcp_sk(sk);
115
116 vegas->baseRTT = 0x7fffffff;
117 vegas_enable(sk);
118
119 vegas->dwnd = 0;
120 vegas->cwnd = tp->snd_cwnd;
121}
122
123/* Do RTT sampling needed for Vegas.
124 * Basically we:
125 * o min-filter RTT samples from within an RTT to get the current
126 * propagation delay + queuing delay (we are min-filtering to try to
127 * avoid the effects of delayed ACKs)
128 * o min-filter RTT samples from a much longer window (forever for now)
129 * to find the propagation delay (baseRTT)
130 */
131static void tcp_compound_rtt_calc(struct sock *sk, u32 usrtt)
132{
133 struct compound *vegas = inet_csk_ca(sk);
134 u32 vrtt = usrtt + 1; /* Never allow zero rtt or baseRTT */
135
136 /* Filter to find propagation delay: */
137 if (vrtt < vegas->baseRTT)
138 vegas->baseRTT = vrtt;
139
140 /* Find the min RTT during the last RTT to find
141 * the current prop. delay + queuing delay:
142 */
143
144 vegas->minRTT = min(vegas->minRTT, vrtt);
145 vegas->cntRTT++;
146}
147
148static void tcp_compound_state(struct sock *sk, u8 ca_state)
149{
150
151 if (ca_state == TCP_CA_Open)
152 vegas_enable(sk);
153 else
154 vegas_disable(sk);
155}
156
157
158/* 64bit divisor, dividend and result. dynamic precision */
159static inline u64 div64_64(u64 dividend, u64 divisor)
160{
161 u32 d = divisor;
162
163 if (divisor > 0xffffffffULL) {
164 unsigned int shift = fls(divisor >> 32);
165
166 d = divisor >> shift;
167 dividend >>= shift;
168 }
169
170 /* avoid 64 bit division if possible */
171 if (dividend >> 32)
172 do_div(dividend, d);
173 else
174 dividend = (u32) dividend / d;
175
176 return dividend;
177}
178
179/* calculate the quartic root of "a" using Newton-Raphson */
180static u32 qroot(u64 a)
181{
182 u32 x, x1;
183
184 /* Initial estimate is based on:
185 * qrt(x) = exp(log(x) / 4)
186 */
187 x = 1u << (fls64(a) >> 2);
188
189 /*
190 * Iteration based on:
191 * 3
192 * x = ( 3 * x + a / x ) / 4
193 * k+1 k k
194 */
195 do {
196 u64 x3 = x;
197
198 x1 = x;
199 x3 *= x;
200 x3 *= x;
201
202 x = (3 * x + (u32) div64_64(a, x3)) / 4;
203 } while (abs(x1 - x) > 1);
204
205 return x;
206}
207
208
209/*
210 * If the connection is idle and we are restarting,
211 * then we don't want to do any Vegas calculations
212 * until we get fresh RTT samples. So when we
213 * restart, we reset our Vegas state to a clean
214 * slate. After we get acks for this flight of
215 * packets, _then_ we can make Vegas calculations
216 * again.
217 */
218static void tcp_compound_cwnd_event(struct sock *sk, enum tcp_ca_event event)
219{
220 if (event == CA_EVENT_CWND_RESTART || event == CA_EVENT_TX_START)
221 tcp_compound_init(sk);
222}
223
224static void tcp_compound_cong_avoid(struct sock *sk, u32 ack,
225 u32 seq_rtt, u32 in_flight, int flag)
226{
227 struct tcp_sock *tp = tcp_sk(sk);
228 struct compound *vegas = inet_csk_ca(sk);
229 u8 inc = 0;
230
231 if (vegas->cwnd + vegas->dwnd > tp->snd_cwnd) {
232 if (vegas->cwnd > tp->snd_cwnd || vegas->dwnd > tp->snd_cwnd) {
233 vegas->cwnd = tp->snd_cwnd;
234 vegas->dwnd = 0;
235 } else
236 vegas->cwnd = tp->snd_cwnd - vegas->dwnd;
237
238 }
239
240 if (!tcp_is_cwnd_limited(sk, in_flight))
241 return;
242
243 if (vegas->cwnd <= tp->snd_ssthresh)
244 inc = 1;
245 else if (tp->snd_cwnd_cnt < tp->snd_cwnd)
246 tp->snd_cwnd_cnt++;
247
248 if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
249 inc = 1;
250 tp->snd_cwnd_cnt = 0;
251 }
252
253 if (inc && tp->snd_cwnd < tp->snd_cwnd_clamp)
254 vegas->cwnd++;
255
256 /* The key players are v_beg_snd_una and v_beg_snd_nxt.
257 *
258 * These are so named because they represent the approximate values
259 * of snd_una and snd_nxt at the beginning of the current RTT. More
260 * precisely, they represent the amount of data sent during the RTT.
261 * At the end of the RTT, when we receive an ACK for v_beg_snd_nxt,
262 * we will calculate that (v_beg_snd_nxt - v_beg_snd_una) outstanding
263 * bytes of data have been ACKed during the course of the RTT, giving
264 * an "actual" rate of:
265 *
266 * (v_beg_snd_nxt - v_beg_snd_una) / (rtt duration)
267 *
268 * Unfortunately, v_beg_snd_una is not exactly equal to snd_una,
269 * because delayed ACKs can cover more than one segment, so they
270 * don't line up nicely with the boundaries of RTTs.
271 *
272 * Another unfortunate fact of life is that delayed ACKs delay the
273 * advance of the left edge of our send window, so that the number
274 * of bytes we send in an RTT is often less than our cwnd will allow.
275 * So we keep track of our cwnd separately, in v_beg_snd_cwnd.
276 */
277
278 if (after(ack, vegas->beg_snd_nxt)) {
279 /* Do the Vegas once-per-RTT cwnd adjustment. */
280 u32 old_wnd, old_snd_cwnd;
281
282 /* Here old_wnd is essentially the window of data that was
283 * sent during the previous RTT, and has all
284 * been acknowledged in the course of the RTT that ended
285 * with the ACK we just received. Likewise, old_snd_cwnd
286 * is the cwnd during the previous RTT.
287 */
288 if (!tp->mss_cache)
289 return;
290
291 old_wnd = (vegas->beg_snd_nxt - vegas->beg_snd_una) /
292 tp->mss_cache;
293 old_snd_cwnd = vegas->beg_snd_cwnd;
294
295 /* Save the extent of the current window so we can use this
296 * at the end of the next RTT.
297 */
298 vegas->beg_snd_una = vegas->beg_snd_nxt;
299 vegas->beg_snd_nxt = tp->snd_nxt;
300 vegas->beg_snd_cwnd = tp->snd_cwnd;
301
302 /* We do the Vegas calculations only if we got enough RTT
303 * samples that we can be reasonably sure that we got
304 * at least one RTT sample that wasn't from a delayed ACK.
305 * If we only had 2 samples total,
306 * then that means we're getting only 1 ACK per RTT, which
307 * means they're almost certainly delayed ACKs.
308 * If we have 3 samples, we should be OK.
309 */
310
311 if (vegas->cntRTT > 2) {
312 u32 rtt, target_cwnd, diff;
313 u32 brtt, dwnd;
314
315 /* We have enough RTT samples, so, using the Vegas
316 * algorithm, we determine if we should increase or
317 * decrease cwnd, and by how much.
318 */
319
320 /* Pluck out the RTT we are using for the Vegas
321 * calculations. This is the min RTT seen during the
322 * last RTT. Taking the min filters out the effects
323 * of delayed ACKs, at the cost of noticing congestion
324 * a bit later.
325 */
326 rtt = vegas->minRTT;
327
328 /* Calculate the cwnd we should have, if we weren't
329 * going too fast.
330 *
331 * This is:
332 * (actual rate in segments) * baseRTT
333 * We keep it as a fixed point number with
334 * V_PARAM_SHIFT bits to the right of the binary point.
335 */
336 if (!rtt)
337 return;
338
339 brtt = vegas->baseRTT;
340 target_cwnd = ((old_wnd * brtt)
341 << V_PARAM_SHIFT) / rtt;
342
343 /* Calculate the difference between the window we had,
344 * and the window we would like to have. This quantity
345 * is the "Diff" from the Arizona Vegas papers.
346 *
347 * Again, this is a fixed point number with
348 * V_PARAM_SHIFT bits to the right of the binary
349 * point.
350 */
351
352 diff = (old_wnd << V_PARAM_SHIFT) - target_cwnd;
353
354 dwnd = vegas->dwnd;
355
356 if (diff < (TCP_COMPOUND_GAMMA << V_PARAM_SHIFT)) {
357 u64 v;
358 u32 x;
359
360 /*
361 * The TCP Compound paper describes the choice
362 * of "k" determines the agressiveness,
363 * ie. slope of the response function.
364 *
365 * For same value as HSTCP would be 0.8
366 * but for computaional reasons, both the
367 * original authors and this implementation
368 * use 0.75.
369 */
370 v = old_wnd;
371 x = qroot(v * v * v) >> TCP_COMPOUND_ALPHA;
372 if (x > 1)
373 dwnd = x - 1;
374 else
375 dwnd = 0;
376
377 dwnd += vegas->dwnd;
378
379 } else if ((dwnd << V_PARAM_SHIFT) <
380 (diff * TCP_COMPOUND_BETA))
381 dwnd = 0;
382 else
383 dwnd =
384 ((dwnd << V_PARAM_SHIFT) -
385 (diff *
386 TCP_COMPOUND_BETA)) >> V_PARAM_SHIFT;
387
388 vegas->dwnd = dwnd;
389
390 }
391
392 /* Wipe the slate clean for the next RTT. */
393 vegas->cntRTT = 0;
394 vegas->minRTT = 0x7fffffff;
395 }
396
397 tp->snd_cwnd = vegas->cwnd + vegas->dwnd;
398}
399
400/* Extract info for Tcp socket info provided via netlink. */
401static void tcp_compound_get_info(struct sock *sk, u32 ext, struct sk_buff *skb)
402{
403 const struct compound *ca = inet_csk_ca(sk);
404 if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
405 struct tcpvegas_info *info;
406
407 info = RTA_DATA(__RTA_PUT(skb, INET_DIAG_VEGASINFO,
408 sizeof(*info)));
409
410 info->tcpv_enabled = ca->doing_vegas_now;
411 info->tcpv_rttcnt = ca->cntRTT;
412 info->tcpv_rtt = ca->baseRTT;
413 info->tcpv_minrtt = ca->minRTT;
414 rtattr_failure:;
415 }
416}
417
418static struct tcp_congestion_ops tcp_compound = {
419 .init = tcp_compound_init,
420 .ssthresh = tcp_reno_ssthresh,
421 .cong_avoid = tcp_compound_cong_avoid,
422 .rtt_sample = tcp_compound_rtt_calc,
423 .set_state = tcp_compound_state,
424 .cwnd_event = tcp_compound_cwnd_event,
425 .get_info = tcp_compound_get_info,
426
427 .owner = THIS_MODULE,
428 .name = "compound",
429};
430
431static int __init tcp_compound_register(void)
432{
433 BUG_ON(sizeof(struct compound) > ICSK_CA_PRIV_SIZE);
434 tcp_register_congestion_control(&tcp_compound);
435 return 0;
436}
437
438static void __exit tcp_compound_unregister(void)
439{
440 tcp_unregister_congestion_control(&tcp_compound);
441}
442
443module_init(tcp_compound_register);
444module_exit(tcp_compound_unregister);
445
446MODULE_AUTHOR("Angelo P. Castellani, Stephen Hemminger");
447MODULE_LICENSE("GPL");
448MODULE_DESCRIPTION("TCP Compound");
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 91c2f41c7f58..857eefc52aab 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -38,7 +38,7 @@ int tcp_register_congestion_control(struct tcp_congestion_ops *ca)
38 int ret = 0; 38 int ret = 0;
39 39
40 /* all algorithms must implement ssthresh and cong_avoid ops */ 40 /* all algorithms must implement ssthresh and cong_avoid ops */
41 if (!ca->ssthresh || !ca->cong_avoid || !ca->min_cwnd) { 41 if (!ca->ssthresh || !ca->cong_avoid) {
42 printk(KERN_ERR "TCP %s does not implement required ops\n", 42 printk(KERN_ERR "TCP %s does not implement required ops\n",
43 ca->name); 43 ca->name);
44 return -EINVAL; 44 return -EINVAL;
@@ -251,8 +251,8 @@ u32 tcp_reno_ssthresh(struct sock *sk)
251} 251}
252EXPORT_SYMBOL_GPL(tcp_reno_ssthresh); 252EXPORT_SYMBOL_GPL(tcp_reno_ssthresh);
253 253
254/* Lower bound on congestion window. */ 254/* Lower bound on congestion window with halving. */
255u32 tcp_reno_min_cwnd(struct sock *sk) 255u32 tcp_reno_min_cwnd(const struct sock *sk)
256{ 256{
257 const struct tcp_sock *tp = tcp_sk(sk); 257 const struct tcp_sock *tp = tcp_sk(sk);
258 return tp->snd_ssthresh/2; 258 return tp->snd_ssthresh/2;
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 31a4986dfbf7..78b7a6b9e4de 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -325,11 +325,6 @@ static u32 bictcp_undo_cwnd(struct sock *sk)
325 return max(tcp_sk(sk)->snd_cwnd, ca->last_max_cwnd); 325 return max(tcp_sk(sk)->snd_cwnd, ca->last_max_cwnd);
326} 326}
327 327
328static u32 bictcp_min_cwnd(struct sock *sk)
329{
330 return tcp_sk(sk)->snd_ssthresh;
331}
332
333static void bictcp_state(struct sock *sk, u8 new_state) 328static void bictcp_state(struct sock *sk, u8 new_state)
334{ 329{
335 if (new_state == TCP_CA_Loss) 330 if (new_state == TCP_CA_Loss)
@@ -357,7 +352,6 @@ static struct tcp_congestion_ops cubictcp = {
357 .cong_avoid = bictcp_cong_avoid, 352 .cong_avoid = bictcp_cong_avoid,
358 .set_state = bictcp_state, 353 .set_state = bictcp_state,
359 .undo_cwnd = bictcp_undo_cwnd, 354 .undo_cwnd = bictcp_undo_cwnd,
360 .min_cwnd = bictcp_min_cwnd,
361 .pkts_acked = bictcp_acked, 355 .pkts_acked = bictcp_acked,
362 .owner = THIS_MODULE, 356 .owner = THIS_MODULE,
363 .name = "cubic", 357 .name = "cubic",
diff --git a/net/ipv4/tcp_highspeed.c b/net/ipv4/tcp_highspeed.c
index ba7c63ca5bb1..1120245b2373 100644
--- a/net/ipv4/tcp_highspeed.c
+++ b/net/ipv4/tcp_highspeed.c
@@ -98,6 +98,10 @@ struct hstcp {
98 u32 ai; 98 u32 ai;
99}; 99};
100 100
101static int max_ssthresh = 100;
102module_param(max_ssthresh, int, 0644);
103MODULE_PARM_DESC(max_ssthresh, "limited slow start threshold (RFC3742)");
104
101static void hstcp_init(struct sock *sk) 105static void hstcp_init(struct sock *sk)
102{ 106{
103 struct tcp_sock *tp = tcp_sk(sk); 107 struct tcp_sock *tp = tcp_sk(sk);
@@ -119,9 +123,23 @@ static void hstcp_cong_avoid(struct sock *sk, u32 adk, u32 rtt,
119 if (!tcp_is_cwnd_limited(sk, in_flight)) 123 if (!tcp_is_cwnd_limited(sk, in_flight))
120 return; 124 return;
121 125
122 if (tp->snd_cwnd <= tp->snd_ssthresh) 126 if (tp->snd_cwnd <= tp->snd_ssthresh) {
123 tcp_slow_start(tp); 127 /* RFC3742: limited slow start
124 else { 128 * the window is increased by 1/K MSS for each arriving ACK,
129 * for K = int(cwnd/(0.5 max_ssthresh))
130 */
131 if (max_ssthresh > 0 && tp->snd_cwnd > max_ssthresh) {
132 u32 k = max(tp->snd_cwnd / (max_ssthresh >> 1), 1U);
133 if (++tp->snd_cwnd_cnt >= k) {
134 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
135 tp->snd_cwnd++;
136 tp->snd_cwnd_cnt = 0;
137 }
138 } else {
139 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
140 tp->snd_cwnd++;
141 }
142 } else {
125 /* Update AIMD parameters */ 143 /* Update AIMD parameters */
126 if (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd) { 144 if (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd) {
127 while (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd && 145 while (tp->snd_cwnd > hstcp_aimd_vals[ca->ai].cwnd &&
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 1b2ff53f98ed..3d92c1859267 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -246,14 +246,6 @@ static void htcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt,
246 } 246 }
247} 247}
248 248
249/* Lower bound on congestion window. */
250static u32 htcp_min_cwnd(struct sock *sk)
251{
252 const struct tcp_sock *tp = tcp_sk(sk);
253 return tp->snd_ssthresh;
254}
255
256
257static void htcp_init(struct sock *sk) 249static void htcp_init(struct sock *sk)
258{ 250{
259 struct htcp *ca = inet_csk_ca(sk); 251 struct htcp *ca = inet_csk_ca(sk);
@@ -285,7 +277,6 @@ static void htcp_state(struct sock *sk, u8 new_state)
285static struct tcp_congestion_ops htcp = { 277static struct tcp_congestion_ops htcp = {
286 .init = htcp_init, 278 .init = htcp_init,
287 .ssthresh = htcp_recalc_ssthresh, 279 .ssthresh = htcp_recalc_ssthresh,
288 .min_cwnd = htcp_min_cwnd,
289 .cong_avoid = htcp_cong_avoid, 280 .cong_avoid = htcp_cong_avoid,
290 .set_state = htcp_state, 281 .set_state = htcp_state,
291 .undo_cwnd = htcp_cwnd_undo, 282 .undo_cwnd = htcp_cwnd_undo,
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 4a538bc1683d..e08245bdda3a 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -71,6 +71,7 @@
71#include <net/inet_common.h> 71#include <net/inet_common.h>
72#include <linux/ipsec.h> 72#include <linux/ipsec.h>
73#include <asm/unaligned.h> 73#include <asm/unaligned.h>
74#include <net/netdma.h>
74 75
75int sysctl_tcp_timestamps = 1; 76int sysctl_tcp_timestamps = 1;
76int sysctl_tcp_window_scaling = 1; 77int sysctl_tcp_window_scaling = 1;
@@ -1649,7 +1650,7 @@ static void tcp_update_scoreboard(struct sock *sk, struct tcp_sock *tp)
1649 * Hence, we can detect timed out packets during fast 1650 * Hence, we can detect timed out packets during fast
1650 * retransmit without falling to slow start. 1651 * retransmit without falling to slow start.
1651 */ 1652 */
1652 if (tcp_head_timedout(sk, tp)) { 1653 if (!IsReno(tp) && tcp_head_timedout(sk, tp)) {
1653 struct sk_buff *skb; 1654 struct sk_buff *skb;
1654 1655
1655 skb = tp->scoreboard_skb_hint ? tp->scoreboard_skb_hint 1656 skb = tp->scoreboard_skb_hint ? tp->scoreboard_skb_hint
@@ -1662,8 +1663,6 @@ static void tcp_update_scoreboard(struct sock *sk, struct tcp_sock *tp)
1662 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_TAGBITS)) { 1663 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_TAGBITS)) {
1663 TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; 1664 TCP_SKB_CB(skb)->sacked |= TCPCB_LOST;
1664 tp->lost_out += tcp_skb_pcount(skb); 1665 tp->lost_out += tcp_skb_pcount(skb);
1665 if (IsReno(tp))
1666 tcp_remove_reno_sacks(sk, tp, tcp_skb_pcount(skb) + 1);
1667 1666
1668 /* clear xmit_retrans hint */ 1667 /* clear xmit_retrans hint */
1669 if (tp->retransmit_skb_hint && 1668 if (tp->retransmit_skb_hint &&
@@ -1690,17 +1689,26 @@ static inline void tcp_moderate_cwnd(struct tcp_sock *tp)
1690 tp->snd_cwnd_stamp = tcp_time_stamp; 1689 tp->snd_cwnd_stamp = tcp_time_stamp;
1691} 1690}
1692 1691
1692/* Lower bound on congestion window is slow start threshold
1693 * unless congestion avoidance choice decides to overide it.
1694 */
1695static inline u32 tcp_cwnd_min(const struct sock *sk)
1696{
1697 const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
1698
1699 return ca_ops->min_cwnd ? ca_ops->min_cwnd(sk) : tcp_sk(sk)->snd_ssthresh;
1700}
1701
1693/* Decrease cwnd each second ack. */ 1702/* Decrease cwnd each second ack. */
1694static void tcp_cwnd_down(struct sock *sk) 1703static void tcp_cwnd_down(struct sock *sk)
1695{ 1704{
1696 const struct inet_connection_sock *icsk = inet_csk(sk);
1697 struct tcp_sock *tp = tcp_sk(sk); 1705 struct tcp_sock *tp = tcp_sk(sk);
1698 int decr = tp->snd_cwnd_cnt + 1; 1706 int decr = tp->snd_cwnd_cnt + 1;
1699 1707
1700 tp->snd_cwnd_cnt = decr&1; 1708 tp->snd_cwnd_cnt = decr&1;
1701 decr >>= 1; 1709 decr >>= 1;
1702 1710
1703 if (decr && tp->snd_cwnd > icsk->icsk_ca_ops->min_cwnd(sk)) 1711 if (decr && tp->snd_cwnd > tcp_cwnd_min(sk))
1704 tp->snd_cwnd -= decr; 1712 tp->snd_cwnd -= decr;
1705 1713
1706 tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1); 1714 tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
@@ -3787,6 +3795,50 @@ static inline int tcp_checksum_complete_user(struct sock *sk, struct sk_buff *sk
3787 __tcp_checksum_complete_user(sk, skb); 3795 __tcp_checksum_complete_user(sk, skb);
3788} 3796}
3789 3797
3798#ifdef CONFIG_NET_DMA
3799static int tcp_dma_try_early_copy(struct sock *sk, struct sk_buff *skb, int hlen)
3800{
3801 struct tcp_sock *tp = tcp_sk(sk);
3802 int chunk = skb->len - hlen;
3803 int dma_cookie;
3804 int copied_early = 0;
3805
3806 if (tp->ucopy.wakeup)
3807 return 0;
3808
3809 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
3810 tp->ucopy.dma_chan = get_softnet_dma();
3811
3812 if (tp->ucopy.dma_chan && skb->ip_summed == CHECKSUM_UNNECESSARY) {
3813
3814 dma_cookie = dma_skb_copy_datagram_iovec(tp->ucopy.dma_chan,
3815 skb, hlen, tp->ucopy.iov, chunk, tp->ucopy.pinned_list);
3816
3817 if (dma_cookie < 0)
3818 goto out;
3819
3820 tp->ucopy.dma_cookie = dma_cookie;
3821 copied_early = 1;
3822
3823 tp->ucopy.len -= chunk;
3824 tp->copied_seq += chunk;
3825 tcp_rcv_space_adjust(sk);
3826
3827 if ((tp->ucopy.len == 0) ||
3828 (tcp_flag_word(skb->h.th) & TCP_FLAG_PSH) ||
3829 (atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1))) {
3830 tp->ucopy.wakeup = 1;
3831 sk->sk_data_ready(sk, 0);
3832 }
3833 } else if (chunk > 0) {
3834 tp->ucopy.wakeup = 1;
3835 sk->sk_data_ready(sk, 0);
3836 }
3837out:
3838 return copied_early;
3839}
3840#endif /* CONFIG_NET_DMA */
3841
3790/* 3842/*
3791 * TCP receive function for the ESTABLISHED state. 3843 * TCP receive function for the ESTABLISHED state.
3792 * 3844 *
@@ -3888,8 +3940,6 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
3888 tp->rcv_nxt == tp->rcv_wup) 3940 tp->rcv_nxt == tp->rcv_wup)
3889 tcp_store_ts_recent(tp); 3941 tcp_store_ts_recent(tp);
3890 3942
3891 tcp_rcv_rtt_measure_ts(sk, skb);
3892
3893 /* We know that such packets are checksummed 3943 /* We know that such packets are checksummed
3894 * on entry. 3944 * on entry.
3895 */ 3945 */
@@ -3903,14 +3953,23 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
3903 } 3953 }
3904 } else { 3954 } else {
3905 int eaten = 0; 3955 int eaten = 0;
3956 int copied_early = 0;
3906 3957
3907 if (tp->ucopy.task == current && 3958 if (tp->copied_seq == tp->rcv_nxt &&
3908 tp->copied_seq == tp->rcv_nxt && 3959 len - tcp_header_len <= tp->ucopy.len) {
3909 len - tcp_header_len <= tp->ucopy.len && 3960#ifdef CONFIG_NET_DMA
3910 sock_owned_by_user(sk)) { 3961 if (tcp_dma_try_early_copy(sk, skb, tcp_header_len)) {
3911 __set_current_state(TASK_RUNNING); 3962 copied_early = 1;
3963 eaten = 1;
3964 }
3965#endif
3966 if (tp->ucopy.task == current && sock_owned_by_user(sk) && !copied_early) {
3967 __set_current_state(TASK_RUNNING);
3912 3968
3913 if (!tcp_copy_to_iovec(sk, skb, tcp_header_len)) { 3969 if (!tcp_copy_to_iovec(sk, skb, tcp_header_len))
3970 eaten = 1;
3971 }
3972 if (eaten) {
3914 /* Predicted packet is in window by definition. 3973 /* Predicted packet is in window by definition.
3915 * seq == rcv_nxt and rcv_wup <= rcv_nxt. 3974 * seq == rcv_nxt and rcv_wup <= rcv_nxt.
3916 * Hence, check seq<=rcv_wup reduces to: 3975 * Hence, check seq<=rcv_wup reduces to:
@@ -3926,8 +3985,9 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
3926 __skb_pull(skb, tcp_header_len); 3985 __skb_pull(skb, tcp_header_len);
3927 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 3986 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
3928 NET_INC_STATS_BH(LINUX_MIB_TCPHPHITSTOUSER); 3987 NET_INC_STATS_BH(LINUX_MIB_TCPHPHITSTOUSER);
3929 eaten = 1;
3930 } 3988 }
3989 if (copied_early)
3990 tcp_cleanup_rbuf(sk, skb->len);
3931 } 3991 }
3932 if (!eaten) { 3992 if (!eaten) {
3933 if (tcp_checksum_complete_user(sk, skb)) 3993 if (tcp_checksum_complete_user(sk, skb))
@@ -3968,6 +4028,11 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
3968 4028
3969 __tcp_ack_snd_check(sk, 0); 4029 __tcp_ack_snd_check(sk, 0);
3970no_ack: 4030no_ack:
4031#ifdef CONFIG_NET_DMA
4032 if (copied_early)
4033 __skb_queue_tail(&sk->sk_async_wait_queue, skb);
4034 else
4035#endif
3971 if (eaten) 4036 if (eaten)
3972 __kfree_skb(skb); 4037 __kfree_skb(skb);
3973 else 4038 else
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 672950e54c49..25ecc6e2478b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -71,6 +71,7 @@
71#include <net/inet_common.h> 71#include <net/inet_common.h>
72#include <net/timewait_sock.h> 72#include <net/timewait_sock.h>
73#include <net/xfrm.h> 73#include <net/xfrm.h>
74#include <net/netdma.h>
74 75
75#include <linux/inet.h> 76#include <linux/inet.h>
76#include <linux/ipv6.h> 77#include <linux/ipv6.h>
@@ -1091,8 +1092,18 @@ process:
1091 bh_lock_sock(sk); 1092 bh_lock_sock(sk);
1092 ret = 0; 1093 ret = 0;
1093 if (!sock_owned_by_user(sk)) { 1094 if (!sock_owned_by_user(sk)) {
1094 if (!tcp_prequeue(sk, skb)) 1095#ifdef CONFIG_NET_DMA
1096 struct tcp_sock *tp = tcp_sk(sk);
1097 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
1098 tp->ucopy.dma_chan = get_softnet_dma();
1099 if (tp->ucopy.dma_chan)
1095 ret = tcp_v4_do_rcv(sk, skb); 1100 ret = tcp_v4_do_rcv(sk, skb);
1101 else
1102#endif
1103 {
1104 if (!tcp_prequeue(sk, skb))
1105 ret = tcp_v4_do_rcv(sk, skb);
1106 }
1096 } else 1107 } else
1097 sk_add_backlog(sk, skb); 1108 sk_add_backlog(sk, skb);
1098 bh_unlock_sock(sk); 1109 bh_unlock_sock(sk);
@@ -1296,6 +1307,11 @@ int tcp_v4_destroy_sock(struct sock *sk)
1296 /* Cleans up our, hopefully empty, out_of_order_queue. */ 1307 /* Cleans up our, hopefully empty, out_of_order_queue. */
1297 __skb_queue_purge(&tp->out_of_order_queue); 1308 __skb_queue_purge(&tp->out_of_order_queue);
1298 1309
1310#ifdef CONFIG_NET_DMA
1311 /* Cleans up our sk_async_wait_queue */
1312 __skb_queue_purge(&sk->sk_async_wait_queue);
1313#endif
1314
1299 /* Clean prequeue, it must be empty really */ 1315 /* Clean prequeue, it must be empty really */
1300 __skb_queue_purge(&tp->ucopy.prequeue); 1316 __skb_queue_purge(&tp->ucopy.prequeue);
1301 1317
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
new file mode 100644
index 000000000000..1f977b6ee9a1
--- /dev/null
+++ b/net/ipv4/tcp_lp.c
@@ -0,0 +1,338 @@
1/*
2 * TCP Low Priority (TCP-LP)
3 *
4 * TCP Low Priority is a distributed algorithm whose goal is to utilize only
5 * the excess network bandwidth as compared to the ``fair share`` of
6 * bandwidth as targeted by TCP. Available from:
7 * http://www.ece.rice.edu/~akuzma/Doc/akuzma/TCP-LP.pdf
8 *
9 * Original Author:
10 * Aleksandar Kuzmanovic <akuzma@northwestern.edu>
11 *
12 * See http://www-ece.rice.edu/networks/TCP-LP/ for their implementation.
13 * As of 2.6.13, Linux supports pluggable congestion control algorithms.
14 * Due to the limitation of the API, we take the following changes from
15 * the original TCP-LP implementation:
16 * o We use newReno in most core CA handling. Only add some checking
17 * within cong_avoid.
18 * o Error correcting in remote HZ, therefore remote HZ will be keeped
19 * on checking and updating.
20 * o Handling calculation of One-Way-Delay (OWD) within rtt_sample, sicne
21 * OWD have a similar meaning as RTT. Also correct the buggy formular.
22 * o Handle reaction for Early Congestion Indication (ECI) within
23 * pkts_acked, as mentioned within pseudo code.
24 * o OWD is handled in relative format, where local time stamp will in
25 * tcp_time_stamp format.
26 *
27 * Port from 2.4.19 to 2.6.16 as module by:
28 * Wong Hoi Sing Edison <hswong3i@gmail.com>
29 * Hung Hing Lun <hlhung3i@gmail.com>
30 *
31 * Version: $Id: tcp_lp.c,v 1.22 2006-05-02 18:18:19 hswong3i Exp $
32 */
33
34#include <linux/config.h>
35#include <linux/module.h>
36#include <net/tcp.h>
37
38/* resolution of owd */
39#define LP_RESOL 1000
40
41/**
42 * enum tcp_lp_state
43 * @LP_VALID_RHZ: is remote HZ valid?
44 * @LP_VALID_OWD: is OWD valid?
45 * @LP_WITHIN_THR: are we within threshold?
46 * @LP_WITHIN_INF: are we within inference?
47 *
48 * TCP-LP's state flags.
49 * We create this set of state flag mainly for debugging.
50 */
51enum tcp_lp_state {
52 LP_VALID_RHZ = (1 << 0),
53 LP_VALID_OWD = (1 << 1),
54 LP_WITHIN_THR = (1 << 3),
55 LP_WITHIN_INF = (1 << 4),
56};
57
58/**
59 * struct lp
60 * @flag: TCP-LP state flag
61 * @sowd: smoothed OWD << 3
62 * @owd_min: min OWD
63 * @owd_max: max OWD
64 * @owd_max_rsv: resrved max owd
65 * @remote_hz: estimated remote HZ
66 * @remote_ref_time: remote reference time
67 * @local_ref_time: local reference time
68 * @last_drop: time for last active drop
69 * @inference: current inference
70 *
71 * TCP-LP's private struct.
72 * We get the idea from original TCP-LP implementation where only left those we
73 * found are really useful.
74 */
75struct lp {
76 u32 flag;
77 u32 sowd;
78 u32 owd_min;
79 u32 owd_max;
80 u32 owd_max_rsv;
81 u32 remote_hz;
82 u32 remote_ref_time;
83 u32 local_ref_time;
84 u32 last_drop;
85 u32 inference;
86};
87
88/**
89 * tcp_lp_init
90 *
91 * Init all required variables.
92 * Clone the handling from Vegas module implementation.
93 */
94static void tcp_lp_init(struct sock *sk)
95{
96 struct lp *lp = inet_csk_ca(sk);
97
98 lp->flag = 0;
99 lp->sowd = 0;
100 lp->owd_min = 0xffffffff;
101 lp->owd_max = 0;
102 lp->owd_max_rsv = 0;
103 lp->remote_hz = 0;
104 lp->remote_ref_time = 0;
105 lp->local_ref_time = 0;
106 lp->last_drop = 0;
107 lp->inference = 0;
108}
109
110/**
111 * tcp_lp_cong_avoid
112 *
113 * Implementation of cong_avoid.
114 * Will only call newReno CA when away from inference.
115 * From TCP-LP's paper, this will be handled in additive increasement.
116 */
117static void tcp_lp_cong_avoid(struct sock *sk, u32 ack, u32 rtt, u32 in_flight,
118 int flag)
119{
120 struct lp *lp = inet_csk_ca(sk);
121
122 if (!(lp->flag & LP_WITHIN_INF))
123 tcp_reno_cong_avoid(sk, ack, rtt, in_flight, flag);
124}
125
126/**
127 * tcp_lp_remote_hz_estimator
128 *
129 * Estimate remote HZ.
130 * We keep on updating the estimated value, where original TCP-LP
131 * implementation only guest it for once and use forever.
132 */
133static u32 tcp_lp_remote_hz_estimator(struct sock *sk)
134{
135 struct tcp_sock *tp = tcp_sk(sk);
136 struct lp *lp = inet_csk_ca(sk);
137 s64 rhz = lp->remote_hz << 6; /* remote HZ << 6 */
138 s64 m = 0;
139
140 /* not yet record reference time
141 * go away!! record it before come back!! */
142 if (lp->remote_ref_time == 0 || lp->local_ref_time == 0)
143 goto out;
144
145 /* we can't calc remote HZ with no different!! */
146 if (tp->rx_opt.rcv_tsval == lp->remote_ref_time
147 || tp->rx_opt.rcv_tsecr == lp->local_ref_time)
148 goto out;
149
150 m = HZ * (tp->rx_opt.rcv_tsval -
151 lp->remote_ref_time) / (tp->rx_opt.rcv_tsecr -
152 lp->local_ref_time);
153 if (m < 0)
154 m = -m;
155
156 if (rhz != 0) {
157 m -= rhz >> 6; /* m is now error in remote HZ est */
158 rhz += m; /* 63/64 old + 1/64 new */
159 } else
160 rhz = m << 6;
161
162 /* record time for successful remote HZ calc */
163 lp->flag |= LP_VALID_RHZ;
164
165 out:
166 /* record reference time stamp */
167 lp->remote_ref_time = tp->rx_opt.rcv_tsval;
168 lp->local_ref_time = tp->rx_opt.rcv_tsecr;
169
170 return rhz >> 6;
171}
172
173/**
174 * tcp_lp_owd_calculator
175 *
176 * Calculate one way delay (in relative format).
177 * Original implement OWD as minus of remote time difference to local time
178 * difference directly. As this time difference just simply equal to RTT, when
179 * the network status is stable, remote RTT will equal to local RTT, and result
180 * OWD into zero.
181 * It seems to be a bug and so we fixed it.
182 */
183static u32 tcp_lp_owd_calculator(struct sock *sk)
184{
185 struct tcp_sock *tp = tcp_sk(sk);
186 struct lp *lp = inet_csk_ca(sk);
187 s64 owd = 0;
188
189 lp->remote_hz = tcp_lp_remote_hz_estimator(sk);
190
191 if (lp->flag & LP_VALID_RHZ) {
192 owd =
193 tp->rx_opt.rcv_tsval * (LP_RESOL / lp->remote_hz) -
194 tp->rx_opt.rcv_tsecr * (LP_RESOL / HZ);
195 if (owd < 0)
196 owd = -owd;
197 }
198
199 if (owd > 0)
200 lp->flag |= LP_VALID_OWD;
201 else
202 lp->flag &= ~LP_VALID_OWD;
203
204 return owd;
205}
206
207/**
208 * tcp_lp_rtt_sample
209 *
210 * Implementation or rtt_sample.
211 * Will take the following action,
212 * 1. calc OWD,
213 * 2. record the min/max OWD,
214 * 3. calc smoothed OWD (SOWD).
215 * Most ideas come from the original TCP-LP implementation.
216 */
217static void tcp_lp_rtt_sample(struct sock *sk, u32 usrtt)
218{
219 struct lp *lp = inet_csk_ca(sk);
220 s64 mowd = tcp_lp_owd_calculator(sk);
221
222 /* sorry that we don't have valid data */
223 if (!(lp->flag & LP_VALID_RHZ) || !(lp->flag & LP_VALID_OWD))
224 return;
225
226 /* record the next min owd */
227 if (mowd < lp->owd_min)
228 lp->owd_min = mowd;
229
230 /* always forget the max of the max
231 * we just set owd_max as one below it */
232 if (mowd > lp->owd_max) {
233 if (mowd > lp->owd_max_rsv) {
234 if (lp->owd_max_rsv == 0)
235 lp->owd_max = mowd;
236 else
237 lp->owd_max = lp->owd_max_rsv;
238 lp->owd_max_rsv = mowd;
239 } else
240 lp->owd_max = mowd;
241 }
242
243 /* calc for smoothed owd */
244 if (lp->sowd != 0) {
245 mowd -= lp->sowd >> 3; /* m is now error in owd est */
246 lp->sowd += mowd; /* owd = 7/8 owd + 1/8 new */
247 } else
248 lp->sowd = mowd << 3; /* take the measured time be owd */
249}
250
251/**
252 * tcp_lp_pkts_acked
253 *
254 * Implementation of pkts_acked.
255 * Deal with active drop under Early Congestion Indication.
256 * Only drop to half and 1 will be handle, because we hope to use back
257 * newReno in increase case.
258 * We work it out by following the idea from TCP-LP's paper directly
259 */
260static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked)
261{
262 struct tcp_sock *tp = tcp_sk(sk);
263 struct lp *lp = inet_csk_ca(sk);
264
265 /* calc inference */
266 if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
267 lp->inference = 3 * (tcp_time_stamp - tp->rx_opt.rcv_tsecr);
268
269 /* test if within inference */
270 if (lp->last_drop && (tcp_time_stamp - lp->last_drop < lp->inference))
271 lp->flag |= LP_WITHIN_INF;
272 else
273 lp->flag &= ~LP_WITHIN_INF;
274
275 /* test if within threshold */
276 if (lp->sowd >> 3 <
277 lp->owd_min + 15 * (lp->owd_max - lp->owd_min) / 100)
278 lp->flag |= LP_WITHIN_THR;
279 else
280 lp->flag &= ~LP_WITHIN_THR;
281
282 pr_debug("TCP-LP: %05o|%5u|%5u|%15u|%15u|%15u\n", lp->flag,
283 tp->snd_cwnd, lp->remote_hz, lp->owd_min, lp->owd_max,
284 lp->sowd >> 3);
285
286 if (lp->flag & LP_WITHIN_THR)
287 return;
288
289 /* FIXME: try to reset owd_min and owd_max here
290 * so decrease the chance the min/max is no longer suitable
291 * and will usually within threshold when whithin inference */
292 lp->owd_min = lp->sowd >> 3;
293 lp->owd_max = lp->sowd >> 2;
294 lp->owd_max_rsv = lp->sowd >> 2;
295
296 /* happened within inference
297 * drop snd_cwnd into 1 */
298 if (lp->flag & LP_WITHIN_INF)
299 tp->snd_cwnd = 1U;
300
301 /* happened after inference
302 * cut snd_cwnd into half */
303 else
304 tp->snd_cwnd = max(tp->snd_cwnd >> 1U, 1U);
305
306 /* record this drop time */
307 lp->last_drop = tcp_time_stamp;
308}
309
310static struct tcp_congestion_ops tcp_lp = {
311 .init = tcp_lp_init,
312 .ssthresh = tcp_reno_ssthresh,
313 .cong_avoid = tcp_lp_cong_avoid,
314 .min_cwnd = tcp_reno_min_cwnd,
315 .rtt_sample = tcp_lp_rtt_sample,
316 .pkts_acked = tcp_lp_pkts_acked,
317
318 .owner = THIS_MODULE,
319 .name = "lp"
320};
321
322static int __init tcp_lp_register(void)
323{
324 BUG_ON(sizeof(struct lp) > ICSK_CA_PRIV_SIZE);
325 return tcp_register_congestion_control(&tcp_lp);
326}
327
328static void __exit tcp_lp_unregister(void)
329{
330 tcp_unregister_congestion_control(&tcp_lp);
331}
332
333module_init(tcp_lp_register);
334module_exit(tcp_lp_unregister);
335
336MODULE_AUTHOR("Wong Hoi Sing Edison, Hung Hing Lun");
337MODULE_LICENSE("GPL");
338MODULE_DESCRIPTION("TCP Low Priority");
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index f33c9dddaa12..07bb5a2b375e 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -59,6 +59,9 @@ int sysctl_tcp_tso_win_divisor = 3;
59int sysctl_tcp_mtu_probing = 0; 59int sysctl_tcp_mtu_probing = 0;
60int sysctl_tcp_base_mss = 512; 60int sysctl_tcp_base_mss = 512;
61 61
62/* By default, RFC2861 behavior. */
63int sysctl_tcp_slow_start_after_idle = 1;
64
62static void update_send_head(struct sock *sk, struct tcp_sock *tp, 65static void update_send_head(struct sock *sk, struct tcp_sock *tp,
63 struct sk_buff *skb) 66 struct sk_buff *skb)
64{ 67{
@@ -138,7 +141,8 @@ static void tcp_event_data_sent(struct tcp_sock *tp,
138 struct inet_connection_sock *icsk = inet_csk(sk); 141 struct inet_connection_sock *icsk = inet_csk(sk);
139 const u32 now = tcp_time_stamp; 142 const u32 now = tcp_time_stamp;
140 143
141 if (!tp->packets_out && (s32)(now - tp->lsndtime) > icsk->icsk_rto) 144 if (sysctl_tcp_slow_start_after_idle &&
145 (!tp->packets_out && (s32)(now - tp->lsndtime) > icsk->icsk_rto))
142 tcp_cwnd_restart(sk, __sk_dst_get(sk)); 146 tcp_cwnd_restart(sk, __sk_dst_get(sk));
143 147
144 tp->lsndtime = now; 148 tp->lsndtime = now;
diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
new file mode 100644
index 000000000000..d7d517a3a238
--- /dev/null
+++ b/net/ipv4/tcp_probe.c
@@ -0,0 +1,181 @@
1/*
2 * tcpprobe - Observe the TCP flow with kprobes.
3 *
4 * The idea for this came from Werner Almesberger's umlsim
5 * Copyright (C) 2004, Stephen Hemminger <shemminger@osdl.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/kernel.h>
23#include <linux/kprobes.h>
24#include <linux/socket.h>
25#include <linux/tcp.h>
26#include <linux/proc_fs.h>
27#include <linux/module.h>
28#include <linux/kfifo.h>
29#include <linux/vmalloc.h>
30
31#include <net/tcp.h>
32
33MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
34MODULE_DESCRIPTION("TCP cwnd snooper");
35MODULE_LICENSE("GPL");
36
37static int port = 0;
38MODULE_PARM_DESC(port, "Port to match (0=all)");
39module_param(port, int, 0);
40
41static int bufsize = 64*1024;
42MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k)");
43module_param(bufsize, int, 0);
44
45static const char procname[] = "tcpprobe";
46
47struct {
48 struct kfifo *fifo;
49 spinlock_t lock;
50 wait_queue_head_t wait;
51 struct timeval tstart;
52} tcpw;
53
54static void printl(const char *fmt, ...)
55{
56 va_list args;
57 int len;
58 struct timeval now;
59 char tbuf[256];
60
61 va_start(args, fmt);
62 do_gettimeofday(&now);
63
64 now.tv_sec -= tcpw.tstart.tv_sec;
65 now.tv_usec -= tcpw.tstart.tv_usec;
66 if (now.tv_usec < 0) {
67 --now.tv_sec;
68 now.tv_usec += 1000000;
69 }
70
71 len = sprintf(tbuf, "%lu.%06lu ",
72 (unsigned long) now.tv_sec,
73 (unsigned long) now.tv_usec);
74 len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
75 va_end(args);
76
77 kfifo_put(tcpw.fifo, tbuf, len);
78 wake_up(&tcpw.wait);
79}
80
81static int jtcp_sendmsg(struct kiocb *iocb, struct sock *sk,
82 struct msghdr *msg, size_t size)
83{
84 const struct tcp_sock *tp = tcp_sk(sk);
85 const struct inet_sock *inet = inet_sk(sk);
86
87 if (port == 0 || ntohs(inet->dport) == port ||
88 ntohs(inet->sport) == port) {
89 printl("%d.%d.%d.%d:%u %d.%d.%d.%d:%u %d %#x %#x %u %u %u\n",
90 NIPQUAD(inet->saddr), ntohs(inet->sport),
91 NIPQUAD(inet->daddr), ntohs(inet->dport),
92 size, tp->snd_nxt, tp->snd_una,
93 tp->snd_cwnd, tcp_current_ssthresh(sk),
94 tp->snd_wnd);
95 }
96
97 jprobe_return();
98 return 0;
99}
100
101static struct jprobe tcp_send_probe = {
102 .kp = { .addr = (kprobe_opcode_t *) &tcp_sendmsg, },
103 .entry = (kprobe_opcode_t *) &jtcp_sendmsg,
104};
105
106
107static int tcpprobe_open(struct inode * inode, struct file * file)
108{
109 kfifo_reset(tcpw.fifo);
110 do_gettimeofday(&tcpw.tstart);
111 return 0;
112}
113
114static ssize_t tcpprobe_read(struct file *file, char __user *buf,
115 size_t len, loff_t *ppos)
116{
117 int error = 0, cnt;
118 unsigned char *tbuf;
119
120 if (!buf || len < 0)
121 return -EINVAL;
122
123 if (len == 0)
124 return 0;
125
126 tbuf = vmalloc(len);
127 if (!tbuf)
128 return -ENOMEM;
129
130 error = wait_event_interruptible(tcpw.wait,
131 __kfifo_len(tcpw.fifo) != 0);
132 if (error)
133 return error;
134
135 cnt = kfifo_get(tcpw.fifo, tbuf, len);
136 error = copy_to_user(buf, tbuf, cnt);
137
138 vfree(tbuf);
139
140 return error ? error : cnt;
141}
142
143static struct file_operations tcpprobe_fops = {
144 .owner = THIS_MODULE,
145 .open = tcpprobe_open,
146 .read = tcpprobe_read,
147};
148
149static __init int tcpprobe_init(void)
150{
151 int ret = -ENOMEM;
152
153 init_waitqueue_head(&tcpw.wait);
154 spin_lock_init(&tcpw.lock);
155 tcpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &tcpw.lock);
156
157 if (!proc_net_fops_create(procname, S_IRUSR, &tcpprobe_fops))
158 goto err0;
159
160 ret = register_jprobe(&tcp_send_probe);
161 if (ret)
162 goto err1;
163
164 pr_info("TCP watch registered (port=%d)\n", port);
165 return 0;
166 err1:
167 proc_net_remove(procname);
168 err0:
169 kfifo_free(tcpw.fifo);
170 return ret;
171}
172module_init(tcpprobe_init);
173
174static __exit void tcpprobe_exit(void)
175{
176 kfifo_free(tcpw.fifo);
177 proc_net_remove(procname);
178 unregister_jprobe(&tcp_send_probe);
179
180}
181module_exit(tcpprobe_exit);
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
new file mode 100644
index 000000000000..11b42a7135c1
--- /dev/null
+++ b/net/ipv4/tcp_veno.c
@@ -0,0 +1,231 @@
1/*
2 * TCP Veno congestion control
3 *
4 * This is based on the congestion detection/avoidance scheme described in
5 * C. P. Fu, S. C. Liew.
6 * "TCP Veno: TCP Enhancement for Transmission over Wireless Access Networks."
7 * IEEE Journal on Selected Areas in Communication,
8 * Feb. 2003.
9 * See http://www.ntu.edu.sg/home5/ZHOU0022/papers/CPFu03a.pdf
10 */
11
12#include <linux/config.h>
13#include <linux/mm.h>
14#include <linux/module.h>
15#include <linux/skbuff.h>
16#include <linux/inet_diag.h>
17
18#include <net/tcp.h>
19
20/* Default values of the Veno variables, in fixed-point representation
21 * with V_PARAM_SHIFT bits to the right of the binary point.
22 */
23#define V_PARAM_SHIFT 1
24static const int beta = 3 << V_PARAM_SHIFT;
25
26/* Veno variables */
27struct veno {
28 u8 doing_veno_now; /* if true, do veno for this rtt */
29 u16 cntrtt; /* # of rtts measured within last rtt */
30 u32 minrtt; /* min of rtts measured within last rtt (in usec) */
31 u32 basertt; /* the min of all Veno rtt measurements seen (in usec) */
32 u32 inc; /* decide whether to increase cwnd */
33 u32 diff; /* calculate the diff rate */
34};
35
36/* There are several situations when we must "re-start" Veno:
37 *
38 * o when a connection is established
39 * o after an RTO
40 * o after fast recovery
41 * o when we send a packet and there is no outstanding
42 * unacknowledged data (restarting an idle connection)
43 *
44 */
45static inline void veno_enable(struct sock *sk)
46{
47 struct veno *veno = inet_csk_ca(sk);
48
49 /* turn on Veno */
50 veno->doing_veno_now = 1;
51
52 veno->minrtt = 0x7fffffff;
53}
54
55static inline void veno_disable(struct sock *sk)
56{
57 struct veno *veno = inet_csk_ca(sk);
58
59 /* turn off Veno */
60 veno->doing_veno_now = 0;
61}
62
63static void tcp_veno_init(struct sock *sk)
64{
65 struct veno *veno = inet_csk_ca(sk);
66
67 veno->basertt = 0x7fffffff;
68 veno->inc = 1;
69 veno_enable(sk);
70}
71
72/* Do rtt sampling needed for Veno. */
73static void tcp_veno_rtt_calc(struct sock *sk, u32 usrtt)
74{
75 struct veno *veno = inet_csk_ca(sk);
76 u32 vrtt = usrtt + 1; /* Never allow zero rtt or basertt */
77
78 /* Filter to find propagation delay: */
79 if (vrtt < veno->basertt)
80 veno->basertt = vrtt;
81
82 /* Find the min rtt during the last rtt to find
83 * the current prop. delay + queuing delay:
84 */
85 veno->minrtt = min(veno->minrtt, vrtt);
86 veno->cntrtt++;
87}
88
89static void tcp_veno_state(struct sock *sk, u8 ca_state)
90{
91 if (ca_state == TCP_CA_Open)
92 veno_enable(sk);
93 else
94 veno_disable(sk);
95}
96
97/*
98 * If the connection is idle and we are restarting,
99 * then we don't want to do any Veno calculations
100 * until we get fresh rtt samples. So when we
101 * restart, we reset our Veno state to a clean
102 * state. After we get acks for this flight of
103 * packets, _then_ we can make Veno calculations
104 * again.
105 */
106static void tcp_veno_cwnd_event(struct sock *sk, enum tcp_ca_event event)
107{
108 if (event == CA_EVENT_CWND_RESTART || event == CA_EVENT_TX_START)
109 tcp_veno_init(sk);
110}
111
112static void tcp_veno_cong_avoid(struct sock *sk, u32 ack,
113 u32 seq_rtt, u32 in_flight, int flag)
114{
115 struct tcp_sock *tp = tcp_sk(sk);
116 struct veno *veno = inet_csk_ca(sk);
117
118 if (!veno->doing_veno_now)
119 return tcp_reno_cong_avoid(sk, ack, seq_rtt, in_flight, flag);
120
121 /* limited by applications */
122 if (!tcp_is_cwnd_limited(sk, in_flight))
123 return;
124
125 /* We do the Veno calculations only if we got enough rtt samples */
126 if (veno->cntrtt <= 2) {
127 /* We don't have enough rtt samples to do the Veno
128 * calculation, so we'll behave like Reno.
129 */
130 tcp_reno_cong_avoid(sk, ack, seq_rtt, in_flight, flag);
131 } else {
132 u32 rtt, target_cwnd;
133
134 /* We have enough rtt samples, so, using the Veno
135 * algorithm, we determine the state of the network.
136 */
137
138 rtt = veno->minrtt;
139
140 target_cwnd = ((tp->snd_cwnd * veno->basertt)
141 << V_PARAM_SHIFT) / rtt;
142
143 veno->diff = (tp->snd_cwnd << V_PARAM_SHIFT) - target_cwnd;
144
145 if (tp->snd_cwnd <= tp->snd_ssthresh) {
146 /* Slow start. */
147 tcp_slow_start(tp);
148 } else {
149 /* Congestion avoidance. */
150 if (veno->diff < beta) {
151 /* In the "non-congestive state", increase cwnd
152 * every rtt.
153 */
154 if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
155 if (tp->snd_cwnd < tp->snd_cwnd_clamp)
156 tp->snd_cwnd++;
157 tp->snd_cwnd_cnt = 0;
158 } else
159 tp->snd_cwnd_cnt++;
160 } else {
161 /* In the "congestive state", increase cwnd
162 * every other rtt.
163 */
164 if (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
165 if (veno->inc
166 && tp->snd_cwnd <
167 tp->snd_cwnd_clamp) {
168 tp->snd_cwnd++;
169 veno->inc = 0;
170 } else
171 veno->inc = 1;
172 tp->snd_cwnd_cnt = 0;
173 } else
174 tp->snd_cwnd_cnt++;
175 }
176
177 }
178 if (tp->snd_cwnd < 2)
179 tp->snd_cwnd = 2;
180 else if (tp->snd_cwnd > tp->snd_cwnd_clamp)
181 tp->snd_cwnd = tp->snd_cwnd_clamp;
182 }
183 /* Wipe the slate clean for the next rtt. */
184 /* veno->cntrtt = 0; */
185 veno->minrtt = 0x7fffffff;
186}
187
188/* Veno MD phase */
189static u32 tcp_veno_ssthresh(struct sock *sk)
190{
191 const struct tcp_sock *tp = tcp_sk(sk);
192 struct veno *veno = inet_csk_ca(sk);
193
194 if (veno->diff < beta)
195 /* in "non-congestive state", cut cwnd by 1/5 */
196 return max(tp->snd_cwnd * 4 / 5, 2U);
197 else
198 /* in "congestive state", cut cwnd by 1/2 */
199 return max(tp->snd_cwnd >> 1U, 2U);
200}
201
202static struct tcp_congestion_ops tcp_veno = {
203 .init = tcp_veno_init,
204 .ssthresh = tcp_veno_ssthresh,
205 .cong_avoid = tcp_veno_cong_avoid,
206 .rtt_sample = tcp_veno_rtt_calc,
207 .set_state = tcp_veno_state,
208 .cwnd_event = tcp_veno_cwnd_event,
209
210 .owner = THIS_MODULE,
211 .name = "veno",
212};
213
214static int __init tcp_veno_register(void)
215{
216 BUG_ON(sizeof(struct veno) > ICSK_CA_PRIV_SIZE);
217 tcp_register_congestion_control(&tcp_veno);
218 return 0;
219}
220
221static void __exit tcp_veno_unregister(void)
222{
223 tcp_unregister_congestion_control(&tcp_veno);
224}
225
226module_init(tcp_veno_register);
227module_exit(tcp_veno_unregister);
228
229MODULE_AUTHOR("Bin Zhou, Cheng Peng Fu");
230MODULE_LICENSE("GPL");
231MODULE_DESCRIPTION("TCP Veno");
diff --git a/net/ipv4/tcp_westwood.c b/net/ipv4/tcp_westwood.c
index 0c340c3756c2..4247da1384bf 100644
--- a/net/ipv4/tcp_westwood.c
+++ b/net/ipv4/tcp_westwood.c
@@ -1,7 +1,24 @@
1/* 1/*
2 * TCP Westwood+ 2 * TCP Westwood+: end-to-end bandwidth estimation for TCP
3 * 3 *
4 * Angelo Dell'Aera: TCP Westwood+ support 4 * Angelo Dell'Aera: author of the first version of TCP Westwood+ in Linux 2.4
5 *
6 * Support at http://c3lab.poliba.it/index.php/Westwood
7 * Main references in literature:
8 *
9 * - Mascolo S, Casetti, M. Gerla et al.
10 * "TCP Westwood: bandwidth estimation for TCP" Proc. ACM Mobicom 2001
11 *
12 * - A. Grieco, s. Mascolo
13 * "Performance evaluation of New Reno, Vegas, Westwood+ TCP" ACM Computer
14 * Comm. Review, 2004
15 *
16 * - A. Dell'Aera, L. Grieco, S. Mascolo.
17 * "Linux 2.4 Implementation of Westwood+ TCP with Rate-Halving :
18 * A Performance Evaluation Over the Internet" (ICC 2004), Paris, June 2004
19 *
20 * Westwood+ employs end-to-end bandwidth measurement to set cwnd and
21 * ssthresh after packet loss. The probing phase is as the original Reno.
5 */ 22 */
6 23
7#include <linux/config.h> 24#include <linux/config.h>
@@ -22,6 +39,8 @@ struct westwood {
22 u32 accounted; 39 u32 accounted;
23 u32 rtt; 40 u32 rtt;
24 u32 rtt_min; /* minimum observed RTT */ 41 u32 rtt_min; /* minimum observed RTT */
42 u8 first_ack; /* flag which infers that this is the first ack */
43 u8 reset_rtt_min; /* Reset RTT min to next RTT sample*/
25}; 44};
26 45
27 46
@@ -49,9 +68,11 @@ static void tcp_westwood_init(struct sock *sk)
49 w->bw_est = 0; 68 w->bw_est = 0;
50 w->accounted = 0; 69 w->accounted = 0;
51 w->cumul_ack = 0; 70 w->cumul_ack = 0;
71 w->reset_rtt_min = 1;
52 w->rtt_min = w->rtt = TCP_WESTWOOD_INIT_RTT; 72 w->rtt_min = w->rtt = TCP_WESTWOOD_INIT_RTT;
53 w->rtt_win_sx = tcp_time_stamp; 73 w->rtt_win_sx = tcp_time_stamp;
54 w->snd_una = tcp_sk(sk)->snd_una; 74 w->snd_una = tcp_sk(sk)->snd_una;
75 w->first_ack = 1;
55} 76}
56 77
57/* 78/*
@@ -63,10 +84,16 @@ static inline u32 westwood_do_filter(u32 a, u32 b)
63 return (((7 * a) + b) >> 3); 84 return (((7 * a) + b) >> 3);
64} 85}
65 86
66static inline void westwood_filter(struct westwood *w, u32 delta) 87static void westwood_filter(struct westwood *w, u32 delta)
67{ 88{
68 w->bw_ns_est = westwood_do_filter(w->bw_ns_est, w->bk / delta); 89 /* If the filter is empty fill it with the first sample of bandwidth */
69 w->bw_est = westwood_do_filter(w->bw_est, w->bw_ns_est); 90 if (w->bw_ns_est == 0 && w->bw_est == 0) {
91 w->bw_ns_est = w->bk / delta;
92 w->bw_est = w->bw_ns_est;
93 } else {
94 w->bw_ns_est = westwood_do_filter(w->bw_ns_est, w->bk / delta);
95 w->bw_est = westwood_do_filter(w->bw_est, w->bw_ns_est);
96 }
70} 97}
71 98
72/* 99/*
@@ -91,6 +118,15 @@ static void westwood_update_window(struct sock *sk)
91 struct westwood *w = inet_csk_ca(sk); 118 struct westwood *w = inet_csk_ca(sk);
92 s32 delta = tcp_time_stamp - w->rtt_win_sx; 119 s32 delta = tcp_time_stamp - w->rtt_win_sx;
93 120
121 /* Initialize w->snd_una with the first acked sequence number in order
122 * to fix mismatch between tp->snd_una and w->snd_una for the first
123 * bandwidth sample
124 */
125 if (w->first_ack) {
126 w->snd_una = tcp_sk(sk)->snd_una;
127 w->first_ack = 0;
128 }
129
94 /* 130 /*
95 * See if a RTT-window has passed. 131 * See if a RTT-window has passed.
96 * Be careful since if RTT is less than 132 * Be careful since if RTT is less than
@@ -108,6 +144,16 @@ static void westwood_update_window(struct sock *sk)
108 } 144 }
109} 145}
110 146
147static inline void update_rtt_min(struct westwood *w)
148{
149 if (w->reset_rtt_min) {
150 w->rtt_min = w->rtt;
151 w->reset_rtt_min = 0;
152 } else
153 w->rtt_min = min(w->rtt, w->rtt_min);
154}
155
156
111/* 157/*
112 * @westwood_fast_bw 158 * @westwood_fast_bw
113 * It is called when we are in fast path. In particular it is called when 159 * It is called when we are in fast path. In particular it is called when
@@ -123,7 +169,7 @@ static inline void westwood_fast_bw(struct sock *sk)
123 169
124 w->bk += tp->snd_una - w->snd_una; 170 w->bk += tp->snd_una - w->snd_una;
125 w->snd_una = tp->snd_una; 171 w->snd_una = tp->snd_una;
126 w->rtt_min = min(w->rtt, w->rtt_min); 172 update_rtt_min(w);
127} 173}
128 174
129/* 175/*
@@ -162,12 +208,6 @@ static inline u32 westwood_acked_count(struct sock *sk)
162 return w->cumul_ack; 208 return w->cumul_ack;
163} 209}
164 210
165static inline u32 westwood_bw_rttmin(const struct sock *sk)
166{
167 const struct tcp_sock *tp = tcp_sk(sk);
168 const struct westwood *w = inet_csk_ca(sk);
169 return max_t(u32, (w->bw_est * w->rtt_min) / tp->mss_cache, 2);
170}
171 211
172/* 212/*
173 * TCP Westwood 213 * TCP Westwood
@@ -175,9 +215,11 @@ static inline u32 westwood_bw_rttmin(const struct sock *sk)
175 * in packets we use mss_cache). Rttmin is guaranteed to be >= 2 215 * in packets we use mss_cache). Rttmin is guaranteed to be >= 2
176 * so avoids ever returning 0. 216 * so avoids ever returning 0.
177 */ 217 */
178static u32 tcp_westwood_cwnd_min(struct sock *sk) 218static u32 tcp_westwood_bw_rttmin(const struct sock *sk)
179{ 219{
180 return westwood_bw_rttmin(sk); 220 const struct tcp_sock *tp = tcp_sk(sk);
221 const struct westwood *w = inet_csk_ca(sk);
222 return max_t(u32, (w->bw_est * w->rtt_min) / tp->mss_cache, 2);
181} 223}
182 224
183static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event) 225static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event)
@@ -191,17 +233,19 @@ static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event)
191 break; 233 break;
192 234
193 case CA_EVENT_COMPLETE_CWR: 235 case CA_EVENT_COMPLETE_CWR:
194 tp->snd_cwnd = tp->snd_ssthresh = westwood_bw_rttmin(sk); 236 tp->snd_cwnd = tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk);
195 break; 237 break;
196 238
197 case CA_EVENT_FRTO: 239 case CA_EVENT_FRTO:
198 tp->snd_ssthresh = westwood_bw_rttmin(sk); 240 tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk);
241 /* Update RTT_min when next ack arrives */
242 w->reset_rtt_min = 1;
199 break; 243 break;
200 244
201 case CA_EVENT_SLOW_ACK: 245 case CA_EVENT_SLOW_ACK:
202 westwood_update_window(sk); 246 westwood_update_window(sk);
203 w->bk += westwood_acked_count(sk); 247 w->bk += westwood_acked_count(sk);
204 w->rtt_min = min(w->rtt, w->rtt_min); 248 update_rtt_min(w);
205 break; 249 break;
206 250
207 default: 251 default:
@@ -235,7 +279,7 @@ static struct tcp_congestion_ops tcp_westwood = {
235 .init = tcp_westwood_init, 279 .init = tcp_westwood_init,
236 .ssthresh = tcp_reno_ssthresh, 280 .ssthresh = tcp_reno_ssthresh,
237 .cong_avoid = tcp_reno_cong_avoid, 281 .cong_avoid = tcp_reno_cong_avoid,
238 .min_cwnd = tcp_westwood_cwnd_min, 282 .min_cwnd = tcp_westwood_bw_rttmin,
239 .cwnd_event = tcp_westwood_event, 283 .cwnd_event = tcp_westwood_event,
240 .get_info = tcp_westwood_info, 284 .get_info = tcp_westwood_info,
241 .pkts_acked = tcp_westwood_pkts_acked, 285 .pkts_acked = tcp_westwood_pkts_acked,
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
index 3e174c83bfe7..817ed84511a6 100644
--- a/net/ipv4/xfrm4_input.c
+++ b/net/ipv4/xfrm4_input.c
@@ -13,7 +13,6 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/netfilter.h> 14#include <linux/netfilter.h>
15#include <linux/netfilter_ipv4.h> 15#include <linux/netfilter_ipv4.h>
16#include <net/inet_ecn.h>
17#include <net/ip.h> 16#include <net/ip.h>
18#include <net/xfrm.h> 17#include <net/xfrm.h>
19 18
@@ -24,15 +23,6 @@ int xfrm4_rcv(struct sk_buff *skb)
24 23
25EXPORT_SYMBOL(xfrm4_rcv); 24EXPORT_SYMBOL(xfrm4_rcv);
26 25
27static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
28{
29 struct iphdr *outer_iph = skb->nh.iph;
30 struct iphdr *inner_iph = skb->h.ipiph;
31
32 if (INET_ECN_is_ce(outer_iph->tos))
33 IP_ECN_set_ce(inner_iph);
34}
35
36static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq) 26static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
37{ 27{
38 switch (nexthdr) { 28 switch (nexthdr) {
@@ -113,24 +103,10 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
113 103
114 xfrm_vec[xfrm_nr++] = x; 104 xfrm_vec[xfrm_nr++] = x;
115 105
116 iph = skb->nh.iph; 106 if (x->mode->input(x, skb))
107 goto drop;
117 108
118 if (x->props.mode) { 109 if (x->props.mode) {
119 if (iph->protocol != IPPROTO_IPIP)
120 goto drop;
121 if (!pskb_may_pull(skb, sizeof(struct iphdr)))
122 goto drop;
123 if (skb_cloned(skb) &&
124 pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
125 goto drop;
126 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
127 ipv4_copy_dscp(iph, skb->h.ipiph);
128 if (!(x->props.flags & XFRM_STATE_NOECN))
129 ipip_ecn_decapsulate(skb);
130 skb->mac.raw = memmove(skb->data - skb->mac_len,
131 skb->mac.raw, skb->mac_len);
132 skb->nh.raw = skb->data;
133 memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
134 decaps = 1; 110 decaps = 1;
135 break; 111 break;
136 } 112 }
diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
new file mode 100644
index 000000000000..a9e6b3dd19c9
--- /dev/null
+++ b/net/ipv4/xfrm4_mode_transport.c
@@ -0,0 +1,83 @@
1/*
2 * xfrm4_mode_transport.c - Transport mode encapsulation for IPv4.
3 *
4 * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
5 */
6
7#include <linux/init.h>
8#include <linux/kernel.h>
9#include <linux/module.h>
10#include <linux/skbuff.h>
11#include <linux/stringify.h>
12#include <net/dst.h>
13#include <net/ip.h>
14#include <net/xfrm.h>
15
16/* Add encapsulation header.
17 *
18 * The IP header will be moved forward to make space for the encapsulation
19 * header.
20 *
21 * On exit, skb->h will be set to the start of the payload to be processed
22 * by x->type->output and skb->nh will be set to the top IP header.
23 */
24static int xfrm4_transport_output(struct sk_buff *skb)
25{
26 struct xfrm_state *x;
27 struct iphdr *iph;
28 int ihl;
29
30 iph = skb->nh.iph;
31 skb->h.ipiph = iph;
32
33 ihl = iph->ihl * 4;
34 skb->h.raw += ihl;
35
36 x = skb->dst->xfrm;
37 skb->nh.raw = memmove(skb_push(skb, x->props.header_len), iph, ihl);
38 return 0;
39}
40
41/* Remove encapsulation header.
42 *
43 * The IP header will be moved over the top of the encapsulation header.
44 *
45 * On entry, skb->h shall point to where the IP header should be and skb->nh
46 * shall be set to where the IP header currently is. skb->data shall point
47 * to the start of the payload.
48 */
49static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb)
50{
51 int ihl = skb->data - skb->h.raw;
52
53 if (skb->h.raw != skb->nh.raw)
54 skb->nh.raw = memmove(skb->h.raw, skb->nh.raw, ihl);
55 skb->nh.iph->tot_len = htons(skb->len + ihl);
56 skb->h.raw = skb->data;
57 return 0;
58}
59
60static struct xfrm_mode xfrm4_transport_mode = {
61 .input = xfrm4_transport_input,
62 .output = xfrm4_transport_output,
63 .owner = THIS_MODULE,
64 .encap = XFRM_MODE_TRANSPORT,
65};
66
67static int __init xfrm4_transport_init(void)
68{
69 return xfrm_register_mode(&xfrm4_transport_mode, AF_INET);
70}
71
72static void __exit xfrm4_transport_exit(void)
73{
74 int err;
75
76 err = xfrm_unregister_mode(&xfrm4_transport_mode, AF_INET);
77 BUG_ON(err);
78}
79
80module_init(xfrm4_transport_init);
81module_exit(xfrm4_transport_exit);
82MODULE_LICENSE("GPL");
83MODULE_ALIAS_XFRM_MODE(AF_INET, XFRM_MODE_TRANSPORT);
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
new file mode 100644
index 000000000000..f8d880beb12f
--- /dev/null
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -0,0 +1,125 @@
1/*
2 * xfrm4_mode_tunnel.c - Tunnel mode encapsulation for IPv4.
3 *
4 * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
5 */
6
7#include <linux/init.h>
8#include <linux/kernel.h>
9#include <linux/module.h>
10#include <linux/skbuff.h>
11#include <linux/stringify.h>
12#include <net/dst.h>
13#include <net/inet_ecn.h>
14#include <net/ip.h>
15#include <net/xfrm.h>
16
17static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
18{
19 struct iphdr *outer_iph = skb->nh.iph;
20 struct iphdr *inner_iph = skb->h.ipiph;
21
22 if (INET_ECN_is_ce(outer_iph->tos))
23 IP_ECN_set_ce(inner_iph);
24}
25
26/* Add encapsulation header.
27 *
28 * The top IP header will be constructed per RFC 2401. The following fields
29 * in it shall be filled in by x->type->output:
30 * tot_len
31 * check
32 *
33 * On exit, skb->h will be set to the start of the payload to be processed
34 * by x->type->output and skb->nh will be set to the top IP header.
35 */
36static int xfrm4_tunnel_output(struct sk_buff *skb)
37{
38 struct dst_entry *dst = skb->dst;
39 struct xfrm_state *x = dst->xfrm;
40 struct iphdr *iph, *top_iph;
41 int flags;
42
43 iph = skb->nh.iph;
44 skb->h.ipiph = iph;
45
46 skb->nh.raw = skb_push(skb, x->props.header_len);
47 top_iph = skb->nh.iph;
48
49 top_iph->ihl = 5;
50 top_iph->version = 4;
51
52 /* DS disclosed */
53 top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
54
55 flags = x->props.flags;
56 if (flags & XFRM_STATE_NOECN)
57 IP_ECN_clear(top_iph);
58
59 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
60 0 : (iph->frag_off & htons(IP_DF));
61 if (!top_iph->frag_off)
62 __ip_select_ident(top_iph, dst->child, 0);
63
64 top_iph->ttl = dst_metric(dst->child, RTAX_HOPLIMIT);
65
66 top_iph->saddr = x->props.saddr.a4;
67 top_iph->daddr = x->id.daddr.a4;
68 top_iph->protocol = IPPROTO_IPIP;
69
70 memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
71 return 0;
72}
73
74static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
75{
76 struct iphdr *iph = skb->nh.iph;
77 int err = -EINVAL;
78
79 if (iph->protocol != IPPROTO_IPIP)
80 goto out;
81 if (!pskb_may_pull(skb, sizeof(struct iphdr)))
82 goto out;
83
84 if (skb_cloned(skb) &&
85 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
86 goto out;
87
88 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
89 ipv4_copy_dscp(iph, skb->h.ipiph);
90 if (!(x->props.flags & XFRM_STATE_NOECN))
91 ipip_ecn_decapsulate(skb);
92 skb->mac.raw = memmove(skb->data - skb->mac_len,
93 skb->mac.raw, skb->mac_len);
94 skb->nh.raw = skb->data;
95 memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
96 err = 0;
97
98out:
99 return err;
100}
101
102static struct xfrm_mode xfrm4_tunnel_mode = {
103 .input = xfrm4_tunnel_input,
104 .output = xfrm4_tunnel_output,
105 .owner = THIS_MODULE,
106 .encap = XFRM_MODE_TUNNEL,
107};
108
109static int __init xfrm4_tunnel_init(void)
110{
111 return xfrm_register_mode(&xfrm4_tunnel_mode, AF_INET);
112}
113
114static void __exit xfrm4_tunnel_exit(void)
115{
116 int err;
117
118 err = xfrm_unregister_mode(&xfrm4_tunnel_mode, AF_INET);
119 BUG_ON(err);
120}
121
122module_init(xfrm4_tunnel_init);
123module_exit(xfrm4_tunnel_exit);
124MODULE_LICENSE("GPL");
125MODULE_ALIAS_XFRM_MODE(AF_INET, XFRM_MODE_TUNNEL);
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
index 4ef8efaf6a67..ac9d91d4bb05 100644
--- a/net/ipv4/xfrm4_output.c
+++ b/net/ipv4/xfrm4_output.c
@@ -12,67 +12,10 @@
12#include <linux/skbuff.h> 12#include <linux/skbuff.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/netfilter_ipv4.h> 14#include <linux/netfilter_ipv4.h>
15#include <net/inet_ecn.h>
16#include <net/ip.h> 15#include <net/ip.h>
17#include <net/xfrm.h> 16#include <net/xfrm.h>
18#include <net/icmp.h> 17#include <net/icmp.h>
19 18
20/* Add encapsulation header.
21 *
22 * In transport mode, the IP header will be moved forward to make space
23 * for the encapsulation header.
24 *
25 * In tunnel mode, the top IP header will be constructed per RFC 2401.
26 * The following fields in it shall be filled in by x->type->output:
27 * tot_len
28 * check
29 *
30 * On exit, skb->h will be set to the start of the payload to be processed
31 * by x->type->output and skb->nh will be set to the top IP header.
32 */
33static void xfrm4_encap(struct sk_buff *skb)
34{
35 struct dst_entry *dst = skb->dst;
36 struct xfrm_state *x = dst->xfrm;
37 struct iphdr *iph, *top_iph;
38 int flags;
39
40 iph = skb->nh.iph;
41 skb->h.ipiph = iph;
42
43 skb->nh.raw = skb_push(skb, x->props.header_len);
44 top_iph = skb->nh.iph;
45
46 if (!x->props.mode) {
47 skb->h.raw += iph->ihl*4;
48 memmove(top_iph, iph, iph->ihl*4);
49 return;
50 }
51
52 top_iph->ihl = 5;
53 top_iph->version = 4;
54
55 /* DS disclosed */
56 top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
57
58 flags = x->props.flags;
59 if (flags & XFRM_STATE_NOECN)
60 IP_ECN_clear(top_iph);
61
62 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
63 0 : (iph->frag_off & htons(IP_DF));
64 if (!top_iph->frag_off)
65 __ip_select_ident(top_iph, dst->child, 0);
66
67 top_iph->ttl = dst_metric(dst->child, RTAX_HOPLIMIT);
68
69 top_iph->saddr = x->props.saddr.a4;
70 top_iph->daddr = x->id.daddr.a4;
71 top_iph->protocol = IPPROTO_IPIP;
72
73 memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
74}
75
76static int xfrm4_tunnel_check_size(struct sk_buff *skb) 19static int xfrm4_tunnel_check_size(struct sk_buff *skb)
77{ 20{
78 int mtu, ret = 0; 21 int mtu, ret = 0;
@@ -121,7 +64,9 @@ static int xfrm4_output_one(struct sk_buff *skb)
121 if (err) 64 if (err)
122 goto error; 65 goto error;
123 66
124 xfrm4_encap(skb); 67 err = x->mode->output(skb);
68 if (err)
69 goto error;
125 70
126 err = x->type->output(x, skb); 71 err = x->type->output(x, skb);
127 if (err) 72 if (err)
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 8604c747bca5..c0465284dfac 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -17,8 +17,6 @@
17static struct dst_ops xfrm4_dst_ops; 17static struct dst_ops xfrm4_dst_ops;
18static struct xfrm_policy_afinfo xfrm4_policy_afinfo; 18static struct xfrm_policy_afinfo xfrm4_policy_afinfo;
19 19
20static struct xfrm_type_map xfrm4_type_map = { .lock = RW_LOCK_UNLOCKED };
21
22static int xfrm4_dst_lookup(struct xfrm_dst **dst, struct flowi *fl) 20static int xfrm4_dst_lookup(struct xfrm_dst **dst, struct flowi *fl)
23{ 21{
24 return __ip_route_output_key((struct rtable**)dst, fl); 22 return __ip_route_output_key((struct rtable**)dst, fl);
@@ -237,9 +235,7 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
237 235
238static inline int xfrm4_garbage_collect(void) 236static inline int xfrm4_garbage_collect(void)
239{ 237{
240 read_lock(&xfrm4_policy_afinfo.lock);
241 xfrm4_policy_afinfo.garbage_collect(); 238 xfrm4_policy_afinfo.garbage_collect();
242 read_unlock(&xfrm4_policy_afinfo.lock);
243 return (atomic_read(&xfrm4_dst_ops.entries) > xfrm4_dst_ops.gc_thresh*2); 239 return (atomic_read(&xfrm4_dst_ops.entries) > xfrm4_dst_ops.gc_thresh*2);
244} 240}
245 241
@@ -299,8 +295,6 @@ static struct dst_ops xfrm4_dst_ops = {
299 295
300static struct xfrm_policy_afinfo xfrm4_policy_afinfo = { 296static struct xfrm_policy_afinfo xfrm4_policy_afinfo = {
301 .family = AF_INET, 297 .family = AF_INET,
302 .lock = RW_LOCK_UNLOCKED,
303 .type_map = &xfrm4_type_map,
304 .dst_ops = &xfrm4_dst_ops, 298 .dst_ops = &xfrm4_dst_ops,
305 .dst_lookup = xfrm4_dst_lookup, 299 .dst_lookup = xfrm4_dst_lookup,
306 .find_bundle = __xfrm4_find_bundle, 300 .find_bundle = __xfrm4_find_bundle,
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c
index dbabf81a9b7b..81e1751c966e 100644
--- a/net/ipv4/xfrm4_state.c
+++ b/net/ipv4/xfrm4_state.c
@@ -131,7 +131,6 @@ __xfrm4_find_acq(u8 mode, u32 reqid, u8 proto,
131 131
132static struct xfrm_state_afinfo xfrm4_state_afinfo = { 132static struct xfrm_state_afinfo xfrm4_state_afinfo = {
133 .family = AF_INET, 133 .family = AF_INET,
134 .lock = RW_LOCK_UNLOCKED,
135 .init_flags = xfrm4_init_flags, 134 .init_flags = xfrm4_init_flags,
136 .init_tempsel = __xfrm4_init_tempsel, 135 .init_tempsel = __xfrm4_init_tempsel,
137 .state_lookup = __xfrm4_state_lookup, 136 .state_lookup = __xfrm4_state_lookup,
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index f8a107ab5592..e923d4dea418 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -106,6 +106,26 @@ config INET6_TUNNEL
106 tristate 106 tristate
107 default n 107 default n
108 108
109config INET6_XFRM_MODE_TRANSPORT
110 tristate "IPv6: IPsec transport mode"
111 depends on IPV6
112 default IPV6
113 select XFRM
114 ---help---
115 Support for IPsec transport mode.
116
117 If unsure, say Y.
118
119config INET6_XFRM_MODE_TUNNEL
120 tristate "IPv6: IPsec tunnel mode"
121 depends on IPV6
122 default IPV6
123 select XFRM
124 ---help---
125 Support for IPsec tunnel mode.
126
127 If unsure, say Y.
128
109config IPV6_TUNNEL 129config IPV6_TUNNEL
110 tristate "IPv6: IPv6-in-IPv6 tunnel" 130 tristate "IPv6: IPv6-in-IPv6 tunnel"
111 select INET6_TUNNEL 131 select INET6_TUNNEL
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index a760b0988fbb..386e0a626948 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -20,6 +20,8 @@ obj-$(CONFIG_INET6_ESP) += esp6.o
20obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o 20obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o
21obj-$(CONFIG_INET6_XFRM_TUNNEL) += xfrm6_tunnel.o 21obj-$(CONFIG_INET6_XFRM_TUNNEL) += xfrm6_tunnel.o
22obj-$(CONFIG_INET6_TUNNEL) += tunnel6.o 22obj-$(CONFIG_INET6_TUNNEL) += tunnel6.o
23obj-$(CONFIG_INET6_XFRM_MODE_TRANSPORT) += xfrm6_mode_transport.o
24obj-$(CONFIG_INET6_XFRM_MODE_TUNNEL) += xfrm6_mode_tunnel.o
23obj-$(CONFIG_NETFILTER) += netfilter/ 25obj-$(CONFIG_NETFILTER) += netfilter/
24 26
25obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o 27obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 445006ee4522..c2c26fa0943d 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2860,6 +2860,11 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
2860 return inet6_addr_add(ifm->ifa_index, pfx, ifm->ifa_prefixlen); 2860 return inet6_addr_add(ifm->ifa_index, pfx, ifm->ifa_prefixlen);
2861} 2861}
2862 2862
2863/* Maximum length of ifa_cacheinfo attributes */
2864#define INET6_IFADDR_RTA_SPACE \
2865 RTA_SPACE(16) /* IFA_ADDRESS */ + \
2866 RTA_SPACE(sizeof(struct ifa_cacheinfo)) /* CACHEINFO */
2867
2863static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, 2868static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
2864 u32 pid, u32 seq, int event, unsigned int flags) 2869 u32 pid, u32 seq, int event, unsigned int flags)
2865{ 2870{
@@ -3092,7 +3097,7 @@ static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb)
3092static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa) 3097static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
3093{ 3098{
3094 struct sk_buff *skb; 3099 struct sk_buff *skb;
3095 int size = NLMSG_SPACE(sizeof(struct ifaddrmsg)+128); 3100 int size = NLMSG_SPACE(sizeof(struct ifaddrmsg) + INET6_IFADDR_RTA_SPACE);
3096 3101
3097 skb = alloc_skb(size, GFP_ATOMIC); 3102 skb = alloc_skb(size, GFP_ATOMIC);
3098 if (!skb) { 3103 if (!skb) {
@@ -3142,6 +3147,17 @@ static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
3142#endif 3147#endif
3143} 3148}
3144 3149
3150/* Maximum length of ifinfomsg attributes */
3151#define INET6_IFINFO_RTA_SPACE \
3152 RTA_SPACE(IFNAMSIZ) /* IFNAME */ + \
3153 RTA_SPACE(MAX_ADDR_LEN) /* ADDRESS */ + \
3154 RTA_SPACE(sizeof(u32)) /* MTU */ + \
3155 RTA_SPACE(sizeof(int)) /* LINK */ + \
3156 RTA_SPACE(0) /* PROTINFO */ + \
3157 RTA_SPACE(sizeof(u32)) /* FLAGS */ + \
3158 RTA_SPACE(sizeof(struct ifla_cacheinfo)) /* CACHEINFO */ + \
3159 RTA_SPACE(sizeof(__s32[DEVCONF_MAX])) /* CONF */
3160
3145static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, 3161static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
3146 u32 pid, u32 seq, int event, unsigned int flags) 3162 u32 pid, u32 seq, int event, unsigned int flags)
3147{ 3163{
@@ -3235,8 +3251,7 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
3235void inet6_ifinfo_notify(int event, struct inet6_dev *idev) 3251void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
3236{ 3252{
3237 struct sk_buff *skb; 3253 struct sk_buff *skb;
3238 /* 128 bytes ?? */ 3254 int size = NLMSG_SPACE(sizeof(struct ifinfomsg) + INET6_IFINFO_RTA_SPACE);
3239 int size = NLMSG_SPACE(sizeof(struct ifinfomsg)+128);
3240 3255
3241 skb = alloc_skb(size, GFP_ATOMIC); 3256 skb = alloc_skb(size, GFP_ATOMIC);
3242 if (!skb) { 3257 if (!skb) {
@@ -3252,6 +3267,11 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
3252 netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV6_IFINFO, GFP_ATOMIC); 3267 netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV6_IFINFO, GFP_ATOMIC);
3253} 3268}
3254 3269
3270/* Maximum length of prefix_cacheinfo attributes */
3271#define INET6_PREFIX_RTA_SPACE \
3272 RTA_SPACE(sizeof(((struct prefix_info *)NULL)->prefix)) /* ADDRESS */ + \
3273 RTA_SPACE(sizeof(struct prefix_cacheinfo)) /* CACHEINFO */
3274
3255static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev, 3275static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
3256 struct prefix_info *pinfo, u32 pid, u32 seq, 3276 struct prefix_info *pinfo, u32 pid, u32 seq,
3257 int event, unsigned int flags) 3277 int event, unsigned int flags)
@@ -3296,7 +3316,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3296 struct prefix_info *pinfo) 3316 struct prefix_info *pinfo)
3297{ 3317{
3298 struct sk_buff *skb; 3318 struct sk_buff *skb;
3299 int size = NLMSG_SPACE(sizeof(struct prefixmsg)+128); 3319 int size = NLMSG_SPACE(sizeof(struct prefixmsg) + INET6_PREFIX_RTA_SPACE);
3300 3320
3301 skb = alloc_skb(size, GFP_ATOMIC); 3321 skb = alloc_skb(size, GFP_ATOMIC);
3302 if (!skb) { 3322 if (!skb) {
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 6778173a3dda..d31c0d6c0448 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -292,7 +292,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
292 292
293 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len); 293 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
294 memset(ah->auth_data, 0, ahp->icv_trunc_len); 294 memset(ah->auth_data, 0, ahp->icv_trunc_len);
295 skb_push(skb, skb->data - skb->nh.raw); 295 skb_push(skb, hdr_len);
296 ahp->icv(ahp, skb, ah->auth_data); 296 ahp->icv(ahp, skb, ah->auth_data);
297 if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) { 297 if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) {
298 LIMIT_NETDEBUG(KERN_WARNING "ipsec ah authentication error\n"); 298 LIMIT_NETDEBUG(KERN_WARNING "ipsec ah authentication error\n");
@@ -301,12 +301,8 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
301 } 301 }
302 } 302 }
303 303
304 skb->nh.raw = skb_pull(skb, ah_hlen); 304 skb->h.raw = memcpy(skb->nh.raw += ah_hlen, tmp_hdr, hdr_len);
305 memcpy(skb->nh.raw, tmp_hdr, hdr_len); 305 __skb_pull(skb, ah_hlen + hdr_len);
306 skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
307 skb_pull(skb, hdr_len);
308 skb->h.raw = skb->data;
309
310 306
311 kfree(tmp_hdr); 307 kfree(tmp_hdr);
312 308
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 22f046079037..a15a6f320f70 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -142,25 +142,17 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
142 142
143 int hdr_len = skb->h.raw - skb->nh.raw; 143 int hdr_len = skb->h.raw - skb->nh.raw;
144 int nfrags; 144 int nfrags;
145 unsigned char *tmp_hdr = NULL;
146 int ret = 0; 145 int ret = 0;
147 146
148 if (!pskb_may_pull(skb, sizeof(struct ipv6_esp_hdr))) { 147 if (!pskb_may_pull(skb, sizeof(struct ipv6_esp_hdr))) {
149 ret = -EINVAL; 148 ret = -EINVAL;
150 goto out_nofree; 149 goto out;
151 } 150 }
152 151
153 if (elen <= 0 || (elen & (blksize-1))) { 152 if (elen <= 0 || (elen & (blksize-1))) {
154 ret = -EINVAL; 153 ret = -EINVAL;
155 goto out_nofree; 154 goto out;
156 }
157
158 tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC);
159 if (!tmp_hdr) {
160 ret = -ENOMEM;
161 goto out_nofree;
162 } 155 }
163 memcpy(tmp_hdr, skb->nh.raw, hdr_len);
164 156
165 /* If integrity check is required, do this. */ 157 /* If integrity check is required, do this. */
166 if (esp->auth.icv_full_len) { 158 if (esp->auth.icv_full_len) {
@@ -222,16 +214,12 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
222 /* ... check padding bits here. Silly. :-) */ 214 /* ... check padding bits here. Silly. :-) */
223 215
224 pskb_trim(skb, skb->len - alen - padlen - 2); 216 pskb_trim(skb, skb->len - alen - padlen - 2);
225 skb->h.raw = skb_pull(skb, sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen);
226 skb->nh.raw += sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen;
227 memcpy(skb->nh.raw, tmp_hdr, hdr_len);
228 skb->nh.ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
229 ret = nexthdr[1]; 217 ret = nexthdr[1];
230 } 218 }
231 219
220 skb->h.raw = __skb_pull(skb, sizeof(*esph) + esp->conf.ivlen) - hdr_len;
221
232out: 222out:
233 kfree(tmp_hdr);
234out_nofree:
235 return ret; 223 return ret;
236} 224}
237 225
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index e46048974f37..d29620f4910e 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -39,6 +39,7 @@
39#include <linux/in6.h> 39#include <linux/in6.h>
40#include <linux/tcp.h> 40#include <linux/tcp.h>
41#include <linux/route.h> 41#include <linux/route.h>
42#include <linux/module.h>
42 43
43#include <linux/netfilter.h> 44#include <linux/netfilter.h>
44#include <linux/netfilter_ipv6.h> 45#include <linux/netfilter_ipv6.h>
@@ -458,6 +459,7 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
458 nf_bridge_get(to->nf_bridge); 459 nf_bridge_get(to->nf_bridge);
459#endif 460#endif
460#endif 461#endif
462 skb_copy_secmark(to, from);
461} 463}
462 464
463int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) 465int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
@@ -488,6 +490,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
488 490
489 return offset; 491 return offset;
490} 492}
493EXPORT_SYMBOL_GPL(ip6_find_1stfragopt);
491 494
492static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) 495static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
493{ 496{
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 48636436028a..f28cd37feed3 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -65,38 +65,25 @@ static LIST_HEAD(ipcomp6_tfms_list);
65 65
66static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) 66static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
67{ 67{
68 int err = 0; 68 int err = -ENOMEM;
69 u8 nexthdr = 0;
70 int hdr_len = skb->h.raw - skb->nh.raw;
71 unsigned char *tmp_hdr = NULL;
72 struct ipv6hdr *iph; 69 struct ipv6hdr *iph;
70 struct ipv6_comp_hdr *ipch;
73 int plen, dlen; 71 int plen, dlen;
74 struct ipcomp_data *ipcd = x->data; 72 struct ipcomp_data *ipcd = x->data;
75 u8 *start, *scratch; 73 u8 *start, *scratch;
76 struct crypto_tfm *tfm; 74 struct crypto_tfm *tfm;
77 int cpu; 75 int cpu;
78 76
79 if ((skb_is_nonlinear(skb) || skb_cloned(skb)) && 77 if (skb_linearize_cow(skb))
80 skb_linearize(skb, GFP_ATOMIC) != 0) {
81 err = -ENOMEM;
82 goto out; 78 goto out;
83 }
84 79
85 skb->ip_summed = CHECKSUM_NONE; 80 skb->ip_summed = CHECKSUM_NONE;
86 81
87 /* Remove ipcomp header and decompress original payload */ 82 /* Remove ipcomp header and decompress original payload */
88 iph = skb->nh.ipv6h; 83 iph = skb->nh.ipv6h;
89 tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC); 84 ipch = (void *)skb->data;
90 if (!tmp_hdr) 85 skb->h.raw = skb->nh.raw + sizeof(*ipch);
91 goto out; 86 __skb_pull(skb, sizeof(*ipch));
92 memcpy(tmp_hdr, iph, hdr_len);
93 nexthdr = *(u8 *)skb->data;
94 skb_pull(skb, sizeof(struct ipv6_comp_hdr));
95 skb->nh.raw += sizeof(struct ipv6_comp_hdr);
96 memcpy(skb->nh.raw, tmp_hdr, hdr_len);
97 iph = skb->nh.ipv6h;
98 iph->payload_len = htons(ntohs(iph->payload_len) - sizeof(struct ipv6_comp_hdr));
99 skb->h.raw = skb->data;
100 87
101 /* decompression */ 88 /* decompression */
102 plen = skb->len; 89 plen = skb->len;
@@ -125,18 +112,11 @@ static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
125 112
126 skb_put(skb, dlen - plen); 113 skb_put(skb, dlen - plen);
127 memcpy(skb->data, scratch, dlen); 114 memcpy(skb->data, scratch, dlen);
115 err = ipch->nexthdr;
128 116
129 iph = skb->nh.ipv6h;
130 iph->payload_len = htons(skb->len);
131
132out_put_cpu: 117out_put_cpu:
133 put_cpu(); 118 put_cpu();
134out: 119out:
135 kfree(tmp_hdr);
136 if (err)
137 goto error_out;
138 return nexthdr;
139error_out:
140 return err; 120 return err;
141} 121}
142 122
@@ -159,10 +139,8 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb)
159 goto out_ok; 139 goto out_ok;
160 } 140 }
161 141
162 if ((skb_is_nonlinear(skb) || skb_cloned(skb)) && 142 if (skb_linearize_cow(skb))
163 skb_linearize(skb, GFP_ATOMIC) != 0) {
164 goto out_ok; 143 goto out_ok;
165 }
166 144
167 /* compression */ 145 /* compression */
168 plen = skb->len - hdr_len; 146 plen = skb->len - hdr_len;
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 93bae36f2663..2a71c3b669f1 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -189,7 +189,7 @@ static unsigned int ipv6_confirm(unsigned int hooknum,
189 189
190 /* This is where we call the helper: as the packet goes out. */ 190 /* This is where we call the helper: as the packet goes out. */
191 ct = nf_ct_get(*pskb, &ctinfo); 191 ct = nf_ct_get(*pskb, &ctinfo);
192 if (!ct) 192 if (!ct || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY)
193 goto out; 193 goto out;
194 194
195 help = nfct_help(ct); 195 help = nfct_help(ct);
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 86c6703265d0..ef18a7b7014b 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -233,7 +233,7 @@ icmpv6_error(struct sk_buff *skb, unsigned int dataoff,
233 return -NF_ACCEPT; 233 return -NF_ACCEPT;
234 } 234 }
235 235
236 if (hooknum == NF_IP6_PRE_ROUTING && 236 if (nf_conntrack_checksum && hooknum == NF_IP6_PRE_ROUTING &&
237 nf_ip6_checksum(skb, hooknum, dataoff, IPPROTO_ICMPV6)) { 237 nf_ip6_checksum(skb, hooknum, dataoff, IPPROTO_ICMPV6)) {
238 nf_log_packet(PF_INET6, 0, skb, NULL, NULL, NULL, 238 nf_log_packet(PF_INET6, 0, skb, NULL, NULL, NULL,
239 "nf_ct_icmpv6: ICMPv6 checksum failed\n"); 239 "nf_ct_icmpv6: ICMPv6 checksum failed\n");
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 3e319035f82d..c32a029e43f0 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -456,13 +456,9 @@ static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
456 DEBUGP("queue: message is too short.\n"); 456 DEBUGP("queue: message is too short.\n");
457 goto err; 457 goto err;
458 } 458 }
459 if (end-offset < skb->len) { 459 if (pskb_trim_rcsum(skb, end - offset)) {
460 if (pskb_trim(skb, end - offset)) { 460 DEBUGP("Can't trim\n");
461 DEBUGP("Can't trim\n"); 461 goto err;
462 goto err;
463 }
464 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
465 skb->ip_summed = CHECKSUM_NONE;
466 } 462 }
467 463
468 /* Find out which fragments are in front and at the back of us 464 /* Find out which fragments are in front and at the back of us
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 301eee726b0f..a50eb306e9e2 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1218,8 +1218,16 @@ process:
1218 bh_lock_sock(sk); 1218 bh_lock_sock(sk);
1219 ret = 0; 1219 ret = 0;
1220 if (!sock_owned_by_user(sk)) { 1220 if (!sock_owned_by_user(sk)) {
1221 if (!tcp_prequeue(sk, skb)) 1221#ifdef CONFIG_NET_DMA
1222 ret = tcp_v6_do_rcv(sk, skb); 1222 struct tcp_sock *tp = tcp_sk(sk);
1223 if (tp->ucopy.dma_chan)
1224 ret = tcp_v6_do_rcv(sk, skb);
1225 else
1226#endif
1227 {
1228 if (!tcp_prequeue(sk, skb))
1229 ret = tcp_v6_do_rcv(sk, skb);
1230 }
1223 } else 1231 } else
1224 sk_add_backlog(sk, skb); 1232 sk_add_backlog(sk, skb);
1225 bh_unlock_sock(sk); 1233 bh_unlock_sock(sk);
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index 00cfdee18dca..0405d74ff910 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -13,21 +13,9 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/netfilter.h> 14#include <linux/netfilter.h>
15#include <linux/netfilter_ipv6.h> 15#include <linux/netfilter_ipv6.h>
16#include <net/dsfield.h>
17#include <net/inet_ecn.h>
18#include <net/ip.h>
19#include <net/ipv6.h> 16#include <net/ipv6.h>
20#include <net/xfrm.h> 17#include <net/xfrm.h>
21 18
22static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
23{
24 struct ipv6hdr *outer_iph = skb->nh.ipv6h;
25 struct ipv6hdr *inner_iph = skb->h.ipv6h;
26
27 if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph)))
28 IP6_ECN_set_ce(inner_iph);
29}
30
31int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi) 19int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
32{ 20{
33 int err; 21 int err;
@@ -81,21 +69,10 @@ int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
81 69
82 xfrm_vec[xfrm_nr++] = x; 70 xfrm_vec[xfrm_nr++] = x;
83 71
72 if (x->mode->input(x, skb))
73 goto drop;
74
84 if (x->props.mode) { /* XXX */ 75 if (x->props.mode) { /* XXX */
85 if (nexthdr != IPPROTO_IPV6)
86 goto drop;
87 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
88 goto drop;
89 if (skb_cloned(skb) &&
90 pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
91 goto drop;
92 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
93 ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h);
94 if (!(x->props.flags & XFRM_STATE_NOECN))
95 ipip6_ecn_decapsulate(skb);
96 skb->mac.raw = memmove(skb->data - skb->mac_len,
97 skb->mac.raw, skb->mac_len);
98 skb->nh.raw = skb->data;
99 decaps = 1; 76 decaps = 1;
100 break; 77 break;
101 } 78 }
diff --git a/net/ipv6/xfrm6_mode_transport.c b/net/ipv6/xfrm6_mode_transport.c
new file mode 100644
index 000000000000..711d713e36d8
--- /dev/null
+++ b/net/ipv6/xfrm6_mode_transport.c
@@ -0,0 +1,88 @@
1/*
2 * xfrm6_mode_transport.c - Transport mode encapsulation for IPv6.
3 *
4 * Copyright (C) 2002 USAGI/WIDE Project
5 * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
6 */
7
8#include <linux/init.h>
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/skbuff.h>
12#include <linux/stringify.h>
13#include <net/dst.h>
14#include <net/ipv6.h>
15#include <net/xfrm.h>
16
17/* Add encapsulation header.
18 *
19 * The IP header and mutable extension headers will be moved forward to make
20 * space for the encapsulation header.
21 *
22 * On exit, skb->h will be set to the start of the encapsulation header to be
23 * filled in by x->type->output and skb->nh will be set to the nextheader field
24 * of the extension header directly preceding the encapsulation header, or in
25 * its absence, that of the top IP header. The value of skb->data will always
26 * point to the top IP header.
27 */
28static int xfrm6_transport_output(struct sk_buff *skb)
29{
30 struct xfrm_state *x = skb->dst->xfrm;
31 struct ipv6hdr *iph;
32 u8 *prevhdr;
33 int hdr_len;
34
35 skb_push(skb, x->props.header_len);
36 iph = skb->nh.ipv6h;
37
38 hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
39 skb->nh.raw = prevhdr - x->props.header_len;
40 skb->h.raw = skb->data + hdr_len;
41 memmove(skb->data, iph, hdr_len);
42 return 0;
43}
44
45/* Remove encapsulation header.
46 *
47 * The IP header will be moved over the top of the encapsulation header.
48 *
49 * On entry, skb->h shall point to where the IP header should be and skb->nh
50 * shall be set to where the IP header currently is. skb->data shall point
51 * to the start of the payload.
52 */
53static int xfrm6_transport_input(struct xfrm_state *x, struct sk_buff *skb)
54{
55 int ihl = skb->data - skb->h.raw;
56
57 if (skb->h.raw != skb->nh.raw)
58 skb->nh.raw = memmove(skb->h.raw, skb->nh.raw, ihl);
59 skb->nh.ipv6h->payload_len = htons(skb->len + ihl -
60 sizeof(struct ipv6hdr));
61 skb->h.raw = skb->data;
62 return 0;
63}
64
65static struct xfrm_mode xfrm6_transport_mode = {
66 .input = xfrm6_transport_input,
67 .output = xfrm6_transport_output,
68 .owner = THIS_MODULE,
69 .encap = XFRM_MODE_TRANSPORT,
70};
71
72static int __init xfrm6_transport_init(void)
73{
74 return xfrm_register_mode(&xfrm6_transport_mode, AF_INET6);
75}
76
77static void __exit xfrm6_transport_exit(void)
78{
79 int err;
80
81 err = xfrm_unregister_mode(&xfrm6_transport_mode, AF_INET6);
82 BUG_ON(err);
83}
84
85module_init(xfrm6_transport_init);
86module_exit(xfrm6_transport_exit);
87MODULE_LICENSE("GPL");
88MODULE_ALIAS_XFRM_MODE(AF_INET6, XFRM_MODE_TRANSPORT);
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
new file mode 100644
index 000000000000..8af79be2edca
--- /dev/null
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -0,0 +1,121 @@
1/*
2 * xfrm6_mode_tunnel.c - Tunnel mode encapsulation for IPv6.
3 *
4 * Copyright (C) 2002 USAGI/WIDE Project
5 * Copyright (c) 2004-2006 Herbert Xu <herbert@gondor.apana.org.au>
6 */
7
8#include <linux/init.h>
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/skbuff.h>
12#include <linux/stringify.h>
13#include <net/dsfield.h>
14#include <net/dst.h>
15#include <net/inet_ecn.h>
16#include <net/ipv6.h>
17#include <net/xfrm.h>
18
19static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
20{
21 struct ipv6hdr *outer_iph = skb->nh.ipv6h;
22 struct ipv6hdr *inner_iph = skb->h.ipv6h;
23
24 if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph)))
25 IP6_ECN_set_ce(inner_iph);
26}
27
28/* Add encapsulation header.
29 *
30 * The top IP header will be constructed per RFC 2401. The following fields
31 * in it shall be filled in by x->type->output:
32 * payload_len
33 *
34 * On exit, skb->h will be set to the start of the encapsulation header to be
35 * filled in by x->type->output and skb->nh will be set to the nextheader field
36 * of the extension header directly preceding the encapsulation header, or in
37 * its absence, that of the top IP header. The value of skb->data will always
38 * point to the top IP header.
39 */
40static int xfrm6_tunnel_output(struct sk_buff *skb)
41{
42 struct dst_entry *dst = skb->dst;
43 struct xfrm_state *x = dst->xfrm;
44 struct ipv6hdr *iph, *top_iph;
45 int dsfield;
46
47 skb_push(skb, x->props.header_len);
48 iph = skb->nh.ipv6h;
49
50 skb->nh.raw = skb->data;
51 top_iph = skb->nh.ipv6h;
52 skb->nh.raw = &top_iph->nexthdr;
53 skb->h.ipv6h = top_iph + 1;
54
55 top_iph->version = 6;
56 top_iph->priority = iph->priority;
57 top_iph->flow_lbl[0] = iph->flow_lbl[0];
58 top_iph->flow_lbl[1] = iph->flow_lbl[1];
59 top_iph->flow_lbl[2] = iph->flow_lbl[2];
60 dsfield = ipv6_get_dsfield(top_iph);
61 dsfield = INET_ECN_encapsulate(dsfield, dsfield);
62 if (x->props.flags & XFRM_STATE_NOECN)
63 dsfield &= ~INET_ECN_MASK;
64 ipv6_change_dsfield(top_iph, 0, dsfield);
65 top_iph->nexthdr = IPPROTO_IPV6;
66 top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT);
67 ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
68 ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
69 return 0;
70}
71
72static int xfrm6_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
73{
74 int err = -EINVAL;
75
76 if (skb->nh.raw[IP6CB(skb)->nhoff] != IPPROTO_IPV6)
77 goto out;
78 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
79 goto out;
80
81 if (skb_cloned(skb) &&
82 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
83 goto out;
84
85 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
86 ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h);
87 if (!(x->props.flags & XFRM_STATE_NOECN))
88 ipip6_ecn_decapsulate(skb);
89 skb->mac.raw = memmove(skb->data - skb->mac_len,
90 skb->mac.raw, skb->mac_len);
91 skb->nh.raw = skb->data;
92 err = 0;
93
94out:
95 return err;
96}
97
98static struct xfrm_mode xfrm6_tunnel_mode = {
99 .input = xfrm6_tunnel_input,
100 .output = xfrm6_tunnel_output,
101 .owner = THIS_MODULE,
102 .encap = XFRM_MODE_TUNNEL,
103};
104
105static int __init xfrm6_tunnel_init(void)
106{
107 return xfrm_register_mode(&xfrm6_tunnel_mode, AF_INET6);
108}
109
110static void __exit xfrm6_tunnel_exit(void)
111{
112 int err;
113
114 err = xfrm_unregister_mode(&xfrm6_tunnel_mode, AF_INET6);
115 BUG_ON(err);
116}
117
118module_init(xfrm6_tunnel_init);
119module_exit(xfrm6_tunnel_exit);
120MODULE_LICENSE("GPL");
121MODULE_ALIAS_XFRM_MODE(AF_INET6, XFRM_MODE_TUNNEL);
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index 80242172a5df..16e84254a252 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -14,68 +14,9 @@
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/icmpv6.h> 15#include <linux/icmpv6.h>
16#include <linux/netfilter_ipv6.h> 16#include <linux/netfilter_ipv6.h>
17#include <net/dsfield.h>
18#include <net/inet_ecn.h>
19#include <net/ipv6.h> 17#include <net/ipv6.h>
20#include <net/xfrm.h> 18#include <net/xfrm.h>
21 19
22/* Add encapsulation header.
23 *
24 * In transport mode, the IP header and mutable extension headers will be moved
25 * forward to make space for the encapsulation header.
26 *
27 * In tunnel mode, the top IP header will be constructed per RFC 2401.
28 * The following fields in it shall be filled in by x->type->output:
29 * payload_len
30 *
31 * On exit, skb->h will be set to the start of the encapsulation header to be
32 * filled in by x->type->output and skb->nh will be set to the nextheader field
33 * of the extension header directly preceding the encapsulation header, or in
34 * its absence, that of the top IP header. The value of skb->data will always
35 * point to the top IP header.
36 */
37static void xfrm6_encap(struct sk_buff *skb)
38{
39 struct dst_entry *dst = skb->dst;
40 struct xfrm_state *x = dst->xfrm;
41 struct ipv6hdr *iph, *top_iph;
42 int dsfield;
43
44 skb_push(skb, x->props.header_len);
45 iph = skb->nh.ipv6h;
46
47 if (!x->props.mode) {
48 u8 *prevhdr;
49 int hdr_len;
50
51 hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
52 skb->nh.raw = prevhdr - x->props.header_len;
53 skb->h.raw = skb->data + hdr_len;
54 memmove(skb->data, iph, hdr_len);
55 return;
56 }
57
58 skb->nh.raw = skb->data;
59 top_iph = skb->nh.ipv6h;
60 skb->nh.raw = &top_iph->nexthdr;
61 skb->h.ipv6h = top_iph + 1;
62
63 top_iph->version = 6;
64 top_iph->priority = iph->priority;
65 top_iph->flow_lbl[0] = iph->flow_lbl[0];
66 top_iph->flow_lbl[1] = iph->flow_lbl[1];
67 top_iph->flow_lbl[2] = iph->flow_lbl[2];
68 dsfield = ipv6_get_dsfield(top_iph);
69 dsfield = INET_ECN_encapsulate(dsfield, dsfield);
70 if (x->props.flags & XFRM_STATE_NOECN)
71 dsfield &= ~INET_ECN_MASK;
72 ipv6_change_dsfield(top_iph, 0, dsfield);
73 top_iph->nexthdr = IPPROTO_IPV6;
74 top_iph->hop_limit = dst_metric(dst->child, RTAX_HOPLIMIT);
75 ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
76 ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
77}
78
79static int xfrm6_tunnel_check_size(struct sk_buff *skb) 20static int xfrm6_tunnel_check_size(struct sk_buff *skb)
80{ 21{
81 int mtu, ret = 0; 22 int mtu, ret = 0;
@@ -118,7 +59,9 @@ static int xfrm6_output_one(struct sk_buff *skb)
118 if (err) 59 if (err)
119 goto error; 60 goto error;
120 61
121 xfrm6_encap(skb); 62 err = x->mode->output(skb);
63 if (err)
64 goto error;
122 65
123 err = x->type->output(x, skb); 66 err = x->type->output(x, skb);
124 if (err) 67 if (err)
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 88c840f1beb6..ee715f2691e9 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -23,8 +23,6 @@
23static struct dst_ops xfrm6_dst_ops; 23static struct dst_ops xfrm6_dst_ops;
24static struct xfrm_policy_afinfo xfrm6_policy_afinfo; 24static struct xfrm_policy_afinfo xfrm6_policy_afinfo;
25 25
26static struct xfrm_type_map xfrm6_type_map = { .lock = RW_LOCK_UNLOCKED };
27
28static int xfrm6_dst_lookup(struct xfrm_dst **dst, struct flowi *fl) 26static int xfrm6_dst_lookup(struct xfrm_dst **dst, struct flowi *fl)
29{ 27{
30 int err = 0; 28 int err = 0;
@@ -249,9 +247,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
249 247
250static inline int xfrm6_garbage_collect(void) 248static inline int xfrm6_garbage_collect(void)
251{ 249{
252 read_lock(&xfrm6_policy_afinfo.lock);
253 xfrm6_policy_afinfo.garbage_collect(); 250 xfrm6_policy_afinfo.garbage_collect();
254 read_unlock(&xfrm6_policy_afinfo.lock);
255 return (atomic_read(&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2); 251 return (atomic_read(&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2);
256} 252}
257 253
@@ -311,8 +307,6 @@ static struct dst_ops xfrm6_dst_ops = {
311 307
312static struct xfrm_policy_afinfo xfrm6_policy_afinfo = { 308static struct xfrm_policy_afinfo xfrm6_policy_afinfo = {
313 .family = AF_INET6, 309 .family = AF_INET6,
314 .lock = RW_LOCK_UNLOCKED,
315 .type_map = &xfrm6_type_map,
316 .dst_ops = &xfrm6_dst_ops, 310 .dst_ops = &xfrm6_dst_ops,
317 .dst_lookup = xfrm6_dst_lookup, 311 .dst_lookup = xfrm6_dst_lookup,
318 .find_bundle = __xfrm6_find_bundle, 312 .find_bundle = __xfrm6_find_bundle,
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c
index a5723024d3b3..b33296b3f6de 100644
--- a/net/ipv6/xfrm6_state.c
+++ b/net/ipv6/xfrm6_state.c
@@ -135,7 +135,6 @@ __xfrm6_find_acq(u8 mode, u32 reqid, u8 proto,
135 135
136static struct xfrm_state_afinfo xfrm6_state_afinfo = { 136static struct xfrm_state_afinfo xfrm6_state_afinfo = {
137 .family = AF_INET6, 137 .family = AF_INET6,
138 .lock = RW_LOCK_UNLOCKED,
139 .init_tempsel = __xfrm6_init_tempsel, 138 .init_tempsel = __xfrm6_init_tempsel,
140 .state_lookup = __xfrm6_state_lookup, 139 .state_lookup = __xfrm6_state_lookup,
141 .find_acq = __xfrm6_find_acq, 140 .find_acq = __xfrm6_find_acq,
diff --git a/net/ipx/ipx_route.c b/net/ipx/ipx_route.c
index a394c6fe19a2..bba3431cd9a5 100644
--- a/net/ipx/ipx_route.c
+++ b/net/ipx/ipx_route.c
@@ -238,7 +238,7 @@ int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
238 } 238 }
239 239
240 /* Apply checksum. Not allowed on 802.3 links. */ 240 /* Apply checksum. Not allowed on 802.3 links. */
241 if (sk->sk_no_check || intrfc->if_dlink_type == IPX_FRAME_8023) 241 if (sk->sk_no_check || intrfc->if_dlink_type == htons(IPX_FRAME_8023))
242 ipx->ipx_checksum = 0xFFFF; 242 ipx->ipx_checksum = 0xFFFF;
243 else 243 else
244 ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr)); 244 ipx->ipx_checksum = ipx_cksum(ipx, len + sizeof(struct ipxhdr));
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index c19e9ce05a3a..57ea160f470b 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -44,6 +44,8 @@
44#include <net/irda/irlmp.h> 44#include <net/irda/irlmp.h>
45#include <net/irda/irlmp_frame.h> 45#include <net/irda/irlmp_frame.h>
46 46
47#include <asm/unaligned.h>
48
47static __u8 irlmp_find_free_slsap(void); 49static __u8 irlmp_find_free_slsap(void);
48static int irlmp_slsap_inuse(__u8 slsap_sel); 50static int irlmp_slsap_inuse(__u8 slsap_sel);
49 51
@@ -840,6 +842,7 @@ void irlmp_do_expiry(void)
840void irlmp_do_discovery(int nslots) 842void irlmp_do_discovery(int nslots)
841{ 843{
842 struct lap_cb *lap; 844 struct lap_cb *lap;
845 __u16 *data_hintsp;
843 846
844 /* Make sure the value is sane */ 847 /* Make sure the value is sane */
845 if ((nslots != 1) && (nslots != 6) && (nslots != 8) && (nslots != 16)){ 848 if ((nslots != 1) && (nslots != 6) && (nslots != 8) && (nslots != 16)){
@@ -849,7 +852,8 @@ void irlmp_do_discovery(int nslots)
849 } 852 }
850 853
851 /* Construct new discovery info to be used by IrLAP, */ 854 /* Construct new discovery info to be used by IrLAP, */
852 u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word; 855 data_hintsp = (__u16 *) irlmp->discovery_cmd.data.hints;
856 put_unaligned(irlmp->hints.word, data_hintsp);
853 857
854 /* 858 /*
855 * Set character set for device name (we use ASCII), and 859 * Set character set for device name (we use ASCII), and
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 859582275cab..d5e2121ea207 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1454,21 +1454,23 @@ static int pfkey_delete(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
1454 if (x == NULL) 1454 if (x == NULL)
1455 return -ESRCH; 1455 return -ESRCH;
1456 1456
1457 if ((err = security_xfrm_state_delete(x)))
1458 goto out;
1459
1457 if (xfrm_state_kern(x)) { 1460 if (xfrm_state_kern(x)) {
1458 xfrm_state_put(x); 1461 err = -EPERM;
1459 return -EPERM; 1462 goto out;
1460 } 1463 }
1461 1464
1462 err = xfrm_state_delete(x); 1465 err = xfrm_state_delete(x);
1463 if (err < 0) { 1466 if (err < 0)
1464 xfrm_state_put(x); 1467 goto out;
1465 return err;
1466 }
1467 1468
1468 c.seq = hdr->sadb_msg_seq; 1469 c.seq = hdr->sadb_msg_seq;
1469 c.pid = hdr->sadb_msg_pid; 1470 c.pid = hdr->sadb_msg_pid;
1470 c.event = XFRM_MSG_DELSA; 1471 c.event = XFRM_MSG_DELSA;
1471 km_state_notify(x, &c); 1472 km_state_notify(x, &c);
1473out:
1472 xfrm_state_put(x); 1474 xfrm_state_put(x);
1473 1475
1474 return err; 1476 return err;
@@ -2274,11 +2276,14 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
2274 2276
2275 err = 0; 2277 err = 0;
2276 2278
2279 if ((err = security_xfrm_policy_delete(xp)))
2280 goto out;
2277 c.seq = hdr->sadb_msg_seq; 2281 c.seq = hdr->sadb_msg_seq;
2278 c.pid = hdr->sadb_msg_pid; 2282 c.pid = hdr->sadb_msg_pid;
2279 c.event = XFRM_MSG_DELPOLICY; 2283 c.event = XFRM_MSG_DELPOLICY;
2280 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); 2284 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
2281 2285
2286out:
2282 xfrm_pol_put(xp); 2287 xfrm_pol_put(xp);
2283 return err; 2288 return err;
2284} 2289}
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 5a04db745c8d..75c9b1480801 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -674,7 +674,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
674 674
675 lock_sock(sk); 675 lock_sock(sk);
676 copied = -ENOTCONN; 676 copied = -ENOTCONN;
677 if (sk->sk_state == TCP_LISTEN) 677 if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN))
678 goto out; 678 goto out;
679 679
680 timeo = sock_rcvtimeo(sk, nonblock); 680 timeo = sock_rcvtimeo(sk, nonblock);
@@ -733,7 +733,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
733 if (sk->sk_shutdown & RCV_SHUTDOWN) 733 if (sk->sk_shutdown & RCV_SHUTDOWN)
734 break; 734 break;
735 735
736 if (sk->sk_state == TCP_CLOSE) { 736 if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSE) {
737 if (!sock_flag(sk, SOCK_DONE)) { 737 if (!sock_flag(sk, SOCK_DONE)) {
738 /* 738 /*
739 * This occurs when user tries to read 739 * This occurs when user tries to read
@@ -789,7 +789,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
789 continue; 789 continue;
790 790
791 if (!(flags & MSG_PEEK)) { 791 if (!(flags & MSG_PEEK)) {
792 sk_eat_skb(sk, skb); 792 sk_eat_skb(sk, skb, 0);
793 *seq = 0; 793 *seq = 0;
794 } 794 }
795 } while (len > 0); 795 } while (len > 0);
diff --git a/net/llc/llc_if.c b/net/llc/llc_if.c
index ba90f7f0801a..5ae47be7dde0 100644
--- a/net/llc/llc_if.c
+++ b/net/llc/llc_if.c
@@ -26,8 +26,6 @@
26#include <net/llc_c_st.h> 26#include <net/llc_c_st.h>
27#include <net/tcp_states.h> 27#include <net/tcp_states.h>
28 28
29u8 llc_mac_null_var[IFHWADDRLEN];
30
31/** 29/**
32 * llc_build_and_send_pkt - Connection data sending for upper layers. 30 * llc_build_and_send_pkt - Connection data sending for upper layers.
33 * @sk: connection 31 * @sk: connection
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index d62e0f9b9da3..94d2368ade92 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -142,6 +142,8 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
142 struct llc_sap *sap; 142 struct llc_sap *sap;
143 struct llc_pdu_sn *pdu; 143 struct llc_pdu_sn *pdu;
144 int dest; 144 int dest;
145 int (*rcv)(struct sk_buff *, struct net_device *,
146 struct packet_type *, struct net_device *);
145 147
146 /* 148 /*
147 * When the interface is in promisc. mode, drop all the crap that it 149 * When the interface is in promisc. mode, drop all the crap that it
@@ -169,9 +171,11 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
169 * First the upper layer protocols that don't need the full 171 * First the upper layer protocols that don't need the full
170 * LLC functionality 172 * LLC functionality
171 */ 173 */
172 if (sap->rcv_func) { 174 rcv = rcu_dereference(sap->rcv_func);
173 sap->rcv_func(skb, dev, pt, orig_dev); 175 if (rcv) {
174 goto out_put; 176 struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC);
177 if (cskb)
178 rcv(cskb, dev, pt, orig_dev);
175 } 179 }
176 dest = llc_pdu_type(skb); 180 dest = llc_pdu_type(skb);
177 if (unlikely(!dest || !llc_type_handlers[dest - 1])) 181 if (unlikely(!dest || !llc_type_handlers[dest - 1]))
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index 4029ceee9b91..20c4eb5c1ac6 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -282,7 +282,7 @@ static void llc_sap_rcv(struct llc_sap *sap, struct sk_buff *skb)
282 * mac, and local sap. Returns pointer for socket found, %NULL otherwise. 282 * mac, and local sap. Returns pointer for socket found, %NULL otherwise.
283 */ 283 */
284static struct sock *llc_lookup_dgram(struct llc_sap *sap, 284static struct sock *llc_lookup_dgram(struct llc_sap *sap,
285 struct llc_addr *laddr) 285 const struct llc_addr *laddr)
286{ 286{
287 struct sock *rc; 287 struct sock *rc;
288 struct hlist_node *node; 288 struct hlist_node *node;
@@ -304,19 +304,62 @@ found:
304 return rc; 304 return rc;
305} 305}
306 306
307/**
308 * llc_sap_mcast - Deliver multicast PDU's to all matching datagram sockets.
309 * @sap: SAP
310 * @laddr: address of local LLC (MAC + SAP)
311 *
312 * Search socket list of the SAP and finds connections with same sap.
313 * Deliver clone to each.
314 */
315static void llc_sap_mcast(struct llc_sap *sap,
316 const struct llc_addr *laddr,
317 struct sk_buff *skb)
318{
319 struct sock *sk;
320 struct hlist_node *node;
321
322 read_lock_bh(&sap->sk_list.lock);
323 sk_for_each(sk, node, &sap->sk_list.list) {
324 struct llc_sock *llc = llc_sk(sk);
325 struct sk_buff *skb1;
326
327 if (sk->sk_type != SOCK_DGRAM)
328 continue;
329
330 if (llc->laddr.lsap != laddr->lsap)
331 continue;
332
333 skb1 = skb_clone(skb, GFP_ATOMIC);
334 if (!skb1)
335 break;
336
337 sock_hold(sk);
338 skb_set_owner_r(skb1, sk);
339 llc_sap_rcv(sap, skb1);
340 sock_put(sk);
341 }
342 read_unlock_bh(&sap->sk_list.lock);
343}
344
345
307void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb) 346void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb)
308{ 347{
309 struct llc_addr laddr; 348 struct llc_addr laddr;
310 struct sock *sk;
311 349
312 llc_pdu_decode_da(skb, laddr.mac); 350 llc_pdu_decode_da(skb, laddr.mac);
313 llc_pdu_decode_dsap(skb, &laddr.lsap); 351 llc_pdu_decode_dsap(skb, &laddr.lsap);
314 352
315 sk = llc_lookup_dgram(sap, &laddr); 353 if (llc_mac_multicast(laddr.mac)) {
316 if (sk) { 354 llc_sap_mcast(sap, &laddr, skb);
317 skb_set_owner_r(skb, sk);
318 llc_sap_rcv(sap, skb);
319 sock_put(sk);
320 } else
321 kfree_skb(skb); 355 kfree_skb(skb);
356 } else {
357 struct sock *sk = llc_lookup_dgram(sap, &laddr);
358 if (sk) {
359 skb_set_owner_r(skb, sk);
360 llc_sap_rcv(sap, skb);
361 sock_put(sk);
362 } else
363 kfree_skb(skb);
364 }
322} 365}
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index e2893effdfaa..b1622b7de1cf 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -60,6 +60,18 @@ config NF_CONNTRACK_MARK
60 of packets, but this mark value is kept in the conntrack session 60 of packets, but this mark value is kept in the conntrack session
61 instead of the individual packets. 61 instead of the individual packets.
62 62
63config NF_CONNTRACK_SECMARK
64 bool 'Connection tracking security mark support'
65 depends on NF_CONNTRACK && NETWORK_SECMARK
66 help
67 This option enables security markings to be applied to
68 connections. Typically they are copied to connections from
69 packets using the CONNSECMARK target and copied back from
70 connections to packets with the same target, with the packets
71 being originally labeled via SECMARK.
72
73 If unsure, say 'N'.
74
63config NF_CONNTRACK_EVENTS 75config NF_CONNTRACK_EVENTS
64 bool "Connection tracking events (EXPERIMENTAL)" 76 bool "Connection tracking events (EXPERIMENTAL)"
65 depends on EXPERIMENTAL && NF_CONNTRACK 77 depends on EXPERIMENTAL && NF_CONNTRACK
@@ -174,6 +186,26 @@ config NETFILTER_XT_TARGET_NOTRACK
174 If you want to compile it as a module, say M here and read 186 If you want to compile it as a module, say M here and read
175 <file:Documentation/modules.txt>. If unsure, say `N'. 187 <file:Documentation/modules.txt>. If unsure, say `N'.
176 188
189config NETFILTER_XT_TARGET_SECMARK
190 tristate '"SECMARK" target support'
191 depends on NETFILTER_XTABLES && NETWORK_SECMARK
192 help
193 The SECMARK target allows security marking of network
194 packets, for use with security subsystems.
195
196 To compile it as a module, choose M here. If unsure, say N.
197
198config NETFILTER_XT_TARGET_CONNSECMARK
199 tristate '"CONNSECMARK" target support'
200 depends on NETFILTER_XTABLES && (NF_CONNTRACK_SECMARK || IP_NF_CONNTRACK_SECMARK)
201 help
202 The CONNSECMARK target copies security markings from packets
203 to connections, and restores security markings from connections
204 to packets (if the packets are not already marked). This would
205 normally be used in conjunction with the SECMARK target.
206
207 To compile it as a module, choose M here. If unsure, say N.
208
177config NETFILTER_XT_MATCH_COMMENT 209config NETFILTER_XT_MATCH_COMMENT
178 tristate '"comment" match support' 210 tristate '"comment" match support'
179 depends on NETFILTER_XTABLES 211 depends on NETFILTER_XTABLES
@@ -329,6 +361,16 @@ config NETFILTER_XT_MATCH_PKTTYPE
329 361
330 To compile it as a module, choose M here. If unsure, say N. 362 To compile it as a module, choose M here. If unsure, say N.
331 363
364config NETFILTER_XT_MATCH_QUOTA
365 tristate '"quota" match support'
366 depends on NETFILTER_XTABLES
367 help
368 This option adds a `quota' match, which allows to match on a
369 byte counter.
370
371 If you want to compile it as a module, say M here and read
372 <file:Documentation/modules.txt>. If unsure, say `N'.
373
332config NETFILTER_XT_MATCH_REALM 374config NETFILTER_XT_MATCH_REALM
333 tristate '"realm" match support' 375 tristate '"realm" match support'
334 depends on NETFILTER_XTABLES 376 depends on NETFILTER_XTABLES
@@ -365,6 +407,12 @@ config NETFILTER_XT_MATCH_STATE
365 407
366 To compile it as a module, choose M here. If unsure, say N. 408 To compile it as a module, choose M here. If unsure, say N.
367 409
410config NETFILTER_XT_MATCH_STATISTIC
411 tristate '"statistic" match support'
412 depends on NETFILTER_XTABLES
413 help
414 statistic module
415
368config NETFILTER_XT_MATCH_STRING 416config NETFILTER_XT_MATCH_STRING
369 tristate '"string" match support' 417 tristate '"string" match support'
370 depends on NETFILTER_XTABLES 418 depends on NETFILTER_XTABLES
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index 95b7e416512d..6fa4b7580458 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -28,6 +28,8 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
28obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o 28obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o
29obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o 29obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
30obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o 30obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o
31obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o
32obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
31 33
32# matches 34# matches
33obj-$(CONFIG_NETFILTER_XT_MATCH_COMMENT) += xt_comment.o 35obj-$(CONFIG_NETFILTER_XT_MATCH_COMMENT) += xt_comment.o
@@ -44,9 +46,11 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_MARK) += xt_mark.o
44obj-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += xt_multiport.o 46obj-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += xt_multiport.o
45obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o 47obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o
46obj-$(CONFIG_NETFILTER_XT_MATCH_PKTTYPE) += xt_pkttype.o 48obj-$(CONFIG_NETFILTER_XT_MATCH_PKTTYPE) += xt_pkttype.o
49obj-$(CONFIG_NETFILTER_XT_MATCH_QUOTA) += xt_quota.o
47obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o 50obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o
48obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o 51obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o
49obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o 52obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o
53obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
50obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o 54obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o
51obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o 55obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o
52obj-$(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) += xt_physdev.o 56obj-$(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) += xt_physdev.o
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index f9b83f91371a..cd299f4b7db1 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -990,6 +990,9 @@ init_conntrack(const struct nf_conntrack_tuple *tuple,
990#ifdef CONFIG_NF_CONNTRACK_MARK 990#ifdef CONFIG_NF_CONNTRACK_MARK
991 conntrack->mark = exp->master->mark; 991 conntrack->mark = exp->master->mark;
992#endif 992#endif
993#ifdef CONFIG_NF_CONNTRACK_SECMARK
994 conntrack->secmark = exp->master->secmark;
995#endif
993 nf_conntrack_get(&conntrack->master->ct_general); 996 nf_conntrack_get(&conntrack->master->ct_general);
994 NF_CT_STAT_INC(expect_new); 997 NF_CT_STAT_INC(expect_new);
995 } else 998 } else
@@ -1396,6 +1399,12 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
1396 1399
1397 write_lock_bh(&nf_conntrack_lock); 1400 write_lock_bh(&nf_conntrack_lock);
1398 1401
1402 /* Only update if this is not a fixed timeout */
1403 if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status)) {
1404 write_unlock_bh(&nf_conntrack_lock);
1405 return;
1406 }
1407
1399 /* If not in hash table, timer will not be active yet */ 1408 /* If not in hash table, timer will not be active yet */
1400 if (!nf_ct_is_confirmed(ct)) { 1409 if (!nf_ct_is_confirmed(ct)) {
1401 ct->timeout.expires = extra_jiffies; 1410 ct->timeout.expires = extra_jiffies;
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index e38a4b5a3089..11d3be243536 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -67,37 +67,48 @@ static int try_epsv_response(const char *, size_t, struct nf_conntrack_man *,
67 char); 67 char);
68 68
69static struct ftp_search { 69static struct ftp_search {
70 enum ip_conntrack_dir dir;
71 const char *pattern; 70 const char *pattern;
72 size_t plen; 71 size_t plen;
73 char skip; 72 char skip;
74 char term; 73 char term;
75 enum ip_ct_ftp_type ftptype; 74 enum ip_ct_ftp_type ftptype;
76 int (*getnum)(const char *, size_t, struct nf_conntrack_man *, char); 75 int (*getnum)(const char *, size_t, struct nf_conntrack_man *, char);
77} search[] = { 76} search[IP_CT_DIR_MAX][2] = {
78 { 77 [IP_CT_DIR_ORIGINAL] = {
79 IP_CT_DIR_ORIGINAL, 78 {
80 "PORT", sizeof("PORT") - 1, ' ', '\r', 79 .pattern = "PORT",
81 IP_CT_FTP_PORT, 80 .plen = sizeof("PORT") - 1,
82 try_rfc959, 81 .skip = ' ',
82 .term = '\r',
83 .ftptype = IP_CT_FTP_PORT,
84 .getnum = try_rfc959,
85 },
86 {
87 .pattern = "EPRT",
88 .plen = sizeof("EPRT") - 1,
89 .skip = ' ',
90 .term = '\r',
91 .ftptype = IP_CT_FTP_EPRT,
92 .getnum = try_eprt,
93 },
83 }, 94 },
84 { 95 [IP_CT_DIR_REPLY] = {
85 IP_CT_DIR_REPLY, 96 {
86 "227 ", sizeof("227 ") - 1, '(', ')', 97 .pattern = "227 ",
87 IP_CT_FTP_PASV, 98 .plen = sizeof("227 ") - 1,
88 try_rfc959, 99 .skip = '(',
89 }, 100 .term = ')',
90 { 101 .ftptype = IP_CT_FTP_PASV,
91 IP_CT_DIR_ORIGINAL, 102 .getnum = try_rfc959,
92 "EPRT", sizeof("EPRT") - 1, ' ', '\r', 103 },
93 IP_CT_FTP_EPRT, 104 {
94 try_eprt, 105 .pattern = "229 ",
95 }, 106 .plen = sizeof("229 ") - 1,
96 { 107 .skip = '(',
97 IP_CT_DIR_REPLY, 108 .term = ')',
98 "229 ", sizeof("229 ") - 1, '(', ')', 109 .ftptype = IP_CT_FTP_EPSV,
99 IP_CT_FTP_EPSV, 110 .getnum = try_epsv_response,
100 try_epsv_response, 111 },
101 }, 112 },
102}; 113};
103 114
@@ -492,17 +503,15 @@ static int help(struct sk_buff **pskb,
492 memcpy(cmd.u3.all, &ct->tuplehash[dir].tuple.src.u3.all, 503 memcpy(cmd.u3.all, &ct->tuplehash[dir].tuple.src.u3.all,
493 sizeof(cmd.u3.all)); 504 sizeof(cmd.u3.all));
494 505
495 for (i = 0; i < ARRAY_SIZE(search); i++) { 506 for (i = 0; i < ARRAY_SIZE(search[dir]); i++) {
496 if (search[i].dir != dir) continue;
497
498 found = find_pattern(fb_ptr, datalen, 507 found = find_pattern(fb_ptr, datalen,
499 search[i].pattern, 508 search[dir][i].pattern,
500 search[i].plen, 509 search[dir][i].plen,
501 search[i].skip, 510 search[dir][i].skip,
502 search[i].term, 511 search[dir][i].term,
503 &matchoff, &matchlen, 512 &matchoff, &matchlen,
504 &cmd, 513 &cmd,
505 search[i].getnum); 514 search[dir][i].getnum);
506 if (found) break; 515 if (found) break;
507 } 516 }
508 if (found == -1) { 517 if (found == -1) {
@@ -512,7 +521,7 @@ static int help(struct sk_buff **pskb,
512 this case. */ 521 this case. */
513 if (net_ratelimit()) 522 if (net_ratelimit())
514 printk("conntrack_ftp: partial %s %u+%u\n", 523 printk("conntrack_ftp: partial %s %u+%u\n",
515 search[i].pattern, 524 search[dir][i].pattern,
516 ntohl(th->seq), datalen); 525 ntohl(th->seq), datalen);
517 ret = NF_DROP; 526 ret = NF_DROP;
518 goto out; 527 goto out;
@@ -597,7 +606,7 @@ static int help(struct sk_buff **pskb,
597 /* Now, NAT might want to mangle the packet, and register the 606 /* Now, NAT might want to mangle the packet, and register the
598 * (possibly changed) expectation itself. */ 607 * (possibly changed) expectation itself. */
599 if (nf_nat_ftp_hook) 608 if (nf_nat_ftp_hook)
600 ret = nf_nat_ftp_hook(pskb, ctinfo, search[i].ftptype, 609 ret = nf_nat_ftp_hook(pskb, ctinfo, search[dir][i].ftptype,
601 matchoff, matchlen, exp, &seq); 610 matchoff, matchlen, exp, &seq);
602 else { 611 else {
603 /* Can't expect this? Best to drop packet now. */ 612 /* Can't expect this? Best to drop packet now. */
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index bd10eb944b65..b8c7c567c9df 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -407,6 +407,8 @@ nfattr_failure:
407 407
408static int ctnetlink_done(struct netlink_callback *cb) 408static int ctnetlink_done(struct netlink_callback *cb)
409{ 409{
410 if (cb->args[1])
411 nf_ct_put((struct nf_conn *)cb->args[1]);
410 DEBUGP("entered %s\n", __FUNCTION__); 412 DEBUGP("entered %s\n", __FUNCTION__);
411 return 0; 413 return 0;
412} 414}
@@ -416,10 +418,9 @@ static int ctnetlink_done(struct netlink_callback *cb)
416static int 418static int
417ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) 419ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
418{ 420{
419 struct nf_conn *ct = NULL; 421 struct nf_conn *ct, *last;
420 struct nf_conntrack_tuple_hash *h; 422 struct nf_conntrack_tuple_hash *h;
421 struct list_head *i; 423 struct list_head *i;
422 u_int32_t *id = (u_int32_t *) &cb->args[1];
423 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh); 424 struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh);
424 u_int8_t l3proto = nfmsg->nfgen_family; 425 u_int8_t l3proto = nfmsg->nfgen_family;
425 426
@@ -427,7 +428,9 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
427 cb->args[0], *id); 428 cb->args[0], *id);
428 429
429 read_lock_bh(&nf_conntrack_lock); 430 read_lock_bh(&nf_conntrack_lock);
430 for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++, *id = 0) { 431 for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++) {
432restart:
433 last = (struct nf_conn *)cb->args[1];
431 list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) { 434 list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) {
432 h = (struct nf_conntrack_tuple_hash *) i; 435 h = (struct nf_conntrack_tuple_hash *) i;
433 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) 436 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL)
@@ -438,17 +441,30 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
438 * then dump everything. */ 441 * then dump everything. */
439 if (l3proto && L3PROTO(ct) != l3proto) 442 if (l3proto && L3PROTO(ct) != l3proto)
440 continue; 443 continue;
441 if (ct->id <= *id) 444 if (last != NULL) {
442 continue; 445 if (ct == last) {
446 nf_ct_put(last);
447 cb->args[1] = 0;
448 last = NULL;
449 } else
450 continue;
451 }
443 if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, 452 if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
444 cb->nlh->nlmsg_seq, 453 cb->nlh->nlmsg_seq,
445 IPCTNL_MSG_CT_NEW, 454 IPCTNL_MSG_CT_NEW,
446 1, ct) < 0) 455 1, ct) < 0) {
456 nf_conntrack_get(&ct->ct_general);
457 cb->args[1] = (unsigned long)ct;
447 goto out; 458 goto out;
448 *id = ct->id; 459 }
460 }
461 if (last != NULL) {
462 nf_ct_put(last);
463 cb->args[1] = 0;
464 goto restart;
449 } 465 }
450 } 466 }
451out: 467out:
452 read_unlock_bh(&nf_conntrack_lock); 468 read_unlock_bh(&nf_conntrack_lock);
453 469
454 DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id); 470 DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id);
@@ -641,7 +657,7 @@ static const size_t cta_min_nat[CTA_NAT_MAX] = {
641}; 657};
642 658
643static inline int 659static inline int
644ctnetlink_parse_nat(struct nfattr *cda[], 660ctnetlink_parse_nat(struct nfattr *nat,
645 const struct nf_conn *ct, struct ip_nat_range *range) 661 const struct nf_conn *ct, struct ip_nat_range *range)
646{ 662{
647 struct nfattr *tb[CTA_NAT_MAX]; 663 struct nfattr *tb[CTA_NAT_MAX];
@@ -651,7 +667,7 @@ ctnetlink_parse_nat(struct nfattr *cda[],
651 667
652 memset(range, 0, sizeof(*range)); 668 memset(range, 0, sizeof(*range));
653 669
654 nfattr_parse_nested(tb, CTA_NAT_MAX, cda[CTA_NAT-1]); 670 nfattr_parse_nested(tb, CTA_NAT_MAX, nat);
655 671
656 if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat)) 672 if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat))
657 return -EINVAL; 673 return -EINVAL;
@@ -866,39 +882,30 @@ ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[])
866 /* ASSURED bit can only be set */ 882 /* ASSURED bit can only be set */
867 return -EINVAL; 883 return -EINVAL;
868 884
869 if (cda[CTA_NAT-1]) { 885 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
870#ifndef CONFIG_IP_NF_NAT_NEEDED 886#ifndef CONFIG_IP_NF_NAT_NEEDED
871 return -EINVAL; 887 return -EINVAL;
872#else 888#else
873 unsigned int hooknum;
874 struct ip_nat_range range; 889 struct ip_nat_range range;
875 890
876 if (ctnetlink_parse_nat(cda, ct, &range) < 0) 891 if (cda[CTA_NAT_DST-1]) {
877 return -EINVAL; 892 if (ctnetlink_parse_nat(cda[CTA_NAT_DST-1], ct,
878 893 &range) < 0)
879 DEBUGP("NAT: %u.%u.%u.%u-%u.%u.%u.%u:%u-%u\n", 894 return -EINVAL;
880 NIPQUAD(range.min_ip), NIPQUAD(range.max_ip), 895 if (ip_nat_initialized(ct,
881 htons(range.min.all), htons(range.max.all)); 896 HOOK2MANIP(NF_IP_PRE_ROUTING)))
882 897 return -EEXIST;
883 /* This is tricky but it works. ip_nat_setup_info needs the 898 ip_nat_setup_info(ct, &range, hooknum);
884 * hook number as parameter, so let's do the correct 899 }
885 * conversion and run away */ 900 if (cda[CTA_NAT_SRC-1]) {
886 if (status & IPS_SRC_NAT_DONE) 901 if (ctnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct,
887 hooknum = NF_IP_POST_ROUTING; /* IP_NAT_MANIP_SRC */ 902 &range) < 0)
888 else if (status & IPS_DST_NAT_DONE) 903 return -EINVAL;
889 hooknum = NF_IP_PRE_ROUTING; /* IP_NAT_MANIP_DST */ 904 if (ip_nat_initialized(ct,
890 else 905 HOOK2MANIP(NF_IP_POST_ROUTING)))
891 return -EINVAL; /* Missing NAT flags */ 906 return -EEXIST;
892 907 ip_nat_setup_info(ct, &range, hooknum);
893 DEBUGP("NAT status: %lu\n", 908 }
894 status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK));
895
896 if (ip_nat_initialized(ct, HOOK2MANIP(hooknum)))
897 return -EEXIST;
898 ip_nat_setup_info(ct, &range, hooknum);
899
900 DEBUGP("NAT status after setup_info: %lu\n",
901 ct->status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK));
902#endif 909#endif
903 } 910 }
904 911
@@ -1122,7 +1129,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
1122 /* implicit 'else' */ 1129 /* implicit 'else' */
1123 1130
1124 /* we only allow nat config for new conntracks */ 1131 /* we only allow nat config for new conntracks */
1125 if (cda[CTA_NAT-1]) { 1132 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
1126 err = -EINVAL; 1133 err = -EINVAL;
1127 goto out_unlock; 1134 goto out_unlock;
1128 } 1135 }
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 69899f27d26a..12fb7c0a1509 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -828,8 +828,9 @@ static int tcp_error(struct sk_buff *skb,
828 * and moreover root might send raw packets. 828 * and moreover root might send raw packets.
829 */ 829 */
830 /* FIXME: Source route IP option packets --RR */ 830 /* FIXME: Source route IP option packets --RR */
831 if (((pf == PF_INET && hooknum == NF_IP_PRE_ROUTING) || 831 if (nf_conntrack_checksum &&
832 (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING)) && 832 ((pf == PF_INET && hooknum == NF_IP_PRE_ROUTING) ||
833 (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING)) &&
833 nf_checksum(skb, hooknum, dataoff, IPPROTO_TCP, pf)) { 834 nf_checksum(skb, hooknum, dataoff, IPPROTO_TCP, pf)) {
834 if (LOG_INVALID(IPPROTO_TCP)) 835 if (LOG_INVALID(IPPROTO_TCP))
835 nf_log_packet(pf, 0, skb, NULL, NULL, NULL, 836 nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index d93edbfde9e3..ae07ebe3ab37 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -134,7 +134,8 @@ static int udp_error(struct sk_buff *skb, unsigned int dataoff,
134 * because the semantic of CHECKSUM_HW is different there 134 * because the semantic of CHECKSUM_HW is different there
135 * and moreover root might send raw packets. 135 * and moreover root might send raw packets.
136 * FIXME: Source route IP option packets --RR */ 136 * FIXME: Source route IP option packets --RR */
137 if (((pf == PF_INET && hooknum == NF_IP_PRE_ROUTING) || 137 if (nf_conntrack_checksum &&
138 ((pf == PF_INET && hooknum == NF_IP_PRE_ROUTING) ||
138 (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING)) && 139 (pf == PF_INET6 && hooknum == NF_IP6_PRE_ROUTING)) &&
139 nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) { 140 nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) {
140 if (LOG_INVALID(IPPROTO_UDP)) 141 if (LOG_INVALID(IPPROTO_UDP))
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 408960c6a544..e34c574f0351 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -213,6 +213,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
213 return -ENOSPC; 213 return -ENOSPC;
214#endif 214#endif
215 215
216#ifdef CONFIG_NF_CONNTRACK_SECMARK
217 if (seq_printf(s, "secmark=%u ", conntrack->secmark))
218 return -ENOSPC;
219#endif
220
216 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use))) 221 if (seq_printf(s, "use=%u\n", atomic_read(&conntrack->ct_general.use)))
217 return -ENOSPC; 222 return -ENOSPC;
218 223
@@ -455,6 +460,8 @@ extern unsigned int nf_ct_generic_timeout;
455static int log_invalid_proto_min = 0; 460static int log_invalid_proto_min = 0;
456static int log_invalid_proto_max = 255; 461static int log_invalid_proto_max = 255;
457 462
463int nf_conntrack_checksum = 1;
464
458static struct ctl_table_header *nf_ct_sysctl_header; 465static struct ctl_table_header *nf_ct_sysctl_header;
459 466
460static ctl_table nf_ct_sysctl_table[] = { 467static ctl_table nf_ct_sysctl_table[] = {
@@ -483,6 +490,14 @@ static ctl_table nf_ct_sysctl_table[] = {
483 .proc_handler = &proc_dointvec, 490 .proc_handler = &proc_dointvec,
484 }, 491 },
485 { 492 {
493 .ctl_name = NET_NF_CONNTRACK_CHECKSUM,
494 .procname = "nf_conntrack_checksum",
495 .data = &nf_conntrack_checksum,
496 .maxlen = sizeof(unsigned int),
497 .mode = 0644,
498 .proc_handler = &proc_dointvec,
499 },
500 {
486 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT, 501 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
487 .procname = "nf_conntrack_tcp_timeout_syn_sent", 502 .procname = "nf_conntrack_tcp_timeout_syn_sent",
488 .data = &nf_ct_tcp_timeout_syn_sent, 503 .data = &nf_ct_tcp_timeout_syn_sent,
@@ -851,6 +866,7 @@ EXPORT_SYMBOL(nf_ct_proto_put);
851EXPORT_SYMBOL(nf_ct_l3proto_find_get); 866EXPORT_SYMBOL(nf_ct_l3proto_find_get);
852EXPORT_SYMBOL(nf_ct_l3proto_put); 867EXPORT_SYMBOL(nf_ct_l3proto_put);
853EXPORT_SYMBOL(nf_ct_l3protos); 868EXPORT_SYMBOL(nf_ct_l3protos);
869EXPORT_SYMBOL_GPL(nf_conntrack_checksum);
854EXPORT_SYMBOL(nf_conntrack_expect_alloc); 870EXPORT_SYMBOL(nf_conntrack_expect_alloc);
855EXPORT_SYMBOL(nf_conntrack_expect_put); 871EXPORT_SYMBOL(nf_conntrack_expect_put);
856EXPORT_SYMBOL(nf_conntrack_expect_related); 872EXPORT_SYMBOL(nf_conntrack_expect_related);
diff --git a/net/netfilter/xt_CONNSECMARK.c b/net/netfilter/xt_CONNSECMARK.c
new file mode 100644
index 000000000000..8c011e020769
--- /dev/null
+++ b/net/netfilter/xt_CONNSECMARK.c
@@ -0,0 +1,155 @@
1/*
2 * This module is used to copy security markings from packets
3 * to connections, and restore security markings from connections
4 * back to packets. This would normally be performed in conjunction
5 * with the SECMARK target and state match.
6 *
7 * Based somewhat on CONNMARK:
8 * Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com>
9 * by Henrik Nordstrom <hno@marasystems.com>
10 *
11 * (C) 2006 Red Hat, Inc., James Morris <jmorris@redhat.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 *
17 */
18#include <linux/module.h>
19#include <linux/skbuff.h>
20#include <linux/netfilter/x_tables.h>
21#include <linux/netfilter/xt_CONNSECMARK.h>
22#include <net/netfilter/nf_conntrack_compat.h>
23
24#define PFX "CONNSECMARK: "
25
26MODULE_LICENSE("GPL");
27MODULE_AUTHOR("James Morris <jmorris@redhat.com>");
28MODULE_DESCRIPTION("ip[6]tables CONNSECMARK module");
29MODULE_ALIAS("ipt_CONNSECMARK");
30MODULE_ALIAS("ip6t_CONNSECMARK");
31
32/*
33 * If the packet has a security mark and the connection does not, copy
34 * the security mark from the packet to the connection.
35 */
36static void secmark_save(struct sk_buff *skb)
37{
38 if (skb->secmark) {
39 u32 *connsecmark;
40 enum ip_conntrack_info ctinfo;
41
42 connsecmark = nf_ct_get_secmark(skb, &ctinfo);
43 if (connsecmark && !*connsecmark)
44 if (*connsecmark != skb->secmark)
45 *connsecmark = skb->secmark;
46 }
47}
48
49/*
50 * If packet has no security mark, and the connection does, restore the
51 * security mark from the connection to the packet.
52 */
53static void secmark_restore(struct sk_buff *skb)
54{
55 if (!skb->secmark) {
56 u32 *connsecmark;
57 enum ip_conntrack_info ctinfo;
58
59 connsecmark = nf_ct_get_secmark(skb, &ctinfo);
60 if (connsecmark && *connsecmark)
61 if (skb->secmark != *connsecmark)
62 skb->secmark = *connsecmark;
63 }
64}
65
66static unsigned int target(struct sk_buff **pskb, const struct net_device *in,
67 const struct net_device *out, unsigned int hooknum,
68 const struct xt_target *target,
69 const void *targinfo, void *userinfo)
70{
71 struct sk_buff *skb = *pskb;
72 const struct xt_connsecmark_target_info *info = targinfo;
73
74 switch (info->mode) {
75 case CONNSECMARK_SAVE:
76 secmark_save(skb);
77 break;
78
79 case CONNSECMARK_RESTORE:
80 secmark_restore(skb);
81 break;
82
83 default:
84 BUG();
85 }
86
87 return XT_CONTINUE;
88}
89
90static int checkentry(const char *tablename, const void *entry,
91 const struct xt_target *target, void *targinfo,
92 unsigned int targinfosize, unsigned int hook_mask)
93{
94 struct xt_connsecmark_target_info *info = targinfo;
95
96 switch (info->mode) {
97 case CONNSECMARK_SAVE:
98 case CONNSECMARK_RESTORE:
99 break;
100
101 default:
102 printk(KERN_INFO PFX "invalid mode: %hu\n", info->mode);
103 return 0;
104 }
105
106 return 1;
107}
108
109static struct xt_target ipt_connsecmark_reg = {
110 .name = "CONNSECMARK",
111 .target = target,
112 .targetsize = sizeof(struct xt_connsecmark_target_info),
113 .table = "mangle",
114 .checkentry = checkentry,
115 .me = THIS_MODULE,
116 .family = AF_INET,
117 .revision = 0,
118};
119
120static struct xt_target ip6t_connsecmark_reg = {
121 .name = "CONNSECMARK",
122 .target = target,
123 .targetsize = sizeof(struct xt_connsecmark_target_info),
124 .table = "mangle",
125 .checkentry = checkentry,
126 .me = THIS_MODULE,
127 .family = AF_INET6,
128 .revision = 0,
129};
130
131static int __init xt_connsecmark_init(void)
132{
133 int err;
134
135 need_conntrack();
136
137 err = xt_register_target(&ipt_connsecmark_reg);
138 if (err)
139 return err;
140
141 err = xt_register_target(&ip6t_connsecmark_reg);
142 if (err)
143 xt_unregister_target(&ipt_connsecmark_reg);
144
145 return err;
146}
147
148static void __exit xt_connsecmark_fini(void)
149{
150 xt_unregister_target(&ip6t_connsecmark_reg);
151 xt_unregister_target(&ipt_connsecmark_reg);
152}
153
154module_init(xt_connsecmark_init);
155module_exit(xt_connsecmark_fini);
diff --git a/net/netfilter/xt_SECMARK.c b/net/netfilter/xt_SECMARK.c
new file mode 100644
index 000000000000..c2ce9c4011cc
--- /dev/null
+++ b/net/netfilter/xt_SECMARK.c
@@ -0,0 +1,156 @@
1/*
2 * Module for modifying the secmark field of the skb, for use by
3 * security subsystems.
4 *
5 * Based on the nfmark match by:
6 * (C) 1999-2001 Marc Boucher <marc@mbsi.ca>
7 *
8 * (C) 2006 Red Hat, Inc., James Morris <jmorris@redhat.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */
15#include <linux/module.h>
16#include <linux/skbuff.h>
17#include <linux/selinux.h>
18#include <linux/netfilter/x_tables.h>
19#include <linux/netfilter/xt_SECMARK.h>
20
21MODULE_LICENSE("GPL");
22MODULE_AUTHOR("James Morris <jmorris@redhat.com>");
23MODULE_DESCRIPTION("ip[6]tables SECMARK modification module");
24MODULE_ALIAS("ipt_SECMARK");
25MODULE_ALIAS("ip6t_SECMARK");
26
27#define PFX "SECMARK: "
28
29static u8 mode;
30
31static unsigned int target(struct sk_buff **pskb, const struct net_device *in,
32 const struct net_device *out, unsigned int hooknum,
33 const struct xt_target *target,
34 const void *targinfo, void *userinfo)
35{
36 u32 secmark = 0;
37 const struct xt_secmark_target_info *info = targinfo;
38
39 BUG_ON(info->mode != mode);
40
41 switch (mode) {
42 case SECMARK_MODE_SEL:
43 secmark = info->u.sel.selsid;
44 break;
45
46 default:
47 BUG();
48 }
49
50 if ((*pskb)->secmark != secmark)
51 (*pskb)->secmark = secmark;
52
53 return XT_CONTINUE;
54}
55
56static int checkentry_selinux(struct xt_secmark_target_info *info)
57{
58 int err;
59 struct xt_secmark_target_selinux_info *sel = &info->u.sel;
60
61 err = selinux_string_to_sid(sel->selctx, &sel->selsid);
62 if (err) {
63 if (err == -EINVAL)
64 printk(KERN_INFO PFX "invalid SELinux context \'%s\'\n",
65 sel->selctx);
66 return 0;
67 }
68
69 if (!sel->selsid) {
70 printk(KERN_INFO PFX "unable to map SELinux context \'%s\'\n",
71 sel->selctx);
72 return 0;
73 }
74
75 err = selinux_relabel_packet_permission(sel->selsid);
76 if (err) {
77 printk(KERN_INFO PFX "unable to obtain relabeling permission\n");
78 return 0;
79 }
80
81 return 1;
82}
83
84static int checkentry(const char *tablename, const void *entry,
85 const struct xt_target *target, void *targinfo,
86 unsigned int targinfosize, unsigned int hook_mask)
87{
88 struct xt_secmark_target_info *info = targinfo;
89
90 if (mode && mode != info->mode) {
91 printk(KERN_INFO PFX "mode already set to %hu cannot mix with "
92 "rules for mode %hu\n", mode, info->mode);
93 return 0;
94 }
95
96 switch (info->mode) {
97 case SECMARK_MODE_SEL:
98 if (!checkentry_selinux(info))
99 return 0;
100 break;
101
102 default:
103 printk(KERN_INFO PFX "invalid mode: %hu\n", info->mode);
104 return 0;
105 }
106
107 if (!mode)
108 mode = info->mode;
109 return 1;
110}
111
112static struct xt_target ipt_secmark_reg = {
113 .name = "SECMARK",
114 .target = target,
115 .targetsize = sizeof(struct xt_secmark_target_info),
116 .table = "mangle",
117 .checkentry = checkentry,
118 .me = THIS_MODULE,
119 .family = AF_INET,
120 .revision = 0,
121};
122
123static struct xt_target ip6t_secmark_reg = {
124 .name = "SECMARK",
125 .target = target,
126 .targetsize = sizeof(struct xt_secmark_target_info),
127 .table = "mangle",
128 .checkentry = checkentry,
129 .me = THIS_MODULE,
130 .family = AF_INET6,
131 .revision = 0,
132};
133
134static int __init xt_secmark_init(void)
135{
136 int err;
137
138 err = xt_register_target(&ipt_secmark_reg);
139 if (err)
140 return err;
141
142 err = xt_register_target(&ip6t_secmark_reg);
143 if (err)
144 xt_unregister_target(&ipt_secmark_reg);
145
146 return err;
147}
148
149static void __exit xt_secmark_fini(void)
150{
151 xt_unregister_target(&ip6t_secmark_reg);
152 xt_unregister_target(&ipt_secmark_reg);
153}
154
155module_init(xt_secmark_init);
156module_exit(xt_secmark_fini);
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index dc26a27cbcaf..56324c8aff0a 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -58,7 +58,7 @@ checkentry(const char *tablename,
58 unsigned int matchsize, 58 unsigned int matchsize,
59 unsigned int hook_mask) 59 unsigned int hook_mask)
60{ 60{
61 struct xt_connmark_info *cm = (struct xt_connmark_info *)matchinfo; 61 struct xt_connmark_info *cm = matchinfo;
62 62
63 if (cm->mark > 0xffffffff || cm->mask > 0xffffffff) { 63 if (cm->mark > 0xffffffff || cm->mask > 0xffffffff) {
64 printk(KERN_WARNING "connmark: only support 32bit mark\n"); 64 printk(KERN_WARNING "connmark: only support 32bit mark\n");
diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index dfb10b648e57..2e2f825dad4c 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -101,8 +101,7 @@ match(const struct sk_buff *skb,
101 unsigned int protoff, 101 unsigned int protoff,
102 int *hotdrop) 102 int *hotdrop)
103{ 103{
104 const struct xt_dccp_info *info = 104 const struct xt_dccp_info *info = matchinfo;
105 (const struct xt_dccp_info *)matchinfo;
106 struct dccp_hdr _dh, *dh; 105 struct dccp_hdr _dh, *dh;
107 106
108 if (offset) 107 if (offset)
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index 8b385a34886d..876bc5797738 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -42,7 +42,7 @@ checkentry(const char *tablename,
42 unsigned int matchsize, 42 unsigned int matchsize,
43 unsigned int hook_mask) 43 unsigned int hook_mask)
44{ 44{
45 struct xt_mark_info *minfo = (struct xt_mark_info *) matchinfo; 45 const struct xt_mark_info *minfo = matchinfo;
46 46
47 if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) { 47 if (minfo->mark > 0xffffffff || minfo->mask > 0xffffffff) {
48 printk(KERN_WARNING "mark: only supports 32bit mark\n"); 48 printk(KERN_WARNING "mark: only supports 32bit mark\n");
diff --git a/net/netfilter/xt_multiport.c b/net/netfilter/xt_multiport.c
index b56cd2baaac2..1ff0a25396e7 100644
--- a/net/netfilter/xt_multiport.c
+++ b/net/netfilter/xt_multiport.c
@@ -1,4 +1,4 @@
1/* Kernel module to match one of a list of TCP/UDP ports: ports are in 1/* Kernel module to match one of a list of TCP/UDP/SCTP/DCCP ports: ports are in
2 the same place so we can treat them as equal. */ 2 the same place so we can treat them as equal. */
3 3
4/* (C) 1999-2001 Paul `Rusty' Russell 4/* (C) 1999-2001 Paul `Rusty' Russell
@@ -160,8 +160,9 @@ check(u_int16_t proto,
160 u_int8_t match_flags, 160 u_int8_t match_flags,
161 u_int8_t count) 161 u_int8_t count)
162{ 162{
163 /* Must specify proto == TCP/UDP, no unknown flags or bad count */ 163 /* Must specify supported protocol, no unknown flags or bad count */
164 return (proto == IPPROTO_TCP || proto == IPPROTO_UDP) 164 return (proto == IPPROTO_TCP || proto == IPPROTO_UDP
165 || proto == IPPROTO_SCTP || proto == IPPROTO_DCCP)
165 && !(ip_invflags & XT_INV_PROTO) 166 && !(ip_invflags & XT_INV_PROTO)
166 && (match_flags == XT_MULTIPORT_SOURCE 167 && (match_flags == XT_MULTIPORT_SOURCE
167 || match_flags == XT_MULTIPORT_DESTINATION 168 || match_flags == XT_MULTIPORT_DESTINATION
diff --git a/net/netfilter/xt_quota.c b/net/netfilter/xt_quota.c
new file mode 100644
index 000000000000..4cdba7469dc4
--- /dev/null
+++ b/net/netfilter/xt_quota.c
@@ -0,0 +1,96 @@
1/*
2 * netfilter module to enforce network quotas
3 *
4 * Sam Johnston <samj@samj.net>
5 */
6#include <linux/skbuff.h>
7#include <linux/spinlock.h>
8
9#include <linux/netfilter/x_tables.h>
10#include <linux/netfilter/xt_quota.h>
11
12MODULE_LICENSE("GPL");
13MODULE_AUTHOR("Sam Johnston <samj@samj.net>");
14
15static DEFINE_SPINLOCK(quota_lock);
16
17static int
18match(const struct sk_buff *skb,
19 const struct net_device *in, const struct net_device *out,
20 const struct xt_match *match, const void *matchinfo,
21 int offset, unsigned int protoff, int *hotdrop)
22{
23 struct xt_quota_info *q = ((struct xt_quota_info *)matchinfo)->master;
24 int ret = q->flags & XT_QUOTA_INVERT ? 1 : 0;
25
26 spin_lock_bh(&quota_lock);
27 if (q->quota >= skb->len) {
28 q->quota -= skb->len;
29 ret ^= 1;
30 } else {
31 /* we do not allow even small packets from now on */
32 q->quota = 0;
33 }
34 spin_unlock_bh(&quota_lock);
35
36 return ret;
37}
38
39static int
40checkentry(const char *tablename, const void *entry,
41 const struct xt_match *match, void *matchinfo,
42 unsigned int matchsize, unsigned int hook_mask)
43{
44 struct xt_quota_info *q = (struct xt_quota_info *)matchinfo;
45
46 if (q->flags & ~XT_QUOTA_MASK)
47 return 0;
48 /* For SMP, we only want to use one set of counters. */
49 q->master = q;
50 return 1;
51}
52
53static struct xt_match quota_match = {
54 .name = "quota",
55 .family = AF_INET,
56 .match = match,
57 .matchsize = sizeof(struct xt_quota_info),
58 .checkentry = checkentry,
59 .me = THIS_MODULE
60};
61
62static struct xt_match quota_match6 = {
63 .name = "quota",
64 .family = AF_INET6,
65 .match = match,
66 .matchsize = sizeof(struct xt_quota_info),
67 .checkentry = checkentry,
68 .me = THIS_MODULE
69};
70
71static int __init xt_quota_init(void)
72{
73 int ret;
74
75 ret = xt_register_match(&quota_match);
76 if (ret)
77 goto err1;
78 ret = xt_register_match(&quota_match6);
79 if (ret)
80 goto err2;
81 return ret;
82
83err2:
84 xt_unregister_match(&quota_match);
85err1:
86 return ret;
87}
88
89static void __exit xt_quota_fini(void)
90{
91 xt_unregister_match(&quota_match6);
92 xt_unregister_match(&quota_match);
93}
94
95module_init(xt_quota_init);
96module_exit(xt_quota_fini);
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index 34bd87259a09..b5110e5b54b0 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -129,11 +129,9 @@ match(const struct sk_buff *skb,
129 unsigned int protoff, 129 unsigned int protoff,
130 int *hotdrop) 130 int *hotdrop)
131{ 131{
132 const struct xt_sctp_info *info; 132 const struct xt_sctp_info *info = matchinfo;
133 sctp_sctphdr_t _sh, *sh; 133 sctp_sctphdr_t _sh, *sh;
134 134
135 info = (const struct xt_sctp_info *)matchinfo;
136
137 if (offset) { 135 if (offset) {
138 duprintf("Dropping non-first fragment.. FIXME\n"); 136 duprintf("Dropping non-first fragment.. FIXME\n");
139 return 0; 137 return 0;
diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
new file mode 100644
index 000000000000..de1037f58596
--- /dev/null
+++ b/net/netfilter/xt_statistic.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright (c) 2006 Patrick McHardy <kaber@trash.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Based on ipt_random and ipt_nth by Fabrice MARIE <fabrice@netfilter.org>.
9 */
10
11#include <linux/init.h>
12#include <linux/spinlock.h>
13#include <linux/skbuff.h>
14#include <linux/net.h>
15
16#include <linux/netfilter/xt_statistic.h>
17#include <linux/netfilter/x_tables.h>
18
19MODULE_LICENSE("GPL");
20MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
21MODULE_DESCRIPTION("xtables statistical match module");
22MODULE_ALIAS("ipt_statistic");
23MODULE_ALIAS("ip6t_statistic");
24
25static DEFINE_SPINLOCK(nth_lock);
26
27static int
28match(const struct sk_buff *skb,
29 const struct net_device *in, const struct net_device *out,
30 const struct xt_match *match, const void *matchinfo,
31 int offset, unsigned int protoff, int *hotdrop)
32{
33 struct xt_statistic_info *info = (struct xt_statistic_info *)matchinfo;
34 int ret = info->flags & XT_STATISTIC_INVERT ? 1 : 0;
35
36 switch (info->mode) {
37 case XT_STATISTIC_MODE_RANDOM:
38 if ((net_random() & 0x7FFFFFFF) < info->u.random.probability)
39 ret ^= 1;
40 break;
41 case XT_STATISTIC_MODE_NTH:
42 info = info->master;
43 spin_lock_bh(&nth_lock);
44 if (info->u.nth.count++ == info->u.nth.every) {
45 info->u.nth.count = 0;
46 ret ^= 1;
47 }
48 spin_unlock_bh(&nth_lock);
49 break;
50 }
51
52 return ret;
53}
54
55static int
56checkentry(const char *tablename, const void *entry,
57 const struct xt_match *match, void *matchinfo,
58 unsigned int matchsize, unsigned int hook_mask)
59{
60 struct xt_statistic_info *info = (struct xt_statistic_info *)matchinfo;
61
62 if (info->mode > XT_STATISTIC_MODE_MAX ||
63 info->flags & ~XT_STATISTIC_MASK)
64 return 0;
65 info->master = info;
66 return 1;
67}
68
69static struct xt_match statistic_match = {
70 .name = "statistic",
71 .match = match,
72 .matchsize = sizeof(struct xt_statistic_info),
73 .checkentry = checkentry,
74 .family = AF_INET,
75 .me = THIS_MODULE,
76};
77
78static struct xt_match statistic_match6 = {
79 .name = "statistic",
80 .match = match,
81 .matchsize = sizeof(struct xt_statistic_info),
82 .checkentry = checkentry,
83 .family = AF_INET6,
84 .me = THIS_MODULE,
85};
86
87static int __init xt_statistic_init(void)
88{
89 int ret;
90
91 ret = xt_register_match(&statistic_match);
92 if (ret)
93 goto err1;
94
95 ret = xt_register_match(&statistic_match6);
96 if (ret)
97 goto err2;
98 return ret;
99err2:
100 xt_unregister_match(&statistic_match);
101err1:
102 return ret;
103}
104
105static void __exit xt_statistic_fini(void)
106{
107 xt_unregister_match(&statistic_match6);
108 xt_unregister_match(&statistic_match);
109}
110
111module_init(xt_statistic_init);
112module_exit(xt_statistic_fini);
diff --git a/net/netfilter/xt_string.c b/net/netfilter/xt_string.c
index 79d9ea6964ba..0ebb6ac2c8c7 100644
--- a/net/netfilter/xt_string.c
+++ b/net/netfilter/xt_string.c
@@ -30,8 +30,8 @@ static int match(const struct sk_buff *skb,
30 unsigned int protoff, 30 unsigned int protoff,
31 int *hotdrop) 31 int *hotdrop)
32{ 32{
33 const struct xt_string_info *conf = matchinfo;
33 struct ts_state state; 34 struct ts_state state;
34 struct xt_string_info *conf = (struct xt_string_info *) matchinfo;
35 35
36 memset(&state, 0, sizeof(struct ts_state)); 36 memset(&state, 0, sizeof(struct ts_state));
37 37
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 138ea92ed268..b1e4c5e20ac7 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -72,9 +72,9 @@ void qdisc_unlock_tree(struct net_device *dev)
72 dev->queue_lock serializes queue accesses for this device 72 dev->queue_lock serializes queue accesses for this device
73 AND dev->qdisc pointer itself. 73 AND dev->qdisc pointer itself.
74 74
75 dev->xmit_lock serializes accesses to device driver. 75 netif_tx_lock serializes accesses to device driver.
76 76
77 dev->queue_lock and dev->xmit_lock are mutually exclusive, 77 dev->queue_lock and netif_tx_lock are mutually exclusive,
78 if one is grabbed, another must be free. 78 if one is grabbed, another must be free.
79 */ 79 */
80 80
@@ -108,7 +108,7 @@ int qdisc_restart(struct net_device *dev)
108 * will be requeued. 108 * will be requeued.
109 */ 109 */
110 if (!nolock) { 110 if (!nolock) {
111 if (!spin_trylock(&dev->xmit_lock)) { 111 if (!netif_tx_trylock(dev)) {
112 collision: 112 collision:
113 /* So, someone grabbed the driver. */ 113 /* So, someone grabbed the driver. */
114 114
@@ -126,8 +126,6 @@ int qdisc_restart(struct net_device *dev)
126 __get_cpu_var(netdev_rx_stat).cpu_collision++; 126 __get_cpu_var(netdev_rx_stat).cpu_collision++;
127 goto requeue; 127 goto requeue;
128 } 128 }
129 /* Remember that the driver is grabbed by us. */
130 dev->xmit_lock_owner = smp_processor_id();
131 } 129 }
132 130
133 { 131 {
@@ -142,8 +140,7 @@ int qdisc_restart(struct net_device *dev)
142 ret = dev->hard_start_xmit(skb, dev); 140 ret = dev->hard_start_xmit(skb, dev);
143 if (ret == NETDEV_TX_OK) { 141 if (ret == NETDEV_TX_OK) {
144 if (!nolock) { 142 if (!nolock) {
145 dev->xmit_lock_owner = -1; 143 netif_tx_unlock(dev);
146 spin_unlock(&dev->xmit_lock);
147 } 144 }
148 spin_lock(&dev->queue_lock); 145 spin_lock(&dev->queue_lock);
149 return -1; 146 return -1;
@@ -157,8 +154,7 @@ int qdisc_restart(struct net_device *dev)
157 /* NETDEV_TX_BUSY - we need to requeue */ 154 /* NETDEV_TX_BUSY - we need to requeue */
158 /* Release the driver */ 155 /* Release the driver */
159 if (!nolock) { 156 if (!nolock) {
160 dev->xmit_lock_owner = -1; 157 netif_tx_unlock(dev);
161 spin_unlock(&dev->xmit_lock);
162 } 158 }
163 spin_lock(&dev->queue_lock); 159 spin_lock(&dev->queue_lock);
164 q = dev->qdisc; 160 q = dev->qdisc;
@@ -187,7 +183,7 @@ static void dev_watchdog(unsigned long arg)
187{ 183{
188 struct net_device *dev = (struct net_device *)arg; 184 struct net_device *dev = (struct net_device *)arg;
189 185
190 spin_lock(&dev->xmit_lock); 186 netif_tx_lock(dev);
191 if (dev->qdisc != &noop_qdisc) { 187 if (dev->qdisc != &noop_qdisc) {
192 if (netif_device_present(dev) && 188 if (netif_device_present(dev) &&
193 netif_running(dev) && 189 netif_running(dev) &&
@@ -203,7 +199,7 @@ static void dev_watchdog(unsigned long arg)
203 dev_hold(dev); 199 dev_hold(dev);
204 } 200 }
205 } 201 }
206 spin_unlock(&dev->xmit_lock); 202 netif_tx_unlock(dev);
207 203
208 dev_put(dev); 204 dev_put(dev);
209} 205}
@@ -227,17 +223,17 @@ void __netdev_watchdog_up(struct net_device *dev)
227 223
228static void dev_watchdog_up(struct net_device *dev) 224static void dev_watchdog_up(struct net_device *dev)
229{ 225{
230 spin_lock_bh(&dev->xmit_lock); 226 netif_tx_lock_bh(dev);
231 __netdev_watchdog_up(dev); 227 __netdev_watchdog_up(dev);
232 spin_unlock_bh(&dev->xmit_lock); 228 netif_tx_unlock_bh(dev);
233} 229}
234 230
235static void dev_watchdog_down(struct net_device *dev) 231static void dev_watchdog_down(struct net_device *dev)
236{ 232{
237 spin_lock_bh(&dev->xmit_lock); 233 netif_tx_lock_bh(dev);
238 if (del_timer(&dev->watchdog_timer)) 234 if (del_timer(&dev->watchdog_timer))
239 dev_put(dev); 235 dev_put(dev);
240 spin_unlock_bh(&dev->xmit_lock); 236 netif_tx_unlock_bh(dev);
241} 237}
242 238
243void netif_carrier_on(struct net_device *dev) 239void netif_carrier_on(struct net_device *dev)
@@ -582,7 +578,7 @@ void dev_deactivate(struct net_device *dev)
582 while (test_bit(__LINK_STATE_SCHED, &dev->state)) 578 while (test_bit(__LINK_STATE_SCHED, &dev->state))
583 yield(); 579 yield();
584 580
585 spin_unlock_wait(&dev->xmit_lock); 581 spin_unlock_wait(&dev->_xmit_lock);
586} 582}
587 583
588void dev_init_scheduler(struct net_device *dev) 584void dev_init_scheduler(struct net_device *dev)
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 79b8ef34c6e4..4c16ad57a3e4 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -302,20 +302,17 @@ restart:
302 302
303 switch (teql_resolve(skb, skb_res, slave)) { 303 switch (teql_resolve(skb, skb_res, slave)) {
304 case 0: 304 case 0:
305 if (spin_trylock(&slave->xmit_lock)) { 305 if (netif_tx_trylock(slave)) {
306 slave->xmit_lock_owner = smp_processor_id();
307 if (!netif_queue_stopped(slave) && 306 if (!netif_queue_stopped(slave) &&
308 slave->hard_start_xmit(skb, slave) == 0) { 307 slave->hard_start_xmit(skb, slave) == 0) {
309 slave->xmit_lock_owner = -1; 308 netif_tx_unlock(slave);
310 spin_unlock(&slave->xmit_lock);
311 master->slaves = NEXT_SLAVE(q); 309 master->slaves = NEXT_SLAVE(q);
312 netif_wake_queue(dev); 310 netif_wake_queue(dev);
313 master->stats.tx_packets++; 311 master->stats.tx_packets++;
314 master->stats.tx_bytes += len; 312 master->stats.tx_bytes += len;
315 return 0; 313 return 0;
316 } 314 }
317 slave->xmit_lock_owner = -1; 315 netif_tx_unlock(slave);
318 spin_unlock(&slave->xmit_lock);
319 } 316 }
320 if (netif_queue_stopped(dev)) 317 if (netif_queue_stopped(dev))
321 busy = 1; 318 busy = 1;
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 1662f9cc869e..42b66e74bbb5 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -141,7 +141,8 @@ int sctp_rcv(struct sk_buff *skb)
141 __skb_pull(skb, skb->h.raw - skb->data); 141 __skb_pull(skb, skb->h.raw - skb->data);
142 if (skb->len < sizeof(struct sctphdr)) 142 if (skb->len < sizeof(struct sctphdr))
143 goto discard_it; 143 goto discard_it;
144 if (sctp_rcv_checksum(skb) < 0) 144 if ((skb->ip_summed != CHECKSUM_UNNECESSARY) &&
145 (sctp_rcv_checksum(skb) < 0))
145 goto discard_it; 146 goto discard_it;
146 147
147 skb_pull(skb, sizeof(struct sctphdr)); 148 skb_pull(skb, sizeof(struct sctphdr));
@@ -170,7 +171,8 @@ int sctp_rcv(struct sk_buff *skb)
170 * IP broadcast addresses cannot be used in an SCTP transport 171 * IP broadcast addresses cannot be used in an SCTP transport
171 * address." 172 * address."
172 */ 173 */
173 if (!af->addr_valid(&src, NULL) || !af->addr_valid(&dest, NULL)) 174 if (!af->addr_valid(&src, NULL, skb) ||
175 !af->addr_valid(&dest, NULL, skb))
174 goto discard_it; 176 goto discard_it;
175 177
176 asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport); 178 asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport);
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index c20d282fac06..8ef08070c8b6 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -523,7 +523,9 @@ static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp)
523 * Return 0 - If the address is a non-unicast or an illegal address. 523 * Return 0 - If the address is a non-unicast or an illegal address.
524 * Return 1 - If the address is a unicast. 524 * Return 1 - If the address is a unicast.
525 */ 525 */
526static int sctp_v6_addr_valid(union sctp_addr *addr, struct sctp_sock *sp) 526static int sctp_v6_addr_valid(union sctp_addr *addr,
527 struct sctp_sock *sp,
528 const struct sk_buff *skb)
527{ 529{
528 int ret = ipv6_addr_type(&addr->v6.sin6_addr); 530 int ret = ipv6_addr_type(&addr->v6.sin6_addr);
529 531
@@ -537,7 +539,7 @@ static int sctp_v6_addr_valid(union sctp_addr *addr, struct sctp_sock *sp)
537 if (sp && ipv6_only_sock(sctp_opt2sk(sp))) 539 if (sp && ipv6_only_sock(sctp_opt2sk(sp)))
538 return 0; 540 return 0;
539 sctp_v6_map_v4(addr); 541 sctp_v6_map_v4(addr);
540 return sctp_get_af_specific(AF_INET)->addr_valid(addr, sp); 542 return sctp_get_af_specific(AF_INET)->addr_valid(addr, sp, skb);
541 } 543 }
542 544
543 /* Is this a non-unicast address */ 545 /* Is this a non-unicast address */
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 437cba7260a4..cdc5a3936766 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -295,14 +295,14 @@ int sctp_packet_transmit(struct sctp_packet *packet)
295 struct sctp_transport *tp = packet->transport; 295 struct sctp_transport *tp = packet->transport;
296 struct sctp_association *asoc = tp->asoc; 296 struct sctp_association *asoc = tp->asoc;
297 struct sctphdr *sh; 297 struct sctphdr *sh;
298 __u32 crc32; 298 __u32 crc32 = 0;
299 struct sk_buff *nskb; 299 struct sk_buff *nskb;
300 struct sctp_chunk *chunk, *tmp; 300 struct sctp_chunk *chunk, *tmp;
301 struct sock *sk; 301 struct sock *sk;
302 int err = 0; 302 int err = 0;
303 int padding; /* How much padding do we need? */ 303 int padding; /* How much padding do we need? */
304 __u8 has_data = 0; 304 __u8 has_data = 0;
305 struct dst_entry *dst; 305 struct dst_entry *dst = tp->dst;
306 306
307 SCTP_DEBUG_PRINTK("%s: packet:%p\n", __FUNCTION__, packet); 307 SCTP_DEBUG_PRINTK("%s: packet:%p\n", __FUNCTION__, packet);
308 308
@@ -327,6 +327,19 @@ int sctp_packet_transmit(struct sctp_packet *packet)
327 */ 327 */
328 skb_set_owner_w(nskb, sk); 328 skb_set_owner_w(nskb, sk);
329 329
330 /* The 'obsolete' field of dst is set to 2 when a dst is freed. */
331 if (!dst || (dst->obsolete > 1)) {
332 dst_release(dst);
333 sctp_transport_route(tp, NULL, sctp_sk(sk));
334 if (asoc && (asoc->param_flags & SPP_PMTUD_ENABLE)) {
335 sctp_assoc_sync_pmtu(asoc);
336 }
337 }
338 nskb->dst = dst_clone(tp->dst);
339 if (!nskb->dst)
340 goto no_route;
341 dst = nskb->dst;
342
330 /* Build the SCTP header. */ 343 /* Build the SCTP header. */
331 sh = (struct sctphdr *)skb_push(nskb, sizeof(struct sctphdr)); 344 sh = (struct sctphdr *)skb_push(nskb, sizeof(struct sctphdr));
332 sh->source = htons(packet->source_port); 345 sh->source = htons(packet->source_port);
@@ -350,7 +363,8 @@ int sctp_packet_transmit(struct sctp_packet *packet)
350 * Note: Adler-32 is no longer applicable, as has been replaced 363 * Note: Adler-32 is no longer applicable, as has been replaced
351 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>. 364 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
352 */ 365 */
353 crc32 = sctp_start_cksum((__u8 *)sh, sizeof(struct sctphdr)); 366 if (!(dst->dev->features & NETIF_F_NO_CSUM))
367 crc32 = sctp_start_cksum((__u8 *)sh, sizeof(struct sctphdr));
354 368
355 /** 369 /**
356 * 6.10 Bundling 370 * 6.10 Bundling
@@ -402,9 +416,14 @@ int sctp_packet_transmit(struct sctp_packet *packet)
402 if (padding) 416 if (padding)
403 memset(skb_put(chunk->skb, padding), 0, padding); 417 memset(skb_put(chunk->skb, padding), 0, padding);
404 418
405 crc32 = sctp_update_copy_cksum(skb_put(nskb, chunk->skb->len), 419 if (dst->dev->features & NETIF_F_NO_CSUM)
406 chunk->skb->data, 420 memcpy(skb_put(nskb, chunk->skb->len),
407 chunk->skb->len, crc32); 421 chunk->skb->data, chunk->skb->len);
422 else
423 crc32 = sctp_update_copy_cksum(skb_put(nskb,
424 chunk->skb->len),
425 chunk->skb->data,
426 chunk->skb->len, crc32);
408 427
409 SCTP_DEBUG_PRINTK("%s %p[%s] %s 0x%x, %s %d, %s %d, %s %d\n", 428 SCTP_DEBUG_PRINTK("%s %p[%s] %s 0x%x, %s %d, %s %d, %s %d\n",
410 "*** Chunk", chunk, 429 "*** Chunk", chunk,
@@ -427,7 +446,8 @@ int sctp_packet_transmit(struct sctp_packet *packet)
427 } 446 }
428 447
429 /* Perform final transformation on checksum. */ 448 /* Perform final transformation on checksum. */
430 crc32 = sctp_end_cksum(crc32); 449 if (!(dst->dev->features & NETIF_F_NO_CSUM))
450 crc32 = sctp_end_cksum(crc32);
431 451
432 /* 3) Put the resultant value into the checksum field in the 452 /* 3) Put the resultant value into the checksum field in the
433 * common header, and leave the rest of the bits unchanged. 453 * common header, and leave the rest of the bits unchanged.
@@ -477,20 +497,6 @@ int sctp_packet_transmit(struct sctp_packet *packet)
477 } 497 }
478 } 498 }
479 499
480 dst = tp->dst;
481 /* The 'obsolete' field of dst is set to 2 when a dst is freed. */
482 if (!dst || (dst->obsolete > 1)) {
483 dst_release(dst);
484 sctp_transport_route(tp, NULL, sctp_sk(sk));
485 if (asoc->param_flags & SPP_PMTUD_ENABLE) {
486 sctp_assoc_sync_pmtu(asoc);
487 }
488 }
489
490 nskb->dst = dst_clone(tp->dst);
491 if (!nskb->dst)
492 goto no_route;
493
494 SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n", 500 SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n",
495 nskb->len); 501 nskb->len);
496 502
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index f148f9576dd2..e5faa351aaad 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -1262,6 +1262,7 @@ static void sctp_check_transmitted(struct sctp_outq *q,
1262 if (!tchunk->tsn_gap_acked && 1262 if (!tchunk->tsn_gap_acked &&
1263 !tchunk->resent && 1263 !tchunk->resent &&
1264 tchunk->rtt_in_progress) { 1264 tchunk->rtt_in_progress) {
1265 tchunk->rtt_in_progress = 0;
1265 rtt = jiffies - tchunk->sent_at; 1266 rtt = jiffies - tchunk->sent_at;
1266 sctp_transport_update_rto(transport, 1267 sctp_transport_update_rto(transport,
1267 rtt); 1268 rtt);
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 2088aa992b7a..816c033d7886 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -365,12 +365,18 @@ static int sctp_v4_is_any(const union sctp_addr *addr)
365 * Return 0 - If the address is a non-unicast or an illegal address. 365 * Return 0 - If the address is a non-unicast or an illegal address.
366 * Return 1 - If the address is a unicast. 366 * Return 1 - If the address is a unicast.
367 */ 367 */
368static int sctp_v4_addr_valid(union sctp_addr *addr, struct sctp_sock *sp) 368static int sctp_v4_addr_valid(union sctp_addr *addr,
369 struct sctp_sock *sp,
370 const struct sk_buff *skb)
369{ 371{
370 /* Is this a non-unicast address or a unusable SCTP address? */ 372 /* Is this a non-unicast address or a unusable SCTP address? */
371 if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr)) 373 if (IS_IPV4_UNUSABLE_ADDRESS(&addr->v4.sin_addr.s_addr))
372 return 0; 374 return 0;
373 375
376 /* Is this a broadcast address? */
377 if (skb && ((struct rtable *)skb->dst)->rt_flags & RTCF_BROADCAST)
378 return 0;
379
374 return 1; 380 return 1;
375} 381}
376 382
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 8bc279219a72..9e58144f4851 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -5293,10 +5293,18 @@ static int sctp_eat_data(const struct sctp_association *asoc,
5293 * seems a bit troublesome in that frag_point varies based on 5293 * seems a bit troublesome in that frag_point varies based on
5294 * PMTU. In cases, such as loopback, this might be a rather 5294 * PMTU. In cases, such as loopback, this might be a rather
5295 * large spill over. 5295 * large spill over.
5296 * NOTE: If we have a full receive buffer here, we only renege if
5297 * our receiver can still make progress without the tsn being
5298 * received. We do this because in the event that the associations
5299 * receive queue is empty we are filling a leading gap, and since
5300 * reneging moves the gap to the end of the tsn stream, we are likely
5301 * to stall again very shortly. Avoiding the renege when we fill a
5302 * leading gap is a good heuristic for avoiding such steady state
5303 * stalls.
5296 */ 5304 */
5297 if (!asoc->rwnd || asoc->rwnd_over || 5305 if (!asoc->rwnd || asoc->rwnd_over ||
5298 (datalen > asoc->rwnd + asoc->frag_point) || 5306 (datalen > asoc->rwnd + asoc->frag_point) ||
5299 rcvbuf_over) { 5307 (rcvbuf_over && (!skb_queue_len(&sk->sk_receive_queue)))) {
5300 5308
5301 /* If this is the next TSN, consider reneging to make 5309 /* If this is the next TSN, consider reneging to make
5302 * room. Note: Playing nice with a confused sender. A 5310 * room. Note: Playing nice with a confused sender. A
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 174d4d35e951..b811691c35bf 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -172,7 +172,7 @@ static inline int sctp_verify_addr(struct sock *sk, union sctp_addr *addr,
172 return -EINVAL; 172 return -EINVAL;
173 173
174 /* Is this a valid SCTP address? */ 174 /* Is this a valid SCTP address? */
175 if (!af->addr_valid(addr, sctp_sk(sk))) 175 if (!af->addr_valid(addr, sctp_sk(sk), NULL))
176 return -EINVAL; 176 return -EINVAL;
177 177
178 if (!sctp_sk(sk)->pf->send_verify(sctp_sk(sk), (addr))) 178 if (!sctp_sk(sk)->pf->send_verify(sctp_sk(sk), (addr)))
@@ -2530,8 +2530,32 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, int o
2530 2530
2531 /* Set the values to the specific association */ 2531 /* Set the values to the specific association */
2532 if (asoc) { 2532 if (asoc) {
2533 if (assocparams.sasoc_asocmaxrxt != 0) 2533 if (assocparams.sasoc_asocmaxrxt != 0) {
2534 __u32 path_sum = 0;
2535 int paths = 0;
2536 struct list_head *pos;
2537 struct sctp_transport *peer_addr;
2538
2539 list_for_each(pos, &asoc->peer.transport_addr_list) {
2540 peer_addr = list_entry(pos,
2541 struct sctp_transport,
2542 transports);
2543 path_sum += peer_addr->pathmaxrxt;
2544 paths++;
2545 }
2546
2547 /* Only validate asocmaxrxt if we have more then
2548 * one path/transport. We do this because path
2549 * retransmissions are only counted when we have more
2550 * then one path.
2551 */
2552 if (paths > 1 &&
2553 assocparams.sasoc_asocmaxrxt > path_sum)
2554 return -EINVAL;
2555
2534 asoc->max_retrans = assocparams.sasoc_asocmaxrxt; 2556 asoc->max_retrans = assocparams.sasoc_asocmaxrxt;
2557 }
2558
2535 if (assocparams.sasoc_cookie_life != 0) { 2559 if (assocparams.sasoc_cookie_life != 0) {
2536 asoc->cookie_life.tv_sec = 2560 asoc->cookie_life.tv_sec =
2537 assocparams.sasoc_cookie_life / 1000; 2561 assocparams.sasoc_cookie_life / 1000;
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index ba97f974f57c..ee236784a6bb 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -51,6 +51,8 @@
51static void sctp_ulpevent_receive_data(struct sctp_ulpevent *event, 51static void sctp_ulpevent_receive_data(struct sctp_ulpevent *event,
52 struct sctp_association *asoc); 52 struct sctp_association *asoc);
53static void sctp_ulpevent_release_data(struct sctp_ulpevent *event); 53static void sctp_ulpevent_release_data(struct sctp_ulpevent *event);
54static void sctp_ulpevent_release_frag_data(struct sctp_ulpevent *event);
55
54 56
55/* Initialize an ULP event from an given skb. */ 57/* Initialize an ULP event from an given skb. */
56SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, int msg_flags) 58SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, int msg_flags)
@@ -883,6 +885,7 @@ static void sctp_ulpevent_receive_data(struct sctp_ulpevent *event,
883static void sctp_ulpevent_release_data(struct sctp_ulpevent *event) 885static void sctp_ulpevent_release_data(struct sctp_ulpevent *event)
884{ 886{
885 struct sk_buff *skb, *frag; 887 struct sk_buff *skb, *frag;
888 unsigned int len;
886 889
887 /* Current stack structures assume that the rcv buffer is 890 /* Current stack structures assume that the rcv buffer is
888 * per socket. For UDP style sockets this is not true as 891 * per socket. For UDP style sockets this is not true as
@@ -892,7 +895,30 @@ static void sctp_ulpevent_release_data(struct sctp_ulpevent *event)
892 */ 895 */
893 896
894 skb = sctp_event2skb(event); 897 skb = sctp_event2skb(event);
895 sctp_assoc_rwnd_increase(event->asoc, skb_headlen(skb)); 898 len = skb->len;
899
900 if (!skb->data_len)
901 goto done;
902
903 /* Don't forget the fragments. */
904 for (frag = skb_shinfo(skb)->frag_list; frag; frag = frag->next) {
905 /* NOTE: skb_shinfos are recursive. Although IP returns
906 * skb's with only 1 level of fragments, SCTP reassembly can
907 * increase the levels.
908 */
909 sctp_ulpevent_release_frag_data(sctp_skb2event(frag));
910 }
911
912done:
913 sctp_assoc_rwnd_increase(event->asoc, len);
914 sctp_ulpevent_release_owner(event);
915}
916
917static void sctp_ulpevent_release_frag_data(struct sctp_ulpevent *event)
918{
919 struct sk_buff *skb, *frag;
920
921 skb = sctp_event2skb(event);
896 922
897 if (!skb->data_len) 923 if (!skb->data_len)
898 goto done; 924 goto done;
@@ -903,7 +929,7 @@ static void sctp_ulpevent_release_data(struct sctp_ulpevent *event)
903 * skb's with only 1 level of fragments, SCTP reassembly can 929 * skb's with only 1 level of fragments, SCTP reassembly can
904 * increase the levels. 930 * increase the levels.
905 */ 931 */
906 sctp_ulpevent_release_data(sctp_skb2event(frag)); 932 sctp_ulpevent_release_frag_data(sctp_skb2event(frag));
907 } 933 }
908 934
909done: 935done:
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index b469c8b54613..b8936926c24b 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -46,45 +46,43 @@ static DEFINE_SPINLOCK(xfrm_policy_gc_lock);
46 46
47static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family); 47static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family);
48static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo); 48static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo);
49static struct xfrm_policy_afinfo *xfrm_policy_lock_afinfo(unsigned int family);
50static void xfrm_policy_unlock_afinfo(struct xfrm_policy_afinfo *afinfo);
49 51
50int xfrm_register_type(struct xfrm_type *type, unsigned short family) 52int xfrm_register_type(struct xfrm_type *type, unsigned short family)
51{ 53{
52 struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family); 54 struct xfrm_policy_afinfo *afinfo = xfrm_policy_lock_afinfo(family);
53 struct xfrm_type_map *typemap; 55 struct xfrm_type **typemap;
54 int err = 0; 56 int err = 0;
55 57
56 if (unlikely(afinfo == NULL)) 58 if (unlikely(afinfo == NULL))
57 return -EAFNOSUPPORT; 59 return -EAFNOSUPPORT;
58 typemap = afinfo->type_map; 60 typemap = afinfo->type_map;
59 61
60 write_lock_bh(&typemap->lock); 62 if (likely(typemap[type->proto] == NULL))
61 if (likely(typemap->map[type->proto] == NULL)) 63 typemap[type->proto] = type;
62 typemap->map[type->proto] = type;
63 else 64 else
64 err = -EEXIST; 65 err = -EEXIST;
65 write_unlock_bh(&typemap->lock); 66 xfrm_policy_unlock_afinfo(afinfo);
66 xfrm_policy_put_afinfo(afinfo);
67 return err; 67 return err;
68} 68}
69EXPORT_SYMBOL(xfrm_register_type); 69EXPORT_SYMBOL(xfrm_register_type);
70 70
71int xfrm_unregister_type(struct xfrm_type *type, unsigned short family) 71int xfrm_unregister_type(struct xfrm_type *type, unsigned short family)
72{ 72{
73 struct xfrm_policy_afinfo *afinfo = xfrm_policy_get_afinfo(family); 73 struct xfrm_policy_afinfo *afinfo = xfrm_policy_lock_afinfo(family);
74 struct xfrm_type_map *typemap; 74 struct xfrm_type **typemap;
75 int err = 0; 75 int err = 0;
76 76
77 if (unlikely(afinfo == NULL)) 77 if (unlikely(afinfo == NULL))
78 return -EAFNOSUPPORT; 78 return -EAFNOSUPPORT;
79 typemap = afinfo->type_map; 79 typemap = afinfo->type_map;
80 80
81 write_lock_bh(&typemap->lock); 81 if (unlikely(typemap[type->proto] != type))
82 if (unlikely(typemap->map[type->proto] != type))
83 err = -ENOENT; 82 err = -ENOENT;
84 else 83 else
85 typemap->map[type->proto] = NULL; 84 typemap[type->proto] = NULL;
86 write_unlock_bh(&typemap->lock); 85 xfrm_policy_unlock_afinfo(afinfo);
87 xfrm_policy_put_afinfo(afinfo);
88 return err; 86 return err;
89} 87}
90EXPORT_SYMBOL(xfrm_unregister_type); 88EXPORT_SYMBOL(xfrm_unregister_type);
@@ -92,7 +90,7 @@ EXPORT_SYMBOL(xfrm_unregister_type);
92struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family) 90struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
93{ 91{
94 struct xfrm_policy_afinfo *afinfo; 92 struct xfrm_policy_afinfo *afinfo;
95 struct xfrm_type_map *typemap; 93 struct xfrm_type **typemap;
96 struct xfrm_type *type; 94 struct xfrm_type *type;
97 int modload_attempted = 0; 95 int modload_attempted = 0;
98 96
@@ -102,11 +100,9 @@ retry:
102 return NULL; 100 return NULL;
103 typemap = afinfo->type_map; 101 typemap = afinfo->type_map;
104 102
105 read_lock(&typemap->lock); 103 type = typemap[proto];
106 type = typemap->map[proto];
107 if (unlikely(type && !try_module_get(type->owner))) 104 if (unlikely(type && !try_module_get(type->owner)))
108 type = NULL; 105 type = NULL;
109 read_unlock(&typemap->lock);
110 if (!type && !modload_attempted) { 106 if (!type && !modload_attempted) {
111 xfrm_policy_put_afinfo(afinfo); 107 xfrm_policy_put_afinfo(afinfo);
112 request_module("xfrm-type-%d-%d", 108 request_module("xfrm-type-%d-%d",
@@ -142,6 +138,89 @@ void xfrm_put_type(struct xfrm_type *type)
142 module_put(type->owner); 138 module_put(type->owner);
143} 139}
144 140
141int xfrm_register_mode(struct xfrm_mode *mode, int family)
142{
143 struct xfrm_policy_afinfo *afinfo;
144 struct xfrm_mode **modemap;
145 int err;
146
147 if (unlikely(mode->encap >= XFRM_MODE_MAX))
148 return -EINVAL;
149
150 afinfo = xfrm_policy_lock_afinfo(family);
151 if (unlikely(afinfo == NULL))
152 return -EAFNOSUPPORT;
153
154 err = -EEXIST;
155 modemap = afinfo->mode_map;
156 if (likely(modemap[mode->encap] == NULL)) {
157 modemap[mode->encap] = mode;
158 err = 0;
159 }
160
161 xfrm_policy_unlock_afinfo(afinfo);
162 return err;
163}
164EXPORT_SYMBOL(xfrm_register_mode);
165
166int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
167{
168 struct xfrm_policy_afinfo *afinfo;
169 struct xfrm_mode **modemap;
170 int err;
171
172 if (unlikely(mode->encap >= XFRM_MODE_MAX))
173 return -EINVAL;
174
175 afinfo = xfrm_policy_lock_afinfo(family);
176 if (unlikely(afinfo == NULL))
177 return -EAFNOSUPPORT;
178
179 err = -ENOENT;
180 modemap = afinfo->mode_map;
181 if (likely(modemap[mode->encap] == mode)) {
182 modemap[mode->encap] = NULL;
183 err = 0;
184 }
185
186 xfrm_policy_unlock_afinfo(afinfo);
187 return err;
188}
189EXPORT_SYMBOL(xfrm_unregister_mode);
190
191struct xfrm_mode *xfrm_get_mode(unsigned int encap, int family)
192{
193 struct xfrm_policy_afinfo *afinfo;
194 struct xfrm_mode *mode;
195 int modload_attempted = 0;
196
197 if (unlikely(encap >= XFRM_MODE_MAX))
198 return NULL;
199
200retry:
201 afinfo = xfrm_policy_get_afinfo(family);
202 if (unlikely(afinfo == NULL))
203 return NULL;
204
205 mode = afinfo->mode_map[encap];
206 if (unlikely(mode && !try_module_get(mode->owner)))
207 mode = NULL;
208 if (!mode && !modload_attempted) {
209 xfrm_policy_put_afinfo(afinfo);
210 request_module("xfrm-mode-%d-%d", family, encap);
211 modload_attempted = 1;
212 goto retry;
213 }
214
215 xfrm_policy_put_afinfo(afinfo);
216 return mode;
217}
218
219void xfrm_put_mode(struct xfrm_mode *mode)
220{
221 module_put(mode->owner);
222}
223
145static inline unsigned long make_jiffies(long secs) 224static inline unsigned long make_jiffies(long secs)
146{ 225{
147 if (secs >= (MAX_SCHEDULE_TIMEOUT-1)/HZ) 226 if (secs >= (MAX_SCHEDULE_TIMEOUT-1)/HZ)
@@ -1306,17 +1385,31 @@ static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family)
1306 return NULL; 1385 return NULL;
1307 read_lock(&xfrm_policy_afinfo_lock); 1386 read_lock(&xfrm_policy_afinfo_lock);
1308 afinfo = xfrm_policy_afinfo[family]; 1387 afinfo = xfrm_policy_afinfo[family];
1309 if (likely(afinfo != NULL)) 1388 if (unlikely(!afinfo))
1310 read_lock(&afinfo->lock); 1389 read_unlock(&xfrm_policy_afinfo_lock);
1311 read_unlock(&xfrm_policy_afinfo_lock);
1312 return afinfo; 1390 return afinfo;
1313} 1391}
1314 1392
1315static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo) 1393static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo)
1316{ 1394{
1317 if (unlikely(afinfo == NULL)) 1395 read_unlock(&xfrm_policy_afinfo_lock);
1318 return; 1396}
1319 read_unlock(&afinfo->lock); 1397
1398static struct xfrm_policy_afinfo *xfrm_policy_lock_afinfo(unsigned int family)
1399{
1400 struct xfrm_policy_afinfo *afinfo;
1401 if (unlikely(family >= NPROTO))
1402 return NULL;
1403 write_lock_bh(&xfrm_policy_afinfo_lock);
1404 afinfo = xfrm_policy_afinfo[family];
1405 if (unlikely(!afinfo))
1406 write_unlock_bh(&xfrm_policy_afinfo_lock);
1407 return afinfo;
1408}
1409
1410static void xfrm_policy_unlock_afinfo(struct xfrm_policy_afinfo *afinfo)
1411{
1412 write_unlock_bh(&xfrm_policy_afinfo_lock);
1320} 1413}
1321 1414
1322static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr) 1415static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 93a2f36ad3db..17b29ec3c417 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -77,6 +77,8 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x)
77 kfree(x->ealg); 77 kfree(x->ealg);
78 kfree(x->calg); 78 kfree(x->calg);
79 kfree(x->encap); 79 kfree(x->encap);
80 if (x->mode)
81 xfrm_put_mode(x->mode);
80 if (x->type) { 82 if (x->type) {
81 x->type->destructor(x); 83 x->type->destructor(x);
82 xfrm_put_type(x->type); 84 xfrm_put_type(x->type);
@@ -1103,17 +1105,14 @@ static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family)
1103 return NULL; 1105 return NULL;
1104 read_lock(&xfrm_state_afinfo_lock); 1106 read_lock(&xfrm_state_afinfo_lock);
1105 afinfo = xfrm_state_afinfo[family]; 1107 afinfo = xfrm_state_afinfo[family];
1106 if (likely(afinfo != NULL)) 1108 if (unlikely(!afinfo))
1107 read_lock(&afinfo->lock); 1109 read_unlock(&xfrm_state_afinfo_lock);
1108 read_unlock(&xfrm_state_afinfo_lock);
1109 return afinfo; 1110 return afinfo;
1110} 1111}
1111 1112
1112static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo) 1113static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo)
1113{ 1114{
1114 if (unlikely(afinfo == NULL)) 1115 read_unlock(&xfrm_state_afinfo_lock);
1115 return;
1116 read_unlock(&afinfo->lock);
1117} 1116}
1118 1117
1119/* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */ 1118/* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */
@@ -1196,6 +1195,10 @@ int xfrm_init_state(struct xfrm_state *x)
1196 if (err) 1195 if (err)
1197 goto error; 1196 goto error;
1198 1197
1198 x->mode = xfrm_get_mode(x->props.mode, family);
1199 if (x->mode == NULL)
1200 goto error;
1201
1199 x->km.state = XFRM_STATE_VALID; 1202 x->km.state = XFRM_STATE_VALID;
1200 1203
1201error: 1204error:
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 81d1005830f4..c21dc26141ea 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -427,23 +427,25 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
427 if (x == NULL) 427 if (x == NULL)
428 return -ESRCH; 428 return -ESRCH;
429 429
430 if ((err = security_xfrm_state_delete(x)) != 0)
431 goto out;
432
430 if (xfrm_state_kern(x)) { 433 if (xfrm_state_kern(x)) {
431 xfrm_state_put(x); 434 err = -EPERM;
432 return -EPERM; 435 goto out;
433 } 436 }
434 437
435 err = xfrm_state_delete(x); 438 err = xfrm_state_delete(x);
436 if (err < 0) { 439 if (err < 0)
437 xfrm_state_put(x); 440 goto out;
438 return err;
439 }
440 441
441 c.seq = nlh->nlmsg_seq; 442 c.seq = nlh->nlmsg_seq;
442 c.pid = nlh->nlmsg_pid; 443 c.pid = nlh->nlmsg_pid;
443 c.event = nlh->nlmsg_type; 444 c.event = nlh->nlmsg_type;
444 km_state_notify(x, &c); 445 km_state_notify(x, &c);
445 xfrm_state_put(x);
446 446
447out:
448 xfrm_state_put(x);
447 return err; 449 return err;
448} 450}
449 451
@@ -1055,6 +1057,8 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
1055 MSG_DONTWAIT); 1057 MSG_DONTWAIT);
1056 } 1058 }
1057 } else { 1059 } else {
1060 if ((err = security_xfrm_policy_delete(xp)) != 0)
1061 goto out;
1058 c.data.byid = p->index; 1062 c.data.byid = p->index;
1059 c.event = nlh->nlmsg_type; 1063 c.event = nlh->nlmsg_type;
1060 c.seq = nlh->nlmsg_seq; 1064 c.seq = nlh->nlmsg_seq;
@@ -1064,6 +1068,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
1064 1068
1065 xfrm_pol_put(xp); 1069 xfrm_pol_put(xp);
1066 1070
1071out:
1067 return err; 1072 return err;
1068} 1073}
1069 1074
diff --git a/security/dummy.c b/security/dummy.c
index 8ccccccc12ac..64f6da0f422e 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -810,6 +810,11 @@ static void dummy_xfrm_policy_free_security(struct xfrm_policy *xp)
810{ 810{
811} 811}
812 812
813static int dummy_xfrm_policy_delete_security(struct xfrm_policy *xp)
814{
815 return 0;
816}
817
813static int dummy_xfrm_state_alloc_security(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) 818static int dummy_xfrm_state_alloc_security(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
814{ 819{
815 return 0; 820 return 0;
@@ -819,6 +824,11 @@ static void dummy_xfrm_state_free_security(struct xfrm_state *x)
819{ 824{
820} 825}
821 826
827static int dummy_xfrm_state_delete_security(struct xfrm_state *x)
828{
829 return 0;
830}
831
822static int dummy_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) 832static int dummy_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
823{ 833{
824 return 0; 834 return 0;
@@ -1024,8 +1034,10 @@ void security_fixup_ops (struct security_operations *ops)
1024 set_to_dummy_if_null(ops, xfrm_policy_alloc_security); 1034 set_to_dummy_if_null(ops, xfrm_policy_alloc_security);
1025 set_to_dummy_if_null(ops, xfrm_policy_clone_security); 1035 set_to_dummy_if_null(ops, xfrm_policy_clone_security);
1026 set_to_dummy_if_null(ops, xfrm_policy_free_security); 1036 set_to_dummy_if_null(ops, xfrm_policy_free_security);
1037 set_to_dummy_if_null(ops, xfrm_policy_delete_security);
1027 set_to_dummy_if_null(ops, xfrm_state_alloc_security); 1038 set_to_dummy_if_null(ops, xfrm_state_alloc_security);
1028 set_to_dummy_if_null(ops, xfrm_state_free_security); 1039 set_to_dummy_if_null(ops, xfrm_state_free_security);
1040 set_to_dummy_if_null(ops, xfrm_state_delete_security);
1029 set_to_dummy_if_null(ops, xfrm_policy_lookup); 1041 set_to_dummy_if_null(ops, xfrm_policy_lookup);
1030#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1042#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1031#ifdef CONFIG_KEYS 1043#ifdef CONFIG_KEYS
diff --git a/security/selinux/Kconfig b/security/selinux/Kconfig
index f636f53ca544..814ddc42f1f4 100644
--- a/security/selinux/Kconfig
+++ b/security/selinux/Kconfig
@@ -1,6 +1,7 @@
1config SECURITY_SELINUX 1config SECURITY_SELINUX
2 bool "NSA SELinux Support" 2 bool "NSA SELinux Support"
3 depends on SECURITY_NETWORK && AUDIT && NET && INET 3 depends on SECURITY_NETWORK && AUDIT && NET && INET
4 select NETWORK_SECMARK
4 default n 5 default n
5 help 6 help
6 This selects NSA Security-Enhanced Linux (SELinux). 7 This selects NSA Security-Enhanced Linux (SELinux).
@@ -95,3 +96,31 @@ config SECURITY_SELINUX_CHECKREQPROT_VALUE
95 via /selinux/checkreqprot if authorized by policy. 96 via /selinux/checkreqprot if authorized by policy.
96 97
97 If you are unsure how to answer this question, answer 1. 98 If you are unsure how to answer this question, answer 1.
99
100config SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT
101 bool "NSA SELinux enable new secmark network controls by default"
102 depends on SECURITY_SELINUX
103 default n
104 help
105 This option determines whether the new secmark-based network
106 controls will be enabled by default. If not, the old internal
107 per-packet controls will be enabled by default, preserving
108 old behavior.
109
110 If you enable the new controls, you will need updated
111 SELinux userspace libraries, tools and policy. Typically,
112 your distribution will provide these and enable the new controls
113 in the kernel they also distribute.
114
115 Note that this option can be overriden at boot with the
116 selinux_compat_net parameter, and after boot via
117 /selinux/compat_net. See Documentation/kernel-parameters.txt
118 for details on this parameter.
119
120 If you enable the new network controls, you will likely
121 also require the SECMARK and CONNSECMARK targets, as
122 well as any conntrack helpers for protocols which you
123 wish to control.
124
125 If you are unsure what do do here, select N.
126
diff --git a/security/selinux/exports.c b/security/selinux/exports.c
index ae4c73eb3085..9d7737db5e51 100644
--- a/security/selinux/exports.c
+++ b/security/selinux/exports.c
@@ -72,3 +72,25 @@ void selinux_get_task_sid(struct task_struct *tsk, u32 *sid)
72 *sid = 0; 72 *sid = 0;
73} 73}
74 74
75int selinux_string_to_sid(char *str, u32 *sid)
76{
77 if (selinux_enabled)
78 return security_context_to_sid(str, strlen(str), sid);
79 else {
80 *sid = 0;
81 return 0;
82 }
83}
84EXPORT_SYMBOL_GPL(selinux_string_to_sid);
85
86int selinux_relabel_packet_permission(u32 sid)
87{
88 if (selinux_enabled) {
89 struct task_security_struct *tsec = current->security;
90
91 return avc_has_perm(tsec->sid, sid, SECCLASS_PACKET,
92 PACKET__RELABELTO, NULL);
93 }
94 return 0;
95}
96EXPORT_SYMBOL_GPL(selinux_relabel_packet_permission);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 90b4cdc0c948..54adc9d31e92 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -80,6 +80,7 @@
80 80
81extern unsigned int policydb_loaded_version; 81extern unsigned int policydb_loaded_version;
82extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm); 82extern int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm);
83extern int selinux_compat_net;
83 84
84#ifdef CONFIG_SECURITY_SELINUX_DEVELOP 85#ifdef CONFIG_SECURITY_SELINUX_DEVELOP
85int selinux_enforcing = 0; 86int selinux_enforcing = 0;
@@ -696,6 +697,8 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
696 return SECCLASS_PACKET_SOCKET; 697 return SECCLASS_PACKET_SOCKET;
697 case PF_KEY: 698 case PF_KEY:
698 return SECCLASS_KEY_SOCKET; 699 return SECCLASS_KEY_SOCKET;
700 case PF_APPLETALK:
701 return SECCLASS_APPLETALK_SOCKET;
699 } 702 }
700 703
701 return SECCLASS_SOCKET; 704 return SECCLASS_SOCKET;
@@ -3214,47 +3217,17 @@ static int selinux_socket_unix_may_send(struct socket *sock,
3214 return 0; 3217 return 0;
3215} 3218}
3216 3219
3217static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) 3220static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
3221 struct avc_audit_data *ad, u32 sock_sid, u16 sock_class,
3222 u16 family, char *addrp, int len)
3218{ 3223{
3219 u16 family; 3224 int err = 0;
3220 char *addrp;
3221 int len, err = 0;
3222 u32 netif_perm, node_perm, node_sid, if_sid, recv_perm = 0; 3225 u32 netif_perm, node_perm, node_sid, if_sid, recv_perm = 0;
3223 u32 sock_sid = 0;
3224 u16 sock_class = 0;
3225 struct socket *sock;
3226 struct net_device *dev;
3227 struct avc_audit_data ad;
3228
3229 family = sk->sk_family;
3230 if (family != PF_INET && family != PF_INET6)
3231 goto out;
3232
3233 /* Handle mapped IPv4 packets arriving via IPv6 sockets */
3234 if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP))
3235 family = PF_INET;
3236
3237 read_lock_bh(&sk->sk_callback_lock);
3238 sock = sk->sk_socket;
3239 if (sock) {
3240 struct inode *inode;
3241 inode = SOCK_INODE(sock);
3242 if (inode) {
3243 struct inode_security_struct *isec;
3244 isec = inode->i_security;
3245 sock_sid = isec->sid;
3246 sock_class = isec->sclass;
3247 }
3248 }
3249 read_unlock_bh(&sk->sk_callback_lock);
3250 if (!sock_sid)
3251 goto out;
3252 3226
3253 dev = skb->dev; 3227 if (!skb->dev)
3254 if (!dev)
3255 goto out; 3228 goto out;
3256 3229
3257 err = sel_netif_sids(dev, &if_sid, NULL); 3230 err = sel_netif_sids(skb->dev, &if_sid, NULL);
3258 if (err) 3231 if (err)
3259 goto out; 3232 goto out;
3260 3233
@@ -3277,44 +3250,88 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3277 break; 3250 break;
3278 } 3251 }
3279 3252
3280 AVC_AUDIT_DATA_INIT(&ad, NET); 3253 err = avc_has_perm(sock_sid, if_sid, SECCLASS_NETIF, netif_perm, ad);
3281 ad.u.net.netif = dev->name;
3282 ad.u.net.family = family;
3283
3284 err = selinux_parse_skb(skb, &ad, &addrp, &len, 1);
3285 if (err)
3286 goto out;
3287
3288 err = avc_has_perm(sock_sid, if_sid, SECCLASS_NETIF, netif_perm, &ad);
3289 if (err) 3254 if (err)
3290 goto out; 3255 goto out;
3291 3256
3292 /* Fixme: this lookup is inefficient */
3293 err = security_node_sid(family, addrp, len, &node_sid); 3257 err = security_node_sid(family, addrp, len, &node_sid);
3294 if (err) 3258 if (err)
3295 goto out; 3259 goto out;
3296 3260
3297 err = avc_has_perm(sock_sid, node_sid, SECCLASS_NODE, node_perm, &ad); 3261 err = avc_has_perm(sock_sid, node_sid, SECCLASS_NODE, node_perm, ad);
3298 if (err) 3262 if (err)
3299 goto out; 3263 goto out;
3300 3264
3301 if (recv_perm) { 3265 if (recv_perm) {
3302 u32 port_sid; 3266 u32 port_sid;
3303 3267
3304 /* Fixme: make this more efficient */
3305 err = security_port_sid(sk->sk_family, sk->sk_type, 3268 err = security_port_sid(sk->sk_family, sk->sk_type,
3306 sk->sk_protocol, ntohs(ad.u.net.sport), 3269 sk->sk_protocol, ntohs(ad->u.net.sport),
3307 &port_sid); 3270 &port_sid);
3308 if (err) 3271 if (err)
3309 goto out; 3272 goto out;
3310 3273
3311 err = avc_has_perm(sock_sid, port_sid, 3274 err = avc_has_perm(sock_sid, port_sid,
3312 sock_class, recv_perm, &ad); 3275 sock_class, recv_perm, ad);
3313 } 3276 }
3314 3277
3315 if (!err) 3278out:
3316 err = selinux_xfrm_sock_rcv_skb(sock_sid, skb); 3279 return err;
3280}
3281
3282static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3283{
3284 u16 family;
3285 u16 sock_class = 0;
3286 char *addrp;
3287 int len, err = 0;
3288 u32 sock_sid = 0;
3289 struct socket *sock;
3290 struct avc_audit_data ad;
3291
3292 family = sk->sk_family;
3293 if (family != PF_INET && family != PF_INET6)
3294 goto out;
3295
3296 /* Handle mapped IPv4 packets arriving via IPv6 sockets */
3297 if (family == PF_INET6 && skb->protocol == ntohs(ETH_P_IP))
3298 family = PF_INET;
3299
3300 read_lock_bh(&sk->sk_callback_lock);
3301 sock = sk->sk_socket;
3302 if (sock) {
3303 struct inode *inode;
3304 inode = SOCK_INODE(sock);
3305 if (inode) {
3306 struct inode_security_struct *isec;
3307 isec = inode->i_security;
3308 sock_sid = isec->sid;
3309 sock_class = isec->sclass;
3310 }
3311 }
3312 read_unlock_bh(&sk->sk_callback_lock);
3313 if (!sock_sid)
3314 goto out;
3315
3316 AVC_AUDIT_DATA_INIT(&ad, NET);
3317 ad.u.net.netif = skb->dev ? skb->dev->name : "[unknown]";
3318 ad.u.net.family = family;
3319
3320 err = selinux_parse_skb(skb, &ad, &addrp, &len, 1);
3321 if (err)
3322 goto out;
3323
3324 if (selinux_compat_net)
3325 err = selinux_sock_rcv_skb_compat(sk, skb, &ad, sock_sid,
3326 sock_class, family,
3327 addrp, len);
3328 else
3329 err = avc_has_perm(sock_sid, skb->secmark, SECCLASS_PACKET,
3330 PACKET__RECV, &ad);
3331 if (err)
3332 goto out;
3317 3333
3334 err = selinux_xfrm_sock_rcv_skb(sock_sid, skb);
3318out: 3335out:
3319 return err; 3336 return err;
3320} 3337}
@@ -3454,42 +3471,18 @@ out:
3454 3471
3455#ifdef CONFIG_NETFILTER 3472#ifdef CONFIG_NETFILTER
3456 3473
3457static unsigned int selinux_ip_postroute_last(unsigned int hooknum, 3474static int selinux_ip_postroute_last_compat(struct sock *sk, struct net_device *dev,
3458 struct sk_buff **pskb, 3475 struct inode_security_struct *isec,
3459 const struct net_device *in, 3476 struct avc_audit_data *ad,
3460 const struct net_device *out, 3477 u16 family, char *addrp, int len)
3461 int (*okfn)(struct sk_buff *),
3462 u16 family)
3463{ 3478{
3464 char *addrp; 3479 int err;
3465 int len, err = NF_ACCEPT;
3466 u32 netif_perm, node_perm, node_sid, if_sid, send_perm = 0; 3480 u32 netif_perm, node_perm, node_sid, if_sid, send_perm = 0;
3467 struct sock *sk;
3468 struct socket *sock;
3469 struct inode *inode;
3470 struct sk_buff *skb = *pskb;
3471 struct inode_security_struct *isec;
3472 struct avc_audit_data ad;
3473 struct net_device *dev = (struct net_device *)out;
3474 3481
3475 sk = skb->sk;
3476 if (!sk)
3477 goto out;
3478
3479 sock = sk->sk_socket;
3480 if (!sock)
3481 goto out;
3482
3483 inode = SOCK_INODE(sock);
3484 if (!inode)
3485 goto out;
3486
3487 err = sel_netif_sids(dev, &if_sid, NULL); 3482 err = sel_netif_sids(dev, &if_sid, NULL);
3488 if (err) 3483 if (err)
3489 goto out; 3484 goto out;
3490 3485
3491 isec = inode->i_security;
3492
3493 switch (isec->sclass) { 3486 switch (isec->sclass) {
3494 case SECCLASS_UDP_SOCKET: 3487 case SECCLASS_UDP_SOCKET:
3495 netif_perm = NETIF__UDP_SEND; 3488 netif_perm = NETIF__UDP_SEND;
@@ -3509,55 +3502,88 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
3509 break; 3502 break;
3510 } 3503 }
3511 3504
3512 3505 err = avc_has_perm(isec->sid, if_sid, SECCLASS_NETIF, netif_perm, ad);
3513 AVC_AUDIT_DATA_INIT(&ad, NET); 3506 if (err)
3514 ad.u.net.netif = dev->name;
3515 ad.u.net.family = family;
3516
3517 err = selinux_parse_skb(skb, &ad, &addrp,
3518 &len, 0) ? NF_DROP : NF_ACCEPT;
3519 if (err != NF_ACCEPT)
3520 goto out;
3521
3522 err = avc_has_perm(isec->sid, if_sid, SECCLASS_NETIF,
3523 netif_perm, &ad) ? NF_DROP : NF_ACCEPT;
3524 if (err != NF_ACCEPT)
3525 goto out; 3507 goto out;
3526 3508
3527 /* Fixme: this lookup is inefficient */ 3509 err = security_node_sid(family, addrp, len, &node_sid);
3528 err = security_node_sid(family, addrp, len, 3510 if (err)
3529 &node_sid) ? NF_DROP : NF_ACCEPT;
3530 if (err != NF_ACCEPT)
3531 goto out; 3511 goto out;
3532 3512
3533 err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE, 3513 err = avc_has_perm(isec->sid, node_sid, SECCLASS_NODE, node_perm, ad);
3534 node_perm, &ad) ? NF_DROP : NF_ACCEPT; 3514 if (err)
3535 if (err != NF_ACCEPT)
3536 goto out; 3515 goto out;
3537 3516
3538 if (send_perm) { 3517 if (send_perm) {
3539 u32 port_sid; 3518 u32 port_sid;
3540 3519
3541 /* Fixme: make this more efficient */
3542 err = security_port_sid(sk->sk_family, 3520 err = security_port_sid(sk->sk_family,
3543 sk->sk_type, 3521 sk->sk_type,
3544 sk->sk_protocol, 3522 sk->sk_protocol,
3545 ntohs(ad.u.net.dport), 3523 ntohs(ad->u.net.dport),
3546 &port_sid) ? NF_DROP : NF_ACCEPT; 3524 &port_sid);
3547 if (err != NF_ACCEPT) 3525 if (err)
3548 goto out; 3526 goto out;
3549 3527
3550 err = avc_has_perm(isec->sid, port_sid, isec->sclass, 3528 err = avc_has_perm(isec->sid, port_sid, isec->sclass,
3551 send_perm, &ad) ? NF_DROP : NF_ACCEPT; 3529 send_perm, ad);
3552 } 3530 }
3531out:
3532 return err;
3533}
3534
3535static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
3536 struct sk_buff **pskb,
3537 const struct net_device *in,
3538 const struct net_device *out,
3539 int (*okfn)(struct sk_buff *),
3540 u16 family)
3541{
3542 char *addrp;
3543 int len, err = 0;
3544 struct sock *sk;
3545 struct socket *sock;
3546 struct inode *inode;
3547 struct sk_buff *skb = *pskb;
3548 struct inode_security_struct *isec;
3549 struct avc_audit_data ad;
3550 struct net_device *dev = (struct net_device *)out;
3553 3551
3554 if (err != NF_ACCEPT) 3552 sk = skb->sk;
3553 if (!sk)
3555 goto out; 3554 goto out;
3556 3555
3557 err = selinux_xfrm_postroute_last(isec->sid, skb); 3556 sock = sk->sk_socket;
3557 if (!sock)
3558 goto out;
3559
3560 inode = SOCK_INODE(sock);
3561 if (!inode)
3562 goto out;
3563
3564 isec = inode->i_security;
3565
3566 AVC_AUDIT_DATA_INIT(&ad, NET);
3567 ad.u.net.netif = dev->name;
3568 ad.u.net.family = family;
3569
3570 err = selinux_parse_skb(skb, &ad, &addrp, &len, 0);
3571 if (err)
3572 goto out;
3573
3574 if (selinux_compat_net)
3575 err = selinux_ip_postroute_last_compat(sk, dev, isec, &ad,
3576 family, addrp, len);
3577 else
3578 err = avc_has_perm(isec->sid, skb->secmark, SECCLASS_PACKET,
3579 PACKET__SEND, &ad);
3558 3580
3581 if (err)
3582 goto out;
3583
3584 err = selinux_xfrm_postroute_last(isec->sid, skb);
3559out: 3585out:
3560 return err; 3586 return err ? NF_DROP : NF_ACCEPT;
3561} 3587}
3562 3588
3563static unsigned int selinux_ipv4_postroute_last(unsigned int hooknum, 3589static unsigned int selinux_ipv4_postroute_last(unsigned int hooknum,
@@ -4374,8 +4400,10 @@ static struct security_operations selinux_ops = {
4374 .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc, 4400 .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc,
4375 .xfrm_policy_clone_security = selinux_xfrm_policy_clone, 4401 .xfrm_policy_clone_security = selinux_xfrm_policy_clone,
4376 .xfrm_policy_free_security = selinux_xfrm_policy_free, 4402 .xfrm_policy_free_security = selinux_xfrm_policy_free,
4403 .xfrm_policy_delete_security = selinux_xfrm_policy_delete,
4377 .xfrm_state_alloc_security = selinux_xfrm_state_alloc, 4404 .xfrm_state_alloc_security = selinux_xfrm_state_alloc,
4378 .xfrm_state_free_security = selinux_xfrm_state_free, 4405 .xfrm_state_free_security = selinux_xfrm_state_free,
4406 .xfrm_state_delete_security = selinux_xfrm_state_delete,
4379 .xfrm_policy_lookup = selinux_xfrm_policy_lookup, 4407 .xfrm_policy_lookup = selinux_xfrm_policy_lookup,
4380#endif 4408#endif
4381}; 4409};
diff --git a/security/selinux/include/av_inherit.h b/security/selinux/include/av_inherit.h
index b0e6b12931c9..a68fdd55597f 100644
--- a/security/selinux/include/av_inherit.h
+++ b/security/selinux/include/av_inherit.h
@@ -29,3 +29,4 @@
29 S_(SECCLASS_NETLINK_IP6FW_SOCKET, socket, 0x00400000UL) 29 S_(SECCLASS_NETLINK_IP6FW_SOCKET, socket, 0x00400000UL)
30 S_(SECCLASS_NETLINK_DNRT_SOCKET, socket, 0x00400000UL) 30 S_(SECCLASS_NETLINK_DNRT_SOCKET, socket, 0x00400000UL)
31 S_(SECCLASS_NETLINK_KOBJECT_UEVENT_SOCKET, socket, 0x00400000UL) 31 S_(SECCLASS_NETLINK_KOBJECT_UEVENT_SOCKET, socket, 0x00400000UL)
32 S_(SECCLASS_APPLETALK_SOCKET, socket, 0x00400000UL)
diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h
index 591e98d9315a..70ee65a58817 100644
--- a/security/selinux/include/av_perm_to_string.h
+++ b/security/selinux/include/av_perm_to_string.h
@@ -239,3 +239,6 @@
239 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, "sendto") 239 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, "sendto")
240 S_(SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, "recvfrom") 240 S_(SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, "recvfrom")
241 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, "setcontext") 241 S_(SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, "setcontext")
242 S_(SECCLASS_PACKET, PACKET__SEND, "send")
243 S_(SECCLASS_PACKET, PACKET__RECV, "recv")
244 S_(SECCLASS_PACKET, PACKET__RELABELTO, "relabelto")
diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h
index d7f02edf3930..1d9cf3d306bc 100644
--- a/security/selinux/include/av_permissions.h
+++ b/security/selinux/include/av_permissions.h
@@ -933,3 +933,29 @@
933#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG 0x00100000UL 933#define NETLINK_KOBJECT_UEVENT_SOCKET__SEND_MSG 0x00100000UL
934#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND 0x00200000UL 934#define NETLINK_KOBJECT_UEVENT_SOCKET__NAME_BIND 0x00200000UL
935 935
936#define APPLETALK_SOCKET__IOCTL 0x00000001UL
937#define APPLETALK_SOCKET__READ 0x00000002UL
938#define APPLETALK_SOCKET__WRITE 0x00000004UL
939#define APPLETALK_SOCKET__CREATE 0x00000008UL
940#define APPLETALK_SOCKET__GETATTR 0x00000010UL
941#define APPLETALK_SOCKET__SETATTR 0x00000020UL
942#define APPLETALK_SOCKET__LOCK 0x00000040UL
943#define APPLETALK_SOCKET__RELABELFROM 0x00000080UL
944#define APPLETALK_SOCKET__RELABELTO 0x00000100UL
945#define APPLETALK_SOCKET__APPEND 0x00000200UL
946#define APPLETALK_SOCKET__BIND 0x00000400UL
947#define APPLETALK_SOCKET__CONNECT 0x00000800UL
948#define APPLETALK_SOCKET__LISTEN 0x00001000UL
949#define APPLETALK_SOCKET__ACCEPT 0x00002000UL
950#define APPLETALK_SOCKET__GETOPT 0x00004000UL
951#define APPLETALK_SOCKET__SETOPT 0x00008000UL
952#define APPLETALK_SOCKET__SHUTDOWN 0x00010000UL
953#define APPLETALK_SOCKET__RECVFROM 0x00020000UL
954#define APPLETALK_SOCKET__SENDTO 0x00040000UL
955#define APPLETALK_SOCKET__RECV_MSG 0x00080000UL
956#define APPLETALK_SOCKET__SEND_MSG 0x00100000UL
957#define APPLETALK_SOCKET__NAME_BIND 0x00200000UL
958
959#define PACKET__SEND 0x00000001UL
960#define PACKET__RECV 0x00000002UL
961#define PACKET__RELABELTO 0x00000004UL
diff --git a/security/selinux/include/class_to_string.h b/security/selinux/include/class_to_string.h
index 77b2c5996f35..3aec75fee4f7 100644
--- a/security/selinux/include/class_to_string.h
+++ b/security/selinux/include/class_to_string.h
@@ -58,3 +58,5 @@
58 S_("nscd") 58 S_("nscd")
59 S_("association") 59 S_("association")
60 S_("netlink_kobject_uevent_socket") 60 S_("netlink_kobject_uevent_socket")
61 S_("appletalk_socket")
62 S_("packet")
diff --git a/security/selinux/include/flask.h b/security/selinux/include/flask.h
index eb9f50823f6e..a0eb9e281d18 100644
--- a/security/selinux/include/flask.h
+++ b/security/selinux/include/flask.h
@@ -60,6 +60,8 @@
60#define SECCLASS_NSCD 53 60#define SECCLASS_NSCD 53
61#define SECCLASS_ASSOCIATION 54 61#define SECCLASS_ASSOCIATION 54
62#define SECCLASS_NETLINK_KOBJECT_UEVENT_SOCKET 55 62#define SECCLASS_NETLINK_KOBJECT_UEVENT_SOCKET 55
63#define SECCLASS_APPLETALK_SOCKET 56
64#define SECCLASS_PACKET 57
63 65
64/* 66/*
65 * Security identifier indices for initial entities 67 * Security identifier indices for initial entities
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index c10f1fc41502..c96498a10eb8 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -9,8 +9,10 @@
9int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); 9int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
10int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new); 10int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
11void selinux_xfrm_policy_free(struct xfrm_policy *xp); 11void selinux_xfrm_policy_free(struct xfrm_policy *xp);
12int selinux_xfrm_policy_delete(struct xfrm_policy *xp);
12int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); 13int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
13void selinux_xfrm_state_free(struct xfrm_state *x); 14void selinux_xfrm_state_free(struct xfrm_state *x);
15int selinux_xfrm_state_delete(struct xfrm_state *x);
14int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir); 16int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
15 17
16/* 18/*
@@ -49,7 +51,7 @@ static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb)
49 51
50static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb) 52static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb)
51{ 53{
52 return NF_ACCEPT; 54 return 0;
53} 55}
54 56
55static inline int selinux_socket_getpeer_stream(struct sock *sk) 57static inline int selinux_socket_getpeer_stream(struct sock *sk)
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index a4efc966f065..2e73d3279f2d 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -38,6 +38,14 @@
38 38
39unsigned int selinux_checkreqprot = CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE; 39unsigned int selinux_checkreqprot = CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE;
40 40
41#ifdef CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT
42#define SELINUX_COMPAT_NET_VALUE 0
43#else
44#define SELINUX_COMPAT_NET_VALUE 1
45#endif
46
47int selinux_compat_net = SELINUX_COMPAT_NET_VALUE;
48
41static int __init checkreqprot_setup(char *str) 49static int __init checkreqprot_setup(char *str)
42{ 50{
43 selinux_checkreqprot = simple_strtoul(str,NULL,0) ? 1 : 0; 51 selinux_checkreqprot = simple_strtoul(str,NULL,0) ? 1 : 0;
@@ -45,6 +53,13 @@ static int __init checkreqprot_setup(char *str)
45} 53}
46__setup("checkreqprot=", checkreqprot_setup); 54__setup("checkreqprot=", checkreqprot_setup);
47 55
56static int __init selinux_compat_net_setup(char *str)
57{
58 selinux_compat_net = simple_strtoul(str,NULL,0) ? 1 : 0;
59 return 1;
60}
61__setup("selinux_compat_net=", selinux_compat_net_setup);
62
48 63
49static DEFINE_MUTEX(sel_mutex); 64static DEFINE_MUTEX(sel_mutex);
50 65
@@ -85,6 +100,7 @@ enum sel_inos {
85 SEL_AVC, /* AVC management directory */ 100 SEL_AVC, /* AVC management directory */
86 SEL_MEMBER, /* compute polyinstantiation membership decision */ 101 SEL_MEMBER, /* compute polyinstantiation membership decision */
87 SEL_CHECKREQPROT, /* check requested protection, not kernel-applied one */ 102 SEL_CHECKREQPROT, /* check requested protection, not kernel-applied one */
103 SEL_COMPAT_NET, /* whether to use old compat network packet controls */
88}; 104};
89 105
90#define TMPBUFLEN 12 106#define TMPBUFLEN 12
@@ -364,6 +380,55 @@ static struct file_operations sel_checkreqprot_ops = {
364 .write = sel_write_checkreqprot, 380 .write = sel_write_checkreqprot,
365}; 381};
366 382
383static ssize_t sel_read_compat_net(struct file *filp, char __user *buf,
384 size_t count, loff_t *ppos)
385{
386 char tmpbuf[TMPBUFLEN];
387 ssize_t length;
388
389 length = scnprintf(tmpbuf, TMPBUFLEN, "%d", selinux_compat_net);
390 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
391}
392
393static ssize_t sel_write_compat_net(struct file * file, const char __user * buf,
394 size_t count, loff_t *ppos)
395{
396 char *page;
397 ssize_t length;
398 int new_value;
399
400 length = task_has_security(current, SECURITY__LOAD_POLICY);
401 if (length)
402 return length;
403
404 if (count >= PAGE_SIZE)
405 return -ENOMEM;
406 if (*ppos != 0) {
407 /* No partial writes. */
408 return -EINVAL;
409 }
410 page = (char*)get_zeroed_page(GFP_KERNEL);
411 if (!page)
412 return -ENOMEM;
413 length = -EFAULT;
414 if (copy_from_user(page, buf, count))
415 goto out;
416
417 length = -EINVAL;
418 if (sscanf(page, "%d", &new_value) != 1)
419 goto out;
420
421 selinux_compat_net = new_value ? 1 : 0;
422 length = count;
423out:
424 free_page((unsigned long) page);
425 return length;
426}
427static struct file_operations sel_compat_net_ops = {
428 .read = sel_read_compat_net,
429 .write = sel_write_compat_net,
430};
431
367/* 432/*
368 * Remaining nodes use transaction based IO methods like nfsd/nfsctl.c 433 * Remaining nodes use transaction based IO methods like nfsd/nfsctl.c
369 */ 434 */
@@ -1219,6 +1284,7 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
1219 [SEL_DISABLE] = {"disable", &sel_disable_ops, S_IWUSR}, 1284 [SEL_DISABLE] = {"disable", &sel_disable_ops, S_IWUSR},
1220 [SEL_MEMBER] = {"member", &transaction_ops, S_IRUGO|S_IWUGO}, 1285 [SEL_MEMBER] = {"member", &transaction_ops, S_IRUGO|S_IWUGO},
1221 [SEL_CHECKREQPROT] = {"checkreqprot", &sel_checkreqprot_ops, S_IRUGO|S_IWUSR}, 1286 [SEL_CHECKREQPROT] = {"checkreqprot", &sel_checkreqprot_ops, S_IRUGO|S_IWUSR},
1287 [SEL_COMPAT_NET] = {"compat_net", &sel_compat_net_ops, S_IRUGO|S_IWUSR},
1222 /* last one */ {""} 1288 /* last one */ {""}
1223 }; 1289 };
1224 ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files); 1290 ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files);
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index abe99d881376..6633fb059313 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -132,10 +132,7 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_us
132 goto out; 132 goto out;
133 133
134 /* 134 /*
135 * Does the subject have permission to set security or permission to 135 * Does the subject have permission to set security context?
136 * do the relabel?
137 * Must be permitted to relabel from default socket type (process type)
138 * to specified context
139 */ 136 */
140 rc = avc_has_perm(tsec->sid, ctx->ctx_sid, 137 rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
141 SECCLASS_ASSOCIATION, 138 SECCLASS_ASSOCIATION,
@@ -201,6 +198,23 @@ void selinux_xfrm_policy_free(struct xfrm_policy *xp)
201} 198}
202 199
203/* 200/*
201 * LSM hook implementation that authorizes deletion of labeled policies.
202 */
203int selinux_xfrm_policy_delete(struct xfrm_policy *xp)
204{
205 struct task_security_struct *tsec = current->security;
206 struct xfrm_sec_ctx *ctx = xp->security;
207 int rc = 0;
208
209 if (ctx)
210 rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
211 SECCLASS_ASSOCIATION,
212 ASSOCIATION__SETCONTEXT, NULL);
213
214 return rc;
215}
216
217/*
204 * LSM hook implementation that allocs and transfers sec_ctx spec to 218 * LSM hook implementation that allocs and transfers sec_ctx spec to
205 * xfrm_state. 219 * xfrm_state.
206 */ 220 */
@@ -292,6 +306,23 @@ u32 selinux_socket_getpeer_dgram(struct sk_buff *skb)
292 return SECSID_NULL; 306 return SECSID_NULL;
293} 307}
294 308
309 /*
310 * LSM hook implementation that authorizes deletion of labeled SAs.
311 */
312int selinux_xfrm_state_delete(struct xfrm_state *x)
313{
314 struct task_security_struct *tsec = current->security;
315 struct xfrm_sec_ctx *ctx = x->security;
316 int rc = 0;
317
318 if (ctx)
319 rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
320 SECCLASS_ASSOCIATION,
321 ASSOCIATION__SETCONTEXT, NULL);
322
323 return rc;
324}
325
295/* 326/*
296 * LSM hook that controls access to unlabelled packets. If 327 * LSM hook that controls access to unlabelled packets. If
297 * a xfrm_state is authorizable (defined by macro) then it was 328 * a xfrm_state is authorizable (defined by macro) then it was
@@ -356,18 +387,12 @@ int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb)
356 struct xfrm_state *x = dst_test->xfrm; 387 struct xfrm_state *x = dst_test->xfrm;
357 388
358 if (x && selinux_authorizable_xfrm(x)) 389 if (x && selinux_authorizable_xfrm(x))
359 goto accept; 390 goto out;
360 } 391 }
361 } 392 }
362 393
363 rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION, 394 rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION,
364 ASSOCIATION__SENDTO, NULL); 395 ASSOCIATION__SENDTO, NULL);
365 if (rc) 396out:
366 goto drop; 397 return rc;
367
368accept:
369 return NF_ACCEPT;
370
371drop:
372 return NF_DROP;
373} 398}
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index 558c6ed443be..080ab036b67a 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -98,8 +98,8 @@ config SOUND_HAL2
98 tristate "SGI HAL2 sound (EXPERIMENTAL)" 98 tristate "SGI HAL2 sound (EXPERIMENTAL)"
99 depends on SOUND_PRIME && SGI_IP22 && EXPERIMENTAL 99 depends on SOUND_PRIME && SGI_IP22 && EXPERIMENTAL
100 help 100 help
101 Say Y or M if you have an SGI Indy system and want to be able to 101 Say Y or M if you have an SGI Indy or Indigo2 system and want to be able to
102 use it's on-board A2 audio system. 102 use its on-board A2 audio system.
103 103
104config SOUND_IT8172 104config SOUND_IT8172
105 tristate "IT8172G Sound" 105 tristate "IT8172G Sound"